Skip to content

Commit e0b1102

Browse files
committed
chore: change prop names
1 parent aab160d commit e0b1102

File tree

6 files changed

+20
-23
lines changed

6 files changed

+20
-23
lines changed

.storybook/preview.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const VanillaProviderWrapper = ({ children, isDark, primaryColor }) => {
7575
Provider,
7676
{
7777
forcedTheme: isDark ? 'dark' : 'light',
78-
defaultPrimaryColor: primaryColor,
78+
primaryColor,
7979
},
8080
children,
8181
);

components/Badge/Badge.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { VariantProps } from '../../stitches.config';
55
import { modifyVariantsForStory } from '../../utils/modifyVariantsForStory';
66
import { Flex } from '../Flex';
77
import { UnstyledLink } from '../Link';
8-
import { Badge, COLORS } from './Badge';
9-
import { BadgeVanilla } from './Badge.vanilla';
8+
import { Badge } from './Badge';
9+
import { BadgeVanilla, COLORS } from './Badge.vanilla';
1010

1111
type BadgeVariants = VariantProps<typeof Badge>;
1212
type BadgeProps = BadgeVariants & NonNullable<unknown>;

components/Badge/Badge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Slot } from '@radix-ui/react-slot';
22
import React, { ComponentProps, useMemo } from 'react';
33

44
import { styled, VariantProps } from '../../stitches.config';
5+
import { COLORS } from './Badge.vanilla';
56

6-
export const COLORS = ['gray', 'red', 'blue', 'green', 'neon', 'orange', 'purple'] as const;
77
type COLOR_VALUES = (typeof COLORS)[number];
88

99
const getColorBadgeStyles = (color: COLOR_VALUES) => ({

components/Badge/Badge.vanilla.css.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { recipe } from '@vanilla-extract/recipes';
33

44
import { tokens } from '../../styles/tokens.css';
55

6-
export const COLORS = ['gray', 'red', 'blue', 'green', 'neon', 'orange', 'purple'] as const;
7-
86
const baseBadge = style({
97
alignItems: 'center',
108
appearance: 'none',

components/Badge/Badge.vanilla.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import React, { useMemo } from 'react';
55

66
import { CSSProps, processCSSProp } from '../../styles/cssProps';
77
import { useVanillaExtractTheme } from '../../styles/themeContext';
8-
import { badgeRecipe, COLORS, interactiveBadgeRecipe } from './Badge.vanilla.css';
8+
import { badgeRecipe, interactiveBadgeRecipe } from './Badge.vanilla.css';
99

10-
export { COLORS };
10+
export const COLORS = ['gray', 'red', 'blue', 'green', 'neon', 'orange', 'purple'] as const;
1111

1212
type BadgeRecipeVariants = RecipeVariants<typeof badgeRecipe>;
1313

styles/themeContext.tsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type { PrimaryColor };
99
interface ThemeContextValue {
1010
mode: ThemeMode;
1111
resolvedTheme: 'light' | 'dark';
12-
primaryColor: PrimaryColor;
12+
primColor: PrimaryColor;
1313
colors: typeof lightColors | typeof darkColors;
1414
setMode: (mode: ThemeMode) => void;
1515
setPrimaryColor: (color: PrimaryColor) => void;
@@ -19,25 +19,24 @@ const ThemeContext = createContext<ThemeContextValue | undefined>(undefined);
1919

2020
interface VanillaExtractThemeProviderProps {
2121
children: React.ReactNode;
22-
defaultMode?: ThemeMode;
23-
defaultPrimaryColor?: PrimaryColor;
22+
defaultTheme?: ThemeMode;
23+
primaryColor?: PrimaryColor;
2424
forcedTheme?: 'light' | 'dark';
2525
}
2626

2727
export function VanillaExtractThemeProvider({
2828
children,
29-
defaultMode = 'system',
30-
defaultPrimaryColor = 'blue',
29+
defaultTheme = 'system',
30+
primaryColor = 'blue',
3131
forcedTheme,
3232
}: VanillaExtractThemeProviderProps) {
33-
const [mode, setMode] = useState<ThemeMode>(defaultMode);
34-
const [primaryColor, setPrimaryColor] = useState<PrimaryColor>(defaultPrimaryColor);
33+
const [mode, setMode] = useState<ThemeMode>(defaultTheme);
34+
const [primColor, setPrimaryColor] = useState<PrimaryColor>(primaryColor);
3535
const [systemTheme, setSystemTheme] = useState<'light' | 'dark'>('light');
3636

37-
// Update primaryColor when defaultPrimaryColor prop changes
3837
useEffect(() => {
39-
setPrimaryColor(defaultPrimaryColor);
40-
}, [defaultPrimaryColor]);
38+
setPrimaryColor(primaryColor);
39+
}, [primaryColor]);
4140

4241
useEffect(() => {
4342
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
@@ -59,7 +58,7 @@ export function VanillaExtractThemeProvider({
5958
const semanticColors =
6059
resolvedTheme === 'dark'
6160
? {
62-
primary: darkColors[`${primaryColor}9`],
61+
primary: darkColors[`${primColor}9`],
6362
contentBg: darkColors['00dp'],
6463
hiContrast: 'white',
6564
loContrast: darkColors.deepBlue2,
@@ -82,7 +81,7 @@ export function VanillaExtractThemeProvider({
8281
ring: '#60a5fa',
8382
}
8483
: {
85-
primary: lightColors[`${primaryColor}9`],
84+
primary: lightColors[`${primColor}9`],
8685
contentBg: lightColors['00dp'],
8786
hiContrast: lightColors.deepBlue11,
8887
loContrast: 'white',
@@ -111,7 +110,7 @@ export function VanillaExtractThemeProvider({
111110
};
112111

113112
useEffect(() => {
114-
const themeClass = themes[resolvedTheme][primaryColor];
113+
const themeClass = themes[resolvedTheme][primColor];
115114

116115
// Remove all theme classes
117116
Object.values(themes.light).forEach((cls) => document.body.classList.remove(cls));
@@ -123,12 +122,12 @@ export function VanillaExtractThemeProvider({
123122
return () => {
124123
document.body.classList.remove(themeClass);
125124
};
126-
}, [resolvedTheme, primaryColor]);
125+
}, [resolvedTheme, primColor]);
127126

128127
const contextValue: ThemeContextValue = {
129128
mode,
130129
resolvedTheme,
131-
primaryColor,
130+
primColor,
132131
colors,
133132
setMode,
134133
setPrimaryColor,

0 commit comments

Comments
 (0)