Skip to content

Commit d3d8ae5

Browse files
authored
css: Add CSS variables for better organization and flexibility (#1001)
Closes #655
1 parent eb35b17 commit d3d8ae5

2 files changed

Lines changed: 72 additions & 39 deletions

File tree

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ New Features
99

1010
- Add Catalan localisation (`#966`_, welpo)
1111
- Make <code class="language-$lang"> for syntax highlighting (`#998`_, pkvach)
12+
- Add CSS variables for better organization and flexibility (`#1001`_, pkvach)
1213

1314
.. _#966: https://github.com/posativ/isso/pull/966
1415
.. _#998: https://github.com/isso-comments/isso/pull/998
16+
.. _#1001: https://github.com/isso-comments/isso/pull/1001
1517

1618
Breaking Changes
1719
^^^^^^^^^^^^^^^^

isso/css/isso.css

Lines changed: 70 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1+
:root {
2+
--isso-primary-text-color: #555;
3+
--isso-secondary-text-color: #808080;
4+
5+
--isso-border: 1px solid rgba(0, 0, 0, 0.2);
6+
--isso-box-shadow-color: rgba(0, 0, 0, 0.1);
7+
--isso-hover-color: #606060;
8+
9+
--isso-link-hover-color: #111;
10+
--isso-link-text-shadow-color: #aaa;
11+
12+
--isso-input-background-color: #fff;
13+
--isso-input-outline-color: #3584e4;
14+
15+
--isso-button-background-color: #ddd;
16+
--isso-button-border: 1px solid #ccc;
17+
--isso-button-hover-background-color: #ccc;
18+
--isso-button-active-background-color: #bbb;
19+
20+
--isso-preview-border-color: #f0f0f0;
21+
--isso-preview-box-shadow-color: #888;
22+
--isso-preview-background: repeating-linear-gradient(
23+
-45deg,
24+
#f8f8f8,
25+
#f8f8f8 10px,
26+
#fff 10px,
27+
#fff 20px
28+
);
29+
30+
--isso-pre-color: #4d4d4c;
31+
--isso-pre-background-color: #eee;
32+
--isso-pre-border-color: #ddd;
33+
34+
--isso-comment-divider-color: rgba(0, 0, 0, 0.1);
35+
--isso-page-author-suffix-color: #2c2c2c;
36+
--isso-target-fade-background-color: #eee5a1;
37+
}
38+
139
/* ========================================================================== */
240
/* Generic styling */
341
/* ========================================================================== */
@@ -16,7 +54,7 @@
1654
margin: 0;
1755
}
1856
h4.isso-thread-heading {
19-
color: #555;
57+
color: var(--isso-primary-text-color);
2058
font-weight: bold;
2159
}
2260
.isso-feedlink {
@@ -42,7 +80,7 @@ h4.isso-thread-heading {
4280
}
4381
.isso-comment:not(:first-of-type),
4482
.isso-follow-up .isso-comment {
45-
border-top: 1px solid rgba(0, 0, 0, 0.1);
83+
border-top: 1px solid var(--isso-comment-divider-color);
4684
margin-bottom: 0.5em;
4785
}
4886
.isso-avatar {
@@ -55,9 +93,9 @@ h4.isso-thread-heading {
5593
max-height: 48px;
5694
width: 100%;
5795
height: 100%;
58-
border: 1px solid rgba(0, 0, 0, 0.2);
96+
border: var(--isso-border);
5997
border-radius: 3px;
60-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
98+
box-shadow: 0 1px 2px var(--isso-box-shadow-color);
6199
}
62100
.isso-text-wrapper {
63101
display: block;
@@ -83,34 +121,34 @@ h4.isso-thread-heading {
83121
.isso-permalink,
84122
.isso-note,
85123
.isso-parent {
86-
color: gray;
124+
color: var(--isso-secondary-text-color);
87125
font-weight: normal;
88126
text-shadow: none;
89127
}
90128
.isso-spacer:hover,
91129
.isso-permalink:hover,
92130
.isso-note:hover,
93131
.isso-parent:hover {
94-
color: #606060;
132+
color: var(--isso-hover-color);
95133
}
96134
.isso-note {
97135
float: right;
98136
}
99137
.isso-author {
100138
font-weight: bold;
101-
color: #555;
139+
color: var(--isso-primary-text-color);
102140
}
103141
.isso-page-author-suffix {
104142
font-weight: bold;
105-
color: #2c2c2c;
143+
color: var(--isso-page-author-suffix-color);
106144
}
107145
.isso-textarea,
108146
.isso-preview {
109147
margin-top: 0.2em;
110148
width: 100%;
111-
border: 1px solid #f0f0f0;
149+
border: 1px solid var(--isso-preview-border-color);
112150
border-radius: 2px;
113-
box-shadow: 0 0 2px #888;
151+
box-shadow: 0 0 2px var(--isso-box-shadow-color);
114152
}
115153
.isso-text {
116154
word-break: break-word;
@@ -131,23 +169,23 @@ h4.isso-thread-heading {
131169
font-weight: bold;
132170
}
133171
.isso-text pre {
134-
background: #eee;
135-
border: 1px solid #ddd;
172+
background: var(--isso-pre-background-color);
173+
border: 1px solid var(--isso-pre-border-color);
136174
padding: 10px 15px;
137-
color: #4d4d4c;
175+
color: var(--isso-pre-color);
138176
overflow: auto;
139177
line-height: 1.5em;
140178
}
141179
.isso-text :not(pre) > code {
142180
padding: .2em .4em;
143181
margin: 0;
144182
font-size: 85%;
145-
background-color: #eeeeee;
183+
background-color: var(--isso-pre-background-color);
146184
border-radius: 6px;
147185
}
148186
.isso-comment-footer {
149187
font-size: 0.80em;
150-
color: gray;
188+
color: var(--isso-secondary-text-color);
151189
clear: left;
152190
}
153191
.isso-feedlink,
@@ -157,8 +195,8 @@ h4.isso-thread-heading {
157195
}
158196
.isso-feedlink:hover,
159197
.isso-comment-footer a:hover {
160-
color: #111111;
161-
text-shadow: #aaaaaa 0 0 1px;
198+
color: var(--isso-link-hover-color);
199+
text-shadow: var(--isso-link-text-shadow-color) 0 0 1px;
162200
}
163201
.isso-comment-footer > a {
164202
position: relative;
@@ -168,7 +206,7 @@ h4.isso-thread-heading {
168206
padding-left: 1em;
169207
}
170208
.isso-comment-footer .isso-votes {
171-
color: gray;
209+
color: var(--isso-secondary-text-color);
172210
}
173211
.isso-upvote svg,
174212
.isso-downvote svg {
@@ -200,9 +238,9 @@ h4.isso-thread-heading {
200238
margin: 0 0 .3em;
201239
padding: .4em .8em;
202240
border-radius: 3px;
203-
background-color: #fff;
204-
border: 1px solid rgba(0, 0, 0, 0.2);
205-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
241+
background-color: var(--isso-input-background-color);
242+
border: var(--isso-border);
243+
box-shadow: 0 1px 2px var(--isso-box-shadow-color);
206244
}
207245
.isso-textarea {
208246
outline: 0;
@@ -227,7 +265,7 @@ h4.isso-thread-heading {
227265
.isso-textarea:focus,
228266
.isso-input-wrapper input:focus,
229267
.isso-auth-section input:focus {
230-
outline: 2px solid #3584e4;
268+
outline: 2px solid var(--isso-input-outline-color);
231269
}
232270
.isso-input-wrapper {
233271
display: inline-block;
@@ -239,10 +277,10 @@ h4.isso-thread-heading {
239277
padding: .3em 10px;
240278
max-width: 100%;
241279
border-radius: 3px;
242-
background-color: #fff;
280+
background-color: var(--isso-input-background-color);
243281
line-height: 1.4em;
244-
border: 1px solid rgba(0, 0, 0, 0.2);
245-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
282+
border: var(--isso-border);
283+
box-shadow: 0 1px 2px var(--isso-box-shadow-color);
246284
}
247285
.isso-input-wrapper label {
248286
display: block;
@@ -257,18 +295,18 @@ h4.isso-thread-heading {
257295
.isso-post-action > input {
258296
padding: calc(.3em - 1px);
259297
border-radius: 2px;
260-
border: 1px solid #ccc;
261-
background-color: #ddd;
298+
border: var(--isso-button-border);
299+
background-color: var(--isso-button-background-color);
262300
cursor: pointer;
263301
outline: 0;
264302
line-height: 1.4em;
265-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
303+
box-shadow: 0 1px 2px var(--isso-box-shadow-color);
266304
}
267305
.isso-post-action > input:hover {
268-
background-color: #ccc;
306+
background-color: var(--isso-button-hover-background-color);
269307
}
270308
.isso-post-action > input:active {
271-
background-color: #bbb;
309+
background-color: var(--isso-button-active-background-color);
272310
}
273311

274312
/* ========================================================================== */
@@ -287,14 +325,7 @@ h4.isso-thread-heading {
287325
display: inline;
288326
}
289327
.isso-preview {
290-
background-color: #f8f8f8;
291-
background: repeating-linear-gradient(
292-
-45deg,
293-
#f8f8f8,
294-
#f8f8f8 10px,
295-
#fff 10px,
296-
#fff 20px
297-
);
328+
background: var(--isso-preview-background);
298329
}
299330

300331
/* ========================================================================== */
@@ -308,7 +339,7 @@ h4.isso-thread-heading {
308339
animation: isso-target-fade 5s ease-out;
309340
}
310341
@keyframes isso-target-fade {
311-
0% { background-color: #eee5a1; }
342+
0% { background-color: var(--isso-target-fade-background-color); }
312343
/* This color should be changed when used on a dark background,
313344
* maybe #3f3c1c for example
314345
*/

0 commit comments

Comments
 (0)