Skip to content

Commit

Permalink
✨ 95 build a wrapper component for icons (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
langehm authored May 31, 2024
1 parent 0b2733e commit fc6810e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/components/Icon/MucIcon.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { fn } from "@storybook/test";

import MucIcon from "./MucIcon.vue";

export default {
component: MucIcon,
title: "MucIcon",
tags: ["autodocs"],
// 👇 Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
parameters: {
docs: {
description: {
component: `The \`muc-icon\` component is a wrapper commponent for all icons in the patternlab.
[🔗 Patternlab-Docs](https://patternlab.muenchen.space/?p=viewall-guidelines-icons)
[🖼 Iconography](https://it-at-m.github.io/muc-patternlab-vue/?path=/docs/iconography--docs)
`,
},
},
},
};

export const Weather = {
args: {
icon: "weather",
},
};

export const Youtube = {
args: {
icon: "youtube",
color: "red",
},
};
23 changes: 23 additions & 0 deletions src/components/Icon/MucIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<svg
aria-hidden="true"
class="m-button__icon"
:style="{ color: color }"
>
<use :href="'#icon-' + icon" />
</svg>
</template>

<script setup lang="ts">
defineProps<{
/**
* String of the icon to be displayed.
*/
icon: string;
/**
* Optional css-color for the icon.
*/
color?: string;
}>();
</script>
3 changes: 3 additions & 0 deletions src/components/Icon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import MucIcon from "./MucIcon.vue";

export { MucIcon };
2 changes: 2 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MucButton } from "./Button";
import { MucCallout } from "./Callout";
import { MucCard, MucCardContainer } from "./Card";
import { MucComment, MucCommentText } from "./Comment/";
import { MucIcon } from "./Icon";
import { MucIntro } from "./Intro";

export {
Expand All @@ -14,4 +15,5 @@ export {
MucCardContainer,
MucComment,
MucCommentText,
MucIcon,
};

0 comments on commit fc6810e

Please sign in to comment.