|
| 1 | +import { Story, Canvas, Meta } from '@storybook/addon-docs'; |
| 2 | +import inlineSizeDemo from './demo/inline-size.twig'; |
| 3 | +import responsiveDemo from './demo/responsive.twig'; |
| 4 | +import './demo/styles.scss'; |
| 5 | + |
| 6 | +<Meta title="Utilities/Size" /> |
| 7 | + |
| 8 | +# Size |
| 9 | + |
| 10 | +Utilities for specifying the size occupied by an element. While largely unnecessary in objects and components thanks to [CSS Grid Layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout), these utilities can still be useful for fine-tuning one-off elements in page content. |
| 11 | + |
| 12 | +## Logical Properties |
| 13 | + |
| 14 | +All of our utilities use [logical properties](https://www.w3.org/TR/css-logical-1/) instead of specific directions [in supported browsers](https://caniuse.com/#feat=css-logical-props) to simplify potential localization projects. |
| 15 | + |
| 16 | +The following table maps the traditional physical property for `direction: ltr` and `writing-mode: horizontal-tb` to its equivalent logical property: |
| 17 | + |
| 18 | +| Physical Property | Logical Property | |
| 19 | +| ----------------- | ---------------- | |
| 20 | +| `height` | `block-size` | |
| 21 | +| `width` | `inline-size` | |
| 22 | + |
| 23 | +You can observe how utilities respond to various `direction` and `writing-mode` values by selecting a different "Text flow" in this project's toolbar. |
| 24 | + |
| 25 | +## Inline size |
| 26 | + |
| 27 | +Utilities beginning with `u-size-inline-` specify the `inline-size` of an element: |
| 28 | + |
| 29 | +- `u-size-inline-{fraction}` for percentage widths, where `{fraction}` represents the desired ratio. For example, `u-size-inline-2/5` would set `inline-size` to `40%`. Fractions with denominators of `2` through `6` are supported. |
| 30 | +- `u-size-inline-full` sets the `inline-size` to `100%` of the container. |
| 31 | +- `u-size-inline-auto` sets the `inline-size` to the natural value for the element. |
| 32 | + |
| 33 | +<Canvas> |
| 34 | + <Story name="Inline size (Width)">{() => inlineSizeDemo()}</Story> |
| 35 | +</Canvas> |
| 36 | + |
| 37 | +## Responsive |
| 38 | + |
| 39 | +All of these utilities include responsive variations. Appending `@{breakpoint}` to the end of the class name will cause the utility to change for the given breakpoint. |
| 40 | + |
| 41 | +<Canvas> |
| 42 | + <Story name="Responsive">{() => responsiveDemo()}</Story> |
| 43 | +</Canvas> |
0 commit comments