Skip to content

Commit 125a85c

Browse files
authored
fix: components are not showing correct high contrast colors in Edge chromium, removed hard code value, and add more examples (#2327)
* add disabled and anchor stories, add opt out property to fix components where HC is not showing up * add function to check for forced-color for hyperlinks, fixed anchor colors on buttons * create match-media file to test window.matchMedia method in components spec files * address regressions, delete import mock files from specs, create mock.js file in packages to use for Jest testing * prettier * fix dim text for input text and set color value on hypertext so it doesn't get overridden * run prettier * combined selectors in call to action primary
1 parent 4528631 commit 125a85c

File tree

47 files changed

+841
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+841
-206
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// tslint:disable-next-line: typedef
2+
window.matchMedia = jest.fn().mockImplementation(query => {
3+
return {
4+
matches: false,
5+
media: query,
6+
};
7+
});

packages/fast-component-explorer/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
},
3131
"license": "MIT",
3232
"jest": {
33+
"setupFilesAfterEnv": ["./mock.js"],
3334
"collectCoverage": true,
3435
"coverageThreshold": {
3536
"global": {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// tslint:disable-next-line: typedef
2+
window.matchMedia = jest.fn().mockImplementation(query => {
3+
return {
4+
matches: false,
5+
media: query,
6+
};
7+
});

packages/fast-components-react-msft/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"watch": "tsc -p ./tsconfig.build.json -w --preserveWatchOutput"
3737
},
3838
"jest": {
39+
"setupFilesAfterEnv": ["./mock.js"],
3940
"collectCoverage": true,
4041
"coverageThreshold": {
4142
"global": {

packages/fast-components-react-msft/src/accent-button/accent-button.stories.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ import { glyphFactory, SVGGlyph } from "../../assets/svg-element";
55

66
storiesOf("Accent button", module)
77
.add("Default", () => <AccentButton>Accent button</AccentButton>)
8-
.add("Anchor", () => <AccentButton href="#">Anchor button</AccentButton>)
8+
.add("Anchor", () => (
9+
<AccentButton
10+
href="#"
11+
beforeContent={glyphFactory(SVGGlyph.download)}
12+
afterContent={glyphFactory(SVGGlyph.user)}
13+
>
14+
Anchor button
15+
</AccentButton>
16+
))
917
.add("Before content", () => (
1018
<AccentButton beforeContent={glyphFactory(SVGGlyph.download)}>
1119
With before content

packages/fast-components-react-msft/src/button/button.stories.tsx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ import { glyphFactory, SVGGlyph } from "../../assets/svg-element";
55

66
storiesOf("Button", module)
77
.add("Default", () => <Button>Button</Button>)
8-
.add("Anchor", () => <Button href="#">Anchor button</Button>)
8+
.add("Anchor", () => (
9+
<Button
10+
href="#"
11+
beforeContent={glyphFactory(SVGGlyph.user)}
12+
afterContent={glyphFactory(SVGGlyph.download)}
13+
>
14+
Anchor button
15+
</Button>
16+
))
917
.add("Anchor - disabled", () => (
1018
<Button href="#" disabled={true}>
1119
Anchor button
@@ -14,6 +22,16 @@ storiesOf("Button", module)
1422
.add("Primary", () => (
1523
<Button appearance={ButtonAppearance.primary}>Primary Button</Button>
1624
))
25+
.add("Primary Anchor", () => (
26+
<Button
27+
appearance={ButtonAppearance.primary}
28+
href="#"
29+
beforeContent={glyphFactory(SVGGlyph.user)}
30+
afterContent={glyphFactory(SVGGlyph.download)}
31+
>
32+
Primary Anchor
33+
</Button>
34+
))
1735
.add("Primary - disabled", () => (
1836
<Button appearance={ButtonAppearance.primary} disabled={true}>
1937
Primary Button
@@ -35,6 +53,21 @@ storiesOf("Button", module)
3553
Lightweight Button
3654
</Button>
3755
))
56+
.add("Lightweight Anchor", () => (
57+
<Button
58+
appearance={ButtonAppearance.lightweight}
59+
href="#"
60+
beforeContent={glyphFactory(SVGGlyph.user)}
61+
afterContent={glyphFactory(SVGGlyph.download)}
62+
>
63+
Lightweight Button
64+
</Button>
65+
))
66+
.add("Lightweight Anchor - disabled", () => (
67+
<Button appearance={ButtonAppearance.lightweight} href="#" disabled={true}>
68+
Lightweight Button
69+
</Button>
70+
))
3871
.add("Justified", () => (
3972
<Button appearance={ButtonAppearance.justified}>Justified Button</Button>
4073
))

packages/fast-components-react-msft/src/call-to-action/call-to-action.stories.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ storiesOf("Call to action", module)
77
.add("Primary", () => (
88
<CallToAction appearance={CallToActionAppearance.primary}>Buy now</CallToAction>
99
))
10+
.add(" Primary Anchor", () => (
11+
<CallToAction appearance={CallToActionAppearance.primary} href="#">
12+
Buy now
13+
</CallToAction>
14+
))
1015
.add("Justified", () => (
1116
<CallToAction appearance={CallToActionAppearance.justified}>Buy now</CallToAction>
1217
))

packages/fast-components-react-msft/src/checkbox/checkbox.stories.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,22 @@ storiesOf("Checkbox", module)
6262
</Label>
6363
);
6464
return <Checkbox inputId={id} onChange={action("onChnage")} label={label} />;
65+
})
66+
.add("Disabled with label", () => {
67+
const id: string = uniqueId();
68+
const label: (className: string) => React.ReactNode = (
69+
className: string
70+
): React.ReactNode => (
71+
<Label className={className} htmlFor={id}>
72+
Hello render prop
73+
</Label>
74+
);
75+
return (
76+
<Checkbox
77+
inputId={id}
78+
onChange={action("onChnage")}
79+
label={label}
80+
disabled={true}
81+
/>
82+
);
6583
});

packages/fast-components-react-msft/src/lightweight-button/lightweight-button.stories.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ import { glyphFactory, SVGGlyph } from "../../assets/svg-element";
55

66
storiesOf("Lightweight button", module)
77
.add("Default", () => <LightweightButton>Lightweight button</LightweightButton>)
8-
.add("Anchor", () => <LightweightButton href="#">Anchor button</LightweightButton>)
8+
.add("Anchor", () => (
9+
<LightweightButton
10+
href="#"
11+
beforeContent={glyphFactory(SVGGlyph.download)}
12+
afterContent={glyphFactory(SVGGlyph.user)}
13+
>
14+
Anchor button
15+
</LightweightButton>
16+
))
917
.add("Before content", () => (
1018
<LightweightButton beforeContent={glyphFactory(SVGGlyph.download)}>
1119
With before content

packages/fast-components-react-msft/src/neutral-button/neutral-button.stories.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ import { glyphFactory, SVGGlyph } from "../../assets/svg-element";
55

66
storiesOf("Neutral button", module)
77
.add("Default", () => <NeutralButton>Neutral button</NeutralButton>)
8-
.add("Anchor", () => <NeutralButton href="#">Anchor button</NeutralButton>)
8+
.add("Anchor", () => (
9+
<NeutralButton
10+
href="#"
11+
beforeContent={glyphFactory(SVGGlyph.download)}
12+
afterContent={glyphFactory(SVGGlyph.user)}
13+
>
14+
Anchor button
15+
</NeutralButton>
16+
))
917
.add("Before content", () => (
1018
<NeutralButton beforeContent={glyphFactory(SVGGlyph.download)}>
1119
With before content

0 commit comments

Comments
 (0)