File tree 2 files changed +100
-5
lines changed
2 files changed +100
-5
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div id =" app" >
3
- <img src =" ./assets/logo.png" >
4
- <hello ></hello >
3
+ <img src =" ./assets/logo.png" class = " logo " >
4
+ <selector-form ></selector-form >
5
5
</div >
6
6
</template >
7
7
8
8
<script >
9
- import Hello from ' ./components/Hello ' ;
9
+ import SelectorForm from ' ./components/SelectorForm ' ;
10
10
11
11
export default {
12
12
name: ' app' ,
13
13
components: {
14
- Hello ,
14
+ SelectorForm ,
15
15
},
16
16
};
17
17
</script >
@@ -23,6 +23,10 @@ export default {
23
23
-moz-osx-font-smoothing : grayscale ;
24
24
text-align : center ;
25
25
color : #2c3e50 ;
26
- margin-top : 60px ;
26
+ margin-top : 40px ;
27
+ }
28
+
29
+ .logo {
30
+ height : 120px ;
27
31
}
28
32
</style >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" hello" >
3
+ <h1 >CSSpecify</h1 >
4
+ <input class =" selector-input" type =" text" v-model =" selectorString" />
5
+ <ul >
6
+ <li v-for =" token in tokens" >{{token}}</li >
7
+ </ul >
8
+ <h2 >specificity: {{ specificity }}</h2 >
9
+ </div >
10
+ </template >
11
+
12
+ <script >
13
+ export default {
14
+ name: ' hello' ,
15
+ data () {
16
+ return {
17
+ selectorString: ' ul#bacon.foo li.bar p #crispy' ,
18
+ idMatcher: / #[A-z0-9 -_] + / g ,
19
+ classMatcher: / \. [A-z0-9 -_] + / g ,
20
+ tagMatcher: / (?:^ | )\w + / g ,
21
+ };
22
+ },
23
+ methods: {
24
+ extractTokens (regex ) {
25
+ const match = this .selectorString .match (regex);
26
+ if (! match) {
27
+ return [];
28
+ }
29
+ return match;
30
+ },
31
+ },
32
+ computed: {
33
+ idTokens () {
34
+ return this .extractTokens (this .idMatcher );
35
+ },
36
+ classTokens () {
37
+ return this .extractTokens (this .classMatcher );
38
+ },
39
+ tagTokens () {
40
+ return this .extractTokens (this .tagMatcher );
41
+ },
42
+ tokens () {
43
+ return this .idTokens .concat (this .classTokens ).concat (this .tagTokens );
44
+ },
45
+ specificity () {
46
+ let result = ' ' ;
47
+ result += this .idTokens .length .toString ();
48
+ result += this .classTokens .length .toString ();
49
+ result += this .tagTokens .length .toString ();
50
+ return result;
51
+ },
52
+ },
53
+ };
54
+ </script >
55
+
56
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
57
+ <style scoped>
58
+ h1, h2 {
59
+ font-weight: normal;
60
+ }
61
+
62
+ h1 {
63
+ font-size: 100px;
64
+ margin: 20px 0 60px;
65
+ }
66
+
67
+ .selector-input {
68
+ display: block;
69
+ margin: 0 auto;
70
+ height: 60px;
71
+ width: 600px;
72
+ font-size: 40px;
73
+ font-weight: lighter;
74
+ padding: 10px 20px;
75
+ text-align: center;
76
+ }
77
+
78
+ a {
79
+ color: #42b983;
80
+ }
81
+
82
+ ul {
83
+ list-style-type: none;
84
+ padding: 0;
85
+ }
86
+
87
+ li {
88
+ display: inline-block;
89
+ margin: 0 10px;
90
+ }
91
+ </style>
You can’t perform that action at this time.
0 commit comments