foundations.mdx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. import { Meta, ColorItem, ColorPalette, Title, Typeset } from '@storybook/blocks';
  2. import colors from '../../stylesheets/foundations/tokens/colors.json';
  3. import typography from '../../stylesheets/foundations/tokens/typography.json';
  4. import borderRadius from '../../stylesheets/foundations/tokens/borderRadius.json';
  5. import spacing from '../../stylesheets/foundations/tokens/spacing.json';
  6. <Meta title="Storybook Guideline / Foundations" />
  7. # Foundations
  8. Foundations in UX design are the basic rules and core elements, like colors, fonts, and spacing, that ensure consistency across the design.
  9. <p>
  10. These palettes are generated from our token files. The tokens were exported from Figma and split into separate files to categorise: <a href="https://github.com/overleaf/internal/tree/main/services/web/frontend/stylesheets/bootstrap-5/foundations/tokens" target="_blank" rel="noopener noreferrer">Token files on GitHub</a>
  11. </p>
  12. **Table of Contents**
  13. - [Primitive colors](#primitive-colors)
  14. - [Background colors](#background-colors)
  15. - [Content colors](#content-colors)
  16. - [Border colors](#border-colors)
  17. - [Link colors](#link-colors)
  18. - [Special colors](#special-colors)
  19. - [Font weight](#font-weight)
  20. - [Font size](#font-size)
  21. - [Border radius](#border-radius)
  22. - [Spacing](#spacing)
  23. # Colors
  24. <br/>
  25. ## Primitive colors
  26. <ColorPalette>
  27. {Object.entries(colors.PrimitiveColor).map(([name, color]) => (
  28. <ColorItem
  29. key={name}
  30. title={name}
  31. colors={[color.$value]}
  32. />
  33. ))}
  34. </ColorPalette>
  35. ## Background colors
  36. Colors used for page and component backgrounds.
  37. <ColorPalette>
  38. {Object.entries(colors)
  39. .filter(([name]) => name.startsWith('bg-'))
  40. .map(([name, colors]) => (
  41. <ColorItem
  42. key={name}
  43. title={name}
  44. subtitle={colors.$primitive}
  45. colors={[colors.$value]}
  46. />
  47. ))}
  48. </ColorPalette>
  49. ## Content colors
  50. Colors used for text and icons.
  51. <ColorPalette>
  52. {Object.entries(colors)
  53. .filter(([name]) => name.startsWith('content-'))
  54. .map(([name, colors]) => (
  55. <ColorItem
  56. key={name}
  57. title={name}
  58. subtitle={colors.$primitive}
  59. colors={[colors.$value]}
  60. />
  61. ))}
  62. </ColorPalette>
  63. ## Border colors
  64. Colors used for borders and dividers.
  65. <ColorPalette>
  66. {Object.entries(colors)
  67. .filter(([name]) => name.startsWith('border-'))
  68. .map(([name, colors]) => (
  69. <ColorItem
  70. key={name}
  71. title={name}
  72. subtitle={colors.$primitive}
  73. colors={[colors.$value]}
  74. />
  75. ))}
  76. </ColorPalette>
  77. ## Link colors
  78. Colors used for hyperlink states.
  79. <ColorPalette>
  80. {Object.entries(colors)
  81. .filter(([name]) => name.startsWith('link-'))
  82. .map(([name, colors]) => (
  83. <ColorItem
  84. key={name}
  85. title={name}
  86. subtitle={colors.$primitive}
  87. colors={[colors.$value]}
  88. />
  89. ))}
  90. </ColorPalette>
  91. ## Special colors
  92. Colors used for specific UI elements like color pickers.
  93. <ColorPalette>
  94. {Object.entries(colors)
  95. .filter(([name]) => name.startsWith('special-'))
  96. .map(([name, colors]) => (
  97. <ColorItem
  98. key={name}
  99. title={name}
  100. subtitle={colors.$primitive}
  101. colors={[colors.$value]}
  102. />
  103. ))}
  104. </ColorPalette>
  105. # Typography
  106. <br/>
  107. ## Font weight
  108. <br/>
  109. {Object.entries(typography.Fontweight).map(([name, typography]) => (
  110. <div key={name}>
  111. <strong>{name}</strong>
  112. <Typeset
  113. fontSizes={[14]}
  114. fontWeight={typography.$value}
  115. sampleText="The quick brown fox jumps over the lazy dog"
  116. />
  117. </div>
  118. ))}
  119. ## Font size
  120. <br/>
  121. {Object.entries(typography['Fontsize']).map(([name, typography]) => {
  122. const mixins = typography.$mixin ? [].concat(typography.$mixin) : [];
  123. return (
  124. <div key={name} style={{ marginBottom: '2rem' }}>
  125. <strong>
  126. {name}
  127. {mixins.map(mixin => (
  128. <span key={mixin}> / @mixin {mixin}</span>
  129. ))}
  130. </strong>
  131. <Typeset
  132. fontSizes={[`${typography.$value}px`]}
  133. fontWeight={500}
  134. sampleText="The quick brown fox jumps over the lazy dog"
  135. />
  136. </div>
  137. );
  138. })}
  139. ## Border radius
  140. <br/>
  141. <table style={{ width: '100%' }}>
  142. <thead>
  143. <tr>
  144. <th>Variable name</th>
  145. <th>Value</th>
  146. <th style={{ textAlign: 'center' }}>Example</th>
  147. </tr>
  148. </thead>
  149. <tbody>
  150. {Object.entries(borderRadius['BorderRadius']).map(([name, borderRadius]) => (
  151. <tr key={name}>
  152. <td>
  153. <strong>{name}</strong>
  154. </td>
  155. <td style={{ textAlign: 'center' }}>{borderRadius.$value}px</td>
  156. <td style={{ textAlign: 'center', padding: '0.5rem' }}>
  157. <div
  158. style={{
  159. width: '80px',
  160. height: '80px',
  161. borderRadius: `${borderRadius.$value}px`,
  162. backgroundColor: '#098842',
  163. display: 'inline-block',
  164. }}
  165. />
  166. </td>
  167. </tr>
  168. ))}
  169. </tbody>
  170. </table>
  171. ## Spacing
  172. <br/>
  173. <table style={{ width: '100%' }}>
  174. <thead>
  175. <tr>
  176. <th>Variable Name</th>
  177. <th>Value</th>
  178. <th style={{ textAlign: 'left', paddingLeft: '1rem' }}>Example</th>
  179. </tr>
  180. </thead>
  181. <tbody>
  182. {Object.entries(spacing.Spacing)
  183. .filter(([, spacing]) => spacing.$value > 0)
  184. .map(([name, spacing]) => (
  185. <tr key={name}>
  186. <td>
  187. <strong>{name}</strong>
  188. </td>
  189. <td style={{ textAlign: 'center' }}>{spacing.$value}px</td>
  190. <td style={{ padding: '0.5rem 1rem', verticalAlign: 'middle' }}>
  191. <div
  192. style={{
  193. height: `${spacing.$value}px`,
  194. width: '100%',
  195. backgroundColor: '#098842',
  196. }}
  197. />
  198. </td>
  199. </tr>
  200. ))}
  201. </tbody>
  202. </table>