Skip to content

Commit

Permalink
feat(#86): add link support to tags (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher authored Aug 14, 2023
1 parent f5092d3 commit fe4ccdd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
11 changes: 2 additions & 9 deletions src/components/NavigationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@
</template>

<script>
import ThemeLink from '../mixins/link'
import ThemeMixin from '../mixins/theme'
export default {
mixins: [ThemeMixin],
mixins: [ThemeLink, ThemeMixin],
props: {
imageAlt: {
Expand All @@ -87,14 +88,6 @@ export default {
type: String,
default: undefined,
},
link: {
type: String,
default: '#'
},
linkExternal: {
type: Boolean,
default: undefined,
},
summary: {
type: String,
default: undefined,
Expand Down
35 changes: 26 additions & 9 deletions src/components/Tag.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<template>
<span
class="ct-tag"
:class="{
[themeClass]: true,
[`ct-tag--${type}`]: type,
[`ct-tag--with-icon ct-tag--icon-${iconPosition}`]: icon && iconPosition
}"
<CTLink
v-if="link"
:class="classes"
:external="linkExternal"
:icon="icon"
:icon-position="iconPosition"
:link="link"
:text="model"
:title="model"
/>

<span
v-else
:aria-label="model"
:class="classes"
:title="model"
>
<CTIcon
v-if="icon && iconPosition === 'before'"
Expand All @@ -24,10 +31,11 @@
</template>

<script>
import ThemeLink from '../mixins/link'
import ThemeMixin from '../mixins/theme'
export default {
mixins: [ThemeMixin],
mixins: [ThemeLink, ThemeMixin],
props: {
icon: {
Expand All @@ -50,6 +58,15 @@ export default {
data: ({ value }) => ({
model: value
})
}),
computed: {
classes: ({ icon, iconPosition, themeClass, type }) => ({
'ct-tag': true,
[themeClass]: true,
[`ct-tag--${type}`]: type,
[`ct-tag--with-icon ct-tag--icon-${iconPosition}`]: icon && iconPosition,
})
}
}
</script>
12 changes: 12 additions & 0 deletions src/mixins/link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
props: {
link: {
type: String,
default: '#'
},
linkExternal: {
type: Boolean,
default: undefined,
},
},
}

0 comments on commit fe4ccdd

Please sign in to comment.