Skip to content

Commit 536ab8f

Browse files
committed
fix(icon): update icon component to use Material Symbols Rounded and improve accessibility
1 parent c718c6f commit 536ab8f

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

packages/components/icon/README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ pnpm add @devbyray/vue-wc-icon
1010
yarn add @devbyray/vue-wc-icon
1111
```
1212

13+
You have to load the Google Material Icon font yourself via HTML or CSS:
14+
15+
```css
16+
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded');
17+
```
18+
19+
```html
20+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded" />
21+
```
22+
23+
_This is because the components are web components and work with a Shadow DOM._
24+
25+
## Available Icons
26+
27+
This component uses Google Material Icons. You can find all available icons in the [Material Icons Library](https://fonts.google.com/icons?selected=Material+Icons).
28+
1329
## Usage
1430

1531
```html
@@ -36,9 +52,9 @@ import '@devbyray/vue-wc-icon';
3652
<vwc-icon name="delete" label="Delete item"></vwc-icon>
3753
```
3854

39-
## Available Icons
4055

41-
This component uses Google Material Icons. You can find all available icons in the [Material Icons Library](https://fonts.google.com/icons?selected=Material+Icons).
56+
57+
4258

4359
## Props
4460

packages/components/icon/src/Icon.ce.vue

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
<template>
2-
<span
3-
:id="props.id"
4-
class="vwc-icon"
5-
:class="[props.size, { 'vwc-icon-spin': props.spin }]"
6-
:aria-hidden="!props.label"
7-
:aria-label="props.label"
8-
:role="props.label ? 'img' : undefined"
9-
>
10-
<span class="material-icons" :style="iconStyles">{{ props.name }}</span>
2+
<span :id="props.id" class="vwc-icon" :class="[props.size, { 'vwc-icon-spin': props.spin }]"
3+
:aria-hidden="!props.label" :aria-label="props.label" :role="props.label ? 'img' : undefined">
4+
<span class="material-symbols" :style="iconStyles">{{ props.name }}</span>
115
</span>
126
</template>
137

@@ -47,13 +41,15 @@ const props = withDefaults(defineProps<IconProps>(), {
4741
const iconStyles = computed(() => {
4842
return {
4943
color: props.color || 'currentColor',
44+
'font-variation-settings': "'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24",
5045
};
5146
});
5247
</script>
5348

5449
<style>
55-
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');
56-
50+
.material-symbols {
51+
font-family: var(--vwc-icon-font-family, 'Material Symbols Rounded');
52+
}
5753
.vwc-icon {
5854
display: inline-flex;
5955
align-items: center;
@@ -85,6 +81,7 @@ const iconStyles = computed(() => {
8581
from {
8682
transform: rotate(0deg);
8783
}
84+
8885
to {
8986
transform: rotate(360deg);
9087
}

0 commit comments

Comments
 (0)