@sanity/ui 2.0.0-alpha.11 → 2.0.0-alpha.13
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/dist/index.d.ts +12 -2
- package/dist/index.esm.js +34 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +34 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/tab/tab.tsx +4 -1
- package/src/primitives/button/button.tsx +7 -3
- package/src/primitives/button/styles.ts +8 -2
- package/src/types/button.ts +5 -0
package/package.json
CHANGED
|
@@ -31,7 +31,10 @@ const CustomButton = styled(Button)`
|
|
|
31
31
|
*/
|
|
32
32
|
export const Tab = forwardRef(function Tab(
|
|
33
33
|
props: TabProps &
|
|
34
|
-
Omit<
|
|
34
|
+
Omit<
|
|
35
|
+
React.HTMLProps<HTMLButtonElement>,
|
|
36
|
+
'aria-controls' | 'as' | 'id' | 'label' | 'type' | 'width'
|
|
37
|
+
>,
|
|
35
38
|
forwardedRef: React.ForwardedRef<HTMLButtonElement>,
|
|
36
39
|
) {
|
|
37
40
|
const {
|
|
@@ -5,7 +5,7 @@ import {useArrayProp} from '../../hooks'
|
|
|
5
5
|
import {ThemeProps} from '../../styles'
|
|
6
6
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
7
7
|
import {useTheme} from '../../theme'
|
|
8
|
-
import {ButtonMode, ButtonTextAlign, ButtonTone, FlexJustify} from '../../types'
|
|
8
|
+
import {ButtonMode, ButtonTextAlign, ButtonTone, ButtonWidth, FlexJustify} from '../../types'
|
|
9
9
|
import {Box} from '../box'
|
|
10
10
|
import {Flex} from '../flex'
|
|
11
11
|
import {Spinner} from '../spinner'
|
|
@@ -34,10 +34,12 @@ export interface ButtonProps extends ResponsivePaddingProps, ResponsiveRadiusPro
|
|
|
34
34
|
text?: React.ReactNode
|
|
35
35
|
tone?: ButtonTone
|
|
36
36
|
type?: 'button' | 'reset' | 'submit'
|
|
37
|
+
width?: ButtonWidth
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
const Root = styled.button<
|
|
40
|
-
{$mode: ButtonMode; $tone: ButtonTone} & ResponsiveRadiusStyleProps &
|
|
41
|
+
{$mode: ButtonMode; $tone: ButtonTone; $width?: ButtonWidth} & ResponsiveRadiusStyleProps &
|
|
42
|
+
ThemeProps
|
|
41
43
|
>(responsiveRadiusStyle, buttonBaseStyles, buttonColorStyles)
|
|
42
44
|
|
|
43
45
|
const LoadingBox = styled.div`
|
|
@@ -59,7 +61,7 @@ const LoadingBox = styled.div`
|
|
|
59
61
|
* @public
|
|
60
62
|
*/
|
|
61
63
|
export const Button = forwardRef(function Button(
|
|
62
|
-
props: ButtonProps & Omit<React.HTMLProps<HTMLButtonElement>, 'as'>,
|
|
64
|
+
props: ButtonProps & Omit<React.HTMLProps<HTMLButtonElement>, 'as' | 'width'>,
|
|
63
65
|
ref: React.ForwardedRef<HTMLButtonElement>,
|
|
64
66
|
) {
|
|
65
67
|
const {
|
|
@@ -86,6 +88,7 @@ export const Button = forwardRef(function Button(
|
|
|
86
88
|
tone = 'default',
|
|
87
89
|
type = 'button',
|
|
88
90
|
muted = false,
|
|
91
|
+
width,
|
|
89
92
|
...restProps
|
|
90
93
|
} = props
|
|
91
94
|
|
|
@@ -128,6 +131,7 @@ export const Button = forwardRef(function Button(
|
|
|
128
131
|
disabled={Boolean(loading || disabled)}
|
|
129
132
|
ref={ref}
|
|
130
133
|
type={type}
|
|
134
|
+
$width={width}
|
|
131
135
|
>
|
|
132
136
|
{Boolean(loading) && (
|
|
133
137
|
<LoadingBox>
|
|
@@ -2,13 +2,13 @@ import {css} from 'styled-components'
|
|
|
2
2
|
import {ThemeProps} from '../../styles'
|
|
3
3
|
import {_colorVarsStyle} from '../../styles/colorVars'
|
|
4
4
|
import {focusRingBorderStyle, focusRingStyle} from '../../styles/internal'
|
|
5
|
-
import {ButtonMode, ButtonTone} from '../../types'
|
|
5
|
+
import {ButtonMode, ButtonTone, ButtonWidth} from '../../types'
|
|
6
6
|
import {CSSObject} from '../../types/styled'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
|
-
export function buttonBaseStyles(): ReturnType<typeof css> {
|
|
11
|
+
export function buttonBaseStyles({$width}: {$width?: ButtonWidth}): ReturnType<typeof css> {
|
|
12
12
|
return css`
|
|
13
13
|
-webkit-font-smoothing: inherit;
|
|
14
14
|
appearance: none;
|
|
@@ -27,6 +27,12 @@ export function buttonBaseStyles(): ReturnType<typeof css> {
|
|
|
27
27
|
text-align: left;
|
|
28
28
|
position: relative;
|
|
29
29
|
|
|
30
|
+
${$width === 'fill' &&
|
|
31
|
+
css`
|
|
32
|
+
width: -webkit-fill-available;
|
|
33
|
+
width: stretch;
|
|
34
|
+
`}
|
|
35
|
+
|
|
30
36
|
& > span {
|
|
31
37
|
display: block;
|
|
32
38
|
flex: 1;
|
package/src/types/button.ts
CHANGED