4
4
xmlns =" http://www.w3.org/2000/svg"
5
5
:viewBox =" viewBox"
6
6
:class =" computedClasses"
7
- v-html =" icon.svgContent "
7
+ v-html =" titleCode + iconCode "
8
8
></svg >
9
9
<img
10
10
v-else
@@ -20,7 +20,10 @@ export default {
20
20
content: [String , Array ],
21
21
size: {
22
22
type: String ,
23
- validator : size => [' sm' , ' lg' , ' xl' , ' custom-size' ].includes (size)
23
+ validator : size => [
24
+ ' custom-size' , ' sm' , ' lg' , ' xl' ,
25
+ ' 2xl' , ' 3xl' , ' 4xl' , ' 5xl' , ' 6xl' , ' 7xl' , ' 8xl' , ' 9xl'
26
+ ].includes (size)
24
27
},
25
28
customClasses: [String , Array , Object ],
26
29
src: String
@@ -30,24 +33,24 @@ export default {
30
33
const iconNameIsKebabCase = this .name && this .name .includes (' -' )
31
34
return iconNameIsKebabCase ? this .toCamelCase (this .name ) : this .name
32
35
},
36
+ titleCode () {
37
+ return this .iconName ? ` <title>${ this .iconName } </title>` : ' '
38
+ },
33
39
code () {
34
40
if (this .content ) {
35
41
return this .content
36
42
} else if (this .$root .$options .icons ) {
37
43
return this .$root .$options .icons [this .iconName ]
38
44
}
39
- return undefined
40
45
},
41
- icon () {
42
- if (Array .isArray (this .code )) {
43
- const coordinates = this .code .length > 1 ? this .code [0 ] : ' 64 64'
44
- const svgContent = this .code .length > 1 ? this .code [1 ] : this .code [0 ]
45
- return { coordinates, svgContent }
46
- }
47
- return { coordinates: ' 64 64' , svgContent: this .code }
46
+ iconCode () {
47
+ return Array .isArray (this .code ) ? this .code [1 ] || this .code [0 ] : this .code
48
+ },
49
+ scale () {
50
+ return Array .isArray (this .code ) && this .code .length > 1 ? this .code [0 ] : ' 64 64'
48
51
},
49
52
viewBox () {
50
- return this .$attrs .viewBox || ` 0 0 ${ this .icon . coordinates } `
53
+ return this .$attrs .viewBox || ` 0 0 ${ this .scale } `
51
54
},
52
55
computedSize () {
53
56
return this .$attrs .width || this .$attrs .height ? ' custom-size' : this .size
@@ -66,3 +69,87 @@ export default {
66
69
}
67
70
}
68
71
</script >
72
+
73
+ <style >
74
+ .c-icon {
75
+ display : inline-block ;
76
+ color : inherit ;
77
+ text-align : center ;
78
+ fill : currentColor ;
79
+ width : 1rem ;
80
+ height : 1rem ;
81
+ font-size : 1rem ;
82
+ }
83
+
84
+ .c-icon-2xl {
85
+ width : 2rem ;
86
+ height : 2rem ;
87
+ font-size : 2rem ;
88
+ }
89
+
90
+ .c-icon-3xl {
91
+ width : 3rem ;
92
+ height : 3rem ;
93
+ font-size : 3rem ;
94
+ }
95
+
96
+ .c-icon-4xl {
97
+ width : 4rem ;
98
+ height : 4rem ;
99
+ font-size : 4rem ;
100
+ }
101
+
102
+ .c-icon-5xl {
103
+ width : 5rem ;
104
+ height : 5rem ;
105
+ font-size : 5rem ;
106
+ }
107
+
108
+ .c-icon-6xl {
109
+ width : 6rem ;
110
+ height : 6rem ;
111
+ font-size : 6rem ;
112
+ }
113
+
114
+ .c-icon-7xl {
115
+ width : 7rem ;
116
+ height : 7rem ;
117
+ font-size : 7rem ;
118
+ }
119
+
120
+ .c-icon-8xl {
121
+ width : 8rem ;
122
+ height : 8rem ;
123
+ font-size : 8rem ;
124
+ }
125
+
126
+ .c-icon-9xl {
127
+ width : 9rem ;
128
+ height : 9rem ;
129
+ font-size : 9rem ;
130
+ }
131
+
132
+ .c-icon-xl {
133
+ width : 1.5rem ;
134
+ height : 1.5rem ;
135
+ font-size : 1.5rem ;
136
+ }
137
+
138
+ .c-icon-lg {
139
+ width : 1.25rem ;
140
+ height : 1.25rem ;
141
+ font-size : 1.25rem ;
142
+ }
143
+
144
+ .c-icon-sm {
145
+ width : 0.875rem ;
146
+ height : 0.875rem ;
147
+ font-size : 0.875rem ;
148
+ }
149
+
150
+ .c-icon-c-s ,
151
+ .c-icon-custom-size {
152
+ width : initial !important ;
153
+ height : initial !important ;
154
+ }
155
+ </style >
0 commit comments