Skip to content

Commit

Permalink
Rebrand icons in buttons and links
Browse files Browse the repository at this point in the history
  • Loading branch information
MisRob committed Mar 26, 2024
1 parent d1362b2 commit b95e3c6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
22 changes: 3 additions & 19 deletions lib/buttons-and-links/KButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,6 @@
};
},
computed: {
iconColor() {
if (this.appearance === 'basic-link') {
return this.hovering ? this.$themeTokens.primaryDark : this.$themeTokens.primary;
}
if (this.secondary) {
return this.appearance === 'raised-button'
? this.$themeBrand.textInverted
: this.$themeBrand.secondary;
} else {
return this.$themeBrand.text;
}
},
htmlTag() {
// Necessary to allow basic links to be rendered as 'inline' instead of
// 'inline-block': https://stackoverflow.com/a/27770128
Expand All @@ -139,12 +126,9 @@
return 'button';
},
arrowStyles() {
if (this.secondary) {
return {
fill: this.$themeBrand.textInverted,
};
}
return {};
return {
fill: this.iconColor,
};
},
textStyle() {
let styles = {};
Expand Down
6 changes: 3 additions & 3 deletions lib/buttons-and-links/KExternalLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
v-if="icon"
:icon="icon"
style="top: 4px;"
:color="hovering ? $themeTokens.primaryDark : $themeTokens.primary"
:color="iconColor"
/>
</slot>

Expand All @@ -33,14 +33,14 @@
v-if="iconAfter"
:icon="iconAfter"
style="top: 4px;"
:color="hovering ? $themeTokens.primaryDark : $themeTokens.primary"
:color="iconColor"
/>
</slot>
<KIcon
v-if="openInNewTab"
icon="openNewTab"
style="top: 4px;"
:color="hovering ? $themeTokens.primaryDark : $themeTokens.primary"
:color="iconColor"
/>
</a>

Expand Down
4 changes: 2 additions & 2 deletions lib/buttons-and-links/KRouterLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
v-if="icon"
:icon="icon"
style="top: 4px;"
:color="hovering ? $themeTokens.primaryDark : $themeTokens.primary"
:color="iconColor"
data-test="icon-before"
/>
</slot>
Expand All @@ -39,7 +39,7 @@
v-if="iconAfter"
:icon="iconAfter"
style="top: 4px;"
:color="hovering ? $themeTokens.secondaryDark : $themeTokens.secondary"
:color="iconColor"
data-test="icon-after"
/>
</slot>
Expand Down
15 changes: 15 additions & 0 deletions lib/buttons-and-links/buttonMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ export default {
},
};
},
iconColor() {
if (this.appearance === 'basic-link') {
return this.hovering ? this.$themeTokens.primaryDark : this.$themeTokens.primary;
}

if (this.appearance === 'raised-button') {
return this.primary ? this.$themeTokens.textInverted : this.$themeTokens.text;
}

if (this.appearance === 'flat-button') {
return this.primary ? this.$themeTokens.primary : this.$themeTokens.text;
}

return {};
},
},
methods: {
buttonComputedClass(styles) {
Expand Down

0 comments on commit b95e3c6

Please sign in to comment.