Skip to content

Commit bee45a1

Browse files
committed
refactor: move global styles to main.css; use only scoped styles in App.vue
- `base.css` contains CSS resets and variables - `main.css` is the global styles of the app, to be imported by `main.js` - `App.vue` only contains the styles for the root `App` component
1 parent 62f331a commit bee45a1

File tree

9 files changed

+63
-156
lines changed

9 files changed

+63
-156
lines changed

template/base/src/assets/main.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@import "./base.css";
2+
3+
#app {
4+
max-width: 1280px;
5+
margin: 0 auto;
6+
padding: 2rem;
7+
8+
font-weight: normal;
9+
}
10+
11+
a,
12+
.green {
13+
text-decoration: none;
14+
color: hsla(160, 100%, 37%, 1);
15+
transition: 0.4s;
16+
}
17+
18+
@media (hover: hover) {
19+
a:hover {
20+
background-color: hsla(160, 100%, 37%, 0.2);
21+
}
22+
}
23+
24+
@media (min-width: 1024px) {
25+
body {
26+
display: flex;
27+
place-items: center;
28+
}
29+
30+
#app {
31+
display: grid;
32+
grid-template-columns: 1fr 1fr;
33+
padding: 0 2rem;
34+
}
35+
}

template/code/default/src/App.vue

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,7 @@ import TheWelcome from './components/TheWelcome.vue'
1919
</div>
2020
</template>
2121

22-
<style>
23-
@import './assets/base.css';
24-
25-
#app {
26-
max-width: 1280px;
27-
margin: 0 auto;
28-
padding: 2rem;
29-
30-
font-weight: normal;
31-
}
32-
22+
<style scoped>
3323
header {
3424
line-height: 1.5;
3525
}
@@ -39,45 +29,21 @@ header {
3929
margin: 0 auto 2rem;
4030
}
4131
42-
a,
43-
.green {
44-
text-decoration: none;
45-
color: hsla(160, 100%, 37%, 1);
46-
transition: 0.4s;
47-
}
48-
49-
@media (hover: hover) {
50-
a:hover {
51-
background-color: hsla(160, 100%, 37%, 0.2);
52-
}
53-
}
54-
5532
@media (min-width: 1024px) {
56-
body {
57-
display: flex;
58-
place-items: center;
59-
}
60-
61-
#app {
62-
display: grid;
63-
grid-template-columns: 1fr 1fr;
64-
padding: 0 2rem;
65-
}
66-
6733
header {
6834
display: flex;
6935
place-items: center;
7036
padding-right: calc(var(--section-gap) / 2);
7137
}
7238
39+
.logo {
40+
margin: 0 2rem 0 0;
41+
}
42+
7343
header .wrapper {
7444
display: flex;
7545
place-items: flex-start;
7646
flex-wrap: wrap;
7747
}
78-
79-
.logo {
80-
margin: 0 2rem 0 0;
81-
}
8248
}
8349
</style>

template/code/router/src/App.vue

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,7 @@ import HelloWorld from '@/components/HelloWorld.vue'
2121
</div>
2222
</template>
2323

