Skip to content

Commit 722550f

Browse files
author
QRaimbault
committed
🏗 Change style architecture
1 parent cb132d0 commit 722550f

File tree

15 files changed

+33
-32
lines changed

15 files changed

+33
-32
lines changed

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
A lightweight Vue.js starter.
2222

23+
**YOU CAN READ THIS DOC IN A MORE FRIENDLY WAY [HERE](https://qraimbault.github.io/vue-js-starter-scss/#/).**
24+
2325
- [Vue.JS Starter](#vuejs-starter)
2426
- [Summary](#summary)
2527
- [Built-in modules](#built-in-modules)
@@ -135,13 +137,8 @@ The store is accessible from any component/view using `this.$store`.
135137

136138
## Style
137139

138-
All your style should be located in the `src/scss` directory.
139-
140-
There is 3 sub-directories:
141-
142-
- `global` for your reset, mixins, variables, functions.
143-
- `views` for your view specific styles.
144-
- `components` for your components specific styles.
140+
All you view/component specific styles should be placed in a file named exactly like the component, in the same directory.
141+
You can place project-specific style in `src/scss` and import it from the component specific styles (see example in `src/components/Index).
145142

146143
You should import styles in the `<script>` tag in each component.
147144

@@ -192,9 +189,8 @@ Webpack allows to put some aliases in the webpack config, so you can have shorte
192189
- `@API` pointing to `src/helpers/API.js`, so directly to the configured Axios instance
193190
- `@Config` pointing to `src/config.js`
194191
- `@Component` pointing to `src/components`
195-
- `@ComponentStyle` pointing to `src/scss/components`
196192
- `@View` pointing to `src/views`
197-
- `@ViewStyle` pointing to `src/scss/views`
193+
- `@MasterStyle` pointing to `src/scss/master.scss`
198194
- `@Asset` pointing to `src/assets`
199195
- `@` pointing to `src`
200196

docs/README.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
A lightweight Vue.js starter.
2222

23-
**YOU CAN READ THIS DOC IN A MORE FRIENDLY WAY [HERE](https://qraimbault.github.io/vue-js-starter-scss/#/).**
24-
2523
- [Vue.JS Starter](#vuejs-starter)
2624
- [Summary](#summary)
2725
- [Built-in modules](#built-in-modules)
@@ -137,13 +135,8 @@ The store is accessible from any component/view using `this.$store`.
137135

138136
## Style
139137

140-
All your style should be located in the `src/scss` directory.
141-
142-
There is 3 sub-directories:
143-
144-
- `global` for your reset, mixins, variables, functions.
145-
- `views` for your view specific styles.
146-
- `components` for your components specific styles.
138+
All you view/component specific styles should be placed in a file named exactly like the component, in the same directory.
139+
You can place project-specific style in `src/scss` and import it from the component specific styles (see example in `src/components/Index).
147140

148141
You should import styles in the `<script>` tag in each component.
149142

@@ -194,9 +187,8 @@ Webpack allows to put some aliases in the webpack config, so you can have shorte
194187
- `@API` pointing to `src/helpers/API.js`, so directly to the configured Axios instance
195188
- `@Config` pointing to `src/config.js`
196189
- `@Component` pointing to `src/components`
197-
- `@ComponentStyle` pointing to `src/scss/components`
198190
- `@View` pointing to `src/views`
199-
- `@ViewStyle` pointing to `src/scss/views`
191+
- `@MasterStyle` pointing to `src/scss/master.scss`
200192
- `@Asset` pointing to `src/assets`
201193
- `@` pointing to `src`
202194

jsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"@Config": ["src/config.js"],
88
"@Component/*": ["src/components/*"],
99
"@View/*": ["src/views/*"],
10-
"@ViewStyle/*": ["src/scss/views/*"],
11-
"@ComponentStyle/*": ["src/scss/components/*"],
10+
"@MasterStyle": ["src/scss/master.scss"],
1211
"@Asset/*": ["src/assets/*"],
1312
"@/*": ["src/*"]
1413
}

src/components/Index/Articles.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@import "@MasterStyle";
2+
3+
.list {
4+
&__title {
5+
color: $article-title-color;
6+
}
7+
8+
&__content {
9+
color: $article-content-color;
10+
}
11+
}

src/components/Index/__tests__/Articles.spec.js renamed to src/components/Index/Articles.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { shallow } from 'vue-test-utils'
2-
import Articles from '../Articles.vue';
2+
import Articles from 'Articles.vue';
33

44
describe('Articles.vue', () => {
55
const articles = [
@@ -9,7 +9,7 @@ describe('Articles.vue', () => {
99
},
1010
{
1111
title: 'test2',
12-
body: 'test fz content'
12+
body: 'test content'
1313
}];
1414
it('Displays Title', () => {
1515
const wrapper = shallow(Articles, {

src/components/Index/Articles.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
<template>
2-
<div class="article">
3-
<ul>
2+
<div>
3+
<ul class="list">
44
<li
55
v-for="(article, index) in articles"
66
:key="index">
7-
<h2>{{ article.title }}</h2>
8-
<p>{{ article.body }}</p>
7+
<h2 class="list__title">{{ article.title }}</h2>
8+
<p class="list__content">{{ article.body }}</p>
99
</li>
1010
</ul>
1111
</div>
1212
</template>
1313

1414
<script>
15+
import "./Articles.scss";
16+
1517
export default {
1618
name: "Articles",
1719
props: {

src/scss/components/.gitignore

Whitespace-only changes.

0 commit comments

Comments
 (0)