11import React , { createElement , forwardRef } from 'react' ;
22import type {
3+ ColorsActionTokenAlias ,
4+ ColorsBackdropTokenAlias ,
5+ ColorsBackgroundTokenAlias ,
6+ ColorsOverlayTokenAlias ,
7+ ColorsSurfaceTokenAlias ,
8+ ShapeBorderWidthScale ,
39 DepthShadowAlias ,
410 SpacingSpaceScale ,
511} from '@shopify/polaris-tokens' ;
@@ -12,72 +18,6 @@ type Element = 'div' | 'span' | 'section';
1218
1319type Overflow = 'hidden' | 'scroll' ;
1420
15- export type BackgroundColorTokenScale =
16- | 'action-critical'
17- | 'action-critical-depressed'
18- | 'action-critical-disabled'
19- | 'action-critical-hovered'
20- | 'action-critical-pressed'
21- | 'action-primary'
22- | 'action-primary-depressed'
23- | 'action-primary-disabled'
24- | 'action-primary-hovered'
25- | 'action-primary-pressed'
26- | 'action-secondary'
27- | 'action-secondary-depressed'
28- | 'action-secondary-disabled'
29- | 'action-secondary-hovered'
30- | 'action-secondary-hovered-dark'
31- | 'action-secondary-pressed'
32- | 'action-secondary-pressed-dark'
33- | 'backdrop'
34- | 'background'
35- | 'background-hovered'
36- | 'background-pressed'
37- | 'background-selected'
38- | 'overlay'
39- | 'surface'
40- | 'surface-attention'
41- | 'surface-critical'
42- | 'surface-critical-subdued'
43- | 'surface-critical-subdued-depressed'
44- | 'surface-critical-subdued-hovered'
45- | 'surface-critical-subdued-pressed'
46- | 'surface-dark'
47- | 'surface-depressed'
48- | 'surface-disabled'
49- | 'surface-highlight'
50- | 'surface-highlight-subdued'
51- | 'surface-highlight-subdued-hovered'
52- | 'surface-highlight-subdued-pressed'
53- | 'surface-hovered'
54- | 'surface-hovered-dark'
55- | 'surface-neutral'
56- | 'surface-neutral-disabled'
57- | 'surface-neutral-hovered'
58- | 'surface-neutral-pressed'
59- | 'surface-neutral-subdued'
60- | 'surface-neutral-subdued-dark'
61- | 'surface-pressed'
62- | 'surface-pressed-dark'
63- | 'surface-primary-selected'
64- | 'surface-primary-selected-hovered'
65- | 'surface-primary-selected-pressed'
66- | 'surface-search-field'
67- | 'surface-search-field-dark'
68- | 'surface-selected'
69- | 'surface-selected-hovered'
70- | 'surface-selected-pressed'
71- | 'surface-subdued'
72- | 'surface-success'
73- | 'surface-success-subdued'
74- | 'surface-success-subdued-hovered'
75- | 'surface-success-subdued-pressed'
76- | 'surface-warning'
77- | 'surface-warning-subdued'
78- | 'surface-warning-subdued-hovered'
79- | 'surface-warning-subdued-pressed' ;
80-
8121export type ColorTokenScale =
8222 | 'text'
8323 | 'text-critical'
@@ -121,6 +61,13 @@ export type BorderRadiusTokenScale =
12161 | 'large'
12262 | 'half' ;
12363
64+ export type BackgroundColors =
65+ | ColorsBackdropTokenAlias
66+ | ColorsBackgroundTokenAlias
67+ | ColorsOverlayTokenAlias
68+ | ColorsActionTokenAlias
69+ | ColorsSurfaceTokenAlias ;
70+
12471interface BorderRadius {
12572 startStart : BorderRadiusTokenScale ;
12673 startEnd : BorderRadiusTokenScale ;
@@ -135,11 +82,18 @@ interface Spacing {
13582 inlineEnd : SpacingSpaceScale ;
13683}
13784
85+ interface BorderWidth {
86+ blockStart : ShapeBorderWidthScale ;
87+ blockEnd : ShapeBorderWidthScale ;
88+ inlineStart : ShapeBorderWidthScale ;
89+ inlineEnd : ShapeBorderWidthScale ;
90+ }
91+
13892export interface BoxProps {
13993 /** HTML Element type */
14094 as ?: Element ;
14195 /** Background color */
142- background ?: BackgroundColorTokenScale ;
96+ background ?: BackgroundColors ;
14397 /** Border style */
14498 border ?: BorderTokenAlias ;
14599 /** Vertical end border style */
@@ -160,6 +114,16 @@ export interface BoxProps {
160114 borderRadiusStartStart ?: BorderRadiusTokenScale ;
161115 /** Verital start horizontal end border radius */
162116 borderRadiusStartEnd ?: BorderRadiusTokenScale ;
117+ /** Border width */
118+ borderWidth ?: ShapeBorderWidthScale ;
119+ /** Vertical start border width */
120+ borderBlockStartWidth ?: ShapeBorderWidthScale ;
121+ /** Vertical end border width */
122+ borderBlockEndWidth ?: ShapeBorderWidthScale ;
123+ /** Horizontal start border width */
124+ borderInlineStartWidth ?: ShapeBorderWidthScale ;
125+ /** Horizontal end border width */
126+ borderInlineEndWidth ?: ShapeBorderWidthScale ;
163127 /** Color of children */
164128 color ?: ColorTokenScale ;
165129 /** HTML id attribute */
@@ -202,6 +166,11 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
202166 borderInlineStart,
203167 borderInlineEnd,
204168 borderBlockStart,
169+ borderWidth,
170+ borderBlockStartWidth,
171+ borderBlockEndWidth,
172+ borderInlineStartWidth,
173+ borderInlineEndWidth,
205174 borderRadius,
206175 borderRadiusEndStart,
207176 borderRadiusEndEnd,
@@ -239,6 +208,13 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
239208 startEnd : borderRadiusStartEnd ,
240209 } as BorderRadius ;
241210
211+ const borderWidths = {
212+ blockStart : borderBlockStartWidth ,
213+ blockEnd : borderBlockEndWidth ,
214+ inlineStart : borderInlineStartWidth ,
215+ inlineEnd : borderInlineEndWidth ,
216+ } as BorderWidth ;
217+
242218 const paddings = {
243219 blockEnd : paddingBlockEnd ,
244220 inlineStart : paddingInlineStart ,
@@ -277,6 +253,21 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
277253 '--pc-box-border-radius-start-end' : borderRadiuses . startEnd
278254 ? `var(--p-border-radius-${ borderRadiuses . startEnd } )`
279255 : undefined ,
256+ '--pc-box-border-width' : borderWidth
257+ ? `var(--p-border-width-${ borderWidth } )`
258+ : undefined ,
259+ '--pc-box-border-block-start-width' : borderWidths . blockStart
260+ ? `var(--p-border-width-${ borderWidths . blockStart } )`
261+ : undefined ,
262+ '--pc-box-border-block-end-width' : borderWidths . blockEnd
263+ ? `var(--p-border-width-${ borderWidths . blockEnd } )`
264+ : undefined ,
265+ '--pc-box-border-inline-start-width' : borderWidths . inlineStart
266+ ? `var(--p-border-width-${ borderWidths . inlineStart } )`
267+ : undefined ,
268+ '--pc-box-border-inline-end-width' : borderWidths . inlineEnd
269+ ? `var(--p-border-width-${ borderWidths . inlineEnd } )`
270+ : undefined ,
280271 '--pc-box-min-height' : minHeight ,
281272 '--pc-box-min-width' : minWidth ,
282273 '--pc-box-max-width' : maxWidth ,
0 commit comments