Skip to content

Commit fe9d77a

Browse files
authored
fix(expo): Support secondary button theme colors in native UI (#8997)
1 parent 8c5636b commit fe9d77a

5 files changed

Lines changed: 33 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/expo': patch
3+
---
4+
5+
Allow Expo native theme JSON to configure secondary button background and foreground colors for native SSO buttons.

‎packages/expo/android/src/main/java/expo/modules/clerk/ClerkExpoModule.kt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,9 @@ class ClerkExpoModule : Module() {
484484
border = json.optStringColor("border"),
485485
ring = json.optStringColor("ring"),
486486
muted = json.optStringColor("muted"),
487-
shadow = json.optStringColor("shadow")
487+
shadow = json.optStringColor("shadow"),
488+
secondaryButtonBackground = json.optStringColor("secondaryButtonBackground"),
489+
secondaryButtonForeground = json.optStringColor("secondaryButtonForeground")
488490
)
489491
}
490492

‎packages/expo/app.plugin.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ const withClerkAppleSignIn = config => {
225225
* Accepts a `theme` prop pointing to a JSON file with optional keys:
226226
* - colors: { primary, background, input, danger, success, warning,
227227
* foreground, mutedForeground, primaryForeground, inputForeground,
228-
* neutral, border, ring, muted, shadow } (hex color strings)
228+
* neutral, border, ring, muted, shadow, secondaryButtonBackground,
229+
* secondaryButtonForeground } (hex color strings)
229230
* - darkColors: same keys as colors (for dark mode)
230231
* - design: { fontFamily: string, borderRadius: number }
231232
*
@@ -248,6 +249,8 @@ const VALID_COLOR_KEYS = [
248249
'ring',
249250
'muted',
250251
'shadow',
252+
'secondaryButtonBackground',
253+
'secondaryButtonForeground',
251254
];
252255

253256
const HEX_COLOR_REGEX = /^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;

‎packages/expo/ios/ClerkNativeBridge.swift‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ final class ClerkNativeBridge {
380380
neutral: dict["neutral"].flatMap { colorFromHex($0) } ?? ClerkTheme.Colors.defaultNeutralColor,
381381
ring: dict["ring"].flatMap { colorFromHex($0) } ?? ClerkTheme.Colors.defaultRingColor,
382382
muted: dict["muted"].flatMap { colorFromHex($0) } ?? ClerkTheme.Colors.defaultMutedColor,
383+
secondaryButtonBackground: dict["secondaryButtonBackground"].flatMap { colorFromHex($0) } ?? ClerkTheme.Colors.defaultSecondaryButtonBackgroundColor,
384+
secondaryButtonForeground: dict["secondaryButtonForeground"].flatMap { colorFromHex($0) },
383385
shadow: dict["shadow"].flatMap { colorFromHex($0) } ?? ClerkTheme.Colors.defaultShadowColor,
384386
border: dict["border"].flatMap { colorFromHex($0) } ?? ClerkTheme.Colors.defaultBorderColor
385387
)

‎packages/expo/src/__tests__/appPlugin.theme.test.js‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,25 @@ describe('validateThemeJson', () => {
8888
expect(() => validateThemeJson({ colors: { shadow: '#00000080' } })).not.toThrow();
8989
});
9090

91+
test('accepts secondary button color keys without warnings', () => {
92+
const spy = vi.spyOn(console, 'warn').mockImplementation(() => {});
93+
94+
expect(() =>
95+
validateThemeJson({
96+
colors: {
97+
secondaryButtonBackground: '#FFFFFF',
98+
secondaryButtonForeground: '#111111',
99+
},
100+
darkColors: {
101+
secondaryButtonBackground: '#111111',
102+
secondaryButtonForeground: '#FFFFFF',
103+
},
104+
}),
105+
).not.toThrow();
106+
107+
expect(spy).not.toHaveBeenCalled();
108+
});
109+
91110
// --- unknown keys ---
92111

93112
test('warns on unknown color keys but does not throw', () => {

0 commit comments

Comments
 (0)