|
1 | 1 | import { Canvas, Meta, Story } from '@storybook/addon-docs'; |
2 | | -// The '!!raw-loader!' syntax is a non-standard, Webpack-specific, syntax. |
3 | | -// See: https://github.com/webpack-contrib/raw-loader#examples |
4 | | -// For now, it seems likely Storybook is pretty tied to Webpack, therefore, we are |
5 | | -// okay with the following Webpack-specific raw loader syntax. It's better to leave |
6 | | -// the ESLint rule enabled globally, and only thoughtfully disable as needed (e.g. |
7 | | -// within a Storybook docs page and not within an actual component). |
8 | | -// This can be revisited in the future if Storybook no longer relies on Webpack. |
9 | | -// eslint-disable-next-line @cloudfour/import/no-webpack-loader-syntax |
10 | | -import defaultDemoSource from '!!raw-loader!./demo/demo.twig'; |
11 | | -import defaultDemo from './demo/demo.twig'; |
| 2 | +import demo from './demo/demo.twig'; |
12 | 3 | import logos from './demo/logos.json'; |
| 4 | +const justifyOptions = ['start', 'center', 'end']; |
| 5 | +const demoTemplateSource = (_src, storyContext) => { |
| 6 | + const args = storyContext.args || storyContext.initialArgs; |
| 7 | + const twigArgs = |
| 8 | + Object.keys(args).length > 0 |
| 9 | + ? ` with ${JSON.stringify(args, null, 2)}` |
| 10 | + : ''; |
| 11 | + return `{% embed '@cloudfour/objects/logo-group/logo-group.twig'${twigArgs} %} |
| 12 | + {% block content %} |
| 13 | + {# logos #} |
| 14 | + {% endblock %} |
| 15 | +{% endembed %}`; |
| 16 | +}; |
| 17 | +const demoStory = (args) => demo({ ...args, logos }); |
13 | 18 |
|
14 | | -<Meta title="Objects/Logo Group" /> |
| 19 | +<Meta |
| 20 | + title="Objects/Logo Group" |
| 21 | + parameters={{ |
| 22 | + docs: { |
| 23 | + transformSource: demoTemplateSource, |
| 24 | + }, |
| 25 | + }} |
| 26 | + argTypes={{ |
| 27 | + justify: { |
| 28 | + options: justifyOptions, |
| 29 | + control: { type: 'inline-radio' }, |
| 30 | + }, |
| 31 | + pad: { |
| 32 | + type: { name: 'boolean' }, |
| 33 | + }, |
| 34 | + }} |
| 35 | +/> |
15 | 36 |
|
16 | 37 | # Logo Group |
17 | 38 |
|
18 | | -Logo Group can be used to display a group of logos, such as a summary of past clients. Logos break onto multiple lines depending on the available space and are vertically centered. |
| 39 | +The Logo Group presents multiple logos together with consistent spacing and alignment. It is useful for summarizing a list of projects or clients. |
19 | 40 |
|
20 | | -To enforce consistent sizing or fine-tune alignment, consider using [Logo components](/docs/components-logo--basic-options) within the Logo Group. |
| 41 | +To fine-tune the relative scale or layout of individual logos within, consider using [the Logo component](/docs/components-logo--basic-options). |
| 42 | + |
| 43 | +<Canvas> |
| 44 | + <Story name="Default">{(args) => demoStory(args)}</Story> |
| 45 | +</Canvas> |
| 46 | + |
| 47 | +## Options |
| 48 | + |
| 49 | +The `justify` template property or `o-logo-group--justify-{alignment}` class sets the horizontal alignment of the logos within the group. The default is `start`, but `center` and `end` are also supported. |
| 50 | + |
| 51 | +To repeat the gap between logos around the whole container, set the `pad` template property to `true` or apply the `o-logo-group--pad` modifier class. |
21 | 52 |
|
22 | 53 | <Canvas> |
23 | 54 | <Story |
24 | | - name="Default" |
25 | | - parameters={{ docs: { source: { code: defaultDemoSource } } }} |
| 55 | + name="Centered with padding" |
| 56 | + args={{ |
| 57 | + justify: 'center', |
| 58 | + pad: true, |
| 59 | + }} |
26 | 60 | > |
27 | | - {defaultDemo({ items: logos })} |
| 61 | + {(args) => demoStory(args)} |
28 | 62 | </Story> |
29 | 63 | </Canvas> |
0 commit comments