@sanity/ui 1.0.0-next.3 → 1.0.0
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/LICENSE +1 -1
- package/README.md +2 -2
- package/dist/{types/src/index.d.ts → index.d.ts} +4450 -4398
- package/dist/{sanity-ui.esm.js → index.esm.js} +888 -2678
- package/dist/index.esm.js.map +1 -0
- package/dist/{sanity-ui.js → index.js} +882 -2688
- package/dist/index.js.map +1 -0
- package/package.json +112 -23
- package/src/components/autocomplete/__workshop__/example.tsx +1 -1
- package/src/components/autocomplete/__workshop__/index.ts +36 -32
- package/src/components/autocomplete/autocomplete.styles.tsx +22 -28
- package/src/components/autocomplete/autocomplete.tsx +1 -2
- package/src/components/autocomplete/constants.ts +3 -8
- package/src/components/breadcrumbs/__workshop__/index.ts +11 -7
- package/src/components/breadcrumbs/breadcrumbs.styles.ts +13 -18
- package/src/components/dialog/__workshop__/index.ts +13 -9
- package/src/components/dialog/dialog.tsx +53 -67
- package/src/components/hotkeys/__workshop__/index.ts +11 -3
- package/src/components/hotkeys/hotkeys.tsx +12 -16
- package/src/components/menu/__workshop__/index.ts +71 -67
- package/src/components/menu/menu.tsx +5 -7
- package/src/components/menu/menuButton.tsx +16 -14
- package/src/components/menu/menuDivider.ts +8 -10
- package/src/components/skeleton/__workshop__/index.ts +8 -4
- package/src/components/skeleton/skeleton.tsx +4 -6
- package/src/components/skeleton/styles.ts +13 -9
- package/src/components/skeleton/textSkeleton.tsx +12 -14
- package/src/components/tab/__workshop__/index.ts +11 -3
- package/src/components/toast/__workshop__/index.ts +16 -4
- package/src/components/toast/toast.tsx +6 -11
- package/src/components/toast/toastProvider.tsx +18 -22
- package/src/components/tree/__workshop__/basic.perf.ts +1 -14
- package/src/components/tree/__workshop__/basic.tsx +1 -1
- package/src/components/tree/__workshop__/index.ts +12 -8
- package/src/components/tree/style.ts +78 -76
- package/src/components/tree/treeItem.tsx +7 -12
- package/src/hooks/useElementRect/__workshop__/index.ts +11 -3
- package/src/hooks/useMediaIndex/__workshop__/index.ts +11 -3
- package/src/primitives/_selectable/selectable.tsx +4 -7
- package/src/primitives/_selectable/style.ts +85 -82
- package/src/primitives/avatar/__workshop__/index.ts +16 -12
- package/src/primitives/avatar/avatar.tsx +9 -12
- package/src/primitives/avatar/avatarCounter.tsx +22 -24
- package/src/primitives/avatar/avatarStack.tsx +16 -14
- package/src/primitives/avatar/styles.ts +1 -1
- package/src/primitives/badge/__workshop__/index.ts +16 -12
- package/src/primitives/badge/__workshop__/tones.tsx +1 -1
- package/src/primitives/badge/badge.tsx +6 -5
- package/src/primitives/box/__workshop__/index.ts +16 -4
- package/src/primitives/box/box.tsx +21 -49
- package/src/primitives/button/__workshop__/index.ts +51 -47
- package/src/primitives/button/__workshop__/sanityUploadButton.tsx +19 -20
- package/src/primitives/button/__workshop__/styled1.tsx +6 -6
- package/src/primitives/button/button.tsx +20 -26
- package/src/primitives/button/styles.ts +30 -29
- package/src/primitives/card/__workshop__/index.ts +15 -11
- package/src/primitives/card/card.tsx +9 -25
- package/src/primitives/card/styles.ts +119 -114
- package/src/primitives/checkbox/__workshop__/index.ts +10 -6
- package/src/primitives/checkbox/checkbox.tsx +4 -4
- package/src/primitives/checkbox/styles.ts +71 -69
- package/src/primitives/code/__workshop__/index.ts +16 -12
- package/src/primitives/code/code.tsx +3 -5
- package/src/primitives/code/styles.ts +20 -18
- package/src/primitives/container/__workshop__/index.ts +5 -3
- package/src/primitives/container/container.tsx +5 -4
- package/src/primitives/flex/__workshop__/index.ts +8 -4
- package/src/primitives/flex/flex.tsx +7 -23
- package/src/primitives/grid/__workshop__/index.ts +7 -3
- package/src/primitives/grid/grid.tsx +4 -27
- package/src/primitives/heading/__workshop__/index.ts +16 -12
- package/src/primitives/heading/heading.tsx +10 -17
- package/src/primitives/heading/styles.ts +45 -36
- package/src/primitives/inline/__workshop__/index.ts +5 -3
- package/src/primitives/inline/inline.tsx +3 -5
- package/src/primitives/kbd/__workshop__/index.ts +5 -3
- package/src/primitives/kbd/kbd.tsx +12 -13
- package/src/primitives/label/__workshop__/index.ts +16 -12
- package/src/primitives/label/label.tsx +13 -18
- package/src/primitives/label/styles.ts +24 -18
- package/src/primitives/popover/__workshop__/PlainStory.tsx +0 -1
- package/src/primitives/popover/__workshop__/TestStory.tsx +0 -1
- package/src/primitives/popover/__workshop__/index.ts +36 -32
- package/src/primitives/popover/constants.ts +0 -3
- package/src/primitives/popover/floating-ui/size.ts +40 -25
- package/src/primitives/popover/popover.tsx +220 -196
- package/src/primitives/popover/popoverArrow.tsx +42 -48
- package/src/primitives/popover/popoverCard.tsx +12 -22
- package/src/primitives/radio/__workshop__/index.ts +8 -4
- package/src/primitives/radio/radio.tsx +3 -3
- package/src/primitives/radio/styles.ts +73 -73
- package/src/primitives/select/__workshop__/index.ts +8 -4
- package/src/primitives/select/select.tsx +9 -11
- package/src/primitives/select/styles.ts +77 -77
- package/src/primitives/spinner/__workshop__/index.ts +11 -7
- package/src/primitives/spinner/spinner.tsx +2 -5
- package/src/primitives/stack/__workshop__/index.ts +11 -7
- package/src/primitives/stack/stack.tsx +3 -5
- package/src/primitives/switch/__workshop__/index.ts +8 -4
- package/src/primitives/switch/styles.ts +119 -112
- package/src/primitives/switch/switch.tsx +6 -6
- package/src/primitives/text/__workshop__/index.ts +21 -17
- package/src/primitives/text/styles.ts +51 -45
- package/src/primitives/text/text.tsx +11 -16
- package/src/primitives/textArea/__workshop__/index.ts +11 -7
- package/src/primitives/textArea/textArea.tsx +15 -22
- package/src/primitives/textInput/__workshop__/index.ts +46 -42
- package/src/primitives/textInput/__workshop__/plain.tsx +2 -1
- package/src/primitives/textInput/textInput.tsx +49 -69
- package/src/primitives/tooltip/__workshop__/index.ts +11 -7
- package/src/primitives/tooltip/tooltip.tsx +3 -6
- package/src/primitives/tooltip/tooltipArrow.tsx +69 -59
- package/src/styles/border/borderStyle.ts +10 -18
- package/src/styles/box/boxStyle.ts +14 -18
- package/src/styles/flex/flexItemStyle.ts +7 -1
- package/src/styles/flex/flexStyle.ts +14 -9
- package/src/styles/grid/gridItemStyle.ts +18 -30
- package/src/styles/grid/gridStyle.ts +25 -33
- package/src/styles/helpers.ts +2 -2
- package/src/styles/index.ts +0 -1
- package/src/styles/input/textInputStyle.ts +127 -123
- package/src/styles/margin/marginStyle.ts +11 -10
- package/src/styles/margin/marginsStyle.test.ts +12 -10
- package/src/styles/padding/paddingStyle.test.ts +12 -10
- package/src/styles/padding/paddingStyle.ts +9 -10
- package/src/theme/__workshop__/index.ts +26 -22
- package/src/theme/{ThemeContext.ts → themeContext.ts} +0 -0
- package/src/utils/boundaryElement/__workshop__/index.ts +11 -7
- package/src/utils/elementQuery/__workshop__/index.ts +11 -7
- package/src/utils/layer/__workshop__/index.ts +21 -17
- package/src/utils/layer/layer.tsx +4 -6
- package/src/utils/portal/__workshop__/index.ts +11 -7
- package/src/utils/srOnly/srOnly.tsx +8 -10
- package/src/utils/virtualList/__workshop__/index.ts +26 -22
- package/src/utils/virtualList/virtualList.tsx +10 -14
- package/dist/sanity-ui.esm.js.map +0 -1
- package/dist/sanity-ui.js.map +0 -1
- package/src/__workshop__/color/overview.tsx +0 -101
- package/src/__workshop__/index.ts +0 -10
- package/src/icons/__workshop__/.eslintrc +0 -5
- package/src/icons/__workshop__/index.tsx +0 -6
- package/src/icons/__workshop__/overview.tsx +0 -76
- package/src/styles/compose.ts +0 -35
- package/src/utils/srOnly/__workshop__/.eslintrc +0 -5
|
@@ -1,105 +1,107 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {css, FlattenSimpleInterpolation} from 'styled-components'
|
|
2
2
|
import {rem, ThemeProps} from '../../styles'
|
|
3
3
|
import {_colorVarsStyle} from '../../styles/colorVars'
|
|
4
4
|
|
|
5
|
-
export function treeItemRootStyle():
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
outline:
|
|
9
|
-
cursor:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
position:
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
outline:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
cursor:
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
position:
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
5
|
+
export function treeItemRootStyle(): FlattenSimpleInterpolation {
|
|
6
|
+
return css`
|
|
7
|
+
&[role='none'] > [role='treeitem'] {
|
|
8
|
+
outline: none;
|
|
9
|
+
cursor: default;
|
|
10
|
+
border-radius: 3px;
|
|
11
|
+
|
|
12
|
+
&:focus {
|
|
13
|
+
position: relative;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&[role='treeitem'] {
|
|
18
|
+
outline: none;
|
|
19
|
+
|
|
20
|
+
& > div {
|
|
21
|
+
cursor: default;
|
|
22
|
+
border-radius: 3px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&:focus > div {
|
|
26
|
+
position: relative;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export function treeItemRootColorStyle(props: ThemeProps):
|
|
32
|
+
export function treeItemRootColorStyle(props: ThemeProps): FlattenSimpleInterpolation {
|
|
33
33
|
const {theme} = props
|
|
34
34
|
const $tone = 'default'
|
|
35
35
|
const {base, muted, selectable} = theme.sanity.color
|
|
36
36
|
// @todo: remove use of `muted` here
|
|
37
37
|
const tone = selectable ? selectable[$tone] || selectable.default : muted[$tone] || muted.default
|
|
38
38
|
|
|
39
|
-
return
|
|
39
|
+
return css`
|
|
40
40
|
/* <div role="none"><a data-ui="TreeItem__box" role="treeitem" tabIndex="0"></div> */
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
&[role='none'] {
|
|
42
|
+
& > [role='treeitem'] {
|
|
43
|
+
${_colorVarsStyle(base, tone.enabled)}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
color:
|
|
47
|
-
}
|
|
45
|
+
background-color: var(--card-bg-color);
|
|
46
|
+
color: var(--treeitem-fg-color);
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
49
|
+
&[data-selected] > [role='treeitem'] {
|
|
50
|
+
${_colorVarsStyle(base, tone.pressed)}
|
|
51
|
+
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
53
|
+
@media (hover: hover) {
|
|
54
|
+
&:not([data-selected]) > [role='treeitem']:not(:focus):hover {
|
|
55
|
+
${_colorVarsStyle(base, tone.hovered)}
|
|
56
|
+
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
58
|
+
& > [role='treeitem']:focus {
|
|
59
|
+
${_colorVarsStyle(base, tone.selected)}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
63
|
|
|
64
64
|
/* <div role="treeitem" tabIndex="0"><div data-ui="TreeItem__box"></div> */
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
color:
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
65
|
+
&[role='treeitem'] {
|
|
66
|
+
& > [data-ui='TreeItem__box'] {
|
|
67
|
+
${_colorVarsStyle(base, tone.enabled)}
|
|
68
|
+
|
|
69
|
+
background-color: var(--card-bg-color);
|
|
70
|
+
color: var(--card-fg-color);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&[data-selected] > [data-ui='TreeItem__box'] {
|
|
74
|
+
${_colorVarsStyle(base, tone.pressed)}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@media (hover: hover) {
|
|
78
|
+
&:not([data-selected]):not(:focus) > [data-ui='TreeItem__box']:hover {
|
|
79
|
+
${_colorVarsStyle(base, tone.hovered)}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&:focus > [data-ui='TreeItem__box'] {
|
|
83
|
+
${_colorVarsStyle(base, tone.selected)}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
`
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
export interface TreeItemBoxStyleProps {
|
|
91
91
|
$level: number
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export function treeItemBoxStyle(
|
|
94
|
+
export function treeItemBoxStyle(
|
|
95
|
+
props: TreeItemBoxStyleProps & ThemeProps
|
|
96
|
+
): FlattenSimpleInterpolation {
|
|
95
97
|
const {$level, theme} = props
|
|
96
98
|
const {space} = theme.sanity
|
|
97
99
|
|
|
98
|
-
return
|
|
99
|
-
|
|
100
|
+
return css`
|
|
101
|
+
padding-left: ${rem(space[2] * $level)};
|
|
100
102
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
103
|
+
&[data-as='a'] {
|
|
104
|
+
text-decoration: none;
|
|
105
|
+
}
|
|
106
|
+
`
|
|
105
107
|
}
|
|
@@ -2,7 +2,6 @@ import {ToggleArrowRightIcon} from '@sanity/icons'
|
|
|
2
2
|
import {createElement, memo, useCallback, useEffect, useId, useMemo, useRef} from 'react'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
4
|
import {Box, Flex, Text} from '../../primitives'
|
|
5
|
-
import {compose} from '../../styles'
|
|
6
5
|
import {ThemeFontWeightKey} from '../../theme'
|
|
7
6
|
import {
|
|
8
7
|
treeItemRootStyle,
|
|
@@ -27,19 +26,15 @@ export interface TreeItemProps {
|
|
|
27
26
|
weight?: ThemeFontWeightKey
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
const Root = memo(
|
|
29
|
+
const Root = memo(styled.li(treeItemRootStyle, treeItemRootColorStyle))
|
|
31
30
|
|
|
32
|
-
const TreeItemBox =
|
|
33
|
-
styled(Box)['attrs']({forwardedAs: 'a'})<TreeItemBoxStyleProps>(treeItemBoxStyle)
|
|
34
|
-
)
|
|
31
|
+
const TreeItemBox = styled(Box).attrs({forwardedAs: 'a'})<TreeItemBoxStyleProps>(treeItemBoxStyle)
|
|
35
32
|
|
|
36
|
-
const ToggleArrowText =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})
|
|
42
|
-
)
|
|
33
|
+
const ToggleArrowText = styled(Text)`
|
|
34
|
+
& > svg {
|
|
35
|
+
transition: transform 100ms;
|
|
36
|
+
}
|
|
37
|
+
`
|
|
43
38
|
|
|
44
39
|
/**
|
|
45
40
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'hooks/useElementRect',
|
|
6
|
+
title: 'useElementRect',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'example',
|
|
10
|
+
title: 'Example',
|
|
11
|
+
component: lazy(() => import('./example')),
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
})
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'hooks/use-media-index',
|
|
6
|
+
title: 'useMediaIndex',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'test',
|
|
10
|
+
title: 'Test',
|
|
11
|
+
component: lazy(() => import('./test')),
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
})
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {memo} from 'react'
|
|
2
1
|
import styled from 'styled-components'
|
|
3
2
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/radius'
|
|
4
3
|
import {Box} from '../box'
|
|
@@ -7,10 +6,8 @@ import {selectableBaseStyle, selectableColorStyle, SelectableStyleProps} from '.
|
|
|
7
6
|
/**
|
|
8
7
|
* @internal
|
|
9
8
|
*/
|
|
10
|
-
export const Selectable =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
selectableColorStyle
|
|
15
|
-
)
|
|
9
|
+
export const Selectable = styled(Box)<SelectableStyleProps & ResponsiveRadiusStyleProps>(
|
|
10
|
+
responsiveRadiusStyle,
|
|
11
|
+
selectableBaseStyle,
|
|
12
|
+
selectableColorStyle
|
|
16
13
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {css, FlattenSimpleInterpolation} from 'styled-components'
|
|
2
2
|
import {ThemeProps} from '../../styles'
|
|
3
3
|
import {_colorVarsStyle} from '../../styles/colorVars'
|
|
4
4
|
import {SelectableTone} from '../../types/selectable'
|
|
@@ -10,99 +10,102 @@ export interface SelectableStyleProps {
|
|
|
10
10
|
$tone: SelectableTone
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function selectableBaseStyle():
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
color:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
appearance:
|
|
21
|
-
outline:
|
|
22
|
-
font:
|
|
23
|
-
|
|
24
|
-
border: 0
|
|
25
|
-
width:
|
|
26
|
-
}
|
|
13
|
+
export function selectableBaseStyle(): FlattenSimpleInterpolation {
|
|
14
|
+
return css`
|
|
15
|
+
background-color: inherit;
|
|
16
|
+
color: inherit;
|
|
17
|
+
|
|
18
|
+
&[data-as='button'] {
|
|
19
|
+
-webkit-font-smoothing: inherit;
|
|
20
|
+
appearance: none;
|
|
21
|
+
outline: none;
|
|
22
|
+
font: inherit;
|
|
23
|
+
text-align: inherit;
|
|
24
|
+
border: 0;
|
|
25
|
+
width: stretch;
|
|
26
|
+
}
|
|
27
27
|
|
|
28
28
|
/* &:is(a) */
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
29
|
+
&[data-as='a'] {
|
|
30
|
+
text-decoration: none;
|
|
31
|
+
}
|
|
32
|
+
`
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export function selectableColorStyle(
|
|
35
|
+
export function selectableColorStyle(
|
|
36
|
+
props: SelectableStyleProps & ThemeProps
|
|
37
|
+
): FlattenSimpleInterpolation {
|
|
36
38
|
const {$tone, theme} = props
|
|
37
39
|
const {base, muted, selectable} = theme.sanity.color
|
|
38
40
|
// @todo: remove use of `muted` here
|
|
39
41
|
const tone = selectable ? selectable[$tone] || selectable.default : muted[$tone] || muted.default
|
|
40
42
|
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
+
return css`
|
|
44
|
+
${_colorVarsStyle(base, tone.enabled)}
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
color:
|
|
46
|
-
outline:
|
|
46
|
+
background-color: var(--card-bg-color);
|
|
47
|
+
color: var(--card-fg-color);
|
|
48
|
+
outline: none;
|
|
47
49
|
|
|
48
50
|
/* &:is(button) */
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
51
|
+
&[data-as='button'] {
|
|
52
|
+
&:disabled {
|
|
53
|
+
${_colorVarsStyle(base, tone.disabled)}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&:not(:disabled) {
|
|
57
|
+
&[aria-pressed='true'] {
|
|
58
|
+
${_colorVarsStyle(base, tone.pressed)}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&[data-selected],
|
|
62
|
+
&[aria-selected='true'] > & {
|
|
63
|
+
${_colorVarsStyle(base, tone.selected)}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@media (hover: hover) {
|
|
67
|
+
&:not([data-selected]) {
|
|
68
|
+
&:hover {
|
|
69
|
+
${_colorVarsStyle(base, tone.hovered)}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&:active {
|
|
73
|
+
${_colorVarsStyle(base, tone.pressed)}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
76
79
|
|
|
77
80
|
/* &:is(a) */
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
81
|
+
&[data-as='a'] {
|
|
82
|
+
&[data-disabled] {
|
|
83
|
+
${_colorVarsStyle(base, tone.disabled)}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&:not([data-disabled]) {
|
|
87
|
+
&[data-pressed] {
|
|
88
|
+
${_colorVarsStyle(base, tone.pressed)}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&[data-selected] {
|
|
92
|
+
${_colorVarsStyle(base, tone.selected)}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@media (hover: hover) {
|
|
96
|
+
&:not([data-selected]) {
|
|
97
|
+
&:hover {
|
|
98
|
+
${_colorVarsStyle(base, tone.hovered)}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&:active {
|
|
102
|
+
${_colorVarsStyle(base, tone.pressed)}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
${theme.sanity.styles?.card?.root}
|
|
110
|
+
`
|
|
108
111
|
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'primitives/avatar',
|
|
6
|
+
title: 'Avatar',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'as-button',
|
|
10
|
+
title: 'As button',
|
|
11
|
+
component: lazy(() => import('./asButton')),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'avatar-stack',
|
|
15
|
+
title: 'Avatar stack',
|
|
16
|
+
component: lazy(() => import('./stack')),
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
})
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {forwardRef,
|
|
1
|
+
import {forwardRef, useCallback, useEffect, useId, useMemo, useState} from 'react'
|
|
2
2
|
import ReactIs from 'react-is'
|
|
3
|
+
import styled from 'styled-components'
|
|
3
4
|
import {useArrayProp} from '../../hooks'
|
|
4
|
-
import {compose} from '../../styles'
|
|
5
5
|
import {ThemeColorSpotKey, useTheme} from '../../theme'
|
|
6
6
|
import {AvatarPosition, AvatarSize, AvatarStatus} from '../../types'
|
|
7
7
|
import {Text} from '../text'
|
|
8
8
|
import {avatarStyle, responsiveAvatarSizeStyle} from './styles'
|
|
9
|
-
import {AvatarRootStyleProps, ResponsiveAvatarSizeStyleProps} from './types'
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* @public
|
|
@@ -28,20 +27,18 @@ export interface AvatarProps {
|
|
|
28
27
|
title?: string
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
const Root =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
avatarStyle.root,
|
|
35
|
-
])
|
|
30
|
+
const Root = styled.div<{$color: string; $size: AvatarSize[]}>(
|
|
31
|
+
responsiveAvatarSizeStyle,
|
|
32
|
+
avatarStyle.root
|
|
36
33
|
)
|
|
37
34
|
|
|
38
|
-
const Arrow =
|
|
35
|
+
const Arrow = styled.div(avatarStyle.arrow)
|
|
39
36
|
|
|
40
|
-
const BgStroke =
|
|
37
|
+
const BgStroke = styled.ellipse(avatarStyle.bgStroke)
|
|
41
38
|
|
|
42
|
-
const Stroke =
|
|
39
|
+
const Stroke = styled.ellipse(avatarStyle.stroke)
|
|
43
40
|
|
|
44
|
-
const Initials =
|
|
41
|
+
const Initials = styled.div(avatarStyle.initials)
|
|
45
42
|
|
|
46
43
|
/**
|
|
47
44
|
* @public
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {forwardRef,
|
|
2
|
-
import {
|
|
1
|
+
import {forwardRef, useMemo} from 'react'
|
|
2
|
+
import styled, {css} from 'styled-components'
|
|
3
3
|
import {EMPTY_RECORD} from '../../constants'
|
|
4
4
|
import {useArrayProp} from '../../hooks'
|
|
5
|
-
import {rem, _responsive, ThemeProps
|
|
5
|
+
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
6
6
|
import {AvatarSize} from '../../types'
|
|
7
7
|
import {Text} from '../text'
|
|
8
8
|
|
|
9
|
-
function _responsiveAvatarCounterSizeStyle(props: {$size: AvatarSize[]} & ThemeProps)
|
|
9
|
+
function _responsiveAvatarCounterSizeStyle(props: {$size: AvatarSize[]} & ThemeProps) {
|
|
10
10
|
const {theme} = props
|
|
11
11
|
const {avatar, media} = theme.sanity
|
|
12
12
|
|
|
@@ -23,31 +23,29 @@ function _responsiveAvatarCounterSizeStyle(props: {$size: AvatarSize[]} & ThemeP
|
|
|
23
23
|
})
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function _avatarCounterBaseStyle(props: ThemeProps)
|
|
26
|
+
function _avatarCounterBaseStyle(props: ThemeProps) {
|
|
27
27
|
const {theme} = props
|
|
28
28
|
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
color:
|
|
36
|
-
background:
|
|
37
|
-
|
|
38
|
-
padding:
|
|
29
|
+
return css`
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
user-select: none;
|
|
34
|
+
color: inherit;
|
|
35
|
+
color: var(--card-fg-color);
|
|
36
|
+
background: var(--card-bg-color);
|
|
37
|
+
box-shadow: 0 0 0 1px var(--card-bg-color), inset 0 0 0 1.5px var(--card-hairline-hard-color);
|
|
38
|
+
padding: 0 ${rem(theme.sanity.space[2])};
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
display:
|
|
42
|
-
}
|
|
43
|
-
|
|
40
|
+
&:not([hidden]) {
|
|
41
|
+
display: flex;
|
|
42
|
+
}
|
|
43
|
+
`
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const Root =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
_avatarCounterBaseStyle,
|
|
50
|
-
])
|
|
46
|
+
const Root = styled.div<{$size: AvatarSize[]}>(
|
|
47
|
+
_responsiveAvatarCounterSizeStyle,
|
|
48
|
+
_avatarCounterBaseStyle
|
|
51
49
|
)
|
|
52
50
|
|
|
53
51
|
/**
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import {cloneElement, forwardRef
|
|
2
|
-
import {
|
|
1
|
+
import {cloneElement, forwardRef} from 'react'
|
|
2
|
+
import styled, {css} from 'styled-components'
|
|
3
3
|
import {EMPTY_RECORD} from '../../constants'
|
|
4
4
|
import {useArrayProp} from '../../hooks'
|
|
5
|
-
import {rem, _responsive, ThemeProps
|
|
5
|
+
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
6
6
|
import {AvatarSize} from '../../types'
|
|
7
7
|
import {childrenToElementArray} from '../helpers'
|
|
8
8
|
import {AvatarCounter} from './avatarCounter'
|
|
9
9
|
|
|
10
|
-
const BASE_STYLES
|
|
11
|
-
|
|
10
|
+
const BASE_STYLES = css`
|
|
11
|
+
white-space: nowrap;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
& > div {
|
|
14
|
+
vertical-align: top;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
display:
|
|
18
|
-
}
|
|
19
|
-
}
|
|
16
|
+
&:not([hidden]) {
|
|
17
|
+
display: inline-block;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
function avatarStackStyle() {
|
|
23
|
+
return BASE_STYLES
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
function responsiveAvatarStackSizeStyle(props: {$size: AvatarSize[]} & ThemeProps) {
|
|
@@ -36,9 +40,7 @@ function responsiveAvatarStackSizeStyle(props: {$size: AvatarSize[]} & ThemeProp
|
|
|
36
40
|
})
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
const Root =
|
|
40
|
-
compose<{$size: AvatarSize[]}>('div', [responsiveAvatarStackSizeStyle, BASE_STYLES])
|
|
41
|
-
)
|
|
43
|
+
const Root = styled.div<{$size: AvatarSize[]}>(responsiveAvatarStackSizeStyle, avatarStackStyle)
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
46
|
* @public
|