File tree 2 files changed +24
-8
lines changed
2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change 40
40
display : inline-block;
41
41
font-size : 12px ;
42
42
}
43
+
43
44
small {
44
45
45
- margin : 0 10px ;
46
+ margin : 0 10px ;
46
47
47
- }
48
+ }
48
49
</ style >
49
50
</ head >
50
51
< body >
@@ -56,12 +57,14 @@ <h1>Parse CSS and Convert to PHP Array</h1>
56
57
< p > for convert icon font css to php array like flaticon / fontawesome etc.</ p >
57
58
< p >
58
59
< small > < a target ="_blank " href ="https://github.com/EmranAhmed/vue-generate-php-font-array "> Github</ a > </ small >
59
-
60
+
60
61
< small > < a target ="_blank " href ="https://cdn.materialdesignicons.com/1.7.22/css/materialdesignicons.css "> Material Design Icons</ a > </ small >
61
62
62
63
< small > < a target ="_blank " href ="http://fontawesome.io/assets/font-awesome/css/font-awesome.css "> FontAwesome</ a > </ small >
63
64
64
65
< small > < a target ="_blank " href ="http://www.flaticon.com/ "> FlatIcon</ a > </ small >
66
+
67
+ < small > < a target ="_blank " href ="https://raw.githubusercontent.com/WordPress/dashicons/master/css/dashicons.css "> DashIcons</ a > </ small >
65
68
</ p >
66
69
67
70
< label >
@@ -73,6 +76,9 @@ <h1>Parse CSS and Convert to PHP Array</h1>
73
76
< label >
74
77
< input type ="radio " v-model ="prefix " @change ="beforeClassPrefix " before ="mdi " value ="mdi- "> Material Design Icon
75
78
</ label >
79
+ < label >
80
+ < input type ="radio " v-model ="prefix " @change ="beforeClassPrefix " before ="dashicons " value ="dashicons- "> DashIcons
81
+ </ label >
76
82
< textarea v-model ="css " cols ="30 " placeholder ="Paste CSS Contents " rows ="10 "> </ textarea >
77
83
< textarea v-show ="php " readonly v-model ="php " cols ="30 " rows ="10 "> </ textarea >
78
84
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ new Vue({
3
3
data : {
4
4
prefix : '' ,
5
5
css : '' ,
6
- php : '' ,
7
6
before : ''
8
7
} ,
9
8
@@ -24,16 +23,27 @@ new Vue({
24
23
generatePHP : function ( prefix , css , before ) {
25
24
26
25
var match ,
27
- phpcode = [ ] ,
28
- $pattern = `.(${ prefix } ([^:|^"]+)):before` ,
29
- $regexp = new RegExp ( $pattern , "ig" ) ;
26
+ phpcode = [ ] ,
27
+ $comments = / \/ \* (?: (? ! \* \/ ) [ \s \S ] ) * \* \/ / g,
28
+ $pattern = `.(${ prefix } ([^:|^"]+)):before` ,
29
+ $regexp = new RegExp ( $pattern , "ig" ) ;
30
+
31
+ css = css . replace ( $comments , '' ) ;
30
32
31
33
while ( ( match = $regexp . exec ( css ) ) !== null ) {
32
34
if ( match [ 1 ] . indexOf ( "." ) == - 1 || match [ 1 ] . indexOf ( "," ) == - 1 ) {
33
35
let name = match [ 2 ] . replace ( / - / g, ' ' ) . replace ( / ( \b \w ) / gi, function ( m ) { return m . toUpperCase ( ) ; } ) ;
34
- phpcode . push ( `\t'${ before } ${ match [ 1 ] } '=>'${ name } '` ) ;
36
+
37
+ let icon = `${ before } ${ match [ 1 ] } ` . trim ( ) ;
38
+
39
+ phpcode . push ( `\t'${ icon } '=>'${ name } '` ) ;
40
+
41
+ if ( before == 'dashicons' && match [ 1 ] == 'dashicons-before' ) {
42
+ phpcode . shift ( ) ;
43
+ }
35
44
}
36
45
}
46
+
37
47
return `<?php \nreturn array(\n${ phpcode . join ( ",\n" ) } \n);` ;
38
48
}
39
49
}
You can’t perform that action at this time.
0 commit comments