@sanity/ui 2.0.0-alpha.12 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.0.0-alpha.12",
3
+ "version": "2.0.0-alpha.13",
4
4
  "sideEffects": false,
5
5
  "types": "./dist/index.d.ts",
6
6
  "source": "./src/index.ts",
@@ -31,7 +31,10 @@ const CustomButton = styled(Button)`
31
31
  */
32
32
  export const Tab = forwardRef(function Tab(
33
33
  props: TabProps &
34
- Omit<React.HTMLProps<HTMLButtonElement>, 'aria-controls' | 'as' | 'id' | 'label' | 'type'>,
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 & ThemeProps
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;
@@ -12,3 +12,8 @@ export type ButtonTextAlign = 'left' | 'right' | 'center'
12
12
  * @public
13
13
  */
14
14
  export type ButtonTone = 'default' | 'primary' | 'positive' | 'caution' | 'critical'
15
+
16
+ /**
17
+ * @public
18
+ */
19
+ export type ButtonWidth = 'fill'