@@ -49,13 +49,6 @@ export type BorderTokenAlias =
4949
5050type Spacing = ResponsiveProp < SpacingSpaceScale > ;
5151
52- interface Border {
53- blockStart : BorderTokenAlias ;
54- blockEnd : BorderTokenAlias ;
55- inlineStart : BorderTokenAlias ;
56- inlineEnd : BorderTokenAlias ;
57- }
58-
5952export type BorderRadiusTokenScale =
6053 | '05'
6154 | '1'
@@ -75,20 +68,6 @@ export type BackgroundColors =
7568 | ColorsActionTokenAlias
7669 | ColorsSurfaceTokenAlias ;
7770
78- interface BorderRadius {
79- startStart : BorderRadiusTokenScale ;
80- startEnd : BorderRadiusTokenScale ;
81- endStart : BorderRadiusTokenScale ;
82- endEnd : BorderRadiusTokenScale ;
83- }
84-
85- interface BorderWidth {
86- blockStart : ShapeBorderWidthScale ;
87- blockEnd : ShapeBorderWidthScale ;
88- inlineStart : ShapeBorderWidthScale ;
89- inlineEnd : ShapeBorderWidthScale ;
90- }
91-
9271export interface BoxProps {
9372 /** HTML Element type */
9473 as ?: Element ;
@@ -114,6 +93,8 @@ export interface BoxProps {
11493 borderRadiusStartStart ?: BorderRadiusTokenScale ;
11594 /** Verital start horizontal end border radius */
11695 borderRadiusStartEnd ?: BorderRadiusTokenScale ;
96+ /** Border color */
97+ borderColor ?: ColorTokenScale ;
11798 /** Border width */
11899 borderWidth ?: ShapeBorderWidthScale ;
119100 /** Vertical start border width */
@@ -128,11 +109,11 @@ export interface BoxProps {
128109 color ?: ColorTokenScale ;
129110 /** HTML id attribute */
130111 id ?: string ;
131- /** Set minimum height of container */
112+ /** Minimum height of container */
132113 minHeight ?: string ;
133- /** Set minimum width of container */
114+ /** Minimum width of container */
134115 minWidth ?: string ;
135- /** Set maximum width of container */
116+ /** Maximum width of container */
136117 maxWidth ?: string ;
137118 /** Clip horizontal content of children */
138119 overflowX ?: Overflow ;
@@ -150,10 +131,20 @@ export interface BoxProps {
150131 paddingInlineEnd ?: Spacing ;
151132 /** Shadow */
152133 shadow ?: DepthShadowAlias ;
153- /** Set width of container */
134+ /** Width of container */
154135 width ?: string ;
155136 /** Elements to display inside box */
156137 children ?: React . ReactNode ;
138+ // These could be moved to new layout component(s) in the future
139+ /** Position of the box */
140+ position ?: 'relative' | 'absolute' | 'fixed' | 'sticky' ;
141+ top ?: string ;
142+ right ?: string ;
143+ bottom ?: string ;
144+ left ?: string ;
145+ opacity ?: string ;
146+ visuallyHidden ?: boolean ;
147+ zIndex ?: string ;
157148}
158149
159150export const Box = forwardRef < HTMLElement , BoxProps > (
@@ -166,6 +157,7 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
166157 borderInlineStart,
167158 borderInlineEnd,
168159 borderBlockStart,
160+ borderColor,
169161 borderWidth,
170162 borderBlockStartWidth,
171163 borderBlockEndWidth,
@@ -191,75 +183,65 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
191183 paddingInlineEnd,
192184 shadow,
193185 width,
186+ visuallyHidden,
187+ position,
188+ top,
189+ right,
190+ bottom,
191+ left,
192+ zIndex,
193+ opacity,
194194 } ,
195195 ref ,
196196 ) => {
197- const borders = {
198- blockEnd : borderBlockEnd ,
199- inlineStart : borderInlineStart ,
200- inlineEnd : borderInlineEnd ,
201- blockStart : borderBlockStart ,
202- } as Border ;
203-
204- const borderRadiuses = {
205- endStart : borderRadiusEndStart ,
206- endEnd : borderRadiusEndEnd ,
207- startStart : borderRadiusStartStart ,
208- startEnd : borderRadiusStartEnd ,
209- } as BorderRadius ;
210-
211- const borderWidths = {
212- blockStart : borderBlockStartWidth ,
213- blockEnd : borderBlockEndWidth ,
214- inlineStart : borderInlineStartWidth ,
215- inlineEnd : borderInlineEndWidth ,
216- } as BorderWidth ;
217-
218197 const style = {
219198 '--pc-box-color' : color ? `var(--p-${ color } )` : undefined ,
220199 '--pc-box-background' : background ? `var(--p-${ background } )` : undefined ,
221200 '--pc-box-border' : border ? `var(--p-border-${ border } )` : undefined ,
222- '--pc-box-border-block-end' : borders . blockEnd
223- ? `var(--p-border-${ borders . blockEnd } )`
201+ '--pc-box-border-block-end' : borderBlockEnd
202+ ? `var(--p-border-${ borderBlockEnd } )`
224203 : undefined ,
225- '--pc-box-border-inline-start' : borders . inlineStart
226- ? `var(--p-border-${ borders . inlineStart } )`
204+ '--pc-box-border-inline-start' : borderInlineStart
205+ ? `var(--p-border-${ borderInlineStart } )`
227206 : undefined ,
228- '--pc-box-border-inline-end' : borders . inlineEnd
229- ? `var(--p-border-${ borders . inlineEnd } )`
207+ '--pc-box-border-inline-end' : borderInlineEnd
208+ ? `var(--p-border-${ borderInlineEnd } )`
230209 : undefined ,
231- '--pc-box-border-block-start' : borders . blockStart
232- ? `var(--p-border-${ borders . blockStart } )`
210+ '--pc-box-border-block-start' : borderBlockStart
211+ ? `var(--p-border-${ borderBlockStart } )`
233212 : undefined ,
234213 '--pc-box-border-radius' : borderRadius
235214 ? `var(--p-border-radius-${ borderRadius } )`
236215 : undefined ,
237- '--pc-box-border-radius-end-start' : borderRadiuses . endStart
238- ? `var(--p-border-radius-${ borderRadiuses . endStart } )`
216+ '--pc-box-border-radius-end-start' : borderRadiusEndStart
217+ ? `var(--p-border-radius-${ borderRadiusEndStart } )`
239218 : undefined ,
240- '--pc-box-border-radius-end-end' : borderRadiuses . endEnd
241- ? `var(--p-border-radius-${ borderRadiuses . endEnd } )`
219+ '--pc-box-border-radius-end-end' : borderRadiusEndEnd
220+ ? `var(--p-border-radius-${ borderRadiusEndEnd } )`
242221 : undefined ,
243- '--pc-box-border-radius-start-start' : borderRadiuses . startStart
244- ? `var(--p-border-radius-${ borderRadiuses . startStart } )`
222+ '--pc-box-border-radius-start-start' : borderRadiusStartStart
223+ ? `var(--p-border-radius-${ borderRadiusStartStart } )`
245224 : undefined ,
246- '--pc-box-border-radius-start-end' : borderRadiuses . startEnd
247- ? `var(--p-border-radius-${ borderRadiuses . startEnd } )`
225+ '--pc-box-border-radius-start-end' : borderRadiusStartEnd
226+ ? `var(--p-border-radius-${ borderRadiusStartEnd } )`
227+ : undefined ,
228+ '--pc-box-border-color' : borderColor
229+ ? `var(--p-${ borderColor } )`
248230 : undefined ,
249231 '--pc-box-border-width' : borderWidth
250232 ? `var(--p-border-width-${ borderWidth } )`
251233 : undefined ,
252- '--pc-box-border-block-start-width' : borderWidths . blockStart
253- ? `var(--p-border-width-${ borderWidths . blockStart } )`
234+ '--pc-box-border-block-start-width' : borderBlockStartWidth
235+ ? `var(--p-border-width-${ borderBlockStartWidth } )`
254236 : undefined ,
255- '--pc-box-border-block-end-width' : borderWidths . blockEnd
256- ? `var(--p-border-width-${ borderWidths . blockEnd } )`
237+ '--pc-box-border-block-end-width' : borderBlockEndWidth
238+ ? `var(--p-border-width-${ borderBlockEndWidth } )`
257239 : undefined ,
258- '--pc-box-border-inline-start-width' : borderWidths . inlineStart
259- ? `var(--p-border-width-${ borderWidths . inlineStart } )`
240+ '--pc-box-border-inline-start-width' : borderInlineStartWidth
241+ ? `var(--p-border-width-${ borderInlineStartWidth } )`
260242 : undefined ,
261- '--pc-box-border-inline-end-width' : borderWidths . inlineEnd
262- ? `var(--p-border-width-${ borderWidths . inlineEnd } )`
243+ '--pc-box-border-inline-end-width' : borderInlineEndWidth
244+ ? `var(--p-border-width-${ borderInlineEndWidth } )`
263245 : undefined ,
264246 '--pc-box-min-height' : minHeight ,
265247 '--pc-box-min-width' : minWidth ,
@@ -293,9 +275,19 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
293275 ) ,
294276 '--pc-box-shadow' : shadow ? `var(--p-shadow-${ shadow } )` : undefined ,
295277 '--pc-box-width' : width ,
278+ position,
279+ top,
280+ right,
281+ bottom,
282+ left,
283+ zIndex,
284+ opacity,
296285 } as React . CSSProperties ;
297286
298- const className = classNames ( styles . Box ) ;
287+ const className = classNames (
288+ styles . Box ,
289+ visuallyHidden && styles . visuallyHidden ,
290+ ) ;
299291
300292 return createElement (
301293 as ,
0 commit comments