内容简介:We should ban margin from our components. Hear me out.Margin breaks component encapsulation. A well-built component should not affect anything outside itself.Margin makes reusability harder. Good components are usable in any context or layout.
We should ban margin from our components. Hear me out.
Margin breaks component encapsulation. A well-built component should not affect anything outside itself.
Margin makes reusability harder. Good components are usable in any context or layout.
Margin conflicts with how designers think. Designers think about space in relation and context. They define how far a component should be from another component in a specific instance.
By banning margin from all components you have to build more reusable and encapsulated components.
Moving responsibility
Instead of margin I have started using spacer components, which move the responsibility of managing space to the parent-level.
For example, the Braid design system popularized the
Stack
component
:
<Stack space={3}>
<Item />
<Item />
<Item />
</Stack>
Using spacer components has implications that are not obvious a priori .
Spacer components (such as Stack
above) can restrict spacing values to steps on a scale. That way, all spacing automatically aligns to the grid.
Spacer components define how far a component should be from another component in a specific instance. You have to define space in relation and context.
Who else thinks about space in relation and context? Designers.
Spacer components bring us closer to how designers think. They make our designs more consistent and they force us to build more reusable and encapsulated components.
Use spacer components. Ban margin.
I am not the first one to realize this. Thanks to @markdalgleish and @michaeltaranto at Seek for paving the way and prompting me to think about it.
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
应用Rails进行敏捷Web开发
Dave Thomas, David Hansson等 / 林芷薰 / 电子工业出版社 / 2006-7 / 65.00元
这是第一本关于Ruby on Rails的著作。 全书主要内容分为两大部分。在“构建应用程序”部分中,读者将看到一个完整的“在线购书网站” 示例。在演示的过程中,作者真实地再现了一个完整的迭代式开发过程,让读者亲身体验实际应用开发中遇到的各种问题、以及Rails如何有效解决这些问题。在随后的“Rails框架”部分中,作者深入介绍了Rails框架的各个组成部分。尤为值得一提的是本部分的后几章......一起来看看 《应用Rails进行敏捷Web开发》 这本书的介绍吧!