File tree Expand file tree Collapse file tree 4 files changed +115
-0
lines changed Expand file tree Collapse file tree 4 files changed +115
-0
lines changed Original file line number Diff line number Diff line change 1+ import { fn } from "@storybook/test" ;
2+
3+ import MucLink from "./MucLink.vue" ;
4+
5+ export default {
6+ component : MucLink ,
7+ title : "MucLink" ,
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-link\` component is a wrapper commponent for a standard html-a tag.
15+
16+ [🔗 Patternlab-Docs](https://patternlab.muenchen.space/?p=viewall-elements-links)
17+ ` ,
18+ } ,
19+ } ,
20+ } ,
21+ } ;
22+
23+ export const Weather = {
24+ args : {
25+ label : "Generic link label" ,
26+ } ,
27+ } ;
28+
29+ export const LinkWithIcon = {
30+ args : {
31+ icon : "youtube" ,
32+ label : "youtube" ,
33+ href : "https://www.youtube.com" ,
34+ noUnderline : true ,
35+ } ,
36+ } ;
Original file line number Diff line number Diff line change 1+ <template >
2+ <a
3+ :href =" href"
4+ :target =" target"
5+ class =" m-link"
6+ :class =" reversedUnderlineClass"
7+ >
8+ {{ label }}
9+ <slot name =" icon" >
10+ <muc-icon
11+ v-if =" icon"
12+ :icon =" icon"
13+ class =" icon icon--after"
14+ />
15+ </slot >
16+ </a >
17+ </template >
18+
19+ <script setup lang="ts">
20+ import { computed } from " vue" ;
21+
22+ import { MucIcon } from " ../Icon" ;
23+
24+ const props = withDefaults (
25+ defineProps <{
26+ /**
27+ * Text shown as the link
28+ */
29+ label: string ;
30+
31+ /**
32+ * href to link to
33+ */
34+ href? : string ;
35+
36+ /**
37+ * Optional icon displayed behind the text
38+ */
39+ icon? : string ;
40+
41+ /**
42+ * Target on the link
43+ */
44+ target? : string ;
45+
46+ /**
47+ * Removes the underline from the label text
48+ */
49+ noUnderline? : boolean ;
50+ }>(),
51+ {
52+ noUnderline: false ,
53+ href: " #" ,
54+ target: " _blank" ,
55+ }
56+ );
57+
58+ defineSlots <{
59+ /**
60+ * Icon slots overrides chosen prop icon.
61+ * The icon can be displayed infront or behind the label with these classes: icon--after | icon--before
62+ */
63+ icon(): void ;
64+ }>();
65+
66+ /**
67+ * Computed class to remove the underline if chosen.
68+ */
69+ const reversedUnderlineClass = computed (() =>
70+ props .noUnderline ? " m-link--reversed-underline" : " "
71+ );
72+ </script >
73+
74+ <style scoped></style >
Original file line number Diff line number Diff line change 1+ import MucLink from "./MucLink.vue" ;
2+
3+ export { MucLink } ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
1515} from "./Form" ;
1616import { MucIcon } from "./Icon" ;
1717import { MucIntro } from "./Intro" ;
18+ import { MucLink } from "./Link" ;
1819
1920export {
2021 MucButton ,
@@ -34,4 +35,5 @@ export {
3435 MucSelect ,
3536 MucErrorList ,
3637 MucIcon ,
38+ MucLink ,
3739} ;
You can’t perform that action at this time.
0 commit comments