foundations.mdx 5.6 KB

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