]> git.ipfire.org Git - thirdparty/vuejs/create-vue.git/commitdiff
refactor: move global styles to `main.css`; use only scoped styles in `App.vue`
authorHaoqun Jiang <haoqunjiang@gmail.com>
Tue, 12 Jul 2022 10:16:18 +0000 (18:16 +0800)
committerHaoqun Jiang <haoqunjiang@gmail.com>
Tue, 12 Jul 2022 10:16:18 +0000 (18:16 +0800)
- `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

template/base/src/assets/main.css [new file with mode: 0644]
template/code/default/src/App.vue
template/code/router/src/App.vue
template/code/typescript-default/src/App.vue
template/code/typescript-router/src/App.vue
template/entry/default/src/main.js
template/entry/pinia/src/main.js
template/entry/router-and-pinia/src/main.js
template/entry/router/src/main.js

diff --git a/template/base/src/assets/main.css b/template/base/src/assets/main.css
new file mode 100644 (file)
index 0000000..c133f91
--- /dev/null
@@ -0,0 +1,35 @@
+@import "./base.css";
+
+#app {
+  max-width: 1280px;
+  margin: 0 auto;
+  padding: 2rem;
+
+  font-weight: normal;
+}
+
+a,
+.green {
+  text-decoration: none;
+  color: hsla(160, 100%, 37%, 1);
+  transition: 0.4s;
+}
+
+@media (hover: hover) {
+  a:hover {
+    background-color: hsla(160, 100%, 37%, 0.2);
+  }
+}
+
+@media (min-width: 1024px) {
+  body {
+    display: flex;
+    place-items: center;
+  }
+
+  #app {
+    display: grid;
+    grid-template-columns: 1fr 1fr;
+    padding: 0 2rem;
+  }
+}
index b0b6901bf5d8bd252c01b735605f50569c258095..633a5dfe4e547c48bfa93740a290ba5ba370930a 100644 (file)
@@ -17,17 +17,7 @@ import TheWelcome from './components/TheWelcome.vue'
   </main>
 </template>
 
-<style>
-@import './assets/base.css';
-
-#app {
-  max-width: 1280px;
-  margin: 0 auto;
-  padding: 2rem;
-
-  font-weight: normal;
-}
-
+<style scoped>
 header {
   line-height: 1.5;
 }
@@ -37,45 +27,21 @@ header {
   margin: 0 auto 2rem;
 }
 
-a,
-.green {
-  text-decoration: none;
-  color: hsla(160, 100%, 37%, 1);
-  transition: 0.4s;
-}
-
-@media (hover: hover) {
-  a:hover {
-    background-color: hsla(160, 100%, 37%, 0.2);
-  }
-}
-
 @media (min-width: 1024px) {
-  body {
-    display: flex;
-    place-items: center;
-  }
-
-  #app {
-    display: grid;
-    grid-template-columns: 1fr 1fr;
-    padding: 0 2rem;
-  }
-
   header {
     display: flex;
     place-items: center;
     padding-right: calc(var(--section-gap) / 2);
   }
 
+  .logo {
+    margin: 0 2rem 0 0;
+  }
+
   header .wrapper {
     display: flex;
     place-items: flex-start;
     flex-wrap: wrap;
   }
-
-  .logo {
-    margin: 0 2rem 0 0;
-  }
 }
 </style>
index 460e5b290e74468e38e4034085a6656876fde52e..3ebaac9178452fa493e18c9531814510ed4584fb 100644 (file)
@@ -20,17 +20,7 @@ import HelloWorld from '@/components/HelloWorld.vue'
   <RouterView />
 </template>
 
-<style>
-@import '@/assets/base.css';
-
-#app {
-  max-width: 1280px;
-  margin: 0 auto;
-  padding: 2rem;
-
-  font-weight: normal;
-}
-
+<style scoped>
 header {
   line-height: 1.5;
   max-height: 100vh;
@@ -41,19 +31,6 @@ header {
   margin: 0 auto 2rem;
 }
 
-a,
-.green {
-  text-decoration: none;
-  color: hsla(160, 100%, 37%, 1);
-  transition: 0.4s;
-}
-
-@media (hover: hover) {
-  a:hover {
-    background-color: hsla(160, 100%, 37%, 0.2);
-  }
-}
-
 nav {
   width: 100%;
   font-size: 12px;
@@ -80,33 +57,22 @@ nav a:first-of-type {
 }
 
 @media (min-width: 1024px) {
-  body {
-    display: flex;
-    place-items: center;
-  }
-
-  #app {
-    display: grid;
-    grid-template-columns: 1fr 1fr;
-    padding: 0 2rem;
-  }
-
   header {
     display: flex;
     place-items: center;
     padding-right: calc(var(--section-gap) / 2);
   }
 
+  .logo {
+    margin: 0 2rem 0 0;
+  }
+
   header .wrapper {
     display: flex;
     place-items: flex-start;
     flex-wrap: wrap;
   }
 
-  .logo {
-    margin: 0 2rem 0 0;
-  }
-
   nav {
     text-align: left;
     margin-left: -1rem;
index d91eefc43298580190dd4bd28b96ae9009c540e2..d05208d6ae3d0f1f04e9540501aa7299d923ca4c 100644 (file)
@@ -17,17 +17,7 @@ import TheWelcome from './components/TheWelcome.vue'
   </main>
 </template>
 
-<style>
-@import './assets/base.css';
-
-#app {
-  max-width: 1280px;
-  margin: 0 auto;
-  padding: 2rem;
-
-  font-weight: normal;
-}
-
+<style scoped>
 header {
   line-height: 1.5;
 }
@@ -37,45 +27,21 @@ header {
   margin: 0 auto 2rem;
 }
 
-a,
-.green {
-  text-decoration: none;
-  color: hsla(160, 100%, 37%, 1);
-  transition: 0.4s;
-}
-
-@media (hover: hover) {
-  a:hover {
-    background-color: hsla(160, 100%, 37%, 0.2);
-  }
-}
-
 @media (min-width: 1024px) {
-  body {
-    display: flex;
-    place-items: center;
-  }
-
-  #app {
-    display: grid;
-    grid-template-columns: 1fr 1fr;
-    padding: 0 2rem;
-  }
-
   header {
     display: flex;
     place-items: center;
     padding-right: calc(var(--section-gap) / 2);
   }
 
+  .logo {
+    margin: 0 2rem 0 0;
+  }
+
   header .wrapper {
     display: flex;
     place-items: flex-start;
     flex-wrap: wrap;
   }
-
-  .logo {
-    margin: 0 2rem 0 0;
-  }
 }
 </style>
index 7de68e9bbccd808779979ee0dfeeb8b0016b0d51..ebf59d59e367ca72e35a3b811e08b2ffd0358acc 100644 (file)
@@ -20,17 +20,7 @@ import HelloWorld from '@/components/HelloWorld.vue'
   <RouterView />
 </template>
 
-<style>
-@import '@/assets/base.css';
-
-#app {
-  max-width: 1280px;
-  margin: 0 auto;
-  padding: 2rem;
-
-  font-weight: normal;
-}
-
+<style scoped>
 header {
   line-height: 1.5;
   max-height: 100vh;
@@ -41,19 +31,6 @@ header {
   margin: 0 auto 2rem;
 }
 
-a,
-.green {
-  text-decoration: none;
-  color: hsla(160, 100%, 37%, 1);
-  transition: 0.4s;
-}
-
-@media (hover: hover) {
-  a:hover {
-    background-color: hsla(160, 100%, 37%, 0.2);
-  }
-}
-
 nav {
   width: 100%;
   font-size: 12px;
@@ -80,33 +57,22 @@ nav a:first-of-type {
 }
 
 @media (min-width: 1024px) {
-  body {
-    display: flex;
-    place-items: center;
-  }
-
-  #app {
-    display: grid;
-    grid-template-columns: 1fr 1fr;
-    padding: 0 2rem;
-  }
-
   header {
     display: flex;
     place-items: center;
     padding-right: calc(var(--section-gap) / 2);
   }
 
+  .logo {
+    margin: 0 2rem 0 0;
+  }
+
   header .wrapper {
     display: flex;
     place-items: flex-start;
     flex-wrap: wrap;
   }
 
-  .logo {
-    margin: 0 2rem 0 0;
-  }
-
   nav {
     text-align: left;
     margin-left: -1rem;
index 01433bca2ac76590c48fabfee8d69d7b223f48bb..90e6400b4d8ad8aba0c1caa53874eb4b81380648 100644 (file)
@@ -1,4 +1,6 @@
 import { createApp } from 'vue'
 import App from './App.vue'
 
+import './assets/main.css'
+
 createApp(App).mount('#app')
index 5f77a8911f244df66962baf136f53475149b37f4..8b9d201b6984e782ed64854b7f80a6d595099469 100644 (file)
@@ -2,6 +2,8 @@ import { createApp } from 'vue'
 import { createPinia } from 'pinia'
 import App from './App.vue'
 
+import './assets/main.css'
+
 const app = createApp(App)
 
 app.use(createPinia())
index fda1e6e3e6dc4f11e7f23d3e187d4d541276940f..4fb24b7e0e9bae1121b31644f14a63ea8aec98da 100644 (file)
@@ -4,6 +4,8 @@ import { createPinia } from 'pinia'
 import App from './App.vue'
 import router from './router'
 
+import './assets/main.css'
+
 const app = createApp(App)
 
 app.use(createPinia())
index c8e37b03b9c2289ea08f80feeca1880e2abc3a86..eedade80bfb8466db3eba40502ec70f5cd16d257 100644 (file)
@@ -2,6 +2,8 @@ import { createApp } from 'vue'
 import App from './App.vue'
 import router from './router'
 
+import './assets/main.css'
+
 const app = createApp(App)
 
 app.use(router)