Skip to content

Commit b7185d3

Browse files
Merge pull request #3 from code4rena-dev/develop
Minor accessibility cleanup
2 parents ca76bde + 2b09cc1 commit b7185d3

22 files changed

+134
-62
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ OR
1313
yarn storybook
1414
```
1515

16+
### Storybook Actions
17+
If you want to make use of [Storybook actions](https://storybook.js.org/docs/angular/essentials/actions) for a specific component, please refer to the `Button.stories.tsx` file. The recommendation is to pass the event handler function directly to the Story component as opposed to passing it through _ComponentName.args_. Passing the event handler function through the **args** parameter may not log the event in the `Actions` tab of the Story's dashboard.
18+
1619
## Testing
1720
For testing, we are using [Jest](https://jestjs.io/docs/getting-started) and [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/).
1821

src/components/Alert/Alert.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
a {
2828
display: inline;
2929
color: $color__blurple__text--light;
30+
31+
&:focus {
32+
outline: none;
33+
padding: 0 $spacing__xs;
34+
border: 1px solid $color__white !important;
35+
border-radius: $border-radius__base;
36+
}
3037

3138
&:after {
3239
content: ""

src/components/Alert/Alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import "./Alert.scss";
2020
* @param redirectUrl - Relative path or absolute url to be navigated to.
2121
* @param variant - Style variant to be applied to rendered component.
2222
* @param className - String of custom classes to extend the default styling of the component.
23-
* @param id - Element identifier
23+
* @param id - HTML element identifier
2424
*/
2525
const Alert: React.FC<AlertProps> = ({
2626
title,

src/components/Alert/Alert.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ export interface AlertProps {
1818
variant?: AlertVariant;
1919
/** String of custom classes to extend the default styling of the component. */
2020
className?: string;
21-
/** Element identifier */
21+
/** HTML element identifier */
2222
id?: string;
2323
}

src/components/Button/Button.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ $button__border-width: 2px;
2424
border-radius: $border-radius__m;
2525
color: $color__white;
2626
font-family: $font__default;
27+
font-size: 1.125rem;
28+
line-height: 150%;
2729
font-weight: 500 !important; // These could be inherited from copy/text styles
2830
text-decoration: none !important; // These could be inherited from copy/text styles
2931
text-align: center;

src/components/Button/Button.stories.tsx

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,25 @@ const meta: Meta<typeof Button> = {
1717
tags: ["autodocs"],
1818
argTypes: {
1919
variant: { control: "select" },
20-
type: { control: "select" },
20+
type: { control: "select", if: { arg: "href", truthy: false } },
2121
size: { control: "select" },
2222
onClick: {
2323
control: "function",
24+
action: "clicked",
25+
if: { arg: "href", truthy: false },
26+
},
27+
disabled: {
28+
if: { arg: "href", truthy: false },
2429
},
2530
},
2631
};
2732
export default meta;
2833

2934
type Story = StoryObj<typeof Button>;
3035

31-
export const SampleComponent: Story = (args) => <Button {...args} />;
36+
export const SampleComponent: Story = (args) => (
37+
<Button onClick={() => console.log("Sample Button clicked!")} {...args} />
38+
);
3239
SampleComponent.parameters = {
3340
docs: {
3441
canvas: { sourceState: "shown" },
@@ -44,7 +51,6 @@ SampleComponent.args = {
4451
iconLeft: "",
4552
iconRight: "/icons/edit.svg",
4653
size: ButtonSize.NARROW,
47-
onClick: () => console.log("Sample button clicked!"),
4854
className: "",
4955
id: "",
5056
};
@@ -67,19 +73,19 @@ export const Links: Story = {
6773
<div style={wrapperStyle}>
6874
<Button
6975
variant={ButtonVariant.PRIMARY}
70-
label="Internal Link"
76+
label="Primary Internal Link"
7177
href="#internal-test"
7278
/>
7379
<Button
7480
variant={ButtonVariant.PRIMARY}
7581
external
76-
label="External Link"
82+
label="Primary External Link"
7783
href="https://google.com"
7884
/>
7985
<Button
8086
variant={ButtonVariant.PRIMARY}
8187
href="#internal-test"
82-
label="Link W/ Icons"
88+
label="Primary Link W/ Icons"
8389
iconLeft="/icons/edit.svg"
8490
iconRight="/icons/edit.svg"
8591
/>
@@ -89,26 +95,29 @@ export const Links: Story = {
8995
<div style={wrapperStyle}>
9096
<Button
9197
variant={ButtonVariant.SECONDARY}
92-
label="Internal Link"
98+
label="Secondary Internal Link"
9399
href="#internal-test"
94100
/>
95101
<Button
96102
variant={ButtonVariant.SECONDARY}
97103
external
98-
label="External Link"
104+
label="Secondary External Link"
99105
href="https://google.com"
100106
/>
101107
<Button
102108
variant={ButtonVariant.SECONDARY}
103109
href="#internal-test"
104-
label="Link W/ Icons"
110+
label="Secondary Link W/ Icons"
105111
iconLeft="/icons/edit.svg"
106112
iconRight="/icons/edit.svg"
107113
/>
108114
</div>
109115
</>
110116
),
111117
};
118+
Links.parameters = {
119+
controls: { hideNoControlsWarning: true, include: [] },
120+
};
112121

113122
/**
114123
* Below is a collection of the different states in which you can find C4 buttons.
@@ -130,12 +139,12 @@ export const Buttons: Story = {
130139
<Button
131140
variant={ButtonVariant.PRIMARY}
132141
onClick={() => null}
133-
label="Enabled Button"
142+
label="Primary Enabled Button"
134143
/>
135144
<Button
136145
variant={ButtonVariant.PRIMARY}
137146
onClick={() => null}
138-
label="Button W/ Icons"
147+
label="Primary Button W/ Icons"
139148
iconLeft="/icons/edit.svg"
140149
iconRight="/icons/edit.svg"
141150
/>
@@ -146,22 +155,25 @@ export const Buttons: Story = {
146155
<Button
147156
variant={ButtonVariant.SECONDARY}
148157
onClick={() => null}
149-
label="Enabled Button"
158+
label="Secondary Enabled Button"
150159
/>
151160
<Button
152161
variant={ButtonVariant.SECONDARY}
153162
onClick={() => null}
154-
label="Button W/ Icons"
163+
label="Secondary Button W/ Icons"
155164
iconLeft="/icons/edit.svg"
156165
iconRight="/icons/edit.svg"
157166
/>
158167
<Button
159168
variant={ButtonVariant.SECONDARY}
160169
onClick={() => null}
161-
label="Disabled Button"
170+
label="Primary/Secondary Disabled Button"
162171
disabled
163172
/>
164173
</div>
165174
</>
166175
),
167176
};
177+
Buttons.parameters = {
178+
controls: { hideNoControlsWarning: true, include: [] },
179+
};

src/components/Button/Button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import "./Button.scss";
2222
* @param external - Determines whether navigation should occur on the same page or in a new tab.
2323
* @param onClick - Function to be triggered on button click. Does not apply to links.
2424
* @param className - String of custom classes to extend the default styling of the component.
25-
* @param id - Element identifier.
25+
* @param id - HTML element identifier.
2626
*/
2727
const Button: React.FC<ButtonProps> = ({
2828
label,
@@ -93,7 +93,7 @@ Button.defaultProps = {
9393
size: "NARROW",
9494
href: "",
9595
external: false,
96-
onClick: () => null,
96+
onClick: undefined,
9797
className: "",
9898
id: "",
9999
};

src/components/Button/Button.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ export interface ButtonProps {
3939
onClick?: MouseEventHandler<HTMLButtonElement>;
4040
/** String of custom classes to extend the default styling of the component. */
4141
className?: string;
42-
/** Element identifier */
42+
/** HTML element identifier */
4343
id?: string;
4444
}

src/components/ContestStatus/ContestStatus.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import "./ContestStatus.scss";
1212
*
1313
* @param status - Status indicator for the current contest. Enum of type {@link Status}.
1414
* @param className - String of custom classes to extend the default styling of the component.
15-
* @param id - Element identifier.
15+
* @param id - HTML element identifier.
1616
*/
1717
const ContestStatus: React.FC<ContestStatusProps> = ({
1818
status,

src/components/ContestStatus/ContestStatus.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export interface ContestStatusProps {
99
status?: Status;
1010
/** String of custom classes to extend the default styling of the component. */
1111
className?: string;
12-
/** Element identifier */
12+
/** HTML element identifier */
1313
id?: string;
1414
}

0 commit comments

Comments
 (0)