Skip to content

Commit 5749a70

Browse files
authored
Merge pull request #808 from mpourismaiel/docs/postcss/create
Document postcss configurations and remove purgecss
2 parents 323cdcf + 400b839 commit 5749a70

File tree

9 files changed

+92
-137
lines changed

9 files changed

+92
-137
lines changed

exampleSite/config-dev.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ CanonifyURLs = true
1515
# Google Analytics tracking
1616
googleAnalytics = ""
1717

18-
[build]
19-
writeStats = true
20-
2118
[outputs]
2219
home = ["HTML", "JSON"]
2320

exampleSite/content/docs/global-variables/content.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Set the background of the fragment.
2828
Background also affects the text color of the fragment's content.
2929
For the background colors of `white`, `light`, `secondary` and `primary` we use Bootstrap's `text_dark` class on content and for other backgrounds, we use `text_light`.
3030

31-
List of all supported colors can be found in [supported colors]({{< ref "supported-colors" >}}) section of the docs.
31+
List of all supported colors can be found in [supported colors]({{< ref "styling" >}}#supported-colors) section of the docs.
3232

3333
#### title
3434
*type: string*
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
+++
2+
fragment = "content"
3+
weight = 100
4+
5+
title = "Supported Colors"
6+
7+
[sidebar]
8+
sticky = true
9+
+++
10+
11+
### Supported Colors
12+
13+
Fragments and various elements can be customized further using Bootstrap color classes.
14+
These colors are customized within `config.toml` to fit the Syna theme.
15+
16+
| class | colors |
17+
| --------- | ------- |
18+
| primary | #00838F |
19+
| secondary | #868e96 |
20+
| success | #008f54 |
21+
| info | #00838F |
22+
| warning | #fdf314 |
23+
| danger | #dc1200 |
24+
| light | #f8f9fa |
25+
| dark | #343a40 |
26+
27+
In order to change the primary color, you can update the primary color within your `config.toml` file:
28+
29+
```toml
30+
[params]
31+
[params.colors]
32+
primary = "#00838F"
33+
```
34+
35+
Please note that `colors` is under `params` section of your configuration.
36+
37+
These colors are mainly used for backgrounds and button colors.
38+
By changing the colors, all fragment colors and backgrounds will be changed to the new colors. Links, inline code and other elements will also be changed.
39+
These colors can also be overwritten for more details see our [style documentation]({{< ref "development" >}}#styles).
40+
41+
**Important:** These colors define the color scheme that Bootstrap uses. As you update them, be careful to keep the contrast between different colors. Since it's not possible to recognize the contrast of colors within Syna, we rely on the names of colors when setting different text colors for different backgrounds. So if you change the `primary` color to a darker color, text colors will still use the `text-body` class from Bootstrap which is a dark color and may result in unreadable text.
42+
43+
### PostCSS
44+
45+
PostCSS is enabled by default and will look for its configuration file when Hugo is building your website. You can add your configuration to `postcss.config.js` at the root of your project. Here are some recommended configurations. Please note that you can combine these configurations and use them together.
46+
47+
#### Removing unused CSS
48+
49+
We recommend using `@fullhuman/postcss-purgecss` along PostCSS to remove unused CSS from your website. PurgeCSS will drastically reduce the size of your website. Since we use Bootstrap to develop our built-in fragments, the final CSS bundle is mostly Bootstrap code that goes unused. To remove the unused parts, please run:
50+
51+
- `npm install @fullhuman/postcss-purgecss` or `yarn add @fullhuman/postcss-purgecss`
52+
- Add the following code to `<root-directory>/postcss.config.js`:
53+
54+
```javascript
55+
const purgecss = require('@fullhuman/postcss-purgecss')({
56+
content: ['./hugo_stats.json'],
57+
defaultExtractor: (content) => {
58+
let els = JSON.parse(content).htmlElements;
59+
return els.tags.concat(els.classes, els.ids, [
60+
'active',
61+
'show',
62+
'in',
63+
]);
64+
},
65+
});
66+
67+
module.exports = {
68+
plugins: [
69+
...(process.env.HUGO_ENVIRONMENT === 'production' ? [purgecss] : []),
70+
],
71+
};
72+
```
73+
74+
### RTL stylesheet
75+
76+
Syna is created for LTR languages but changing the theme to accommodate RTL languages is quite easy. In order to change the direction of the stylesheet, please run the following command:
77+
78+
- `npm install rtlcss` or `yarn add rtlcss`
79+
- Add the following code to `<root-directory>/postcss.config.js`:
80+
81+
```javascript
82+
module.exports = {
83+
plugins: [
84+
require('rtlcss')()
85+
]
86+
}
87+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
+++
2+
title = "Styling"
3+
weight = 40
4+
+++

exampleSite/content/docs/supported-colors/content.md

Lines changed: 0 additions & 39 deletions
This file was deleted.

exampleSite/content/docs/supported-colors/index.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

exampleSite/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"webpack-cli": "^3.0.8"
2626
},
2727
"dependencies": {
28-
"@fullhuman/postcss-purgecss": "^2.3.0",
2928
"react": "^16.4.1",
3029
"react-dom": "^16.4.1"
3130
}

exampleSite/postcss.config.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

exampleSite/yarn.lock

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
# yarn lockfile v1
33

44

5-
"@fullhuman/postcss-purgecss@^2.3.0":
6-
version "2.3.0"
7-
resolved "https://registry.yarnpkg.com/@fullhuman/postcss-purgecss/-/postcss-purgecss-2.3.0.tgz#50a954757ec78696615d3e118e3fee2d9291882e"
8-
integrity sha512-qnKm5dIOyPGJ70kPZ5jiz0I9foVOic0j+cOzNDoo8KoCf6HjicIZ99UfO2OmE7vCYSKAAepEwJtNzpiiZAh9xw==
9-
dependencies:
10-
postcss "7.0.32"
11-
purgecss "^2.3.0"
12-
135
"@webassemblyjs/ast@1.5.13":
146
version "1.5.13"
157
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.5.13.tgz#81155a570bd5803a30ec31436bc2c9c0ede38f25"
@@ -1106,15 +1098,6 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.2, chalk@^2.4.1:
11061098
escape-string-regexp "^1.0.5"
11071099
supports-color "^5.3.0"
11081100

1109-
chalk@^2.4.2:
1110-
version "2.4.2"
1111-
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
1112-
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
1113-
dependencies:
1114-
ansi-styles "^3.2.1"
1115-
escape-string-regexp "^1.0.5"
1116-
supports-color "^5.3.0"
1117-
11181101
chardet@^0.5.0:
11191102
version "0.5.0"
11201103
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.5.0.tgz#fe3ac73c00c3d865ffcc02a0682e2c20b6a06029"
@@ -1230,11 +1213,6 @@ combined-stream@1.0.6, combined-stream@^1.0.5, combined-stream@~1.0.5:
12301213
dependencies:
12311214
delayed-stream "~1.0.0"
12321215

1233-
commander@^5.0.0:
1234-
version "5.1.0"
1235-
resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae"
1236-
integrity sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==
1237-
12381216
commander@~2.13.0:
12391217
version "2.13.0"
12401218
resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c"
@@ -1409,11 +1387,6 @@ cssesc@^0.1.0:
14091387
version "0.1.0"
14101388
resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-0.1.0.tgz#c814903e45623371a0477b40109aaafbeeaddbb4"
14111389

1412-
cssesc@^3.0.0:
1413-
version "3.0.0"
1414-
resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee"
1415-
integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==
1416-
14171390
currently-unhandled@^0.4.1:
14181391
version "0.4.1"
14191392
resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea"
@@ -2173,11 +2146,6 @@ indent-string@^2.1.0:
21732146
dependencies:
21742147
repeating "^2.0.0"
21752148

2176-
indexes-of@^1.0.1:
2177-
version "1.0.1"
2178-
resolved "https://registry.yarnpkg.com/indexes-of/-/indexes-of-1.0.1.tgz#f30f716c8e2bd346c7b67d3df3915566a7c05607"
2179-
integrity sha1-8w9xbI4r00bHtn0985FVZqfAVgc=
2180-
21812149
indexof@0.0.1:
21822150
version "0.0.1"
21832151
resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d"
@@ -3216,28 +3184,10 @@ postcss-modules-values@^1.3.0:
32163184
icss-replace-symbols "^1.1.0"
32173185
postcss "^6.0.1"
32183186

3219-
postcss-selector-parser@^6.0.2:
3220-
version "6.0.2"
3221-
resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.2.tgz#934cf799d016c83411859e09dcecade01286ec5c"
3222-
integrity sha512-36P2QR59jDTOAiIkqEprfJDsoNrvwFei3eCqKd1Y0tUsBimsq39BLp7RD+JWny3WgB1zGhJX8XVePwm9k4wdBg==
3223-
dependencies:
3224-
cssesc "^3.0.0"
3225-
indexes-of "^1.0.1"
3226-
uniq "^1.0.1"
3227-
32283187
postcss-value-parser@^3.3.0:
32293188
version "3.3.0"
32303189
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-3.3.0.tgz#87f38f9f18f774a4ab4c8a232f5c5ce8872a9d15"
32313190

3232-
postcss@7.0.32:
3233-
version "7.0.32"
3234-
resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.32.tgz#4310d6ee347053da3433db2be492883d62cec59d"
3235-
integrity sha512-03eXong5NLnNCD05xscnGKGDZ98CyzoqPSMjOe6SuoQY7Z2hIj0Ld1g/O/UQRuOle2aRtiIRDg9tDcTGAkLfKw==
3236-
dependencies:
3237-
chalk "^2.4.2"
3238-
source-map "^0.6.1"
3239-
supports-color "^6.1.0"
3240-
32413191
postcss@^6.0.1, postcss@^6.0.23:
32423192
version "6.0.23"
32433193
resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.23.tgz#61c82cc328ac60e677645f979054eb98bc0e3324"
@@ -3320,16 +3270,6 @@ punycode@^2.1.0:
33203270
version "2.1.1"
33213271
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
33223272

3323-
purgecss@^2.3.0:
3324-
version "2.3.0"
3325-
resolved "https://registry.yarnpkg.com/purgecss/-/purgecss-2.3.0.tgz#5327587abf5795e6541517af8b190a6fb5488bb3"
3326-
integrity sha512-BE5CROfVGsx2XIhxGuZAT7rTH9lLeQx/6M0P7DTXQH4IUc3BBzs9JUzt4yzGf3JrH9enkeq6YJBe9CTtkm1WmQ==
3327-
dependencies:
3328-
commander "^5.0.0"
3329-
glob "^7.0.0"
3330-
postcss "7.0.32"
3331-
postcss-selector-parser "^6.0.2"
3332-
33333273
qs@~6.4.0:
33343274
version "6.4.0"
33353275
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"
@@ -3979,13 +3919,6 @@ supports-color@^5.3.0, supports-color@^5.4.0:
39793919
dependencies:
39803920
has-flag "^3.0.0"
39813921

3982-
supports-color@^6.1.0:
3983-
version "6.1.0"
3984-
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3"
3985-
integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==
3986-
dependencies:
3987-
has-flag "^3.0.0"
3988-
39893922
tapable@^1.0.0:
39903923
version "1.0.0"
39913924
resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.0.0.tgz#cbb639d9002eed9c6b5975eb20598d7936f1f9f2"
@@ -4142,11 +4075,6 @@ union-value@^1.0.0:
41424075
is-extendable "^0.1.1"
41434076
set-value "^0.4.3"
41444077

4145-
uniq@^1.0.1:
4146-
version "1.0.1"
4147-
resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff"
4148-
integrity sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=
4149-
41504078
unique-filename@^1.1.0:
41514079
version "1.1.0"
41524080
resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-1.1.0.tgz#d05f2fe4032560871f30e93cbe735eea201514f3"

0 commit comments

Comments
 (0)