Skip to content

Commit 17380f7

Browse files
committed
feat(javascript): add border radius overrides for Field component and update related styles
1 parent 6ba5b4b commit 17380f7

File tree

7 files changed

+57
-11
lines changed

7 files changed

+57
-11
lines changed

packages/javascript/src/theme/createTheme.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ const toCssVariables = (theme: ThemeConfig): Record<string, string> => {
459459
theme.components.Button.styleOverrides.root.borderRadius;
460460
}
461461

462+
// Field Overrides (Parent of `TextField`, `DatePicker`, `OtpField`, `Select`, etc.)
463+
if (theme.components?.Field?.styleOverrides?.root?.borderRadius) {
464+
cssVars[`--${prefix}-component-field-root-borderRadius`] = theme.components.Field.styleOverrides.root.borderRadius;
465+
}
466+
462467
return cssVars;
463468
};
464469

@@ -473,6 +478,13 @@ const toThemeVars = (theme: ThemeConfig): ThemeVars => {
473478
},
474479
};
475480
}
481+
if (theme.components?.Field?.styleOverrides?.root?.borderRadius) {
482+
componentVars.Field = {
483+
root: {
484+
borderRadius: `var(--${prefix}-component-field-root-borderRadius)`,
485+
},
486+
};
487+
}
476488

477489
const themeVars: ThemeVars = {
478490
colors: {

packages/javascript/src/theme/types.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ export interface ThemeComponents {
122122
defaultProps?: Record<string, any>;
123123
variants?: Array<Record<string, any>>;
124124
};
125+
Field?: {
126+
styleOverrides?: {
127+
root?: {
128+
borderRadius?: string;
129+
[key: string]: any;
130+
};
131+
[slot: string]: Record<string, any> | undefined;
132+
};
133+
defaultProps?: Record<string, any>;
134+
variants?: Array<Record<string, any>>;
135+
};
125136
[componentName: string]:
126137
| {
127138
styleOverrides?: ThemeComponentStyleOverrides;
@@ -192,6 +203,13 @@ export interface ThemeComponentVars {
192203
};
193204
[slot: string]: Record<string, any> | undefined;
194205
};
206+
Field?: {
207+
root?: {
208+
borderRadius?: string;
209+
[key: string]: any;
210+
};
211+
[slot: string]: Record<string, any> | undefined;
212+
};
195213
[componentName: string]:
196214
| {
197215
[slot: string]: Record<string, any> | undefined;

packages/javascript/src/utils/transformBrandingPreferenceToTheme.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,33 @@ const transformThemeVariant = (themeVariant: ThemeVariant, isDark = false): Part
129129
},
130130
};
131131

132-
// --- COMPONENT OVERRIDES: Button borderRadius ---
132+
/* |---------------------------------------------------------------| */
133+
/* | Components | */
134+
/* |---------------------------------------------------------------| */
135+
133136
const buttonBorderRadius = buttons?.primary?.base?.border?.borderRadius;
134-
if (buttonBorderRadius) {
137+
const fieldBorderRadius = inputs?.base?.border?.borderRadius;
138+
139+
if (buttonBorderRadius || fieldBorderRadius) {
135140
config.components = {
136-
Button: {
137-
styleOverrides: {
138-
root: {
139-
borderRadius: buttonBorderRadius,
141+
...(buttonBorderRadius && {
142+
Button: {
143+
styleOverrides: {
144+
root: {
145+
borderRadius: buttonBorderRadius,
146+
},
140147
},
141148
},
142-
},
149+
}),
150+
...(fieldBorderRadius && {
151+
Field: {
152+
styleOverrides: {
153+
root: {
154+
borderRadius: fieldBorderRadius,
155+
},
156+
},
157+
},
158+
}),
143159
};
144160
}
145161

packages/react/src/components/primitives/DatePicker/DatePicker.styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const useStyles = (theme: Theme, colorScheme: string, hasError: boolean, disable
3434
width: 100%;
3535
padding: ${theme.vars.spacing.unit} calc(${theme.vars.spacing.unit} * 1.5);
3636
border: 1px solid ${theme.vars.colors.border};
37-
border-radius: ${theme.vars.borderRadius.medium};
37+
border-radius: ${theme.vars.components?.Field?.root?.borderRadius || theme.vars.borderRadius.medium};
3838
font-size: 1rem;
3939
color: ${theme.vars.colors.text.primary};
4040
background-color: ${theme.vars.colors.background.surface};

packages/react/src/components/primitives/OtpField/OtpField.styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const useStyles = (
5454
font-size: ${theme.vars.typography.fontSizes.xl};
5555
font-weight: 500;
5656
border: 2px solid ${hasError ? theme.vars.colors.error.main : theme.vars.colors.border};
57-
border-radius: ${theme.vars.borderRadius.medium};
57+
border-radius: ${theme.vars.components?.Field?.root?.borderRadius || theme.vars.borderRadius.medium};
5858
color: ${theme.vars.colors.text.primary};
5959
background-color: ${disabled ? theme.vars.colors.background.disabled : theme.vars.colors.background.surface};
6060
outline: none;

packages/react/src/components/primitives/Select/Select.styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const useStyles = (theme: Theme, colorScheme: string, disabled: boolean, hasErro
3737
width: 100%;
3838
padding: ${theme.vars.spacing.unit} calc(${theme.vars.spacing.unit} * 1.5);
3939
border: 1px solid ${hasError ? theme.vars.colors.error.main : theme.vars.colors.border};
40-
border-radius: ${theme.vars.borderRadius.medium};
40+
border-radius: ${theme.vars.components?.Field?.root?.borderRadius || theme.vars.borderRadius.medium};
4141
font-size: ${theme.vars.typography.fontSizes.md};
4242
color: ${theme.vars.colors.text.primary};
4343
background-color: ${disabled ? theme.vars.colors.background.disabled : theme.vars.colors.background.surface};

packages/react/src/components/primitives/TextField/TextField.styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const useStyles = (
5454
width: 100%;
5555
padding: ${theme.vars.spacing.unit} ${rightPadding} ${theme.vars.spacing.unit} ${leftPadding};
5656
border: 1px solid ${hasError ? theme.vars.colors.error.main : theme.vars.colors.border};
57-
border-radius: ${theme.vars.borderRadius.medium};
57+
border-radius: ${theme.vars.components?.Field?.root?.borderRadius || theme.vars.borderRadius.medium};
5858
font-size: ${theme.vars.typography.fontSizes.md};
5959
color: ${theme.vars.colors.text.primary};
6060
background-color: ${disabled ? theme.vars.colors.background.disabled : theme.vars.colors.background.surface};

0 commit comments

Comments
 (0)