@sfgov/design-system 0.0.0-2b1f226

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/babel.config.js +16 -0
  4. package/css/.eslintrc.js +26 -0
  5. package/css/babel.config.js +6 -0
  6. package/css/lib/tailwind/details.js +14 -0
  7. package/css/package-lock.json +35561 -0
  8. package/css/src/base.css +26 -0
  9. package/css/src/components/button.css +61 -0
  10. package/css/src/components/details.css +10 -0
  11. package/css/src/components/grid.css +12 -0
  12. package/css/src/components/index.css +4 -0
  13. package/css/src/components/kbd.css +5 -0
  14. package/css/src/components.css +1 -0
  15. package/css/src/fonts.css +1 -0
  16. package/css/src/icons.css +7 -0
  17. package/css/src/overrides.css +3 -0
  18. package/css/src/sfds.css +6 -0
  19. package/css/src/theme.js +104 -0
  20. package/css/src/tokens/breakpoints.js +5 -0
  21. package/css/src/tokens/colors.js +116 -0
  22. package/css/src/tokens/index.js +8 -0
  23. package/css/src/tokens/spacing.js +27 -0
  24. package/css/src/tokens/typography.js +66 -0
  25. package/css/src/tokens/widths.js +11 -0
  26. package/css/src/typography.css +103 -0
  27. package/css/src/utilities.css +1 -0
  28. package/dist/css/base.css +2 -0
  29. package/dist/css/base.css.map +1 -0
  30. package/dist/css/components.css +2 -0
  31. package/dist/css/components.css.map +1 -0
  32. package/dist/css/fonts.css +2 -0
  33. package/dist/css/fonts.css.map +1 -0
  34. package/dist/css/icons.css +2 -0
  35. package/dist/css/icons.css.map +1 -0
  36. package/dist/css/overrides.css +2 -0
  37. package/dist/css/overrides.css.map +1 -0
  38. package/dist/css/sfds.css +2 -0
  39. package/dist/css/sfds.css.map +1 -0
  40. package/dist/css/typography.css +2 -0
  41. package/dist/css/typography.css.map +1 -0
  42. package/dist/css/utilities.css +2 -0
  43. package/dist/css/utilities.css.map +1 -0
  44. package/dist/css/utilities.json +7350 -0
  45. package/dist/elements/index.d.mts +30 -0
  46. package/dist/elements/index.d.mts.map +1 -0
  47. package/dist/elements/index.d.ts +30 -0
  48. package/dist/elements/index.d.ts.map +1 -0
  49. package/dist/elements/index.js +1 -0
  50. package/dist/elements/index.mjs +1 -0
  51. package/dist/manifest.json +45 -0
  52. package/dist/react/index.d.mts +5725 -0
  53. package/dist/react/index.d.mts.map +1 -0
  54. package/dist/react/index.d.ts +5725 -0
  55. package/dist/react/index.d.ts.map +1 -0
  56. package/dist/react/index.js +1 -0
  57. package/dist/react/index.mjs +1 -0
  58. package/elements/.eslintrc.js +6 -0
  59. package/elements/index.js +1 -0
  60. package/elements/index.mjs +1 -0
  61. package/elements/src/index.js +7 -0
  62. package/elements/src/sfgov-icon.js +109 -0
  63. package/icons/.eslintrc.js +23 -0
  64. package/icons/index.json +439 -0
  65. package/icons/svg/accessibility.svg +4 -0
  66. package/icons/svg/alert.svg +5 -0
  67. package/icons/svg/archive.svg +4 -0
  68. package/icons/svg/arrow-down.svg +3 -0
  69. package/icons/svg/arrow-left.svg +3 -0
  70. package/icons/svg/arrow-right.svg +3 -0
  71. package/icons/svg/arrow-up.svg +3 -0
  72. package/icons/svg/building.svg +7 -0
  73. package/icons/svg/calendar.svg +3 -0
  74. package/icons/svg/caution.svg +3 -0
  75. package/icons/svg/chart.svg +6 -0
  76. package/icons/svg/check.svg +3 -0
  77. package/icons/svg/chevron-down.svg +3 -0
  78. package/icons/svg/chevron-left.svg +3 -0
  79. package/icons/svg/chevron-right.svg +3 -0
  80. package/icons/svg/chevron-up.svg +3 -0
  81. package/icons/svg/clock.svg +4 -0
  82. package/icons/svg/close.svg +3 -0
  83. package/icons/svg/document.svg +3 -0
  84. package/icons/svg/globe.svg +3 -0
  85. package/icons/svg/hamburger-button.svg +5 -0
  86. package/icons/svg/index.json +346 -0
  87. package/icons/svg/info.svg +5 -0
  88. package/icons/svg/location.svg +4 -0
  89. package/icons/svg/mail.svg +3 -0
  90. package/icons/svg/minus.svg +3 -0
  91. package/icons/svg/pencil.svg +3 -0
  92. package/icons/svg/phone.svg +3 -0
  93. package/icons/svg/plus.svg +3 -0
  94. package/icons/svg/question.svg +4 -0
  95. package/icons/svg/search.svg +3 -0
  96. package/icons/svg/wip.svg +3 -0
  97. package/lib/markdownlint/frontmatter.js +51 -0
  98. package/lib/markdownlint/no-empty.js +19 -0
  99. package/package.json +352 -0
  100. package/postcss.config.js +17 -0
  101. package/react/README.md +36 -0
  102. package/react/index.js +1 -0
  103. package/react/index.mjs +1 -0
  104. package/react/scripts/wrap-icons.mjs +25 -0
  105. package/react/src/components/Box.tsx +6 -0
  106. package/react/src/components/Button.tsx +94 -0
  107. package/react/src/components/Container.tsx +19 -0
  108. package/react/src/components/Flex.tsx +16 -0
  109. package/react/src/components/GlobalStyle.tsx +35 -0
  110. package/react/src/components/GoogleFonts.tsx +67 -0
  111. package/react/src/components/Grid.tsx +15 -0
  112. package/react/src/components/SSRStyle.tsx +47 -0
  113. package/react/src/components/SVGIcon.tsx +42 -0
  114. package/react/src/components/Text.tsx +78 -0
  115. package/react/src/components/Tile.tsx +93 -0
  116. package/react/src/components/index.ts +11 -0
  117. package/react/src/components/page/AboutSection.tsx +90 -0
  118. package/react/src/components/page/AgencyHeader.tsx +56 -0
  119. package/react/src/components/page/ArchiveInformation.tsx +43 -0
  120. package/react/src/components/page/ContactSection.tsx +92 -0
  121. package/react/src/components/page/Section.tsx +53 -0
  122. package/react/src/components/page/Spotlight.tsx +70 -0
  123. package/react/src/components/page/index.ts +6 -0
  124. package/react/src/constants.ts +48 -0
  125. package/react/src/icons/IconAccessibility.jsx +3 -0
  126. package/react/src/icons/IconAlert.jsx +3 -0
  127. package/react/src/icons/IconArchive.jsx +3 -0
  128. package/react/src/icons/IconArrowDown.jsx +3 -0
  129. package/react/src/icons/IconArrowLeft.jsx +3 -0
  130. package/react/src/icons/IconArrowRight.jsx +3 -0
  131. package/react/src/icons/IconArrowUp.jsx +3 -0
  132. package/react/src/icons/IconBuilding.jsx +3 -0
  133. package/react/src/icons/IconCalendar.jsx +3 -0
  134. package/react/src/icons/IconCaution.jsx +3 -0
  135. package/react/src/icons/IconChart.jsx +3 -0
  136. package/react/src/icons/IconCheck.jsx +3 -0
  137. package/react/src/icons/IconChevronDown.jsx +3 -0
  138. package/react/src/icons/IconChevronLeft.jsx +3 -0
  139. package/react/src/icons/IconChevronRight.jsx +3 -0
  140. package/react/src/icons/IconChevronUp.jsx +3 -0
  141. package/react/src/icons/IconClock.jsx +3 -0
  142. package/react/src/icons/IconClose.jsx +3 -0
  143. package/react/src/icons/IconDocument.jsx +3 -0
  144. package/react/src/icons/IconGlobe.jsx +3 -0
  145. package/react/src/icons/IconHamburgerButton.jsx +3 -0
  146. package/react/src/icons/IconInfo.jsx +3 -0
  147. package/react/src/icons/IconLocation.jsx +3 -0
  148. package/react/src/icons/IconMail.jsx +3 -0
  149. package/react/src/icons/IconMinus.jsx +3 -0
  150. package/react/src/icons/IconPencil.jsx +3 -0
  151. package/react/src/icons/IconPhone.jsx +3 -0
  152. package/react/src/icons/IconPlus.jsx +3 -0
  153. package/react/src/icons/IconQuestion.jsx +3 -0
  154. package/react/src/icons/IconSearch.jsx +3 -0
  155. package/react/src/icons/IconWIP.jsx +3 -0
  156. package/react/src/icons/index.js +31 -0
  157. package/react/src/icons/index.json +346 -0
  158. package/react/src/icons.tsx +34 -0
  159. package/react/src/index.ts +4 -0
  160. package/react/src/stitches.config.ts +85 -0
  161. package/react/src/theme/breakpoints.ts +14 -0
  162. package/react/src/theme/colors.ts +34 -0
  163. package/react/src/theme/index.tsx +31 -0
  164. package/react/src/theme/space.ts +16 -0
  165. package/react/src/theme/typography.ts +136 -0
  166. package/react/src/types.ts +31 -0
  167. package/react/src/utils.tsx +25 -0
  168. package/rollup.config.mjs +72 -0
  169. package/svgo.config.js +27 -0
  170. package/tailwind.config.js +5 -0
  171. package/tailwind.preset.js +128 -0
