Skip to content

Commit

Permalink
refactor: remove automatic title assignment, add role attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
woothu committed Jan 14, 2020
1 parent b323a26 commit 759f4a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 38 deletions.
22 changes: 3 additions & 19 deletions src/CIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
:viewBox="viewBox"
:class="computedClasses"
v-html="titleCode + iconCode"
role="img"
></svg>
<img
v-else
:src="src"
role="img"
/>
</template>

Expand All @@ -34,16 +36,8 @@ export default {
const iconNameIsKebabCase = this.name && this.name.includes('-')
return iconNameIsKebabCase ? this.toCamelCase(this.name) : this.name
},
titleString () {
if (this.title) {
return this.title
} else if (this.iconName) {
return this.generateTitle(this.iconName)
}
return 'icon'
},
titleCode () {
return `<title>${this.titleString}</title>`
return this.title ? `<title>${this.title}</title>` : ''
},
code () {
if (this.content) {
Expand Down Expand Up @@ -74,16 +68,6 @@ export default {
return str.replace(/([-_][a-z0-9])/ig, ($1) => {
return $1.toUpperCase().replace('-', '')
})
},
generateTitle (title) {
return this.getValidTitle(title).replace(/([a-z0-9])([A-Z])/g, '$1 $2')
},
getValidTitle (title) {
if (['cil', 'cib', 'cif', 'cis'].includes(title.substring(0,3))) {
return title.slice(3)
} else {
return title.charAt(0).toUpperCase() + title.slice(1)
}
}
}
}
Expand Down
22 changes: 3 additions & 19 deletions src/CIconRaw.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
:viewBox="viewBox"
:class="computedClasses"
v-html="titleCode + iconCode"
role="img"
></svg>
<img
v-else
:src="src"
role="img"
/>
</template>

Expand All @@ -34,16 +36,8 @@ export default {
const iconNameIsKebabCase = this.name && this.name.includes('-')
return iconNameIsKebabCase ? this.toCamelCase(this.name) : this.name
},
titleString () {
if (this.title) {
return this.title
} else if (this.iconName) {
return this.generateTitle(this.iconName)
}
return 'icon'
},
titleCode () {
return `<title>${this.titleString}</title>`
return this.title ? `<title>${this.title}</title>` : ''
},
code () {
if (this.content) {
Expand Down Expand Up @@ -74,16 +68,6 @@ export default {
return str.replace(/([-_][a-z0-9])/ig, ($1) => {
return $1.toUpperCase().replace('-', '')
})
},
generateTitle (title) {
return this.getValidTitle(title).replace(/([a-z0-9])([A-Z])/g, '$1 $2')
},
getValidTitle (title) {
if (['cil', 'cib', 'cif', 'cis'].includes(title.substring(0,3))) {
return title.slice(3)
} else {
return title.charAt(0).toUpperCase() + title.slice(1)
}
}
}
}
Expand Down

0 comments on commit 759f4a5

Please sign in to comment.