@primer/components 31.0.2-rc.95622264 → 31.2.0-rc.50908ce9
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.
- package/.storybook/main.js +7 -9
- package/.storybook/preview.js +5 -1
- package/CHANGELOG.md +15 -1
- package/dist/browser.esm.js +1 -1
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +1 -1
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/FilterList.md +2 -2
- package/docs/content/theming.md +23 -0
- package/lib/ActionList/Header.js +1 -1
- package/lib/Autocomplete/Autocomplete.d.ts +4 -4
- package/lib/Autocomplete/AutocompleteInput.d.ts +4 -4
- package/lib/Button/Button.d.ts +5 -5
- package/lib/Button/ButtonBase.d.ts +1 -1
- package/lib/Button/ButtonClose.d.ts +3 -3
- package/lib/Button/ButtonDanger.d.ts +5 -5
- package/lib/Button/ButtonInvisible.d.ts +5 -5
- package/lib/Button/ButtonOutline.d.ts +5 -5
- package/lib/Button/ButtonPrimary.d.ts +5 -5
- package/lib/CircleBadge.d.ts +2 -2
- package/lib/CircleOcticon.d.ts +4 -4
- package/lib/Dialog.d.ts +4 -4
- package/lib/Dropdown.d.ts +16 -16
- package/lib/DropdownMenu/DropdownButton.d.ts +6 -6
- package/lib/FilterList.d.ts +3 -3
- package/lib/Flash.d.ts +1 -1
- package/lib/Label.d.ts +1 -1
- package/lib/Position.d.ts +4 -4
- package/lib/ProgressBar.d.ts +1 -1
- package/lib/SelectMenu/SelectMenu.d.ts +24 -24
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/TextInputWithTokens.d.ts +4 -4
- package/lib/Timeline.d.ts +4 -4
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/Token.d.ts +1 -1
- package/lib/_TextInputWrapper.d.ts +1 -1
- package/lib/__tests__/KeyPaths.types.test.d.ts +11 -0
- package/lib/__tests__/KeyPaths.types.test.js +10 -0
- package/lib/stories/Token.stories.js +19 -2
- package/lib/sx.d.ts +8 -2
- package/lib/theme.d.ts +78 -0
- package/lib/theme.js +3 -1
- package/lib/utils/types/KeyPaths.d.ts +3 -0
- package/lib/utils/types/KeyPaths.js +1 -0
- package/lib-esm/ActionList/Header.js +1 -1
- package/lib-esm/Autocomplete/Autocomplete.d.ts +4 -4
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +4 -4
- package/lib-esm/Button/Button.d.ts +5 -5
- package/lib-esm/Button/ButtonBase.d.ts +1 -1
- package/lib-esm/Button/ButtonClose.d.ts +3 -3
- package/lib-esm/Button/ButtonDanger.d.ts +5 -5
- package/lib-esm/Button/ButtonInvisible.d.ts +5 -5
- package/lib-esm/Button/ButtonOutline.d.ts +5 -5
- package/lib-esm/Button/ButtonPrimary.d.ts +5 -5
- package/lib-esm/CircleBadge.d.ts +2 -2
- package/lib-esm/CircleOcticon.d.ts +4 -4
- package/lib-esm/Dialog.d.ts +4 -4
- package/lib-esm/Dropdown.d.ts +16 -16
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +6 -6
- package/lib-esm/FilterList.d.ts +3 -3
- package/lib-esm/Flash.d.ts +1 -1
- package/lib-esm/Label.d.ts +1 -1
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/ProgressBar.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +24 -24
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +4 -4
- package/lib-esm/Timeline.d.ts +4 -4
- package/lib-esm/Token/AvatarToken.d.ts +1 -1
- package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/_TextInputWrapper.d.ts +1 -1
- package/lib-esm/__tests__/KeyPaths.types.test.d.ts +11 -0
- package/lib-esm/__tests__/KeyPaths.types.test.js +3 -0
- package/lib-esm/stories/Token.stories.js +14 -1
- package/lib-esm/sx.d.ts +8 -2
- package/lib-esm/theme.d.ts +78 -0
- package/lib-esm/theme.js +2 -1
- package/lib-esm/utils/types/KeyPaths.d.ts +3 -0
- package/lib-esm/utils/types/KeyPaths.js +1 -0
- package/package-lock.json +37956 -42
- package/package.json +3 -1
- package/script/build +2 -0
- package/src/ActionList/Header.tsx +1 -1
- package/src/__tests__/KeyPaths.types.test.ts +14 -0
- package/src/stories/Button.stories.tsx +1 -1
- package/src/stories/Token.stories.tsx +12 -1
- package/src/sx.ts +14 -2
- package/src/theme.ts +86 -0
- package/src/utils/types/KeyPaths.ts +10 -0
- package/stats.html +1 -1
- package/.changeset/tiny-ghosts-repeat.md +0 -5
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@primer/components",
|
3
|
-
"version": "31.0
|
3
|
+
"version": "31.2.0-rc.50908ce9",
|
4
4
|
"description": "Primer react components",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"module": "lib-esm/index.js",
|
@@ -132,7 +132,9 @@
|
|
132
132
|
"rollup-plugin-visualizer": "5.5.0",
|
133
133
|
"semver": "7.3.5",
|
134
134
|
"size-limit": "5.0.2",
|
135
|
+
"storybook-addon-performance": "0.16.1",
|
135
136
|
"styled-components": "4.4.1",
|
137
|
+
"ts-toolbelt": "9.6.0",
|
136
138
|
"typescript": "4.2.2"
|
137
139
|
},
|
138
140
|
"peerDependencies": {
|
package/script/build
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
import {Union} from 'ts-toolbelt'
|
2
|
+
import {KeyPaths} from '../utils/types/KeyPaths'
|
3
|
+
|
4
|
+
type NestedObject = {
|
5
|
+
a: string
|
6
|
+
b: {
|
7
|
+
b1: string
|
8
|
+
b2: string
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
export function generatesKeyPathsFromObject(x: Union.Diff<KeyPaths<NestedObject>, 'a' | 'b.b1' | 'b.b2'>): never {
|
13
|
+
return x
|
14
|
+
}
|
@@ -77,7 +77,7 @@ export const buttonGroup = (args: StrictButtonStyleProps) => (
|
|
77
77
|
export const buttonTableList = (args: ButtonStyleProps) => (
|
78
78
|
<ButtonTableList {...args}>Button Table List</ButtonTableList>
|
79
79
|
)
|
80
|
-
export const disabledButton = (args:
|
80
|
+
export const disabledButton = (args: StrictButtonStyleProps) => {
|
81
81
|
const props = {disabled: true, ...args}
|
82
82
|
return <Button {...props}>Disabled</Button>
|
83
83
|
}
|
@@ -7,6 +7,7 @@ import {BaseStyles, ThemeProvider} from '..'
|
|
7
7
|
import Box from '../Box'
|
8
8
|
import Token, {TokenProps} from '../Token/Token'
|
9
9
|
import Text from '../Text'
|
10
|
+
import {GitBranchIcon} from '@primer/octicons-react'
|
10
11
|
|
11
12
|
export default {
|
12
13
|
title: 'Tokens/Default',
|
@@ -29,7 +30,7 @@ export default {
|
|
29
30
|
]
|
30
31
|
} as Meta
|
31
32
|
|
32
|
-
const excludedControlKeys = ['id', 'as', 'tabIndex', 'onRemove']
|
33
|
+
const excludedControlKeys = ['id', 'as', 'tabIndex', 'onRemove', 'leadingVisual']
|
33
34
|
|
34
35
|
const SingleExampleContainer: React.FC<{label?: string}> = ({children, label}) => (
|
35
36
|
<Box
|
@@ -94,6 +95,16 @@ export const Interactive = (args: Omit<TokenProps, 'ref' | 'text'>) => {
|
|
94
95
|
}
|
95
96
|
Interactive.parameters = {controls: {exclude: [...excludedControlKeys, 'hideRemoveButton', 'text']}}
|
96
97
|
|
98
|
+
export const WithLeadingVisual = (args: Omit<TokenProps, 'ref'>) => {
|
99
|
+
return (
|
100
|
+
<ExampleCollectionContainer>
|
101
|
+
<Token {...args} leadingVisual={() => <GitBranchIcon />} />
|
102
|
+
</ExampleCollectionContainer>
|
103
|
+
)
|
104
|
+
}
|
105
|
+
WithLeadingVisual.storyName = 'with leadingVisual'
|
106
|
+
WithLeadingVisual.parameters = {controls: {exclude: [...excludedControlKeys, 'hideRemoveButton']}}
|
107
|
+
|
97
108
|
export const WithOnRemoveFn = (args: Omit<TokenProps, 'ref'>) => {
|
98
109
|
return (
|
99
110
|
<ExampleCollectionContainer>
|
package/src/sx.ts
CHANGED
@@ -1,7 +1,19 @@
|
|
1
|
-
import css, {SystemStyleObject} from '@styled-system/css'
|
1
|
+
import css, {SystemCssProperties, SystemStyleObject} from '@styled-system/css'
|
2
|
+
import {ThemeColorPaths, ThemeShadowPaths} from './theme'
|
3
|
+
import {ColorProps, ShadowProps} from 'styled-system'
|
4
|
+
|
5
|
+
export type BetterCssProperties = {
|
6
|
+
[K in keyof SystemCssProperties]: K extends keyof ColorProps
|
7
|
+
? ThemeColorPaths | SystemCssProperties[K]
|
8
|
+
: K extends keyof ShadowProps
|
9
|
+
? ThemeShadowPaths | SystemCssProperties[K]
|
10
|
+
: SystemCssProperties[K]
|
11
|
+
}
|
12
|
+
|
13
|
+
export type BetterSystemStyleObject = BetterCssProperties | SystemStyleObject
|
2
14
|
|
3
15
|
export interface SxProp {
|
4
|
-
sx?:
|
16
|
+
sx?: BetterSystemStyleObject
|
5
17
|
}
|
6
18
|
|
7
19
|
const sx = (props: SxProp) => css(props.sx)
|
package/src/theme.ts
CHANGED
@@ -1,3 +1,89 @@
|
|
1
1
|
import {theme} from './theme-preval'
|
2
|
+
import {KeyPaths} from './utils/types/KeyPaths'
|
2
3
|
|
3
4
|
export default theme
|
5
|
+
|
6
|
+
// NOTE: for now, ThemeColors and ThemeShadows are handcrafted types. It would be nice if these
|
7
|
+
// were exports from primitives (or a different shape but derived from those exports).
|
8
|
+
|
9
|
+
type ThemeColors = {
|
10
|
+
fg: {
|
11
|
+
default: string
|
12
|
+
muted: string
|
13
|
+
subtle: string
|
14
|
+
onEmphasis: string
|
15
|
+
}
|
16
|
+
canvas: {
|
17
|
+
default: string
|
18
|
+
overlay: string
|
19
|
+
inset: string
|
20
|
+
subtle: string
|
21
|
+
}
|
22
|
+
border: {
|
23
|
+
default: string
|
24
|
+
muted: string
|
25
|
+
subtle: string
|
26
|
+
}
|
27
|
+
|
28
|
+
// Roles
|
29
|
+
neutral: {
|
30
|
+
emphasisPlus: string
|
31
|
+
emphasis: string
|
32
|
+
muted: string
|
33
|
+
subtle: string
|
34
|
+
}
|
35
|
+
accent: {
|
36
|
+
fg: string
|
37
|
+
emphasis: string
|
38
|
+
muted: string
|
39
|
+
subtle: string
|
40
|
+
}
|
41
|
+
success: {
|
42
|
+
fg: string
|
43
|
+
emphasis: string
|
44
|
+
muted: string
|
45
|
+
subtle: string
|
46
|
+
}
|
47
|
+
attention: {
|
48
|
+
fg: string
|
49
|
+
emphasis: string
|
50
|
+
muted: string
|
51
|
+
subtle: string
|
52
|
+
}
|
53
|
+
severe: {
|
54
|
+
fg: string
|
55
|
+
emphasis: string
|
56
|
+
muted: string
|
57
|
+
subtle: string
|
58
|
+
}
|
59
|
+
danger: {
|
60
|
+
fg: string
|
61
|
+
emphasis: string
|
62
|
+
muted: string
|
63
|
+
subtle: string
|
64
|
+
}
|
65
|
+
done: {
|
66
|
+
fg: string
|
67
|
+
emphasis: string
|
68
|
+
muted: string
|
69
|
+
subtle: string
|
70
|
+
}
|
71
|
+
sponsors: {
|
72
|
+
fg: string
|
73
|
+
emphasis: string
|
74
|
+
muted: string
|
75
|
+
subtle: string
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
type ThemeShadows = {
|
80
|
+
shadow: {
|
81
|
+
small: string
|
82
|
+
medium: string
|
83
|
+
large: string
|
84
|
+
extraLarge: string
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
export type ThemeColorPaths = KeyPaths<ThemeColors>
|
89
|
+
export type ThemeShadowPaths = KeyPaths<ThemeShadows>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
// Produces a union of dot-delimited keypaths to the string values in a nested object:
|
2
|
+
export type KeyPaths<O extends Record<string, unknown>> = {
|
3
|
+
[K in keyof O]: K extends string
|
4
|
+
? O[K] extends string
|
5
|
+
? `${K}`
|
6
|
+
: // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
7
|
+
// @ts-ignore TypeScript has bested me, but the KeyPaths type is tested.
|
8
|
+
`${K}.${KeyPaths<O[K]>}`
|
9
|
+
: never
|
10
|
+
}[keyof O]
|