@sanity/ui 0.37.20 → 0.37.21
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/lib/dts/src/components/breadcrumbs/breadcrumbs.d.ts.map +1 -1
- package/lib/dts/src/components/dialog/dialog.d.ts.map +1 -1
- package/lib/dts/src/components/dialog/styles.d.ts +1 -1
- package/lib/dts/src/components/dialog/styles.d.ts.map +1 -1
- package/lib/dts/src/components/hotkeys/hotkeys.d.ts.map +1 -1
- package/lib/dts/src/components/menu/menuGroup.d.ts.map +1 -1
- package/lib/dts/src/components/skeleton/skeleton.d.ts.map +1 -1
- package/lib/dts/src/hooks/index.d.ts +1 -2
- package/lib/dts/src/hooks/index.d.ts.map +1 -1
- package/lib/dts/src/hooks/useElementRect/useElementRect.d.ts +1 -1
- package/lib/dts/src/hooks/useElementRect/useElementRect.d.ts.map +1 -1
- package/lib/dts/src/hooks/useResponsiveProp.d.ts +6 -0
- package/lib/dts/src/hooks/useResponsiveProp.d.ts.map +1 -0
- package/lib/dts/src/index.d.ts +0 -1
- package/lib/dts/src/index.d.ts.map +1 -1
- package/lib/dts/src/primitives/_selectable/selectable.d.ts +2 -1
- package/lib/dts/src/primitives/_selectable/selectable.d.ts.map +1 -1
- package/lib/dts/src/primitives/avatar/avatar.d.ts.map +1 -1
- package/lib/dts/src/primitives/avatar/avatarCounter.d.ts.map +1 -1
- package/lib/dts/src/primitives/avatar/avatarStack.d.ts.map +1 -1
- package/lib/dts/src/primitives/avatar/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/badge/badge.d.ts.map +1 -1
- package/lib/dts/src/primitives/box/box.d.ts.map +1 -1
- package/lib/dts/src/primitives/button/button.d.ts.map +1 -1
- package/lib/dts/src/primitives/card/card.d.ts.map +1 -1
- package/lib/dts/src/primitives/code/code.d.ts.map +1 -1
- package/lib/dts/src/primitives/container/container.d.ts.map +1 -1
- package/lib/dts/src/primitives/container/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/container/types.d.ts +1 -1
- package/lib/dts/src/primitives/container/types.d.ts.map +1 -1
- package/lib/dts/src/primitives/flex/flex.d.ts.map +1 -1
- package/lib/dts/src/primitives/grid/grid.d.ts.map +1 -1
- package/lib/dts/src/primitives/heading/heading.d.ts.map +1 -1
- package/lib/dts/src/primitives/inline/inline.d.ts.map +1 -1
- package/lib/dts/src/primitives/inline/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/inline/types.d.ts +1 -1
- package/lib/dts/src/primitives/inline/types.d.ts.map +1 -1
- package/lib/dts/src/primitives/kbd/kbd.d.ts.map +1 -1
- package/lib/dts/src/primitives/label/label.d.ts.map +1 -1
- package/lib/dts/src/primitives/popover/popover.d.ts.map +1 -1
- package/lib/dts/src/primitives/select/styles.d.ts +1 -5
- package/lib/dts/src/primitives/select/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/stack/stack.d.ts.map +1 -1
- package/lib/dts/src/primitives/stack/styles.d.ts +1 -1
- package/lib/dts/src/primitives/stack/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/text/text.d.ts.map +1 -1
- package/lib/dts/src/primitives/textArea/textArea.d.ts.map +1 -1
- package/lib/dts/src/primitives/textInput/textInput.d.ts.map +1 -1
- package/lib/dts/src/primitives/tooltip/tooltip.d.ts.map +1 -1
- package/lib/dts/src/primitives/types.d.ts +1 -1
- package/lib/dts/src/primitives/types.d.ts.map +1 -1
- package/lib/dts/src/styles/border/types.d.ts +5 -5
- package/lib/dts/src/styles/border/types.d.ts.map +1 -1
- package/lib/dts/src/styles/box/types.d.ts +4 -4
- package/lib/dts/src/styles/box/types.d.ts.map +1 -1
- package/lib/dts/src/styles/flex/flexItemStyle.d.ts.map +1 -1
- package/lib/dts/src/styles/flex/types.d.ts +6 -6
- package/lib/dts/src/styles/flex/types.d.ts.map +1 -1
- package/lib/dts/src/styles/font/responsiveFont.d.ts.map +1 -1
- package/lib/dts/src/styles/font/types.d.ts +3 -3
- package/lib/dts/src/styles/font/types.d.ts.map +1 -1
- package/lib/dts/src/styles/grid/types.d.ts +14 -14
- package/lib/dts/src/styles/grid/types.d.ts.map +1 -1
- package/lib/dts/src/styles/helpers.d.ts +4 -4
- package/lib/dts/src/styles/helpers.d.ts.map +1 -1
- package/lib/dts/src/styles/input/responsiveInputPaddingStyle.d.ts +12 -12
- package/lib/dts/src/styles/input/responsiveInputPaddingStyle.d.ts.map +1 -1
- package/lib/dts/src/styles/input/textInputStyle.d.ts +2 -7
- package/lib/dts/src/styles/input/textInputStyle.d.ts.map +1 -1
- package/lib/dts/src/styles/margin/types.d.ts +7 -7
- package/lib/dts/src/styles/margin/types.d.ts.map +1 -1
- package/lib/dts/src/styles/padding/types.d.ts +7 -7
- package/lib/dts/src/styles/padding/types.d.ts.map +1 -1
- package/lib/dts/src/styles/radius/types.d.ts +1 -1
- package/lib/dts/src/styles/radius/types.d.ts.map +1 -1
- package/lib/dts/src/styles/shadow/shadowStyle.d.ts.map +1 -1
- package/lib/dts/src/styles/shadow/types.d.ts +1 -1
- package/lib/dts/src/styles/shadow/types.d.ts.map +1 -1
- package/lib/dts/src/theme/studioTheme/color.d.ts.map +1 -1
- package/lib/dts/src/utils/elementQuery/elementQuery.d.ts.map +1 -1
- package/lib/dts/src/utils/index.d.ts +1 -0
- package/lib/dts/src/utils/index.d.ts.map +1 -1
- package/lib/dts/src/utils/resizeObserver.d.ts +6 -0
- package/lib/dts/src/utils/resizeObserver.d.ts.map +1 -0
- package/lib/dts/src/utils/virtualList/virtualList.d.ts.map +1 -1
- package/lib/sanity-ui.js +570 -731
- package/lib/sanity-ui.js.map +1 -1
- package/lib/sanity-ui.modern.js +591 -762
- package/lib/sanity-ui.modern.js.map +1 -1
- package/lib/sanity-ui.module.js +566 -725
- package/lib/sanity-ui.module.js.map +1 -1
- package/package.json +11 -11
- package/src/__workshop__/color/overview.tsx +11 -9
- package/src/components/autocomplete/__workshop__/async.tsx +12 -14
- package/src/components/autocomplete/__workshop__/constrainedHeight.tsx +0 -36
- package/src/components/autocomplete/autocomplete.tsx +2 -2
- package/src/components/breadcrumbs/breadcrumbs.tsx +2 -3
- package/src/components/dialog/dialog.tsx +9 -17
- package/src/components/dialog/styles.ts +4 -4
- package/src/components/hotkeys/hotkeys.tsx +1 -3
- package/src/components/menu/__workshop__/constrainedInBoundary.tsx +14 -11
- package/src/components/menu/__workshop__/groups.tsx +1 -1
- package/src/components/menu/menuGroup.tsx +2 -3
- package/src/components/menu/menuItem.tsx +3 -3
- package/src/components/skeleton/skeleton.tsx +1 -10
- package/src/components/skeleton/textSkeleton.tsx +7 -7
- package/src/hooks/index.ts +1 -2
- package/src/hooks/useElementRect/useElementRect.ts +16 -4
- package/src/hooks/useResponsiveProp.ts +10 -0
- package/src/index.ts +0 -1
- package/src/primitives/_selectable/selectable.tsx +4 -5
- package/src/primitives/avatar/avatar.tsx +5 -7
- package/src/primitives/avatar/avatarCounter.tsx +11 -12
- package/src/primitives/avatar/avatarStack.tsx +10 -15
- package/src/primitives/avatar/styles.ts +2 -2
- package/src/primitives/badge/badge.tsx +2 -3
- package/src/primitives/box/box.tsx +25 -26
- package/src/primitives/button/button.tsx +10 -22
- package/src/primitives/card/card.tsx +7 -8
- package/src/primitives/checkbox/__workshop__/example.tsx +2 -4
- package/src/primitives/checkbox/__workshop__/props.tsx +2 -4
- package/src/primitives/checkbox/__workshop__/readOnly.tsx +2 -4
- package/src/primitives/code/__workshop__/props.tsx +1 -1
- package/src/primitives/code/code.tsx +1 -2
- package/src/primitives/container/container.tsx +1 -10
- package/src/primitives/container/styles.ts +2 -2
- package/src/primitives/container/types.ts +1 -1
- package/src/primitives/flex/flex.tsx +5 -6
- package/src/primitives/grid/__workshop__/responsive.tsx +12 -13
- package/src/primitives/grid/grid.tsx +8 -9
- package/src/primitives/heading/__workshop__/opticalAlignment.tsx +7 -19
- package/src/primitives/heading/heading.tsx +2 -3
- package/src/primitives/inline/inline.tsx +6 -12
- package/src/primitives/inline/styles.ts +2 -2
- package/src/primitives/inline/types.ts +1 -1
- package/src/primitives/kbd/kbd.tsx +1 -2
- package/src/primitives/label/label.tsx +3 -4
- package/src/primitives/popover/__workshop__/index.ts +5 -10
- package/src/primitives/popover/__workshop__/{MarginsStory.tsx → margins.tsx} +1 -1
- package/src/primitives/popover/__workshop__/{MatchReferenceWidthStory.tsx → matchReferenceWidth.tsx} +0 -0
- package/src/primitives/popover/__workshop__/{PlainStory.tsx → plain.tsx} +14 -12
- package/src/primitives/popover/__workshop__/{RecursiveStory.tsx → recursive.tsx} +1 -4
- package/src/primitives/popover/__workshop__/rightAligned.tsx +57 -0
- package/src/primitives/popover/popover.tsx +10 -29
- package/src/primitives/select/select.tsx +9 -9
- package/src/primitives/select/styles.ts +4 -10
- package/src/primitives/stack/stack.tsx +1 -2
- package/src/primitives/stack/styles.ts +3 -3
- package/src/primitives/text/__workshop__/opticalAlignment.tsx +5 -15
- package/src/primitives/text/text.tsx +2 -3
- package/src/primitives/textArea/__workshop__/plain.tsx +18 -23
- package/src/primitives/textArea/textArea.tsx +5 -21
- package/src/primitives/textInput/__workshop__/clearButton.tsx +8 -14
- package/src/primitives/textInput/__workshop__/index.ts +2 -2
- package/src/primitives/textInput/__workshop__/plain.tsx +32 -39
- package/src/primitives/textInput/__workshop__/tones.tsx +95 -234
- package/src/primitives/textInput/__workshop__/typed.tsx +2 -8
- package/src/primitives/textInput/textInput.tsx +12 -47
- package/src/primitives/tooltip/__workshop__/props.tsx +2 -7
- package/src/primitives/tooltip/tooltip.tsx +9 -19
- package/src/primitives/types.ts +1 -1
- package/src/styles/border/borderStyle.ts +6 -6
- package/src/styles/border/types.ts +5 -5
- package/src/styles/box/boxStyle.ts +5 -5
- package/src/styles/box/types.ts +4 -4
- package/src/styles/flex/flexItemStyle.ts +4 -5
- package/src/styles/flex/flexStyle.ts +6 -6
- package/src/styles/flex/types.ts +6 -6
- package/src/styles/font/responsiveFont.ts +4 -2
- package/src/styles/font/textAlignStyle.ts +2 -2
- package/src/styles/font/types.ts +3 -4
- package/src/styles/grid/gridItemStyle.ts +7 -7
- package/src/styles/grid/gridStyle.ts +9 -9
- package/src/styles/grid/types.ts +14 -14
- package/src/styles/helpers.ts +9 -9
- package/src/styles/input/responsiveInputPaddingStyle.ts +27 -24
- package/src/styles/input/textInputStyle.ts +80 -92
- package/src/styles/margin/marginStyle.ts +8 -8
- package/src/styles/margin/marginsStyle.test.ts +1 -1
- package/src/styles/margin/types.ts +7 -7
- package/src/styles/padding/paddingStyle.test.ts +1 -1
- package/src/styles/padding/paddingStyle.ts +8 -8
- package/src/styles/padding/types.ts +7 -7
- package/src/styles/radius/radiusStyle.ts +2 -2
- package/src/styles/radius/types.ts +1 -1
- package/src/styles/shadow/shadowStyle.ts +5 -2
- package/src/styles/shadow/types.ts +1 -1
- package/src/theme/studioTheme/color.ts +14 -15
- package/src/theme/studioTheme/fonts.ts +4 -4
- package/src/utils/elementQuery/elementQuery.tsx +18 -5
- package/src/utils/index.ts +1 -0
- package/src/utils/layer/layerProvider.tsx +2 -2
- package/src/{observers → utils}/resizeObserver.ts +3 -1
- package/src/utils/virtualList/virtualList.tsx +1 -3
- package/lib/dts/src/hooks/useArrayProp.d.ts +0 -7
- package/lib/dts/src/hooks/useArrayProp.d.ts.map +0 -1
- package/lib/dts/src/hooks/useElementSize.d.ts +0 -7
- package/lib/dts/src/hooks/useElementSize.d.ts.map +0 -1
- package/lib/dts/src/observers/elementSizeObserver.d.ts +0 -37
- package/lib/dts/src/observers/elementSizeObserver.d.ts.map +0 -1
- package/lib/dts/src/observers/index.d.ts +0 -3
- package/lib/dts/src/observers/index.d.ts.map +0 -1
- package/lib/dts/src/observers/resizeObserver.d.ts +0 -5
- package/lib/dts/src/observers/resizeObserver.d.ts.map +0 -1
- package/src/hooks/useArrayProp.ts +0 -23
- package/src/hooks/useElementSize.ts +0 -18
- package/src/observers/elementSizeObserver.ts +0 -116
- package/src/observers/index.ts +0 -2
- package/src/primitives/popover/__workshop__/RightAlignedStory.tsx +0 -60
- package/src/primitives/popover/__workshop__/TestStory.tsx +0 -79
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {useId} from '@reach/auto-id'
|
|
2
|
-
import React, {forwardRef, useCallback, useEffect,
|
|
2
|
+
import React, {forwardRef, useCallback, useEffect, useState} from 'react'
|
|
3
3
|
import ReactIs from 'react-is'
|
|
4
4
|
import styled from 'styled-components'
|
|
5
|
-
import {
|
|
5
|
+
import {useResponsiveProp} from '../../hooks'
|
|
6
6
|
import {ThemeColorSpotKey, useTheme} from '../../theme'
|
|
7
7
|
import {AvatarPosition, AvatarSize, AvatarStatus} from '../../types'
|
|
8
8
|
import {Text} from '../text'
|
|
@@ -58,11 +58,11 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
58
58
|
arrowPosition: arrowPositionProp,
|
|
59
59
|
animateArrowFrom,
|
|
60
60
|
status = 'online',
|
|
61
|
-
size: sizeProp
|
|
61
|
+
size: sizeProp,
|
|
62
62
|
...restProps
|
|
63
63
|
} = props
|
|
64
64
|
const as = ReactIs.isValidElementType(asProp) ? asProp : 'div'
|
|
65
|
-
const size =
|
|
65
|
+
const size: AvatarSize[] = useResponsiveProp(sizeProp, [0])
|
|
66
66
|
const theme = useTheme()
|
|
67
67
|
const color = theme.sanity.color.spot[colorKey] || theme.sanity.color.spot.gray
|
|
68
68
|
|
|
@@ -101,8 +101,6 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
101
101
|
}
|
|
102
102
|
}, [onImageLoadError])
|
|
103
103
|
|
|
104
|
-
const initialsSize = useMemo(() => size.map((s) => (s === 0 ? 0 : s + 1)), [size])
|
|
105
|
-
|
|
106
104
|
return (
|
|
107
105
|
<Root
|
|
108
106
|
as={as}
|
|
@@ -156,7 +154,7 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
156
154
|
{(imageFailed || !src) && initials && (
|
|
157
155
|
<>
|
|
158
156
|
<Initials>
|
|
159
|
-
<Text as="span" size={
|
|
157
|
+
<Text as="span" size={size.map((s) => (s === 0 ? 0 : s + 1))}>
|
|
160
158
|
<strong>{initials}</strong>
|
|
161
159
|
</Text>
|
|
162
160
|
</Initials>
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import React, {forwardRef
|
|
1
|
+
import React, {forwardRef} from 'react'
|
|
2
2
|
import styled, {css} from 'styled-components'
|
|
3
3
|
import {EMPTY_RECORD} from '../../constants'
|
|
4
|
-
import {
|
|
5
|
-
import {rem,
|
|
4
|
+
import {useResponsiveProp} from '../../hooks'
|
|
5
|
+
import {rem, responsive, ThemeProps} from '../../styles'
|
|
6
6
|
import {AvatarSize} from '../../types'
|
|
7
7
|
import {Text} from '../text'
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function responsiveAvatarCounterSizeStyle(props: {$size: AvatarSize[]} & ThemeProps) {
|
|
10
10
|
const {theme} = props
|
|
11
11
|
const {avatar, media} = theme.sanity
|
|
12
12
|
|
|
13
|
-
return
|
|
13
|
+
return responsive(media, props.$size, (size) => {
|
|
14
14
|
const avatarSize = avatar.sizes[size]
|
|
15
15
|
|
|
16
16
|
if (!avatarSize) return EMPTY_RECORD
|
|
@@ -23,7 +23,7 @@ function _responsiveAvatarCounterSizeStyle(props: {$size: AvatarSize[]} & ThemeP
|
|
|
23
23
|
})
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function
|
|
26
|
+
function avatarCounterBaseStyle(props: ThemeProps) {
|
|
27
27
|
const {theme} = props
|
|
28
28
|
|
|
29
29
|
return css`
|
|
@@ -44,8 +44,8 @@ function _avatarCounterBaseStyle(props: ThemeProps) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const Root = styled.div<{$size: AvatarSize[]}>(
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
responsiveAvatarCounterSizeStyle,
|
|
48
|
+
avatarCounterBaseStyle
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
/**
|
|
@@ -66,12 +66,11 @@ export const AvatarCounter = forwardRef(function AvatarCounter(
|
|
|
66
66
|
ref: React.Ref<HTMLDivElement>
|
|
67
67
|
) {
|
|
68
68
|
const {count, size: sizeProp = 0} = props
|
|
69
|
-
const size =
|
|
70
|
-
const counterSize = useMemo(() => size.map((s) => (s === 0 ? 0 : s + 1)), [size])
|
|
69
|
+
const size: AvatarSize[] = useResponsiveProp(sizeProp, [0])
|
|
71
70
|
|
|
72
71
|
return (
|
|
73
|
-
<Root $size={size}
|
|
74
|
-
<Text as="span" size={
|
|
72
|
+
<Root $size={size} ref={ref}>
|
|
73
|
+
<Text as="span" size={size.map((s) => (s === 0 ? 0 : s + 1))}>
|
|
75
74
|
<strong>{count}</strong>
|
|
76
75
|
</Text>
|
|
77
76
|
</Root>
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React, {cloneElement, forwardRef} from 'react'
|
|
2
2
|
import styled, {css} from 'styled-components'
|
|
3
3
|
import {EMPTY_RECORD} from '../../constants'
|
|
4
|
-
import {
|
|
5
|
-
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
4
|
+
import {getResponsiveProp, rem, responsive, ThemeProps} from '../../styles'
|
|
6
5
|
import {AvatarSize} from '../../types'
|
|
7
6
|
import {childrenToElementArray} from '../helpers'
|
|
8
7
|
import {AvatarCounter} from './avatarCounter'
|
|
@@ -23,11 +22,11 @@ function avatarStackStyle() {
|
|
|
23
22
|
return BASE_STYLES
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
function responsiveAvatarStackSizeStyle(props: {
|
|
25
|
+
function responsiveAvatarStackSizeStyle(props: {size: AvatarSize | AvatarSize[]} & ThemeProps) {
|
|
27
26
|
const {theme} = props
|
|
28
27
|
const {avatar, media} = theme.sanity
|
|
29
28
|
|
|
30
|
-
return
|
|
29
|
+
return responsive(media, getResponsiveProp(props.size), (size) => {
|
|
31
30
|
const avatarSize = avatar.sizes[size]
|
|
32
31
|
|
|
33
32
|
if (!avatarSize) return EMPTY_RECORD
|
|
@@ -40,7 +39,10 @@ function responsiveAvatarStackSizeStyle(props: {$size: AvatarSize[]} & ThemeProp
|
|
|
40
39
|
})
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
const Root = styled.div<{
|
|
42
|
+
const Root = styled.div<{size: AvatarSize | AvatarSize[]}>(
|
|
43
|
+
responsiveAvatarStackSizeStyle,
|
|
44
|
+
avatarStackStyle
|
|
45
|
+
)
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
48
|
* @public
|
|
@@ -60,25 +62,18 @@ export const AvatarStack = forwardRef(function AvatarStack(
|
|
|
60
62
|
props: AvatarStackProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'ref'>,
|
|
61
63
|
ref: React.ForwardedRef<HTMLDivElement>
|
|
62
64
|
) {
|
|
63
|
-
const {
|
|
64
|
-
|
|
65
|
-
maxLength: maxLengthProp = 4,
|
|
66
|
-
size: sizeProp = 0,
|
|
67
|
-
...restProps
|
|
68
|
-
} = props
|
|
65
|
+
const {children: childrenProp, maxLength: maxLengthProp = 4, size = 0, tone, ...restProps} = props
|
|
66
|
+
const maxLength = Math.max(maxLengthProp, 0)
|
|
69
67
|
const children = childrenToElementArray(childrenProp).filter(
|
|
70
68
|
(child) => typeof child !== 'string'
|
|
71
69
|
) as React.ReactElement[]
|
|
72
|
-
const maxLength = Math.max(maxLengthProp, 0)
|
|
73
|
-
const size = useArrayProp(sizeProp)
|
|
74
|
-
|
|
75
70
|
const len = children.length
|
|
76
71
|
const visibleCount = maxLength - 1
|
|
77
72
|
const extraCount = len - visibleCount
|
|
78
73
|
const visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children
|
|
79
74
|
|
|
80
75
|
return (
|
|
81
|
-
<Root data-ui="AvatarStack" {...restProps} ref={ref}
|
|
76
|
+
<Root data-ui="AvatarStack" {...restProps} ref={ref} size={size}>
|
|
82
77
|
{len === 0 && (
|
|
83
78
|
<div>
|
|
84
79
|
<AvatarCounter count={len} />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {CSSObject} from 'styled-components'
|
|
2
|
-
import {rem,
|
|
2
|
+
import {rem, responsive, ThemeProps} from '../../styles'
|
|
3
3
|
import {focusRingStyle} from '../../styles/internal'
|
|
4
4
|
import {AvatarRootStyleProps, ResponsiveAvatarSizeStyleProps} from './types'
|
|
5
5
|
|
|
@@ -103,7 +103,7 @@ export function responsiveAvatarSizeStyle(
|
|
|
103
103
|
const {theme} = props
|
|
104
104
|
const {avatar, media} = theme.sanity
|
|
105
105
|
|
|
106
|
-
return
|
|
106
|
+
return responsive(media, props.$size, (size) => {
|
|
107
107
|
const avatarSize = avatar.sizes[size] || avatar.sizes[0]
|
|
108
108
|
|
|
109
109
|
return {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
|
-
import {useArrayProp} from '../../hooks'
|
|
4
3
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
5
4
|
import {BadgeMode, BadgeTone} from '../../types'
|
|
6
5
|
import {Box, BoxProps} from '../box'
|
|
@@ -47,8 +46,8 @@ export const Badge = forwardRef(function Badge(
|
|
|
47
46
|
{...restProps}
|
|
48
47
|
$mode={mode}
|
|
49
48
|
$tone={tone}
|
|
50
|
-
$radius={
|
|
51
|
-
padding={
|
|
49
|
+
$radius={radius}
|
|
50
|
+
padding={padding}
|
|
52
51
|
ref={ref}
|
|
53
52
|
>
|
|
54
53
|
<Label size={fontSize}>{children}</Label>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
|
-
import {useArrayProp} from '../../hooks'
|
|
4
3
|
import {
|
|
5
4
|
boxStyle,
|
|
6
5
|
flexItemStyle,
|
|
@@ -91,31 +90,31 @@ export const Box = forwardRef(function Box(
|
|
|
91
90
|
data-as={typeof asProp === 'string' ? asProp : undefined}
|
|
92
91
|
data-ui="Box"
|
|
93
92
|
{...restProps}
|
|
94
|
-
$column={
|
|
95
|
-
$columnStart={
|
|
96
|
-
$columnEnd={
|
|
97
|
-
$display={
|
|
98
|
-
$flex={
|
|
99
|
-
$height={
|
|
100
|
-
$margin={
|
|
101
|
-
$marginX={
|
|
102
|
-
$marginY={
|
|
103
|
-
$marginTop={
|
|
104
|
-
$marginRight={
|
|
105
|
-
$marginBottom={
|
|
106
|
-
$marginLeft={
|
|
107
|
-
$overflow={
|
|
108
|
-
$padding={
|
|
109
|
-
$paddingX={
|
|
110
|
-
$paddingY={
|
|
111
|
-
$paddingTop={
|
|
112
|
-
$paddingRight={
|
|
113
|
-
$paddingBottom={
|
|
114
|
-
$paddingLeft={
|
|
115
|
-
$row={
|
|
116
|
-
$rowStart={
|
|
117
|
-
$rowEnd={
|
|
118
|
-
$sizing={
|
|
93
|
+
$column={column}
|
|
94
|
+
$columnStart={columnStart}
|
|
95
|
+
$columnEnd={columnEnd}
|
|
96
|
+
$display={display}
|
|
97
|
+
$flex={flex}
|
|
98
|
+
$height={height}
|
|
99
|
+
$margin={margin}
|
|
100
|
+
$marginX={marginX}
|
|
101
|
+
$marginY={marginY}
|
|
102
|
+
$marginTop={marginTop}
|
|
103
|
+
$marginRight={marginRight}
|
|
104
|
+
$marginBottom={marginBottom}
|
|
105
|
+
$marginLeft={marginLeft}
|
|
106
|
+
$overflow={overflow}
|
|
107
|
+
$padding={padding}
|
|
108
|
+
$paddingX={paddingX}
|
|
109
|
+
$paddingY={paddingY}
|
|
110
|
+
$paddingTop={paddingTop}
|
|
111
|
+
$paddingRight={paddingRight}
|
|
112
|
+
$paddingBottom={paddingBottom}
|
|
113
|
+
$paddingLeft={paddingLeft}
|
|
114
|
+
$row={row}
|
|
115
|
+
$rowStart={rowStart}
|
|
116
|
+
$rowEnd={rowEnd}
|
|
117
|
+
$sizing={sizing}
|
|
119
118
|
as={asProp}
|
|
120
119
|
ref={ref}
|
|
121
120
|
>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, {createElement, forwardRef, isValidElement, useMemo} from 'react'
|
|
2
2
|
import {isValidElementType} from 'react-is'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
|
-
import {useArrayProp} from '../../hooks'
|
|
5
4
|
import {ThemeProps} from '../../styles'
|
|
6
5
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
7
6
|
import {useTheme} from '../../theme'
|
|
@@ -67,19 +66,19 @@ export const Button = forwardRef(function Button(
|
|
|
67
66
|
fontSize,
|
|
68
67
|
icon,
|
|
69
68
|
iconRight,
|
|
70
|
-
justify
|
|
69
|
+
justify = 'center',
|
|
71
70
|
loading,
|
|
72
71
|
mode = 'default',
|
|
73
|
-
padding
|
|
74
|
-
paddingX
|
|
75
|
-
paddingY
|
|
76
|
-
paddingTop
|
|
77
|
-
paddingBottom
|
|
78
|
-
paddingLeft
|
|
79
|
-
paddingRight
|
|
80
|
-
radius
|
|
72
|
+
padding = 3,
|
|
73
|
+
paddingX,
|
|
74
|
+
paddingY,
|
|
75
|
+
paddingTop,
|
|
76
|
+
paddingBottom,
|
|
77
|
+
paddingLeft,
|
|
78
|
+
paddingRight,
|
|
79
|
+
radius = 2,
|
|
81
80
|
selected,
|
|
82
|
-
space
|
|
81
|
+
space = 3,
|
|
83
82
|
text,
|
|
84
83
|
textAlign,
|
|
85
84
|
tone = 'default',
|
|
@@ -87,17 +86,6 @@ export const Button = forwardRef(function Button(
|
|
|
87
86
|
...restProps
|
|
88
87
|
} = props
|
|
89
88
|
|
|
90
|
-
const justify = useArrayProp(justifyProp)
|
|
91
|
-
const padding = useArrayProp(paddingProp)
|
|
92
|
-
const paddingX = useArrayProp(paddingXProp)
|
|
93
|
-
const paddingY = useArrayProp(paddingYProp)
|
|
94
|
-
const paddingTop = useArrayProp(paddingTopProp)
|
|
95
|
-
const paddingBottom = useArrayProp(paddingBottomProp)
|
|
96
|
-
const paddingLeft = useArrayProp(paddingLeftProp)
|
|
97
|
-
const paddingRight = useArrayProp(paddingRightProp)
|
|
98
|
-
const radius = useArrayProp(radiusProp)
|
|
99
|
-
const space = useArrayProp(spaceProp)
|
|
100
|
-
|
|
101
89
|
const theme = useTheme()
|
|
102
90
|
|
|
103
91
|
const boxProps = useMemo(
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, {forwardRef} from 'react'
|
|
2
2
|
import {isValidElementType} from 'react-is'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
|
-
import {useArrayProp} from '../../hooks'
|
|
5
4
|
import {
|
|
6
5
|
responsiveBorderStyle,
|
|
7
6
|
ResponsiveBorderStyleProps,
|
|
@@ -84,15 +83,15 @@ export const Card = forwardRef(function Card(
|
|
|
84
83
|
data-ui="Card"
|
|
85
84
|
data-tone={tone}
|
|
86
85
|
{...restProps}
|
|
87
|
-
$border={
|
|
88
|
-
$borderTop={
|
|
89
|
-
$borderRight={
|
|
90
|
-
$borderBottom={
|
|
91
|
-
$borderLeft={
|
|
86
|
+
$border={border}
|
|
87
|
+
$borderTop={borderTop}
|
|
88
|
+
$borderRight={borderRight}
|
|
89
|
+
$borderBottom={borderBottom}
|
|
90
|
+
$borderLeft={borderLeft}
|
|
92
91
|
$checkered={checkered}
|
|
93
92
|
$focusRing={focusRing}
|
|
94
|
-
$radius={
|
|
95
|
-
$shadow={
|
|
93
|
+
$radius={radius}
|
|
94
|
+
$shadow={shadow}
|
|
96
95
|
$tone={tone}
|
|
97
96
|
data-checkered={checkered ? '' : undefined}
|
|
98
97
|
data-pressed={pressed ? '' : undefined}
|
|
@@ -14,10 +14,8 @@ export default function ExampleStory() {
|
|
|
14
14
|
indeterminate={indeterminate}
|
|
15
15
|
onChange={handleChange}
|
|
16
16
|
/>
|
|
17
|
-
<Box marginLeft={
|
|
18
|
-
<Text
|
|
19
|
-
Toggle
|
|
20
|
-
</Text>
|
|
17
|
+
<Box marginLeft={3}>
|
|
18
|
+
<Text>Label</Text>
|
|
21
19
|
</Box>
|
|
22
20
|
</Flex>
|
|
23
21
|
</Flex>
|
|
@@ -6,10 +6,8 @@ export default function ReadOnlyStory() {
|
|
|
6
6
|
<Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
|
|
7
7
|
<Flex align="center" as="label">
|
|
8
8
|
<Checkbox id="checkbox-example" readOnly />
|
|
9
|
-
<Box marginLeft={
|
|
10
|
-
<Text
|
|
11
|
-
Toggle
|
|
12
|
-
</Text>
|
|
9
|
+
<Box marginLeft={3}>
|
|
10
|
+
<Text>Label</Text>
|
|
13
11
|
</Box>
|
|
14
12
|
</Flex>
|
|
15
13
|
</Flex>
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
export default function PropsStory() {
|
|
10
10
|
const code = useText('Code', `console.log('Hello, world')`, 'Props')
|
|
11
11
|
const language = useSelect('Language', WORKSHOP_CODE_LANGUAGE_OPTIONS, 'typescript', 'Props')
|
|
12
|
-
const size = useSelect('Size', WORKSHOP_TEXT_FONT_SIZE_OPTIONS,
|
|
12
|
+
const size = useSelect('Size', WORKSHOP_TEXT_FONT_SIZE_OPTIONS, undefined, 'Props')
|
|
13
13
|
|
|
14
14
|
return (
|
|
15
15
|
<Box padding={[4, 5, 6]}>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, {forwardRef} from 'react'
|
|
2
2
|
import Refractor from 'react-refractor'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
|
-
import {useArrayProp} from '../../hooks'
|
|
5
4
|
import {responsiveCodeFontStyle, ResponsiveFontStyleProps} from '../../styles/internal'
|
|
6
5
|
import {codeBaseStyle} from './styles'
|
|
7
6
|
|
|
@@ -29,7 +28,7 @@ export const Code = forwardRef(function Code(
|
|
|
29
28
|
const registered = language ? Refractor.hasLanguage(language as any) : false
|
|
30
29
|
|
|
31
30
|
return (
|
|
32
|
-
<Root data-ui="Code" {...restProps} $size={
|
|
31
|
+
<Root data-ui="Code" {...restProps} $size={size} $weight={weight} ref={ref}>
|
|
33
32
|
{!(language && registered) && <code>{children}</code>}
|
|
34
33
|
{language && registered && <Refractor inline language={language} value={String(children)} />}
|
|
35
34
|
</Root>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
|
-
import {useArrayProp} from '../../hooks'
|
|
4
3
|
import {Box, BoxProps} from '../box'
|
|
5
4
|
import {ResponsiveWidthProps} from '../types'
|
|
6
5
|
import {containerBaseStyle, responsiveContainerWidthStyle} from './styles'
|
|
@@ -25,13 +24,5 @@ export const Container = forwardRef(function Container(
|
|
|
25
24
|
) {
|
|
26
25
|
const {as, width = 2, ...restProps} = props
|
|
27
26
|
|
|
28
|
-
return
|
|
29
|
-
<Root
|
|
30
|
-
data-ui="Container"
|
|
31
|
-
{...restProps}
|
|
32
|
-
$width={useArrayProp(width)}
|
|
33
|
-
forwardedAs={as}
|
|
34
|
-
ref={ref}
|
|
35
|
-
/>
|
|
36
|
-
)
|
|
27
|
+
return <Root data-ui="Container" {...restProps} $width={width} forwardedAs={as} ref={ref} />
|
|
37
28
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {CSSObject} from 'styled-components'
|
|
2
|
-
import {rem,
|
|
2
|
+
import {getResponsiveProp, rem, responsive, ThemeProps} from '../../styles'
|
|
3
3
|
import {ResponsiveWidthStyleProps} from './types'
|
|
4
4
|
|
|
5
5
|
const BASE_STYLE: CSSObject = {
|
|
@@ -17,7 +17,7 @@ export function responsiveContainerWidthStyle(
|
|
|
17
17
|
const {theme} = props
|
|
18
18
|
const {container, media} = theme.sanity
|
|
19
19
|
|
|
20
|
-
return
|
|
20
|
+
return responsive(media, getResponsiveProp(props.$width), (val) => ({
|
|
21
21
|
maxWidth: val === 'auto' ? 'none' : rem(container[val]),
|
|
22
22
|
}))
|
|
23
23
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
|
-
import {useArrayProp} from '../../hooks'
|
|
4
3
|
import {
|
|
5
4
|
flexItemStyle,
|
|
6
5
|
FlexItemStyleProps,
|
|
@@ -38,11 +37,11 @@ export const Flex = forwardRef(function Flex(
|
|
|
38
37
|
<Root
|
|
39
38
|
data-ui="Flex"
|
|
40
39
|
{...restProps}
|
|
41
|
-
$align={
|
|
42
|
-
$direction={
|
|
43
|
-
$gap={
|
|
44
|
-
$justify={
|
|
45
|
-
$wrap={
|
|
40
|
+
$align={align}
|
|
41
|
+
$direction={direction}
|
|
42
|
+
$gap={gap}
|
|
43
|
+
$justify={justify}
|
|
44
|
+
$wrap={wrap}
|
|
46
45
|
forwardedAs={as}
|
|
47
46
|
ref={ref}
|
|
48
47
|
/>
|
|
@@ -10,42 +10,41 @@ export default function ResponsiveStory() {
|
|
|
10
10
|
columns={[1, 2, 3, 4, 5, 6, 7]}
|
|
11
11
|
gap={[0, 1, 2, 3, 4, 5, 6]}
|
|
12
12
|
rows={[1, 2, 3, 4, 5, 6, 7]}
|
|
13
|
-
style={{textAlign: 'center'}}
|
|
14
13
|
>
|
|
15
|
-
<Card
|
|
14
|
+
<Card tone="transparent">
|
|
16
15
|
<Code>1</Code>
|
|
17
16
|
</Card>
|
|
18
|
-
<Card
|
|
17
|
+
<Card tone="transparent">
|
|
19
18
|
<Code>2</Code>
|
|
20
19
|
</Card>
|
|
21
|
-
<Card
|
|
20
|
+
<Card tone="transparent">
|
|
22
21
|
<Code>3</Code>
|
|
23
22
|
</Card>
|
|
24
|
-
<Card
|
|
23
|
+
<Card tone="transparent">
|
|
25
24
|
<Code>4</Code>
|
|
26
25
|
</Card>
|
|
27
|
-
<Card
|
|
26
|
+
<Card tone="transparent">
|
|
28
27
|
<Code>5</Code>
|
|
29
28
|
</Card>
|
|
30
|
-
<Card
|
|
29
|
+
<Card tone="transparent">
|
|
31
30
|
<Code>6</Code>
|
|
32
31
|
</Card>
|
|
33
|
-
<Card
|
|
32
|
+
<Card tone="transparent">
|
|
34
33
|
<Code>7</Code>
|
|
35
34
|
</Card>
|
|
36
|
-
<Card
|
|
35
|
+
<Card tone="transparent">
|
|
37
36
|
<Code>8</Code>
|
|
38
37
|
</Card>
|
|
39
|
-
<Card
|
|
38
|
+
<Card tone="transparent">
|
|
40
39
|
<Code>9</Code>
|
|
41
40
|
</Card>
|
|
42
|
-
<Card
|
|
41
|
+
<Card tone="transparent">
|
|
43
42
|
<Code>10</Code>
|
|
44
43
|
</Card>
|
|
45
|
-
<Card
|
|
44
|
+
<Card tone="transparent">
|
|
46
45
|
<Code>11</Code>
|
|
47
46
|
</Card>
|
|
48
|
-
<Card
|
|
47
|
+
<Card tone="transparent">
|
|
49
48
|
<Code>12</Code>
|
|
50
49
|
</Card>
|
|
51
50
|
</Grid>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
|
-
import {useArrayProp} from '../../hooks'
|
|
4
3
|
import {responsiveGridStyle, ResponsiveGridStyleProps} from '../../styles/internal'
|
|
5
4
|
import {Box, BoxProps} from '../box'
|
|
6
5
|
import {ResponsiveGridProps} from '../types'
|
|
@@ -27,14 +26,14 @@ export const Grid = forwardRef(function Grid(
|
|
|
27
26
|
data-as={typeof as === 'string' ? as : undefined}
|
|
28
27
|
data-ui="Grid"
|
|
29
28
|
{...restProps}
|
|
30
|
-
$autoRows={
|
|
31
|
-
$autoCols={
|
|
32
|
-
$autoFlow={
|
|
33
|
-
$columns={
|
|
34
|
-
$gap={
|
|
35
|
-
$gapX={
|
|
36
|
-
$gapY={
|
|
37
|
-
$rows={
|
|
29
|
+
$autoRows={autoRows}
|
|
30
|
+
$autoCols={autoCols}
|
|
31
|
+
$autoFlow={autoFlow}
|
|
32
|
+
$columns={columns}
|
|
33
|
+
$gap={gap}
|
|
34
|
+
$gapX={gapX}
|
|
35
|
+
$gapY={gapY}
|
|
36
|
+
$rows={rows}
|
|
38
37
|
forwardedAs={as}
|
|
39
38
|
ref={ref}
|
|
40
39
|
>
|
|
@@ -8,55 +8,43 @@ export default function OpticalAlignment() {
|
|
|
8
8
|
<Stack space={1}>
|
|
9
9
|
<Flex>
|
|
10
10
|
<Card padding={0} scheme="dark">
|
|
11
|
-
<Heading
|
|
12
|
-
Hamburgefonstiv M
|
|
13
|
-
</Heading>
|
|
11
|
+
<Heading size={5}>Hamburgefonstiv M</Heading>
|
|
14
12
|
</Card>
|
|
15
13
|
</Flex>
|
|
16
14
|
|
|
17
15
|
<Flex>
|
|
18
16
|
<Card padding={0} scheme="dark">
|
|
19
|
-
<Heading
|
|
20
|
-
Hamburgefonstiv M
|
|
21
|
-
</Heading>
|
|
17
|
+
<Heading size={4}>Hamburgefonstiv M</Heading>
|
|
22
18
|
</Card>
|
|
23
19
|
</Flex>
|
|
24
20
|
|
|
25
21
|
<Flex>
|
|
26
22
|
<Card padding={0} scheme="dark">
|
|
27
|
-
<Heading
|
|
28
|
-
Hamburgefonstiv M
|
|
29
|
-
</Heading>
|
|
23
|
+
<Heading size={3}>Hamburgefonstiv M</Heading>
|
|
30
24
|
</Card>
|
|
31
25
|
</Flex>
|
|
32
26
|
|
|
33
27
|
<Flex>
|
|
34
28
|
<Card padding={0} scheme="dark">
|
|
35
|
-
<Heading
|
|
36
|
-
Hamburgefonstiv M
|
|
37
|
-
</Heading>
|
|
29
|
+
<Heading size={2}>Hamburgefonstiv M</Heading>
|
|
38
30
|
</Card>
|
|
39
31
|
</Flex>
|
|
40
32
|
|
|
41
33
|
<Flex>
|
|
42
34
|
<Card padding={0} scheme="dark">
|
|
43
|
-
<Heading
|
|
44
|
-
Hamburgefonstiv M
|
|
45
|
-
</Heading>
|
|
35
|
+
<Heading size={1}>Hamburgefonstiv M</Heading>
|
|
46
36
|
</Card>
|
|
47
37
|
</Flex>
|
|
48
38
|
|
|
49
39
|
<Flex>
|
|
50
40
|
<Card padding={0} scheme="dark">
|
|
51
|
-
<Heading
|
|
52
|
-
Hamburgefonstiv M
|
|
53
|
-
</Heading>
|
|
41
|
+
<Heading size={0}>Hamburgefonstiv M</Heading>
|
|
54
42
|
</Card>
|
|
55
43
|
</Flex>
|
|
56
44
|
|
|
57
45
|
<Flex>
|
|
58
46
|
<Card padding={2} scheme="dark">
|
|
59
|
-
<Heading
|
|
47
|
+
<Heading>
|
|
60
48
|
<AddCircleIcon />
|
|
61
49
|
</Heading>
|
|
62
50
|
</Card>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
|
-
import {useArrayProp} from '../../hooks'
|
|
4
3
|
import {
|
|
5
4
|
ResponsiveFontStyleProps,
|
|
6
5
|
responsiveHeadingFont,
|
|
@@ -70,9 +69,9 @@ export const Heading = forwardRef(function Heading(
|
|
|
70
69
|
data-ui="Heading"
|
|
71
70
|
{...restProps}
|
|
72
71
|
$accent={accent}
|
|
73
|
-
$align={
|
|
72
|
+
$align={align}
|
|
74
73
|
$muted={muted}
|
|
75
|
-
$size={
|
|
74
|
+
$size={size}
|
|
76
75
|
$weight={weight}
|
|
77
76
|
ref={ref}
|
|
78
77
|
>
|