Skip to content

Commit

Permalink
fix(Spinner): use controlActivatedInverse token as default when used …
Browse files Browse the repository at this point in the history
…inside inverse variant (#1133)
  • Loading branch information
marcoskolodny authored May 31, 2024
1 parent 034097e commit 38a192d
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions src/__screenshot_tests__/spinner-screenshot-test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {openStoryPage, screen} from '../test-utils';

const DEVICES = ['DESKTOP', 'MOBILE_ANDROID', 'MOBILE_IOS'] as const;

test.each(DEVICES)('Spinner - default %s', async (device) => {
await openStoryPage({
id: 'components-spinner--default',
device,
});

const spinner = await screen.findByLabelText('Cargando');

const image = await spinner.screenshot();
expect(image).toMatchImageSnapshot();
});

test.each(DEVICES)('Spinner - inverse %s', async (device) => {
await openStoryPage({
id: 'components-spinner--default',
device,
args: {inverse: true},
});

const spinner = await screen.findByLabelText('Cargando');

const image = await spinner.screenshot();
expect(image).toMatchImageSnapshot();
});
15 changes: 12 additions & 3 deletions src/__stories__/spinner-story.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import {Spinner} from '..';
import {Box, ResponsiveLayout, Spinner} from '..';

export default {
title: 'Components/Spinner',
Expand All @@ -9,17 +9,26 @@ export default {
control: {type: 'range', min: 24, max: 100, step: 4},
},
},
parameters: {fullScreen: true},
};

type Args = {
size: number;
inverse: boolean;
};

export const Default: StoryComponent<Args> = ({size}) => {
return <Spinner size={size} />;
export const Default: StoryComponent<Args> = ({size, inverse}) => {
return (
<ResponsiveLayout isInverse={inverse} fullWidth>
<Box padding={16}>
<Spinner size={size} />
</Box>
</ResponsiveLayout>
);
};

Default.storyName = 'Spinner';
Default.args = {
size: 24,
inverse: false,
};
4 changes: 3 additions & 1 deletion src/spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import FadeIn from './fade-in';
import {useAriaId, useTheme} from './hooks';
import * as styles from './spinner.css';
import {vars} from './skins/skin-contract.css';
import {useIsInverseVariant} from './theme-variant-context';

type Props = {
color?: string;
Expand All @@ -17,7 +18,8 @@ type Props = {

const Spinner: React.FC<Props> = ({color, delay = '500ms', size = 24, style, rolePresentation}) => {
const {texts, platformOverrides} = useTheme();
color = color || vars.colors.controlActivated;
const isInverse = useIsInverseVariant();
color = color || (isInverse ? vars.colors.controlActivatedInverse : vars.colors.controlActivated);
const spinnerId = useAriaId();
const withTitle = !rolePresentation;
const title = texts.loading;
Expand Down

1 comment on commit 38a192d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for mistica-web ready!

✅ Preview
https://mistica-3cxivirwc-flows-projects-65bb050e.vercel.app

Built with commit 38a192d.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.