Skip to content

Commit fc6810e

Browse files
authored
✨ 95 build a wrapper component for icons (#97)
1 parent 0b2733e commit fc6810e

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { fn } from "@storybook/test";
2+
3+
import MucIcon from "./MucIcon.vue";
4+
5+
export default {
6+
component: MucIcon,
7+
title: "MucIcon",
8+
tags: ["autodocs"],
9+
// 👇 Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
10+
args: { onClick: fn() },
11+
parameters: {
12+
docs: {
13+
description: {
14+
component: `The \`muc-icon\` component is a wrapper commponent for all icons in the patternlab.
15+
16+
[🔗 Patternlab-Docs](https://patternlab.muenchen.space/?p=viewall-guidelines-icons)
17+
[🖼 Iconography](https://it-at-m.github.io/muc-patternlab-vue/?path=/docs/iconography--docs)
18+
`,
19+
},
20+
},
21+
},
22+
};
23+
24+
export const Weather = {
25+
args: {
26+
icon: "weather",
27+
},
28+
};
29+
30+
export const Youtube = {
31+
args: {
32+
icon: "youtube",
33+
color: "red",
34+
},
35+
};

src/components/Icon/MucIcon.vue

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<template>
2+
<svg
3+
aria-hidden="true"
4+
class="m-button__icon"
5+
:style="{ color: color }"
6+
>
7+
<use :href="'#icon-' + icon" />
8+
</svg>
9+
</template>
10+
11+
<script setup lang="ts">
12+
defineProps<{
13+
/**
14+
* String of the icon to be displayed.
15+
*/
16+
icon: string;
17+
18+
/**
19+
* Optional css-color for the icon.
20+
*/
21+
color?: string;
22+
}>();
23+
</script>

src/components/Icon/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import MucIcon from "./MucIcon.vue";
2+
3+
export { MucIcon };

src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { MucButton } from "./Button";
33
import { MucCallout } from "./Callout";
44
import { MucCard, MucCardContainer } from "./Card";
55
import { MucComment, MucCommentText } from "./Comment/";
6+
import { MucIcon } from "./Icon";
67
import { MucIntro } from "./Intro";
78

89
export {
@@ -14,4 +15,5 @@ export {
1415
MucCardContainer,
1516
MucComment,
1617
MucCommentText,
18+
MucIcon,
1719
};

0 commit comments

Comments
 (0)