This repository was archived by the owner on May 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +176
-0
lines changed
Expand file tree Collapse file tree 4 files changed +176
-0
lines changed Original file line number Diff line number Diff line change 1+ <template >
2+ <a
3+ :class =" [
4+ 'wikit',
5+ 'wikit-Link',
6+ (underlined == true) ? `wikit-Link--underlined` : ''
7+ ]"
8+ :href =" href"
9+ :target =" target"
10+ >
11+ <Icon
12+ v-if =" icon === 'before'"
13+ class =" wikit-Link__icon wikit-Link__icon--before"
14+ type =" link"
15+ color =" progressive"
16+ size =" large"
17+ />
18+ <span class =" wikit-Link__content" ><slot /></span >
19+ <Icon
20+ v-if =" icon === 'after'"
21+ class =" wikit-Link__icon wikit-Link__icon--after"
22+ type =" newwindow"
23+ color =" progressive"
24+ size =" xsmall"
25+ />
26+ </a >
27+ </template >
28+
29+ <script lang="ts">
30+ import { defineComponent } from ' vue' ;
31+ import Icon from ' ./Icon.vue' ;
32+
33+ /**
34+ * Uses the following components internally: Icon
35+ */
36+ export default defineComponent ( {
37+ name: ' WikitLink' ,
38+ props: {
39+ icon: {
40+ type: String ,
41+ default: ' none' ,
42+ validator( value : string ): boolean {
43+ return [ ' before' , ' after' , ' none' ].includes ( value );
44+ },
45+ },
46+ underlined: {
47+ type: Boolean ,
48+ default: false ,
49+ },
50+ href: {
51+ type: String ,
52+ default: ' ' ,
53+ },
54+ target: {
55+ type: String ,
56+ default: ' _self' ,
57+ },
58+ },
59+ components: {
60+ Icon ,
61+ },
62+ } );
63+ </script >
64+
65+ <style lang="scss">
66+ .wikit-Link {
67+ @include Link ();
68+
69+ display : flex ;
70+ text-decoration : none ;
71+ align-items : center ;
72+ overflow-wrap : break-word ;
73+ hyphens : auto ;
74+
75+ & --underlined {
76+ text-decoration : underline ;
77+ }
78+
79+ & __icon {
80+ color : $wikit-Link-icon-color ;
81+
82+ & --before {
83+ padding-inline-end : $wikit-Link-icon-spacing ;
84+ }
85+
86+ & --after {
87+ padding-inline-start : $wikit-Link-icon-spacing ;
88+ }
89+ }
90+ }
91+ </style >
Original file line number Diff line number Diff line change 11@import ' ~ress' ;
22@import ' ~@wmde/wikit-tokens/dist/variables' ;
33@import ' ./mixins/Label' ;
4+ @import ' ./mixins/Link' ;
45@import ' ./mixins/Typography' ;
Original file line number Diff line number Diff line change 1+ @mixin Link {
2+ font-family : $wikit-Link-font-family ;
3+ font-size : $wikit-Link-font-size ;
4+ font-weight : $wikit-Link-font-weight ;
5+ color : $wikit-Link-font-color ;
6+ line-height : $wikit-Link-line-height ;
7+ transition-property : $wikit-Link-transition-property ;
8+ transition-duration : $wikit-Link-transition-duration ;
9+ & :hover {
10+ text-decoration : underline ;
11+ cursor : pointer ;
12+ }
13+ & :active {
14+ color : $wikit-Link-active-font-color ;
15+ text-decoration : underline ;
16+ cursor : pointer ;
17+ }
18+ & :focus {
19+ outline-color : $wikit-Link-focus-outline-color ;
20+ }
21+ & :visited {
22+ color : $wikit-Link-visited-font-color ;
23+ transition-property : color ;
24+ transition-duration : $wikit-Link-transition-duration ;
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ import WikitLink from '@/components/Link' ;
2+ import { Component } from 'vue' ;
3+
4+ export default {
5+ component : WikitLink ,
6+ // the `/` prefix in the title is needed for "Message" to appear as a folded navigation item, and not a headline
7+ title : '/Link' ,
8+ } ;
9+
10+ export function basic ( args : { content : string ; underlined : boolean } ) : Component {
11+ return {
12+ data : ( ) => args ,
13+ components : { WikitLink } ,
14+ template : `
15+ <div>
16+ <p><WikitLink
17+ :underlined="underlined"
18+ :href="'#' + Math.random()"
19+ ><span v-html="content" /></WikitLink></p>
20+ </div>
21+ ` ,
22+ } ;
23+ }
24+
25+ basic . args = {
26+ underlined : false ,
27+ content : 'Controllable link' ,
28+ } ;
29+
30+ basic . argTypes = {
31+ underlined : {
32+ control : {
33+ type : 'boolean' ,
34+ } ,
35+ } ,
36+ content : {
37+ control : {
38+ type : 'text' ,
39+ } ,
40+ } ,
41+ } ;
42+
43+ export function all ( ) : Component {
44+ return {
45+ components : { WikitLink } ,
46+ template : `
47+ <div>
48+ <p><WikitLink :href="'#' + Math.random()">Click here</WikitLink></p>
49+ <p><WikitLink :href="'#' + Math.random()" underlined>Click here</WikitLink></p>
50+ <p><WikitLink :href="'#' + Math.random()" icon="before">About Wikidata</WikitLink></p>
51+ <p><WikitLink :href="'#' + Math.random()" icon="after">About Wikidata</WikitLink></p>
52+ </div>
53+ ` ,
54+ } ;
55+ }
56+ all . parameters = {
57+ controls : { hideNoControlsWarning : true } ,
58+ } ;
You can’t perform that action at this time.
0 commit comments