Skip to content

Commit 723421a

Browse files
authored
Merge pull request #3 from mirisuzanne/fix-modes
Fix broken HTML modes
2 parents 6a74034 + f5ed4f2 commit 723421a

File tree

16 files changed

+210
-132
lines changed

16 files changed

+210
-132
lines changed

.sassdocrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ groups:
1010
Getting Started:
1111
import: Import CSS or Sass
1212
config: Global Settings
13+
fallbacks: Fallback Colors & Modes
14+
modes: Dynamic Modes
1315
'Sass (optional)':
1416
palettes: Color Palettes
1517
tools: Additional Tools

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# Changelog
22

3+
## 0.1.0-beta.10 - 2019/12/5
4+
5+
- BUGFIX: Source & cascade order was causing HTML modes to fail
6+
- BREAKING: Rename `--ccs-mode--invert` to `--ccs-invert`,
7+
and `--ccs-mode--invert-zero` to `--ccs-invert--zero`
8+
- BREAKING: Remove `prefers-color-scheme` media-query from fallback colors,
9+
since more browsers support variables than color-scheme queries
10+
- DOCS: Added documentation of fallback and mode settings
11+
312
## 0.1.0-beta.9 - 2019/11/29
413

5-
- NEW: `--ccs-mode--zero` and `--ccs-mode--invert-zero`
14+
- NEW: `--ccs-mode--zero` and `--ccs-invert--zero`
615
provide mode values of `0` (dark) or `1` (light),
716
rather than `-1` (dark) and `1` (light)
817
- NEW: `if-mode($light, $dark)` function returns a CSS `calc()` toggle

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ to generate a larger palette:
148148
- `--ccs-mode`:
149149
the calculated light (`1`) or dark (`-1`) mode
150150
(user, theme, html, or system preference)
151-
- `--ccs-mode--invert` the opposite of CCS-mode
151+
- `--ccs-invert` the opposite of CCS-mode
152152

153153
You can pass explicit light/dark mode overrides in html
154154
by including a value with the attribute:

css/ccs.css

Lines changed: 33 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/ccs.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ <h2 data-ccs-colors="invert">accent</h2>
104104
<h2 data-ccs-colors="invert">neutral</h2>
105105
<div style="--show: var(--neutral-gradient), var(--neutral-gradient--fade)"></div>
106106
</section>
107+
108+
<ul class="modes" role="presentation">
109+
<li data-ccs-colors="light">light</li>
110+
<li data-ccs-colors="invert">"invert"</li>
111+
<li data-ccs-colors="dark">dark</li>
112+
</ul>
107113
</main>
108114

109115
<footer>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cascading-color-systems",
3-
"version": "0.1.0-beta.9",
3+
"version": "0.1.0-beta.10",
44
"description": "generate dynamic color palettes with custom properties",
55
"main": "dist.js",
66
"module": "index.js",

sass/partials/_colors.scss

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// initial lightness values
1414
--ccs-l--user-percent: calc(var(--ccs-l--user) * 1%);
1515
--ccs-l: var(--ccs-l--user-percent, var(--ccs-l--theme, var(--ccs-lightness--config, 50%)));
16-
--ccs-l--fg-contrast: calc(var(--ccs-l) + var(--ccs-contrast) * var(--ccs-mode--invert));
16+
--ccs-l--fg-contrast: calc(var(--ccs-l) + var(--ccs-contrast) * var(--ccs-invert));
1717
--ccs-l--bg-contrast: calc(var(--ccs-l) + var(--ccs-contrast) * var(--ccs-mode));
1818

1919
// initial saturation values
@@ -24,16 +24,9 @@
2424
--ccs-s--bg-contrast: calc(var(--ccs-s--fg-contrast) - var(--ccs-fade-background));
2525
--ccs-s--neutral: var(--ccs-s-neutral--theme, var(--ccs-s-neutral--config, var(--ccs-s--bg-contrast)));
2626

27-
// final mode calculations
28-
--ccs-mode--cascade: var(--ccs-mode--user, var(--ccs-mode--html, var(--ccs-mode--os, 1)));
29-
--ccs-mode: var(--ccs-mode--cascade, 1);
30-
--ccs-mode--zero: calc((var(--ccs-mode) + 1) * 0.5);
31-
--ccs-mode--invert: calc(-1 * var(--ccs-mode));
32-
--ccs-mode--invert-zero: calc((var(--ccs-mode--invert) + 1) * 0.5);
33-
3427
// full contrast colors, foreground and background
3528
--ccs--bg-full: hsl(0, 0%, calc(100% * var(--ccs-mode)));
36-
--ccs--fg-full: hsl(0, 0%, calc(100% * var(--ccs-mode--invert)));
29+
--ccs--fg-full: hsl(0, 0%, calc(100% * var(--ccs-invert)));
3730

3831
@each $color in ('prime', 'accent', 'neutral') {
3932
$s: if($color == 'neutral', '--neutral', null);

sass/partials/_fallbacks.scss

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@use '../config';
2+
3+
/// # Fallback Colors & Modes
4+
/// fallback values, in case variables are not supported.
5+
/// Since variables have better support than `prefers-color-scheme`,
6+
/// there is no need for a media-query in the fallback modes.
7+
/// @group fallbacks
8+
9+
/// The default is a "light" background theme,
10+
/// which can also be called explicitly.
11+
/// @name light modes
12+
/// @group fallbacks
13+
[data-ccs-colors],
14+
[data-ccs-colors='light'] {
15+
background-color: config.$fallback-light;
16+
color: config.$fallback-dark;
17+
}
18+
19+
/// "Dark" background and "invert" modes
20+
/// reverse the default colors.
21+
/// Since dynamic inversion would increase specificity,
22+
/// the fallback for "invert" has to be static.
23+
/// @name dark modes
24+
/// @group fallbacks
25+
[data-ccs-colors='invert'],
26+
[data-ccs-colors='dark'] {
27+
background-color: config.$fallback-dark;
28+
color: config.$fallback-light;
29+
}

sass/partials/_index.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
// setup
66
@forward 'root';
7-
@forward 'modes';
7+
@forward 'fallbacks';
88
@forward 'colors';
9+
@forward 'modes';
910
@forward 'themes';
1011

1112
// build

0 commit comments

Comments
 (0)