LuccaSA / lucca-front

documentation
https://prisme.lucca.io
MIT License
38 stars 4 forks source link

Box-shadow used as border should be inset. Otherwise they may be cropped #2647

Open BertrandPodevin opened 6 months ago

BertrandPodevin commented 6 months ago

IF a component use a box-shadow: 0 0 0 1px #color; as a border, this shadow should also be defined as inset. Otherwise the shadow overflow it's box and could be cropped by it's parents.

Example with a callout : the laterals shadows are cropped. image

That would'nt be the case with an inset shadow : image

jeremie-lucca commented 6 months ago

@BertrandPodevin It's a requirement from design specs to keep the space inside components not affected by borders. It works the same way on every components, like buttons, textfields, etc. image image

We already discussed it with Clément but it's not going to change for now, so the best approach for now is to avoid to hide overflow when possible.

BertrandPodevin commented 6 months ago

@jeremie-lucca Avoiding using overflow is not always possibility :/

Which leaves 4 options :

An element designed to take 100% of it's parent width should not casualy take 100% + 2px without offering a fallback There should be at least a mod or a css vars to allow a clean override when needed.

Ex box-shadow: var(--component-box-shadow-inset, ) 0px 0px 0px 1px #000000; which can be overrided easily if needed .myComponent {--component-box-shadow-inset: inset;}

BertrandPodevin commented 6 months ago

Here's a comparative between LF16 & 17 https://codepen.io/bertrandpodevin/pen/PogNxPN

jeremie-lucca commented 6 months ago

@BertrandPodevin Could you share some examples/mockups where you cannot bypass hidden overflow ? May concrete examples could convince Clément to use inside borders. If not, we'll consider fallbacks 🙂

BertrandPodevin commented 6 months ago

I don't think that there are designs or mockups that required to combine outset shadow component + overflow.

On the other hand this change (border -> shadow) is breaking for existing screens build without this technical constraint in mind. Some TA screens and our pwa are now exposed to this.

A simple fallback will do the trick.

vvalentin-lucca commented 2 months ago

The same problem can arise when it comes to displaying the outline for keyboard navigation.

You can get away with a negative margin combined with padding of the same value, if necessary.