|
| 1 | +/* |
| 2 | + * Copyright 2024 Adobe. All rights reserved. |
| 3 | + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. You may obtain a copy |
| 5 | + * of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | + * |
| 7 | + * Unless required by applicable law or agreed to in writing, software distributed under |
| 8 | + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS |
| 9 | + * OF ANY KIND, either express or implied. See the License for the specific language |
| 10 | + * governing permissions and limitations under the License. |
| 11 | + */ |
| 12 | + |
| 13 | +import type {Meta} from '@storybook/react'; |
| 14 | +import {style} from '../style' with {type: 'macro'}; |
| 15 | +import {useLocale} from 'react-aria'; |
| 16 | + |
| 17 | +const meta: Meta<any> = { |
| 18 | + title: 'S2 Chromatic/Fonts' |
| 19 | +}; |
| 20 | + |
| 21 | +export default meta; |
| 22 | + |
| 23 | +const messages = { |
| 24 | + 'en': { |
| 25 | + 'button': 'Edit', |
| 26 | + 'copy': 'Copy', |
| 27 | + 'cut': 'Cut', |
| 28 | + 'paste': 'Paste' |
| 29 | + }, |
| 30 | + 'ar': { |
| 31 | + 'button': 'يحرر', |
| 32 | + 'copy': 'ينسخ', |
| 33 | + 'cut': 'يقطع', |
| 34 | + 'paste': 'معجون' |
| 35 | + }, |
| 36 | + 'he': { |
| 37 | + 'button': 'לַעֲרוֹך', |
| 38 | + 'copy': 'עותק', |
| 39 | + 'cut': 'גזירה', |
| 40 | + 'paste': 'לְהַדבִּיק' |
| 41 | + }, |
| 42 | + 'ja': { |
| 43 | + 'button': '編集', |
| 44 | + 'copy': 'コピー', |
| 45 | + 'cut': '切る', |
| 46 | + 'paste': 'ペースト' |
| 47 | + }, |
| 48 | + 'ko': { |
| 49 | + 'button': '편집하다', |
| 50 | + 'copy': '복사', |
| 51 | + 'cut': '자르다', |
| 52 | + 'paste': '반죽' |
| 53 | + }, |
| 54 | + 'zh-Hans': { |
| 55 | + 'button': '编辑', |
| 56 | + 'copy': '复制', |
| 57 | + 'cut': '切', |
| 58 | + 'paste': '粘贴' |
| 59 | + }, |
| 60 | + 'zh-HK': { |
| 61 | + 'button': '編輯', |
| 62 | + 'copy': '複製', |
| 63 | + 'cut': '切', |
| 64 | + 'paste': '粘貼' |
| 65 | + }, |
| 66 | + 'zh-Hant': { |
| 67 | + 'button': '編輯', |
| 68 | + 'copy': '複製', |
| 69 | + 'cut': '切', |
| 70 | + 'paste': '粘貼' |
| 71 | + } |
| 72 | +}; |
| 73 | + |
| 74 | +function Example() { |
| 75 | + let {locale} = useLocale(); |
| 76 | + let m = messages[locale] || messages.en; |
| 77 | + return ( |
| 78 | + <div |
| 79 | + className={style({ |
| 80 | + display: 'grid', |
| 81 | + width: 'full', |
| 82 | + gridTemplateColumns: { |
| 83 | + default: '1fr', |
| 84 | + sm: 'repeat(3, auto)', |
| 85 | + md: 'repeat(6, auto)' |
| 86 | + }, |
| 87 | + justifyContent: 'space-between' |
| 88 | + })}> |
| 89 | + <ul className={style({padding: 0, listStyleType: 'none'})}> |
| 90 | + <li className={style({font: 'ui-xs'})}>{m.button}</li> |
| 91 | + <li className={style({font: 'ui-sm'})}>{m.button}</li> |
| 92 | + <li className={style({font: 'ui'})}>{m.button}</li> |
| 93 | + <li className={style({font: 'ui-lg'})}>{m.button}</li> |
| 94 | + <li className={style({font: 'ui-xl'})}>{m.button}</li> |
| 95 | + <li className={style({font: 'ui-2xl'})}>{m.button}</li> |
| 96 | + <li className={style({font: 'ui-3xl'})}>{m.button}</li> |
| 97 | + </ul> |
| 98 | + <ul className={style({padding: 0, listStyleType: 'none'})}> |
| 99 | + <li className={style({font: 'body-2xs'})}>{m.copy}</li> |
| 100 | + <li className={style({font: 'body-xs'})}>{m.copy}</li> |
| 101 | + <li className={style({font: 'body-sm'})}>{m.copy}</li> |
| 102 | + <li className={style({font: 'body'})}>{m.copy}</li> |
| 103 | + <li className={style({font: 'body-lg'})}>{m.copy}</li> |
| 104 | + <li className={style({font: 'body-xl'})}>{m.copy}</li> |
| 105 | + <li className={style({font: 'body-2xl'})}>{m.copy}</li> |
| 106 | + <li className={style({font: 'body-3xl'})}>{m.copy}</li> |
| 107 | + </ul> |
| 108 | + <ul className={style({padding: 0, listStyleType: 'none'})}> |
| 109 | + <li className={style({font: 'heading-2xs'})}>{m.cut}</li> |
| 110 | + <li className={style({font: 'heading-xs'})}>{m.cut}</li> |
| 111 | + <li className={style({font: 'heading-sm'})}>{m.cut}</li> |
| 112 | + <li className={style({font: 'heading'})}>{m.cut}</li> |
| 113 | + <li className={style({font: 'heading-lg'})}>{m.cut}</li> |
| 114 | + <li className={style({font: 'heading-xl'})}>{m.cut}</li> |
| 115 | + <li className={style({font: 'heading-2xl'})}>{m.cut}</li> |
| 116 | + <li className={style({font: 'heading-3xl'})}>{m.cut}</li> |
| 117 | + </ul> |
| 118 | + <ul className={style({padding: 0, listStyleType: 'none'})}> |
| 119 | + <li className={style({font: 'title-xs'})}>{m.paste}</li> |
| 120 | + <li className={style({font: 'title-sm'})}>{m.paste}</li> |
| 121 | + <li className={style({font: 'title'})}>{m.paste}</li> |
| 122 | + <li className={style({font: 'title-lg'})}>{m.paste}</li> |
| 123 | + <li className={style({font: 'title-xl'})}>{m.paste}</li> |
| 124 | + <li className={style({font: 'title-2xl'})}>{m.paste}</li> |
| 125 | + <li className={style({font: 'title-3xl'})}>{m.paste}</li> |
| 126 | + </ul> |
| 127 | + <ul className={style({padding: 0, listStyleType: 'none'})}> |
| 128 | + <li className={style({font: 'detail-sm'})}>{m.button}</li> |
| 129 | + <li className={style({font: 'detail'})}>{m.button}</li> |
| 130 | + <li className={style({font: 'detail-lg'})}>{m.button}</li> |
| 131 | + <li className={style({font: 'detail-xl'})}>{m.button}</li> |
| 132 | + </ul> |
| 133 | + <ul className={style({padding: 0, listStyleType: 'none'})}> |
| 134 | + <li className={style({font: 'code-sm'})}>{m.cut}</li> |
| 135 | + <li className={style({font: 'code'})}>{m.cut}</li> |
| 136 | + <li className={style({font: 'code-lg'})}>{m.cut}</li> |
| 137 | + <li className={style({font: 'code-xl'})}>{m.cut}</li> |
| 138 | + </ul> |
| 139 | + </div> |
| 140 | + ); |
| 141 | +} |
| 142 | + |
| 143 | +function SerifExample() { |
| 144 | + return ( |
| 145 | + <div |
| 146 | + className={style({ |
| 147 | + display: 'grid', |
| 148 | + width: 'full', |
| 149 | + gridTemplateColumns: { |
| 150 | + default: '1fr', |
| 151 | + sm: 'repeat(3, auto)', |
| 152 | + md: 'repeat(6, auto)' |
| 153 | + }, |
| 154 | + justifyContent: 'space-between' |
| 155 | + })}> |
| 156 | + <ul className={style({padding: 0, listStyleType: 'none'})}> |
| 157 | + <li className={style({font: 'heading-xs', fontFamily: 'serif'})}>Heading</li> |
| 158 | + <li className={style({font: 'heading-sm', fontFamily: 'serif'})}>Heading</li> |
| 159 | + <li className={style({font: 'heading', fontFamily: 'serif'})}>Heading</li> |
| 160 | + <li className={style({font: 'heading-lg', fontFamily: 'serif'})}>Heading</li> |
| 161 | + <li className={style({font: 'heading-xl', fontFamily: 'serif'})}>Heading</li> |
| 162 | + <li className={style({font: 'heading-2xl', fontFamily: 'serif'})}>Heading</li> |
| 163 | + <li className={style({font: 'heading-3xl', fontFamily: 'serif'})}>Heading</li> |
| 164 | + </ul> |
| 165 | + <ul className={style({padding: 0, listStyleType: 'none'})}> |
| 166 | + <li className={style({font: 'body-2xs', fontFamily: 'serif'})}>Body</li> |
| 167 | + <li className={style({font: 'body-xs', fontFamily: 'serif'})}>Body</li> |
| 168 | + <li className={style({font: 'body-sm', fontFamily: 'serif'})}>Body</li> |
| 169 | + <li className={style({font: 'body', fontFamily: 'serif'})}>Body</li> |
| 170 | + <li className={style({font: 'body-lg', fontFamily: 'serif'})}>Body</li> |
| 171 | + <li className={style({font: 'body-xl', fontFamily: 'serif'})}>Body</li> |
| 172 | + <li className={style({font: 'body-2xl', fontFamily: 'serif'})}>Body</li> |
| 173 | + <li className={style({font: 'body-3xl', fontFamily: 'serif'})}>Body</li> |
| 174 | + </ul> |
| 175 | + </div> |
| 176 | + ); |
| 177 | +} |
| 178 | + |
| 179 | +export const Default = { |
| 180 | + render: () => <Example />, |
| 181 | + parameters: { |
| 182 | + chromaticProvider: { |
| 183 | + colorSchemes: ['light'], |
| 184 | + locales: ['en', 'ar', 'he', 'ja', 'ko', 'zh-Hans', 'zh-HK', 'zh-Hant'] |
| 185 | + } |
| 186 | + } |
| 187 | +}; |
| 188 | + |
| 189 | +export const Serif = { |
| 190 | + render: () => <SerifExample />, |
| 191 | + parameters: { |
| 192 | + chromaticProvider: { |
| 193 | + colorSchemes: ['light'], |
| 194 | + // Only en because other locales don't have a serif font. |
| 195 | + locales: ['en'] |
| 196 | + } |
| 197 | + } |
| 198 | +}; |
0 commit comments