Skip to content

Commit

Permalink
[SDPA-2945] Prevent underline from showing after the icon on a text l…
Browse files Browse the repository at this point in the history
…ink. (#450)

* [SDPA-2945] Text Icon fixes.
* Use 'else' statement to avoid vue printing a <!-- --> comment (and inserting an underlined space).
* Move rpl-icon property definitions into a computed value to increase code readability.

* [SDPA-2945] Update snapshot.
  • Loading branch information
alan-cole authored and tim-yao committed Jul 25, 2019
1 parent 9fca011 commit 0389b31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 104 deletions.
16 changes: 12 additions & 4 deletions packages/components/Atoms/Icon/TextIcon.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<span v-if="text && symbol && placement === 'before'">
<span v-if="textWordCount > 1" class="rpl-text-icon__group"><rpl-icon :symbol="symbol" :color="color" :size="size" class="rpl-text-icon--before"/>{{ textFirstWord }}</span>
<span v-if="textWordCount > 1" class="rpl-text-icon__group"><rpl-icon v-bind="iconProps" />{{ textFirstWord }}</span>
<span v-if="textWordCount > 1">{{ textWithoutFirstWord }}</span>
<span v-if="textWordCount <= 1" class="rpl-text-icon__group"><rpl-icon :symbol="symbol" :color="color" :size="size" class="rpl-text-icon--before"/>{{ text }}</span>
<span v-else class="rpl-text-icon__group"><rpl-icon v-bind="iconProps" />{{ text }}</span>
</span>
<span v-else-if="text && symbol && placement === 'after'">
<span v-if="textWordCount > 1">{{ textWithoutLastWord }}</span>
<span v-if="textWordCount > 1" class="rpl-text-icon__group">{{ textLastWord }}<rpl-icon :symbol="symbol" :color="color" :size="size" class="rpl-text-icon--after" /></span>
<span v-if="textWordCount <= 1" class="rpl-text-icon__group">{{ text }}<rpl-icon :symbol="symbol" :color="color" :size="size" class="rpl-text-icon--after" /></span>
<span v-if="textWordCount > 1" class="rpl-text-icon__group">{{ textLastWord }}<rpl-icon v-bind="iconProps" /></span>
<span v-else class="rpl-text-icon__group">{{ text }}<rpl-icon v-bind="iconProps" /></span>
</span>
<span v-else-if="text">{{ text }}</span>
</template>
Expand Down Expand Up @@ -42,6 +42,14 @@ export default {
},
textFirstWord: function () {
return this.text.substr(0, this.text.indexOf(' '))
},
iconProps: function () {
return {
symbol: this.symbol,
color: this.color,
size: this.size,
class: `rpl-text-icon--${this.placement}`
}
}
}
}
Expand Down
Loading

0 comments on commit 0389b31

Please sign in to comment.