|
| 1 | +import linearIllustrations from '@react-spectrum/s2/spectrum-illustrations/linear/*.tsx'; |
| 2 | +import gradientIllustrations from '@react-spectrum/s2/spectrum-illustrations/gradient/*.svg'; |
| 3 | +import Paste from '@react-spectrum/s2/s2wf-icons/S2_Icon_Paste_20_N.svg'; |
| 4 | +import { style } from '../../packages/@react-spectrum/s2/style/spectrum-theme' with {type: 'macro'}; |
| 5 | +import {ActionButton, Text} from '@react-spectrum/s2'; |
| 6 | +import {H2, P, Code, Pre} from './typography'; |
| 7 | +import {highlight} from './highlight' with {type: 'macro'}; |
| 8 | +import { Radio, RadioGroup } from '../../packages/@react-spectrum/s2/src'; |
| 9 | +import { useState } from 'react'; |
| 10 | + |
| 11 | +export function Illustrations() { |
| 12 | + let [gradientStyle, setStyle] = useState('generic1'); |
| 13 | + return ( |
| 14 | + <div className={style({maxWidth: 'lg', marginX: 'auto'})}> |
| 15 | + <div className={style({marginX: 48})}> |
| 16 | + <h1 className={style({font: 'heading-2xl', marginBottom: 48})}> |
| 17 | + Illustrations |
| 18 | + </h1> |
| 19 | + <P>Spectrum 2 offers a collection of illustrations in two styles: gradient and linear. These illustrations can be imported from <Code>@react-spectrum/s2/illustrations</Code>. See below for a full list of available illustrations. Click the clipboard icon to copy the import statement.</P> |
| 20 | + <H2>Gradient illustrations</H2> |
| 21 | + <P>Gradient illustrations are available in two styles: Generic 1 and Generic 2. These should be consistently applied within products. They can be imported using the corresponding sub-path, for example:</P> |
| 22 | + <Pre>{highlight("import Cloud from '@react-spectrum/s2/illustrations/gradient/generic1/Cloud';")}</Pre> |
| 23 | + <RadioGroup label="Style" value={gradientStyle} onChange={setStyle} orientation="horizontal" styles={style({marginTop: 32})}> |
| 24 | + <Radio value="generic1">Generic 1</Radio> |
| 25 | + <Radio value="generic2">Generic 2</Radio> |
| 26 | + </RadioGroup> |
| 27 | + <div className={style({display: 'grid', gridTemplateColumns: 'repeat(auto-fit, 164px)', gap: 20, justifyContent: 'space-between', marginTop: 32})}> |
| 28 | + {Object.keys(gradientIllustrations).filter(name => name.includes(gradientStyle)).map(icon => { |
| 29 | + let Illustration = gradientIllustrations[icon].default; |
| 30 | + let name = icon.replace(/^S2_(fill|lin)_(.+)_(generic\d)_(\d+)$/, (m, type, name) => { |
| 31 | + return name[0].toUpperCase() + name.slice(1).replace(/_/g, ''); |
| 32 | + }); |
| 33 | + let importPath = icon.replace(/^S2_(fill|lin)_(.+)_(generic\d)_(\d+)$/, (m, type, name, style) => { |
| 34 | + name = name[0].toUpperCase() + name.slice(1).replace(/_/g, ''); |
| 35 | + return 'gradient/' + style + '/' + name; |
| 36 | + }); |
| 37 | + return ( |
| 38 | + <div className={style({display: 'flex', flexDirection: 'column', rowGap: 8, alignItems: 'center', padding: 16, borderRadius: 'lg', boxShadow: 'elevated'})}> |
| 39 | + <Illustration UNSAFE_style={{width: 96, height: 96}} /> |
| 40 | + <span className={style({font: 'ui', display: 'flex', gap: 8, alignItems: 'center', maxWidth: 'full'})}> |
| 41 | + <span className={style({truncate: true})}>{name}</span> |
| 42 | + <ActionButton |
| 43 | + size="XS" |
| 44 | + isQuiet |
| 45 | + aria-label="Copy" |
| 46 | + onPress={() => navigator.clipboard.writeText(`import ${name} from '@react-spectrum/s2/illustrations/${importPath}';`)}> |
| 47 | + <Paste /> |
| 48 | + </ActionButton> |
| 49 | + </span> |
| 50 | + </div> |
| 51 | + ); |
| 52 | + })} |
| 53 | + </div> |
| 54 | + <H2>Linear illustrations</H2> |
| 55 | + <P>Linear illustrations can be imported as shown below:</P> |
| 56 | + <Pre>{highlight("import Cloud from '@react-spectrum/s2/illustrations/linear/Cloud';")}</Pre> |
| 57 | + <div className={style({display: 'grid', gridTemplateColumns: 'repeat(auto-fit, 164px)', gap: 20, justifyContent: 'space-between', marginTop: 48})}> |
| 58 | + {Object.keys(linearIllustrations).map(icon => { |
| 59 | + let Illustration = linearIllustrations[icon].default; |
| 60 | + return ( |
| 61 | + <div className={style({display: 'flex', flexDirection: 'column', rowGap: 8, alignItems: 'center', padding: 16, borderRadius: 'lg', boxShadow: 'elevated'})}> |
| 62 | + <Illustration /> |
| 63 | + <span className={style({font: 'ui', display: 'flex', gap: 8, alignItems: 'center', maxWidth: 'full'})}> |
| 64 | + <span className={style({truncate: true})}>{icon}</span> |
| 65 | + <ActionButton |
| 66 | + size="XS" |
| 67 | + isQuiet |
| 68 | + aria-label="Copy" |
| 69 | + onPress={() => navigator.clipboard.writeText(`import ${icon} from '@react-spectrum/s2/illustrations/linear/${icon}';`)}> |
| 70 | + <Paste /> |
| 71 | + </ActionButton> |
| 72 | + </span> |
| 73 | + </div> |
| 74 | + ); |
| 75 | + })} |
| 76 | + </div> |
| 77 | + </div> |
| 78 | + </div> |
| 79 | + ); |
| 80 | +} |
0 commit comments