Skip to content

Commit 71ec4ca

Browse files
langehmFabianWilms
andauthored
💄 changed css-class of mucicon and provided optional override #104 (#150)
* changed css-class of mucicon and provided optional override #104 * changed css-class of mucicon and provided optional override #104 * reworked icon usage in all components #104 * reworked icon usage in all components #104 * added docu and type for muc-icon #104 * updated data-structure of muc-icon #104 * updated datastructur of class attrbute #104 * 📝 updated readme using new muc-icon component #104 --------- Co-authored-by: Fabian Wilms <10800158+FabianWilms@users.noreply.github.com>
1 parent 995a976 commit 71ec4ca

File tree

8 files changed

+38
-56
lines changed

8 files changed

+38
-56
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ So to use an icon from Patternlab you can simply follow the official
6969
documentation: https://patternlab.muenchen.space/?p=viewall-guidelines-icons
7070

7171
```html
72-
73-
<svg aria-hidden="true" class="icon">
74-
<use xlink:href="#icon-{name}"></use>
75-
</svg>
72+
<muc-icon :icon="name"/>
7673
```
7774

7875
## Contributing

src/components/Banner/MucBanner.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script setup lang="ts">
22
import { computed } from "vue";
33
4+
import { MucIcon } from "../Icon";
5+
46
type bannerType = "info" | "success" | "warning" | "emergency";
57
68
const props = withDefaults(
@@ -70,13 +72,13 @@ const typeAriaLabel = computed(() => {
7072
const typeIcon = computed(() => {
7173
switch (props.type) {
7274
case "success":
73-
return "#icon-check";
75+
return "check";
7476
case "warning":
7577
case "emergency":
76-
return "#icon-warning";
78+
return "warning";
7779
case "info":
7880
default:
79-
return "#icon-information";
81+
return "information";
8082
}
8183
});
8284
</script>
@@ -91,9 +93,7 @@ const typeIcon = computed(() => {
9193
:aria-label="typeAriaLabel"
9294
>
9395
<div class="container-fluid">
94-
<svg class="icon">
95-
<use :href="typeIcon" />
96-
</svg>
96+
<muc-icon :icon="typeIcon" />
9797
<slot />
9898
</div>
9999
</div>

src/components/BuisnessHours/MucBusinessHours.vue

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
data-bs-toggle="collapse"
1313
:aria-expanded="!collapsed"
1414
>
15-
<svg
16-
aria-hidden="true"
15+
<muc-icon
16+
:icon="icon"
1717
class="icon icon--before"
18-
>
19-
<use :xlink:href="'#icon-' + icon"></use>
20-
</svg>
18+
/>
2119
<div v-if="todaysBusinessHours">
2220
<span> {{ todaysBusinessHours.weekDay }} geöffnet </span>
2321
<span
@@ -30,13 +28,10 @@
3028
</span>
3129
</span>
3230
</div>
33-
34-
<svg
35-
aria-hidden="true"
31+
<muc-icon
32+
icon="chevron-down"
3633
class="icon icon--after"
37-
>
38-
<use xlink:href="#icon-chevron-down"></use>
39-
</svg>
34+
/>
4035
</button>
4136
<div
4237
class="m-business-hours-toggle__content"
@@ -74,6 +69,7 @@
7469
<script setup lang="ts">
7570
import { computed, ref } from "vue";
7671
72+
import { MucIcon } from "../Icon";
7773
import { BusinessHourType } from "./BusinessHourType";
7874
7975
const LOCALES = "de-DE";

src/components/Button/MucButton.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
>
88
<span>
99
<slot />
10-
<svg
10+
<muc-icon
1111
v-if="icon"
12-
aria-hidden="true"
12+
:icon="icon"
1313
class="m-button__icon"
14-
>
15-
<use :xlink:href="'#icon-' + icon"></use>
16-
</svg>
14+
/>
1715
</span>
1816
</button>
1917
</template>
2018

2119
<script setup lang="ts">
2220
import { computed } from "vue";
2321
22+
import { MucIcon } from "../Icon";
23+
2424
type buttonType = "primary" | "secondary" | "ghost";
2525
2626
const props = withDefaults(

src/components/Callout/MucCallout.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
<div class="m-callout__icon">
99
<slot name="icon">
1010
<!-- fallback icon -->
11-
<svg
12-
aria-hidden="true"
13-
class="icon"
14-
>
15-
<use :xlink:href="`#icon-${fallbackCalloutIcon}`"></use>
16-
</svg>
11+
<muc-icon :icon="fallbackCalloutIcon" />
1712
</slot>
1813
</div>
1914
<div class="m-callout__body">
@@ -38,6 +33,8 @@
3833
<script setup lang="ts">
3934
import { computed } from "vue";
4035
36+
import { MucIcon } from "../Icon";
37+
4138
type calloutType = "info" | "warning" | "success" | "error";
4239
4340
const props = withDefaults(

src/components/Comment/MucComment.vue

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
<slot name="author" />
1313
</span>
1414
<span v-if="showDate">
15-
<span class="m-comment__author"
16-
>&nbsp;<slot name="datePrefix"
17-
/></span>
15+
<span class="m-comment__author">
16+
&nbsp;<slot name="datePrefix" />
17+
</span>
1818
<span class="m-comment__date">&nbsp;<slot name="date" /> </span>
1919
</span>
2020
<div
@@ -27,35 +27,20 @@
2727
:key="n"
2828
class="m-star-rating__item m-star-rating__item--full"
2929
>
30-
<svg
31-
aria-hidden="true"
32-
class="icon"
33-
>
34-
<use xlink:href="#icon-solid-star"></use>
35-
</svg>
30+
<muc-icon icon="solid-star" />
3631
</div>
3732
<div
3833
v-if="evaluateRating.isHalfStar"
3934
class="m-star-rating__item m-star-rating__item--half"
4035
>
41-
<svg
42-
aria-hidden="true"
43-
class="icon"
44-
>
45-
<use xlink:href="#icon-half-star"></use>
46-
</svg>
36+
<muc-icon icon="half-star" />
4737
</div>
4838
<div
4939
v-for="n in evaluateRating.emptyStars"
5040
:key="n"
5141
class="m-star-rating__item"
5242
>
53-
<svg
54-
aria-hidden="true"
55-
class="icon"
56-
>
57-
<use xlink:href="#icon-solid-star"></use>
58-
</svg>
43+
<muc-icon icon="solid-star" />
5944
</div>
6045
<div class="m-star-rating__numeric">
6146
{{ ratingWithDecimalComma }}
@@ -76,6 +61,7 @@
7661
<script setup lang="ts">
7762
import { computed, useSlots } from "vue";
7863
64+
import { MucIcon } from "../Icon";
7965
import CommentType from "./CommentType";
8066
8167
const LOCALES = "de-DE";

src/components/Icon/MucIcon.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
<template>
22
<svg
33
aria-hidden="true"
4-
class="m-button__icon"
4+
:class="iconClass"
55
:style="{ color: color }"
66
>
77
<use :href="'#icon-' + icon" />
88
</svg>
99
</template>
1010

1111
<script setup lang="ts">
12+
import { computed, useAttrs } from "vue";
13+
14+
const attr = useAttrs();
15+
1216
defineProps<{
1317
/**
1418
* String of the icon to be displayed.
@@ -20,4 +24,6 @@ defineProps<{
2024
*/
2125
color?: string;
2226
}>();
27+
28+
const iconClass = computed(() => attr.class ?? "icon");
2329
</script>

src/components/Intro/MucIntro.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ defineSlots<{
4444
<div
4545
v-if="divider"
4646
class="muc-divider"
47-
></div>
47+
/>
4848

4949
<div class="m-intro-vertical__content">
5050
<p style="padding-bottom: 32px">
51-
<slot></slot>
51+
<slot />
5252
</p>
5353
</div>
5454
</div>

0 commit comments

Comments
 (0)