|
| 1 | +import { Canvas, Meta, Story } from '@storybook/addon-docs'; |
| 2 | +import logoTemplate from './logo.twig'; |
| 3 | +import alignmentDemo from './demo/alignment.twig'; |
| 4 | +import './demo/alignment.scss'; |
| 5 | +const alignOptions = ['start', 'center', 'end']; |
| 6 | + |
| 7 | +<!-- |
| 8 | +This component's options rely on CSS custom properties, which are currently |
| 9 | +broken in the library we use for inlining Storybook stories. Until that issue |
| 10 | +is resolved, we must fallback to iframes for these stories. 🙈️ |
| 11 | + |
| 12 | +@see https://github.com/aknuds1/html-to-react/issues/144 |
| 13 | +--> |
| 14 | + |
| 15 | +<Meta title="Components/Logo" parameters={{ docs: { inlineStories: false } }} /> |
| 16 | + |
| 17 | +# Logo |
| 18 | + |
| 19 | +The logo component enforces a consistent height for logos, promoting alignment and consistency for content that summarizes branded projects, client work and case studies. |
| 20 | + |
| 21 | +To showcase several logos together, see [the Logo Group object](/docs/objects-logo-group--default-story). |
| 22 | + |
| 23 | +<Canvas> |
| 24 | + <Story |
| 25 | + name="Basic Options" |
| 26 | + argTypes={{ |
| 27 | + src: { control: { type: 'text' } }, |
| 28 | + alt: { control: { type: 'text' } }, |
| 29 | + class: { control: { type: 'text' } }, |
| 30 | + width: { control: { type: 'number' } }, |
| 31 | + height: { control: { type: 'number' } }, |
| 32 | + scale: { control: { type: 'number' } }, |
| 33 | + align: { |
| 34 | + options: alignOptions, |
| 35 | + control: { type: 'inline-radio' }, |
| 36 | + }, |
| 37 | + justify: { |
| 38 | + options: alignOptions, |
| 39 | + control: { type: 'inline-radio' }, |
| 40 | + }, |
| 41 | + }} |
| 42 | + args={{ |
| 43 | + src: '/media/logos/pleasantest.svg', |
| 44 | + alt: 'Pleasantest', |
| 45 | + width: 180, |
| 46 | + height: 58, |
| 47 | + }} |
| 48 | + > |
| 49 | + {(args) => logoTemplate(args)} |
| 50 | + </Story> |
| 51 | +</Canvas> |
| 52 | + |
| 53 | +## Alignment |
| 54 | + |
| 55 | +Different brands are usually designed in isolation, so it's common for logos to feel inconsistently sized when displayed in a row or a grid. The logo component includes `scale`, `align` and `justify` options for fine-tuning the alignment of logos relative to others nearby. |
| 56 | + |
| 57 | +The following stories show three logos before and after alignment options are set. In the second example, the middle logo has a `scale` lower than `1`, whereas the rightmost logo has a `scale` higher than `1` and an `align` value of `end`. |
| 58 | + |
| 59 | +<Canvas isColumn> |
| 60 | + <Story name="Before Alignment">{alignmentDemo.bind({})}</Story> |
| 61 | + <Story name="After Alignment" args={{ align: true }}> |
| 62 | + {alignmentDemo.bind({})} |
| 63 | + </Story> |
| 64 | +</Canvas> |
| 65 | + |
| 66 | +## Template Options |
| 67 | + |
| 68 | +<!-- |
| 69 | +Because `ArgsTable` doesn't work very well for non-inline stories, we have to |
| 70 | +manually document the options available to this template. |
| 71 | +--> |
| 72 | + |
| 73 | +- `align` (Default: `center`): Specify the block (vertical) alignment. |
| 74 | +- `alt`: A description of the image. For logos, this is typically the name of the brand. |
| 75 | +- `class`: Append additional class names to the element. |
| 76 | +- `content` (block): Specify the `img` or image-like element to display directly. |
| 77 | +- `height`: The height of the image in pixels. |
| 78 | +- `justify` (Default: `inherit`): Specify the inline (horizontal) alignment. |
| 79 | +- `scale`: Scale the logo up or down within its container. |
| 80 | +- `src`: The URL of the image to display. |
| 81 | +- `width`: The width of the image in pixels. |
| 82 | + |
| 83 | +## CSS Custom Properties |
| 84 | + |
| 85 | +- `--logo-align` (Default: `center`): Specify the block (vertical) alignment. |
| 86 | +- `--logo-justify` (Default: `inherit`): Specify the inline (horizontal) alignment. |
| 87 | +- `--logo-scale`: Scale the logo up or down within its container. |
0 commit comments