@@ -36,10 +36,34 @@ type Shadow = 'default' | 'transparent' | 'faint' | 'deep';
3636type ShapeTokenGroup = typeof shape ;
3737type ShapeTokenName = keyof ShapeTokenGroup ;
3838
39- type BorderTokenScale = ShapeTokenName extends `border-${infer Scale } `
39+ type BorderShapeTokenScale = ShapeTokenName extends `border-${infer Scale } `
4040 ? Scale
4141 : never ;
4242
43+ type BorderTokenScale = Exclude <
44+ BorderShapeTokenScale ,
45+ `radius-${string } ` | `width-${string } `
46+ > ;
47+
48+ type Border = {
49+ bottom : BorderTokenScale ;
50+ left : BorderTokenScale ;
51+ right : BorderTokenScale ;
52+ top : BorderTokenScale ;
53+ } ;
54+
55+ type BorderRadiusTokenScale = Extract <
56+ BorderShapeTokenScale ,
57+ `radius-${string } `
58+ > ;
59+
60+ type BorderRadius = {
61+ bottomLeft : BorderRadiusTokenScale | '' ;
62+ bottomRight : BorderRadiusTokenScale | '' ;
63+ topLeft : BorderRadiusTokenScale | '' ;
64+ topRight : BorderRadiusTokenScale | '' ;
65+ } ;
66+
4367type SpacingTokenGroup = typeof spacing ;
4468type SpacingTokenName = keyof SpacingTokenGroup ;
4569
@@ -60,6 +84,24 @@ interface BoxBaseProps {
6084 background ?: Background ;
6185 /** Border styling of the Box */
6286 border ?: BorderTokenScale ;
87+ /** Bottom border styling of the Box */
88+ borderBottom ?: BorderTokenScale ;
89+ /** Left border styling of the Box */
90+ borderLeft ?: BorderTokenScale ;
91+ /** Right border styling of the Box */
92+ borderRight ?: BorderTokenScale ;
93+ /** Top border styling of the Box */
94+ borderTop ?: BorderTokenScale ;
95+ /** Border radius of the Box */
96+ borderRadius ?: BorderRadiusTokenScale ;
97+ /** Bottom left border radius of the Box */
98+ borderRadiusBottomLeft ?: BorderRadiusTokenScale ;
99+ /** Bottom right border radius of the Box */
100+ borderRadiusBottomRight ?: BorderRadiusTokenScale ;
101+ /** Top left border radius of the Box */
102+ borderRadiusTopLeft ?: BorderRadiusTokenScale ;
103+ /** Top right border radius of the Box */
104+ borderRadiusTopRight ?: BorderRadiusTokenScale ;
63105 /** Inner content of the Box */
64106 children : ReactNode ;
65107 /** Spacing outside of the Box */
@@ -95,7 +137,16 @@ export const Box = forwardRef(
95137 {
96138 as : Component = 'div' ,
97139 background,
98- border,
140+ border = '' ,
141+ borderBottom = '' ,
142+ borderLeft = '' ,
143+ borderRight = '' ,
144+ borderTop = '' ,
145+ borderRadius = '' ,
146+ borderRadiusBottomLeft = '' ,
147+ borderRadiusBottomRight = '' ,
148+ borderRadiusTopLeft = '' ,
149+ borderRadiusTopRight = '' ,
99150 children,
100151 margin = '' ,
101152 marginBottom = '' ,
@@ -111,6 +162,26 @@ export const Box = forwardRef(
111162 } ,
112163 ref ,
113164 ) => {
165+ const borders = {
166+ bottom : borderBottom ? borderBottom : border ,
167+ left : borderLeft ? borderLeft : border ,
168+ right : borderRight ? borderRight : border ,
169+ top : borderTop ? borderTop : border ,
170+ } as Border ;
171+
172+ console . log ( { borders} ) ;
173+
174+ const borderRadiuses = {
175+ bottomLeft : borderRadiusBottomLeft
176+ ? borderRadiusBottomLeft
177+ : borderRadius ,
178+ bottomRight : borderRadiusBottomRight
179+ ? borderRadiusBottomRight
180+ : borderRadius ,
181+ topLeft : borderRadiusTopLeft ? borderRadiusTopLeft : borderRadius ,
182+ topRight : borderRadiusTopRight ? borderRadiusTopRight : borderRadius ,
183+ } as BorderRadius ;
184+
114185 const margins = {
115186 bottom : marginBottom ? marginBottom : margin ,
116187 left : marginLeft ? marginLeft : margin ,
@@ -148,12 +219,35 @@ export const Box = forwardRef(
148219 '--pc-box-padding-top' : paddings . top
149220 ? `var(--p-space-${ paddings . top } )`
150221 : '' ,
222+ '--pc-box-border-bottom' : borders . bottom
223+ ? `var(--p-border-${ borders . bottom } )`
224+ : '' ,
225+ '--pc-box-border-left' : borders . left
226+ ? `var(--p-border-${ borders . left } )`
227+ : '' ,
228+ '--pc-box-border-right' : borders . right
229+ ? `var(--p-border-${ borders . right } )`
230+ : '' ,
231+ '--pc-box-border-top' : borders . top
232+ ? `var(--p-border-${ borders . top } )`
233+ : '' ,
234+ '--pc-box-border-radius-bottom-left' : borderRadiuses . bottomLeft
235+ ? `var(--p-border-${ borderRadiuses . bottomLeft } )`
236+ : '' ,
237+ '--pc-box-border-radius-bottom-right' : borderRadiuses . bottomRight
238+ ? `var(--p-border-${ borderRadiuses . bottomRight } )`
239+ : '' ,
240+ '--pc-box-border-radius-top-left' : borderRadiuses . topLeft
241+ ? `var(--p-border-${ borderRadiuses . topLeft } )`
242+ : '' ,
243+ '--pc-box-border-radius-top-right' : borderRadiuses . topRight
244+ ? `var(--p-border-${ borderRadiuses . topRight } )`
245+ : '' ,
151246 } as React . CSSProperties ;
152247
153248 const className = classNames (
154249 styles . root ,
155250 background && styles [ background ] ,
156- border && styles [ border ] ,
157251 shadow && styles [ shadow ] ,
158252 ) ;
159253
0 commit comments