@@ -0,0 +1,136 @@
1
+ import { CSS } from '@stitches/react'
2
+ import { defaultFonts } from '../constants'
3
+
4
+ export const fonts = {
5
+ body: '$sans',
6
+ sans: '$RobotoFlex',
7
+ slab: '$RobotoSlab',
8
+ monospace: '$RobotoMono',
9
+ chinese: '$NotoSansTC',
10
+ ...Object.fromEntries(
11
+ defaultFonts.map(font => [
12
+ font.name.replace(/ +/g, ''),
13
+ `${[font.name, ...font.fallbacks
14
+ ].join(', ')}`])
15
+ )
16
+ }
17
+
18
+ export const textStyles: Record<string, CSS> = {
19
+ body: {
20
+ fontFamily: '$body',
21
+ fontSize: '16px',
22
+ fontWeight: '$normal',
23
+ lineHeight: '24px'
24
+ },
25
+ small: {
26
+ fontFamily: '$body',
27
+ fontSize: '14px',
28
+ lineHeight: '18px'
29
+ },
30
+ bigDesc: {
31
+ fontFamily: '$body',
32
+ fontSize: '20px',
33
+ fontWeight: '$bold',
34
+ lineHeight: '28px'
35
+ },
36
+ bigDescDesktop: {
37
+ fontFamily: '$body',
38
+ fontSize: '24px',
39
+ fontWeight: '$bold',
40
+ lineHeight: '32px'
41
+ },
42
+ titleXs: {
43
+ fontFamily: '$sans',
44
+ fontSize: '20px',
45
+ fontWeight: '$bold',
46
+ lineHeight: '24px'
47
+ },
48
+ titleSm: {
49
+ fontFamily: '$sans',
50
+ fontSize: '24px',
51
+ fontWeight: '$bold',
52
+ lineHeight: '28px'
53
+ },
54
+ titleMd: {
55
+ fontFamily: '$slab',
56
+ fontSize: '24px',
57
+ fontWeight: '$bold',
58
+ lineHeight: '28px'
59
+ },
60
+ titleLg: {
61
+ fontFamily: '$slab',
62
+ fontSize: '28px',
63
+ fontWeight: '$bold',
64
+ lineHeight: '32px'
65
+ },
66
+ titleXl: {
67
+ fontFamily: '$slab',
68
+ fontSize: '32px',
69
+ fontWeight: '$bold',
70
+ lineHeight: '36px'
71
+ },
72
+ displaySm: {
73
+ fontFamily: '$slab',
74
+ fontSize: '36px',
75
+ fontWeight: '$light',
76
+ lineHeight: '40px'
77
+ },
78
+ displayLg: {
79
+ fontFamily: '$slab',
80
+ fontSize: '44px',
81
+ fontWeight: '$light',
82
+ lineHeight: '48px'
83
+ },
84
+ titleMdDesktop: {
85
+ fontFamily: '$slab',
86
+ fontSize: '32px',
87
+ fontWeight: '$bold',
88
+ lineHeight: '36px'
89
+ },
90
+ titleLgDesktop: {
91
+ fontFamily: '$slab',
92
+ fontSize: '44px',
93
+ fontWeight: '$bold',
94
+ lineHeight: '52px'
95
+ },
96
+ titleXlDesktop: {
97
+ fontFamily: '$slab',
98
+ fontSize: '60px',
99
+ fontWeight: '$bold',
100
+ lineHeight: '64px'
101
+ },
102
+ displaySmDesktop: {
103
+ fontFamily: '$slab',
104
+ fontSize: '48px',
105
+ fontWeight: '$light',
106
+ lineHeight: '52px'
107
+ },
108
+ displayLgDesktop: {
109
+ fontFamily: '$slab',
110
+ fontSize: '72px',
111
+ fontWeight: '$light',
112
+ lineHeight: '76px'
113
+ }
114
+ }
115
+
116
+ export const fontWeights = {
117
+ light: 300,
118
+ normal: 400,
119
+ bold: 700,
120
+ boldChinese: 500,
121
+ ...collect('fontWeight')
122
+ }
123
+
124
+ export const fontSizes = collect('fontSize')
125
+ export const lineHeights = collect('lineHeight')
126
+ export const letterSpacings = collect('letterSpacing')
127
+
128
+ function collect (prop: keyof CSS) {
129
+ const map = {}
130
+ for (const [name, style] of Object.entries(textStyles)) {
131
+ if (prop in style) {
132
+ map[name] = style[prop]
133
+ }
134
+ }
135
+ return map
136
+ }
@@ -0,0 +1,31 @@
1
+ import type { ComponentProps } from 'react'
2
+
3
+ export type LinkProps = ComponentProps<'link'>
4
+
5
+ export type FontWeightName = 'light' | 'normal' | 'bold' | 'semibold'
6
+ export type FixedFontWeightMap = Partial<Record<FontWeightName, number>>
7
+
8
+ // "8..144,300;8..144,400;8..144,700"
9
+ type OpticalWeights = Partial<Record<FontWeightName, [number[], number]>>
10
+
11
+ export type OpticalGoogleFont = {
12
+ optical: true
13
+ weights: OpticalWeights
14
+ }
15
+
16
+ export type GoogleFontOptions = {
17
+ optical: false
18
+ } | OpticalGoogleFont
19
+
20
+ export type FontSpec = {
21
+ name: string
22
+ fallbacks?: string[]
23
+ weights: FixedFontWeightMap
24
+ googleFont?: GoogleFontOptions
25
+ }
26
+
27
+ export type FontSpecProps = {
28
+ fonts?: FontSpec[]
29
+ }
30
+
31
+ export type GlobalCSSProps = FontSpecProps
@@ -0,0 +1,25 @@
1
+ import React, { Component, ComponentProps, ComponentType } from 'react'
2
+
3
+ export function identity (v: any) {
4
+ return v
5
+ }
6
+
7
+ export function pxMap (values: number[]): Record<number, string> {
8
+ return values.reduce((o, n) => Object.assign(o, { [n]: px(n) }), {})
9
+ }
10
+
11
+ export function px (n: number | string) {
12
+ return (typeof n === 'string') ? n : n === 0 ? '0' : `${n}px`
13
+ }
14
+
15
+ export function withFixedProps (
16
+ Component: ComponentType<any>,
17
+ fixed: Partial<ComponentProps<typeof Component>>
18
+ ) {
19
+ type Unfixed = Omit<ComponentProps<typeof Component>, keyof typeof fixed>
20
+ return function FixedProps (props: Unfixed) {
21
+ return <Component {...fixed} {...props} />
22
+ }
23
+ }
24
+
25
+ export type VariantProps<T, P extends {} = T extends ComponentType ? ComponentProps<T> : T> = T & JSX.IntrinsicAttributes
@@ -0,0 +1,72 @@
1
+ import commonjs from '@rollup/plugin-commonjs'
2
+ import json from '@rollup/plugin-json'
3
+ import peerDepsExternal from 'rollup-plugin-peer-deps-external'
4
+ import resolve from '@rollup/plugin-node-resolve'
5
+ import ts from 'rollup-plugin-ts'
6
+ import { terser } from 'rollup-plugin-terser'
7
+
8
+ /**
9
+ * @typedef {import('rollup').RollupOptions} RollupOptions
10
+ * @typedef {import('rollup').InputOptions} InputOptions
11
+ * @typedef {import('rollup').OutputOptions} OutputOptions
12
+ */
13
+
14
+ const { NODE_ENV } = process.env
15
+ const production = NODE_ENV === 'production'
16
+ const sourcemap = !production
17
+
18
+ const commonPlugins = [
19
+ commonjs({
20
+ }),
21
+ json({
22
+ compact: true
23
+ }),
24
+ resolve({
25
+ }),
26
+ peerDepsExternal(),
27
+ ts({
28
+ transpiler: 'babel'
29
+ }),
30
+ production && terser()
31
+ ]
32
+
33
+ /** @type {RollupOptions[]} */
34
+ export default [
35
+ {
36
+ input: './elements/src/index.js',
37
+ plugins: commonPlugins,
38
+ output: [
39
+ {
40
+ file: 'dist/elements/index.mjs',
41
+ format: 'esm',
42
+ sourcemap
43
+ },
44
+ {
45
+ file: 'dist/elements/index.js',
46
+ format: 'umd',
47
+ name: 'sfgov.elements',
48
+ sourcemap
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ input: './react/src/index.ts',
54
+ plugins: commonPlugins,
55
+ output: [
56
+ {
57
+ file: 'dist/react/index.mjs',
58
+ format: 'esm',
59
+ sourcemap
60
+ },
61
+ {
62
+ file: 'dist/react/index.js',
63
+ format: 'umd',
64
+ name: 'sfgov.react',
65
+ sourcemap,
66
+ globals: {
67
+ react: 'React'
68
+ }
69
+ }
70
+ ]
71
+ }
72
+ ]
package/svgo.config.js ADDED
@@ -0,0 +1,27 @@
1
+ /** @type {import('svgo/lib/svgo').Config} */
2
+ module.exports = {
3
+ multipass: true,
4
+ js2svg: {
5
+ pretty: true,
6
+ indent: 2
7
+ },
8
+ plugins: [
9
+ 'removeDimensions',
10
+ { name: 'removeViewBox', active: false },
11
+ {
12
+ name: 'removeAttrs',
13
+ params: {
14
+ attrs: ['fill', 'stroke', 'id', 'clipPath', 'clip-path', 'clipRule']
15
+ }
16
+ },
17
+ 'removeUselessDefs',
18
+ 'removeXMLNS',
19
+ 'collapseGroups',
20
+ {
21
+ name: 'addAttributesToSVGElement',
22
+ params: {
23
+ attributes: ['fill="currentcolor"']
24
+ }
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ presets: [
3
+ require('./tailwind.preset')
4
+ ]
5
+ }
@@ -0,0 +1,128 @@
1
+ const theme = require('./css/src/theme')
2
+
3
+ module.exports = {
4
+ theme,
5
+
6
+ important: true,
7
+
8
+ /*
9
+ * This is where we disable Tailwind's "core plugins", most of
10
+ * which generate utility classes. There are a *lot* of these
11
+ * turned on by default. Disabling them here saves us many
12
+ * kilobytes in generated CSS.
13
+ *
14
+ * See: <https://tailwindcss.com/docs/configuration#core-plugins>
15
+ */
16
+ corePlugins: [
17
+ // TODO [^3]: add preflight (https://tailwindcss.com/docs/preflight)
18
+ 'accessibility',
19
+ 'alignContent',
20
+ 'alignItems',
21
+ 'appearance',
22
+ 'backgroundColor',
23
+ 'borderColor',
24
+ 'borderRadius',
25
+ 'borderStyle',
26
+ 'borderWidth',
27
+ 'cursor',
28
+ 'display',
29
+ 'flex',
30
+ 'flexDirection',
31
+ 'flexShrink',
32
+ 'flexWrap',
33
+ 'fontFamily',
34
+ 'fontSize',
35
+ 'fontSmoothing',
36
+ 'fontWeight',
37
+ 'gap',
38
+ 'gridColumn',
39
+ 'gridRow',
40
+ 'gridTemplateColumns',
41
+ 'gridTemplateRows',
42
+ 'height',
43
+ 'inset',
44
+ 'justifyContent',
45
+ 'justifyItems',
46
+ 'letterSpacing',
47
+ 'listStyleType',
48
+ 'margin',
49
+ 'maxWidth',
50
+ 'opacity',
51
+ 'overflow',
52
+ 'padding',
53
+ 'pointerEvents',
54
+ 'position',
55
+ 'space',
56
+ 'textAlign',
57
+ 'textColor',
58
+ 'textDecoration',
59
+ 'verticalAlign',
60
+ 'visibility',
61
+ 'whitespace',
62
+ 'width',
63
+ 'zIndex'
64
+ ],
65
+
66
+ /*
67
+ * This is where we tell Tailwind which variants to make available
68
+ * for each "core plugin". Most plugins get responsive variants out
69
+ * of the box, but we can shrink the size of our CSS significantly
70
+ * by turning off responsive variants for ones that we don't need
71
+ * to change at different screen widths.
72
+ *
73
+ * See: <https://tailwindcss.com/docs/configuring-variants>
74
+ */
75
+ variants: {
76
+ // TODO [^3]: nix 'focus'
77
+ accessibility: ['responsive', 'focus', 'hocus'],
78
+ appearance: [],
79
+ // TODO [^3]: nix 'focus' + 'hover'
80
+ backgroundColor: ['focus', 'focus-within', 'hover', 'hocus', 'group-hocus', 'details'],
81
+ // TODO [^3]: nix 'focus' + 'hover'
82
+ borderColor: ['focus', 'hover', 'hocus', 'group-hocus', 'details'],
83
+ borderWidth: ['hocus'],
84
+ cursor: [],
85
+ display: ['responsive', 'group-hocus', 'details'],
86
+ fill: [],
87
+ fontWeight: ['responsive'],
88
+ fontSize: ['responsive'],
89
+ fontSmoothing: [],
90
+ fontStyle: [],
91
+ flexDirection: ['responsive'],
92
+ flexWrap: [],
93
+ gap: ['responsive'],
94
+ gridColumn: ['responsive'],
95
+ gridRow: ['responsive'],
96
+ gridTemplateColumns: ['responsive'],
97
+ gridTemplateRows: ['responsive'],
98
+ height: ['responsive'],
99
+ inset: ['responsive'],
100
+ letterSpacing: ['responsive'],
101
+ lineHeight: ['responsive'],
102
+ listStyleType: ['responsive'],
103
+ listStylePosition: [],
104
+ overflow: [], // TODO [^2.3]: add 'hocus', 'group-hocus'
105
+ padding: ['responsive'],
106
+ pointerEvents: [],
107
+ position: ['responsive'],
108
+ margin: ['responsive'],
109
+ maxWidth: ['responsive'],
110
+ space: ['responsive'],
111
+ stroke: [],
112
+ strokeWidth: [],
113
+ // TODO [^3]: nix 'focus' + 'hover'
114
+ textColor: ['focus', 'hover', 'hocus', 'group-hocus', 'details'],
115
+ // TODO [^3]: nix 'focus' + 'hover'
116
+ textDecoration: ['focus', 'hover', 'hocus'],
117
+ userSelect: [],
118
+ verticalAlign: ['responsive'],
119
+ visibility: ['responsive', 'group-hocus'],
120
+ width: ['responsive'],
121
+ zIndex: ['responsive']
122
+ },
123
+
124
+ plugins: [
125
+ require('tailwindcss-interaction-variants'),
126
+ require('./css/lib/tailwind/details')
127
+ ]
128
+ }