Skip to content

Commit

Permalink
Merge branch 'beta' into 183-sparkles-divider-component
Browse files Browse the repository at this point in the history
  • Loading branch information
langehm authored Aug 14, 2024
2 parents fbb17e2 + c16840c commit e769cdd
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/components/Link/MucLink.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { fn } from "@storybook/test";

import MucLink from "./MucLink.vue";

export default {
component: MucLink,
title: "MucLink",
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-link\` component is a wrapper commponent for a standard html-a tag.
[🔗 Patternlab-Docs](https://patternlab.muenchen.space/?p=viewall-elements-links)
`,
},
},
},
};

export const Weather = {
args: {
label: "Generic link label",
},
};

export const LinkWithIcon = {
args: {
icon: "youtube",
label: "youtube",
href: "https://www.youtube.com",
noUnderline: true,
},
};
74 changes: 74 additions & 0 deletions src/components/Link/MucLink.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<template>
<a
:href="href"
:target="target"
class="m-link"
:class="reversedUnderlineClass"
>
{{ label }}
<slot name="icon">
<muc-icon
v-if="icon"
:icon="icon"
class="icon icon--after"
/>
</slot>
</a>
</template>

<script setup lang="ts">
import { computed } from "vue";
import { MucIcon } from "../Icon";
const props = withDefaults(
defineProps<{
/**
* Text shown as the link
*/
label: string;
/**
* href to link to
*/
href?: string;
/**
* Optional icon displayed behind the text
*/
icon?: string;
/**
* Target on the link
*/
target?: string;
/**
* Removes the underline from the label text
*/
noUnderline?: boolean;
}>(),
{
noUnderline: false,
href: "#",
target: "_blank",
}
);
defineSlots<{
/**
* Icon slots overrides chosen prop icon.
* The icon can be displayed infront or behind the label with these classes: icon--after | icon--before
*/
icon(): void;
}>();
/**
* Computed class to remove the underline if chosen.
*/
const reversedUnderlineClass = computed(() =>
props.noUnderline ? "m-link--reversed-underline" : ""
);
</script>

<style scoped></style>
3 changes: 3 additions & 0 deletions src/components/Link/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import MucLink from "./MucLink.vue";

export { MucLink };
2 changes: 2 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from "./Form";
import { MucIcon } from "./Icon";
import { MucIntro } from "./Intro";
import { MucLink } from "./Link";

export {
MucButton,
Expand All @@ -36,4 +37,5 @@ export {
MucErrorList,
MucIcon,
MucDivider,
MucLink,
};

0 comments on commit e769cdd

Please sign in to comment.