24-
<style>
25-
@import '@/assets/base.css';
26-
27-
#app {
28-
max-width: 1280px;
29-
margin: 0 auto;
30-
padding: 2rem;
31-
32-
font-weight: normal;
33-
}
34-
24+
<style scoped>
3525
header {
3626
line-height: 1.5;
3727
max-height: 100vh;
@@ -42,19 +32,6 @@ header {
4232
margin: 0 auto 2rem;
4333
}
4434
45-
a,
46-
.green {
47-
text-decoration: none;
48-
color: hsla(160, 100%, 37%, 1);
49-
transition: 0.4s;
50-
}
51-
52-
@media (hover: hover) {
53-
a:hover {
54-
background-color: hsla(160, 100%, 37%, 0.2);
55-
}
56-
}
57-
5835
nav {
5936
width: 100%;
6037
font-size: 12px;
@@ -81,33 +58,22 @@ nav a:first-of-type {
8158
}
8259
8360
@media (min-width: 1024px) {
84-
body {
85-
display: flex;
86-
place-items: center;
87-
}
88-
89-
#app {
90-
display: grid;
91-
grid-template-columns: 1fr 1fr;
92-
padding: 0 2rem;
93-
}
94-
9561
header {
9662
display: flex;
9763
place-items: center;
9864
padding-right: calc(var(--section-gap) / 2);
9965
}
10066
67+
.logo {
68+
margin: 0 2rem 0 0;
69+
}
70+
10171
header .wrapper {
10272
display: flex;
10373
place-items: flex-start;
10474
flex-wrap: wrap;
10575
}
10676
107-
.logo {
108-
margin: 0 2rem 0 0;
109-
}
110-
11177
nav {
11278
text-align: left;
11379
margin-left: -1rem;

template/code/typescript-default/src/App.vue

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,7 @@ import TheWelcome from './components/TheWelcome.vue'
1919
</div>
2020
</template>
2121

22-
<style>
23-
@import './assets/base.css';
24-
25-
#app {
26-
max-width: 1280px;
27-
margin: 0 auto;
28-
padding: 2rem;
29-
30-
font-weight: normal;
31-
}
32-
22+
<style scoped>
3323
header {
3424
line-height: 1.5;
3525
}
@@ -39,45 +29,21 @@ header {
3929
margin: 0 auto 2rem;
4030
}
4131
42-
a,
43-
.green {
44-
text-decoration: none;
45-
color: hsla(160, 100%, 37%, 1);
46-
transition: 0.4s;
47-
}
48-
49-
@media (hover: hover) {
50-
a:hover {
51-
background-color: hsla(160, 100%, 37%, 0.2);
52-
}
53-
}
54-
5532
@media (min-width: 1024px) {
56-
body {
57-
display: flex;
58-
place-items: center;
59-
}
60-
61-
#app {
62-
display: grid;
63-
grid-template-columns: 1fr 1fr;
64-
padding: 0 2rem;
65-
}
66-
6733
header {
6834
display: flex;
6935
place-items: center;
7036
padding-right: calc(var(--section-gap) / 2);
7137
}
7238
39+
.logo {
40+
margin: 0 2rem 0 0;
41+
}
42+
7343
header .wrapper {
7444
display: flex;
7545
place-items: flex-start;
7646
flex-wrap: wrap;
7747
}
78-
79-
.logo {
80-
margin: 0 2rem 0 0;
81-
}
8248
}
8349
</style>

template/code/typescript-router/src/App.vue

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,7 @@ import HelloWorld from '@/components/HelloWorld.vue'
2121
</div>
2222
</template>
2323

24-
<style>
25-
@import '@/assets/base.css';
26-
27-
#app {
28-
max-width: 1280px;
29-
margin: 0 auto;
30-
padding: 2rem;
31-
32-
font-weight: normal;
33-
}
34-
24+
<style scoped>
3525
header {
3626
line-height: 1.5;
3727
max-height: 100vh;
@@ -42,19 +32,6 @@ header {
4232
margin: 0 auto 2rem;
4333
}
4434
45-
a,
46-
.green {
47-
text-decoration: none;
48-
color: hsla(160, 100%, 37%, 1);
49-
transition: 0.4s;
50-
}
51-
52-
@media (hover: hover) {
53-
a:hover {
54-
background-color: hsla(160, 100%, 37%, 0.2);
55-
}
56-
}
57-
5835
nav {
5936
width: 100%;
6037
font-size: 12px;
@@ -81,33 +58,22 @@ nav a:first-of-type {
8158
}
8259
8360
@media (min-width: 1024px) {
84-
body {
85-
display: flex;
86-
place-items: center;
87-
}
88-
89-
#app {
90-
display: grid;
91-
grid-template-columns: 1fr 1fr;
92-
padding: 0 2rem;
93-
}
94-
9561
header {
9662
display: flex;
9763
place-items: center;
9864
padding-right: calc(var(--section-gap) / 2);
9965
}
10066
67+
.logo {
68+
margin: 0 2rem 0 0;
69+
}
70+
10171
header .wrapper {
10272
display: flex;
10373
place-items: flex-start;
10474
flex-wrap: wrap;
10575
}
10676
107-
.logo {
108-
margin: 0 2rem 0 0;
109-
}
110-
11177
nav {
11278
text-align: left;
11379
margin-left: -1rem;

template/entry/default/src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Vue from 'vue'
22
import App from './App.vue'
33

4+
import './assets/main.css'
5+
46
new Vue({
57
render: (h) => h(App)
68
}).$mount('#app')

template/entry/pinia/src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { createPinia, PiniaVuePlugin } from 'pinia'
33

44
import App from './App.vue'
55

6+
import './assets/main.css'
7+
68
Vue.use(PiniaVuePlugin)
79

810
new Vue({

template/entry/router-and-pinia/src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { createPinia, PiniaVuePlugin } from 'pinia'
44
import App from './App.vue'
55
import router from './router'
66

7+
import './assets/main.css'
8+
79
Vue.use(PiniaVuePlugin)
810

911
new Vue({

template/entry/router/src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import Vue from 'vue'
33
import App from './App.vue'
44
import router from './router'
55

6+
import './assets/main.css'
7+
68
new Vue({
79
router,
810
render: (h) => h(App)

0 commit comments

Comments
 (0)