Skip to content

Commit 759f4a5

Browse files
committedJan 14, 2020
refactor: remove automatic title assignment, add role attribute
1 parent b323a26 commit 759f4a5

File tree

2 files changed

+6
-38
lines changed

2 files changed

+6
-38
lines changed
 

‎src/CIcon.vue

+3-19
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
:viewBox="viewBox"
66
:class="computedClasses"
77
v-html="titleCode + iconCode"
8+
role="img"
89
></svg>
910
<img
1011
v-else
1112
:src="src"
13+
role="img"
1214
/>
1315
</template>
1416

@@ -34,16 +36,8 @@ export default {
3436
const iconNameIsKebabCase = this.name && this.name.includes('-')
3537
return iconNameIsKebabCase ? this.toCamelCase(this.name) : this.name
3638
},
37-
titleString () {
38-
if (this.title) {
39-
return this.title
40-
} else if (this.iconName) {
41-
return this.generateTitle(this.iconName)
42-
}
43-
return 'icon'
44-
},
4539
titleCode () {
46-
return `<title>${this.titleString}</title>`
40+
return this.title ? `<title>${this.title}</title>` : ''
4741
},
4842
code () {
4943
if (this.content) {
@@ -74,16 +68,6 @@ export default {
7468
return str.replace(/([-_][a-z0-9])/ig, ($1) => {
7569
return $1.toUpperCase().replace('-', '')
7670
})
77-
},
78-
generateTitle (title) {
79-
return this.getValidTitle(title).replace(/([a-z0-9])([A-Z])/g, '$1 $2')
80-
},
81-
getValidTitle (title) {
82-
if (['cil', 'cib', 'cif', 'cis'].includes(title.substring(0,3))) {
83-
return title.slice(3)
84-
} else {
85-
return title.charAt(0).toUpperCase() + title.slice(1)
86-
}
8771
}
8872
}
8973
}

‎src/CIconRaw.vue

+3-19
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
:viewBox="viewBox"
66
:class="computedClasses"
77
v-html="titleCode + iconCode"
8+
role="img"
89
></svg>
910
<img
1011
v-else
1112
:src="src"
13+
role="img"
1214
/>
1315
</template>
1416

@@ -34,16 +36,8 @@ export default {
3436
const iconNameIsKebabCase = this.name && this.name.includes('-')
3537
return iconNameIsKebabCase ? this.toCamelCase(this.name) : this.name
3638
},
37-
titleString () {
38-
if (this.title) {
39-
return this.title
40-
} else if (this.iconName) {
41-
return this.generateTitle(this.iconName)
42-
}
43-
return 'icon'
44-
},
4539
titleCode () {
46-
return `<title>${this.titleString}</title>`
40+
return this.title ? `<title>${this.title}</title>` : ''
4741
},
4842
code () {
4943
if (this.content) {
@@ -74,16 +68,6 @@ export default {
7468
return str.replace(/([-_][a-z0-9])/ig, ($1) => {
7569
return $1.toUpperCase().replace('-', '')
7670
})
77-
},
78-
generateTitle (title) {
79-
return this.getValidTitle(title).replace(/([a-z0-9])([A-Z])/g, '$1 $2')
80-
},
81-
getValidTitle (title) {
82-
if (['cil', 'cib', 'cif', 'cis'].includes(title.substring(0,3))) {
83-
return title.slice(3)
84-
} else {
85-
return title.charAt(0).toUpperCase() + title.slice(1)
86-
}
8771
}
8872
}
8973
}

0 commit comments

Comments
 (0)
Please sign in to comment.