Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make chromatic less sensitive #1273

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/BrandedNavBar/NavBar.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import theme from "../theme";
import { Button } from "../Button";
import { Text } from "../Type";
import { BrandedNavBar as NDSBrandedNavBar } from "./index";
import numberFromDimension from "../utils/numberFromDimension";

const sampleLogo = "http://pigment.github.io/fake-logos/logos/vector/color/auto-speed.svg";

Expand Down Expand Up @@ -389,9 +390,9 @@ export const WithHamburgerMenu = () => {
};
WithHamburgerMenu.parameters = {
viewport: {
defaultViewport: "small", // for some reason this has to match the viewport key, NOT the name!
defaultViewport: "small", // for some reason, this has to match the viewport key, NOT the name!
},
chromatic: { viewports: [parseInt(theme.breakpoints.small)] },
chromatic: { viewports: [numberFromDimension(theme.breakpoints.small)] },
};

const customPrimaryMenu = [
Expand Down Expand Up @@ -428,7 +429,7 @@ CustomRenderingInHamburger.parameters = {
viewport: {
defaultViewport: "small", // for some reason this has to match the viewport key, NOT the name!
},
chromatic: { viewports: [parseInt(theme.breakpoints.small)] },
chromatic: { viewports: [numberFromDimension(theme.breakpoints.small)] },
};

const primaryMenuWithCustomTriggers = [
Expand Down Expand Up @@ -487,5 +488,5 @@ CustomMenuTriggersInHamburger.parameters = {
viewport: {
defaultViewport: "small", // for some reason this has to match the viewport key, NOT the name!
},
chromatic: { viewports: [parseInt(theme.breakpoints.small)] },
chromatic: { viewports: [numberFromDimension(theme.breakpoints.small)] },
};
3 changes: 2 additions & 1 deletion src/BrandedNavBar/SmallNavBar.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Link } from "../Link";
import { Button, SmallNavBarProps, theme } from "../index";
import BrandLogoContainer from "./BrandLogoContainer";
import { SmallNavBar } from "./index";
import numberFromDimension from "../utils/numberFromDimension";

const ResetStorybookView = styled.div({
position: "absolute",
Expand Down Expand Up @@ -78,7 +79,7 @@ const smallViewport = {
viewport: {
defaultViewport: "small", // for some reason this has to match the viewport key, NOT the name!
},
chromatic: { viewports: [parseInt(theme.breakpoints.small)] },
chromatic: { viewports: [numberFromDimension(theme.breakpoints.small)] },
};

export default {
Expand Down
6 changes: 6 additions & 0 deletions src/Button/IconicButton.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import dashed from "../utils/dashed";

export default {
title: "Components/IconicButton",
parameters: {
// Sets the diffThreshold for 0.2 for a specific story.
chromatic: {
diffThreshold: 0.4,
},
},
};

export const WithoutALabel = () => <IconicButton icon="delete" />;
Expand Down
4 changes: 2 additions & 2 deletions src/DropdownMenu/DropdownMenu.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const customColors = {

export default {
title: "Components/DropdownMenu",
chromatic: {
diffThreshold: 0.4,
parameters: {
chromatic: { diffThreshold: 0.4 },
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/numberFromDimension/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
* Returns the number from a [CSS dimension]{@link https://developer.mozilla.org/en-US/docs/Web/CSS/dimension}.
* @param {string} dimension - A css dimension
*/
export default function (dimension: string | number): number {
export default function numberFromDimension(dimension: string | number): number {
return parseInt(String(dimension), 10);
}
Loading