Skip to content

Commit 64689e9

Browse files
chore: fix React Aria home page "bring your styles" button in light mode (#10242)
* chore: fix React Aria home page "bring your styles" button in light mode * fix button color * fix for transparency * add chromatic story for auto * fix chromatic issue * remove static color from original powerset * get rid of color pickers --------- Co-authored-by: Rob Snow <rsnow@adobe.com>
1 parent 30a5dca commit 64689e9

5 files changed

Lines changed: 53 additions & 7 deletions

File tree

packages/@react-spectrum/s2/chromatic/Button.stories.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ let genaiStates = [{isDisabled: true}, {size: ['S', 'M', 'L', 'XL']}];
5050

5151
let genaiCombinations = generatePowerset(genaiStates);
5252

53+
let staticColorAutoStates = [
54+
{isQuiet: true},
55+
{isDisabled: true},
56+
{size: ['S', 'M', 'L', 'XL']},
57+
{staticColor: ['auto']},
58+
{variant: ['accent', 'negative', 'primary', 'secondary']}
59+
];
60+
61+
let staticColorAutoCombinations = generatePowerset(staticColorAutoStates).filter(
62+
c => c.staticColor != null
63+
);
64+
5365
const Template = (args: ButtonProps & {combos?: any[]}): ReactNode => {
5466
let {children, combos = combinations, variant, ...otherArgs} = args;
5567
return (
@@ -82,7 +94,11 @@ const Template = (args: ButtonProps & {combos?: any[]}): ReactNode => {
8294
</Button>
8395
);
8496
if (c.staticColor != null) {
85-
return <StaticColorProvider staticColor={c.staticColor}>{button}</StaticColorProvider>;
97+
return (
98+
<StaticColorProvider key={`static-${key}`} staticColor={c.staticColor} hideColorPicker>
99+
{button}
100+
</StaticColorProvider>
101+
);
86102
}
87103

88104
return button;
@@ -95,6 +111,10 @@ export const Default: StoryObj<typeof Button> = {
95111
render: args => <Template {...args} />
96112
};
97113

114+
export const StaticColorAuto: StoryObj<typeof Button> = {
115+
render: args => <Template {...args} combos={staticColorAutoCombinations} />
116+
};
117+
98118
export const WithIcon: StoryObj<typeof Button> = {
99119
render: args => <Template {...args} />,
100120
args: {

packages/@react-spectrum/s2/src/Button.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,12 @@ const button = style<ButtonRenderProps & ButtonStyleProps & {isStaticColor: bool
253253
fill: {
254254
variant: {
255255
primary: 'auto',
256-
secondary: 'white',
256+
secondary: {
257+
default: 'transparent-overlay-1000',
258+
isHovered: 'transparent-overlay-1000',
259+
isFocusVisible: 'transparent-overlay-1000',
260+
isPressed: 'transparent-overlay-1000'
261+
},
257262
premium: 'white',
258263
genai: 'white'
259264
}
@@ -263,7 +268,12 @@ const button = style<ButtonRenderProps & ButtonStyleProps & {isStaticColor: bool
263268
premium: 'white',
264269
genai: 'white'
265270
},
266-
default: 'white'
271+
default: {
272+
default: 'transparent-overlay-1000',
273+
isHovered: 'transparent-overlay-1000',
274+
isFocusVisible: 'transparent-overlay-1000',
275+
isPressed: 'transparent-overlay-1000'
276+
}
267277
}
268278
},
269279
isDisabled: 'transparent-overlay-400'

packages/@react-spectrum/s2/stories/utils.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function getBackgroundColor(staticColor: StaticColor) {
3535
export function StaticColorProvider(props: {
3636
children: ReactNode;
3737
staticColor?: StaticColor;
38+
hideColorPicker?: boolean;
3839
}): ReactElement {
3940
let [autoBg, setAutoBg] = useState('#5131c4');
4041
return (
@@ -48,7 +49,7 @@ export function StaticColorProvider(props: {
4849
}}>
4950
{props.children}
5051
</div>
51-
{props.staticColor === 'auto' && (
52+
{props.staticColor === 'auto' && !props.hideColorPicker && (
5253
<label
5354
className={style({
5455
display: 'flex',

packages/dev/s2-docs/pages/react-aria/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {LinkButton} from '../../src/Link';
2929
import HomeHeader from './HomeHeader';
3030
import {Video} from '../../src/Video';
3131
import videoUrl from 'url:./assets/website.mp4';
32-
import {SettingsContextProvider} from '../../src/SettingsProvider';
32+
import {RACSettingsProvider} from '../../src/SettingsProvider';
3333

3434
export const section = 'Overview';
3535
export const title = 'Home';
@@ -76,7 +76,7 @@ export const description = 'Accessible, high quality UI components and hooks for
7676
)}} />
7777
</head>
7878
<body className="m-0" style={{'--s2-container-bg': 'light-dark(white, black)'}}>
79-
<SettingsContextProvider>
79+
<RACSettingsProvider>
8080
<header className="relative header-background isolate pt-20 md:pt-32">
8181
<HomeHeader />
8282
<section className="p-4 md:p-6 box-border overflow-clip bg-white dark:bg-zinc-800/80 dark:backdrop-saturate-200 card-shadow w-fit max-w-[calc(100%-40px)] mx-auto rounded-xl flex items-center flex-col xl:flex-row gap-8">
@@ -648,7 +648,7 @@ export const description = 'Accessible, high quality UI components and hooks for
648648
<li><a href="//www.adobe.com/privacy/ca-rights.html" target="_blank" className="underline text-zinc-500 dark:text-zinc-400">Do not sell my personal information</a></li>
649649
</ul>
650650
</footer>
651-
</SettingsContextProvider>
651+
</RACSettingsProvider>
652652
</body>
653653
</Provider>
654654
</RouterWrapperServer>

packages/dev/s2-docs/src/SettingsProvider.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ export function SettingsContextProvider({children, elementType, locale}: Setting
7777
);
7878
}
7979

80+
export function RACSettingsProvider({children}: Pick<SettingsProviderProps, 'children'>) {
81+
let {colorScheme, toggleColorScheme, systemColorScheme} = useSettingsState();
82+
83+
return (
84+
<SettingsContext.Provider
85+
value={{
86+
colorScheme,
87+
toggleColorScheme,
88+
systemColorScheme
89+
}}>
90+
{children}
91+
</SettingsContext.Provider>
92+
);
93+
}
94+
8095
export function SettingsProvider({children}: SettingsProviderProps) {
8196
let {colorScheme, toggleColorScheme, systemColorScheme, providerColorScheme} = useSettingsState();
8297

0 commit comments

Comments
 (0)