Skip to content

Commit e72a8ed

Browse files
committed
♿️ Improve components accessibility
1 parent b01962b commit e72a8ed

File tree

10 files changed

+69
-20
lines changed

10 files changed

+69
-20
lines changed

src/components/Menu/Menu.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const wrapMenu = (logo?.url || logo?.html) && items?.length && Astro.slots.has('
4545
)}
4646

4747
{!centerLogo && logo?.html && (
48-
<a href="/">
48+
<a href="/" aria-label={logo.alt || 'Logo'}>
4949
<Fragment set:html={logo.html} />
5050
</a>
5151
)}
@@ -77,7 +77,7 @@ const wrapMenu = (logo?.url || logo?.html) && items?.length && Astro.slots.has('
7777
)}
7878

7979
{centerLogo && logo?.html && (
80-
<a href="/">
80+
<a href="/" aria-label={logo.alt || 'Logo'}>
8181
<Fragment set:html={logo.html} />
8282
</a>
8383
)}

src/components/Menu/Menu.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
{/if}
4444

4545
{#if !centerLogo && logo?.html}
46-
<a href="/">{@html logo.html}</a>
46+
<a href="/" aria-label={logo.alt || 'Logo'}>
47+
{@html logo.html}
48+
</a>
4749
{/if}
4850

4951
{#if items?.length}
@@ -73,7 +75,9 @@
7375
{/if}
7476

7577
{#if centerLogo && logo?.html}
76-
<a href="/">{@html logo.html}</a>
78+
<a href="/" aria-label={logo.alt || 'Logo'}>
79+
{@html logo.html}
80+
</a>
7781
{/if}
7882

7983
{#if logo?.url && centerLogo}

src/components/Menu/Menu.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const Menu = ({
5555
<a
5656
href="/"
5757
dangerouslySetInnerHTML={{ __html: logo.html }}
58+
aria-label={logo.alt || 'Logo'}
5859
/>
5960
)}
6061

@@ -88,6 +89,7 @@ const Menu = ({
8889
<a
8990
href="/"
9091
dangerouslySetInnerHTML={{ __html: logo.html }}
92+
aria-label={logo.alt || 'Logo'}
9193
/>
9294
)}
9395

src/components/ThemeSwitcher/ThemeSwitcher.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const buttonClasses = [
3838
<button
3939
style={!useIcons ? `background:${theme};` : undefined}
4040
data-theme={themes[theme]}
41+
aria-label={themes[theme]}
4142
class:list={buttonClasses}
4243
>
4344
{index === 0 && <slot name="primaryIcon" />}

src/components/ThemeSwitcher/ThemeSwitcher.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@
6161
>
6262
{#each Object.keys(themes) as theme, index}
6363
<button
64+
on:click={() => setTheme(toggle ? index : themes[theme])}
6465
style={!useIcons ? `background:${theme};` : undefined}
6566
data-active={currentTheme === themes[theme]}
66-
on:click={() => setTheme(toggle ? index : themes[theme])}
67+
aria-label={themes[theme]}
6768
class={classNames([
6869
styles.switch,
6970
useIcons && styles.icons

src/components/ThemeSwitcher/ThemeSwitcher.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ const ThemeSwitcher = ({
7070
{Object.keys(themes as {}).map((theme, index) => (
7171
<button
7272
key={index}
73-
data-active={currentTheme === themes[theme]}
7473
onClick={() => setTheme(toggle ? index : themes[theme])}
74+
data-active={currentTheme === themes[theme]}
75+
aria-label={themes[theme]}
7576
style={!useIcons ? { background: theme } : undefined}
7677
className={classNames([
7778
styles.switch,

src/data.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,27 @@ export const accordionItems = [{
1414
}]
1515

1616
export const avatarGroup = [
17-
"/img/avatar0.png",
18-
"/img/avatar1.png",
19-
"/img/avatar2.png",
20-
"/img/avatar3.png",
21-
"/img/avatar4.png"
17+
'/img/avatar0.png',
18+
'/img/avatar1.png',
19+
'/img/avatar2.png',
20+
'/img/avatar3.png',
21+
'/img/avatar4.png'
22+
]
23+
24+
export const avatarGroupAlt1 = [
25+
'avatar0',
26+
'avatar1',
27+
'avatar2',
28+
'avatar3',
29+
'avatar4'
30+
]
31+
32+
export const avatarGroupAlt2 = [
33+
'Marcus',
34+
'Giuseppe',
35+
'Emily',
36+
'Frank',
37+
'Jonathan'
2238
]
2339

2440
export const tabItems = [{

src/pages/index.astro

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ import TimelineItem from '@components/TimelineItem/TimelineItem.astro'
2626
import infoIcon from '../icons/info.svg?raw'
2727
import gitHubIcon from '../icons/github.svg?raw'
2828
29-
import { themes, accordionItems, avatarGroup } from '@data'
29+
import {
30+
themes,
31+
accordionItems,
32+
avatarGroup,
33+
avatarGroupAlt2
34+
} from '@data'
3035
3136
import logo from '../../public/img/logo.svg?raw'
3237
@@ -81,6 +86,7 @@ const tabItems = [{
8186
<Avatar
8287
size={[30, 40, 50, 40, 30]}
8388
img={avatarGroup}
89+
alt={avatarGroupAlt2}
8490
/>
8591
</CardWrapper>
8692
<CardWrapper title="Badge" href="/badge">
@@ -197,6 +203,10 @@ const tabItems = [{
197203
color: #61DAFB;
198204
}
199205

206+
.theme-light .r {
207+
color: #00a0cc;
208+
}
209+
200210
.cta {
201211
text-align: center;
202212
display: flex;

src/scss/global/theme.scss

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
--w-color-primary: #FFF;
88
--w-color-primary-10: #DDD;
99
--w-color-primary-20: #BBB;
10-
--w-color-primary-30: #555;
10+
--w-color-primary-30: #757575;
1111
--w-color-primary-40: #333;
1212
--w-color-primary-50: #252525;
1313
--w-color-primary-60: #111;
@@ -22,7 +22,7 @@
2222
--w-color-warning: #FF9F43;
2323
--w-color-warning-accent: #f7AA61;
2424
--w-color-warning-fg: #000;
25-
--w-color-alert: #E73F40;
25+
--w-color-alert: #de3233;
2626
--w-color-alert-accent: #EE5253;
2727
--w-color-alert-fg: #FFF;
2828
}
@@ -49,7 +49,7 @@
4949
--w-color-warning: #FF9F43;
5050
--w-color-warning-accent: #f7AA61;
5151
--w-color-warning-fg: #000;
52-
--w-color-alert: #E73F40;
52+
--w-color-alert: #de3233;
5353
--w-color-alert-accent: #EE5253;
5454
--w-color-alert-fg: #FFF;
5555
}
@@ -61,7 +61,7 @@
6161
--w-color-primary: #FFF;
6262
--w-color-primary-10: #EEE;
6363
--w-color-primary-20: #a5b7cf;
64-
--w-color-primary-30: #516580;
64+
--w-color-primary-30: #667f9e;
6565
--w-color-primary-40: #2d4463;
6666
--w-color-primary-50: #20344e;
6767
--w-color-primary-60: #101a2d;
@@ -76,7 +76,7 @@
7676
--w-color-warning: #FF9F43;
7777
--w-color-warning-accent: #f7AA61;
7878
--w-color-warning-fg: #000;
79-
--w-color-alert: #E73F40;
79+
--w-color-alert: #de3233;
8080
--w-color-alert-accent: #EE5253;
8181
--w-color-alert-fg: #FFF;
8282
}
@@ -103,7 +103,7 @@
103103
--w-color-warning: #FF9F43;
104104
--w-color-warning-accent: #f7AA61;
105105
--w-color-warning-fg: #000;
106-
--w-color-alert: #E73F40;
106+
--w-color-alert: #de3233;
107107
--w-color-alert-accent: #EE5253;
108108
--w-color-alert-fg: #FFF;
109109
}
@@ -130,7 +130,7 @@
130130
--w-color-warning: #FF9F43;
131131
--w-color-warning-accent: #f7AA61;
132132
--w-color-warning-fg: #000;
133-
--w-color-alert: #E73F40;
133+
--w-color-alert: #de3233;
134134
--w-color-alert-accent: #EE5253;
135135
--w-color-alert-fg: #FFF;
136136
}

src/static/Examples.astro

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
2+
import Alert from '@components/Alert/Alert.astro'
23
import Card from '@components/Card/Card.astro'
34
import Input from '@components/Input/Input.astro'
5+
import Icon from '@components/Icon/Icon.astro'
46
import Badge from '@components/Badge/Badge.astro'
57
import Button from '@components/Button/Button.astro'
68
import Checkbox from '@components/Checkbox/Checkbox.astro'
@@ -15,7 +17,7 @@ import Rating from '@components/Rating/Rating.astro'
1517
import Spinner from '@components/Spinner/Spinner.astro'
1618
import TimelineItem from '@components/TimelineItem/TimelineItem.astro'
1719
18-
import { avatarGroup } from '@data'
20+
import { avatarGroup, avatarGroupAlt2 } from '@data'
1921
2022
const tabItems = [{
2123
label: 'Profile',
@@ -207,10 +209,17 @@ const tasks = [
207209
<Avatar
208210
size={[30, 40, 50, 40, 30]}
209211
img={avatarGroup}
212+
alt={avatarGroupAlt2}
210213
/>
211214
</a>
212215
</div>
213216
</Card>
217+
218+
<Alert title="Deployments">
219+
<Icon type="github" slot="icon" />
220+
<span>Connect your project to GitHub to start running automatic deployments.</span>
221+
<Button className="connect">Connect</Button>
222+
</Alert>
214223
</div>
215224
</div>
216225

@@ -265,4 +274,9 @@ const tasks = [
265274
display: block;
266275
}
267276
}
277+
278+
.connect {
279+
@include spacing(mt-sm);
280+
@include typography(md);
281+
}
268282
</style>

0 commit comments

Comments
 (0)