Skip to content

Commit ce49ec9

Browse files
committed
feat: add ns-c-mixin
lets you bind a theme to arbitrary elements
1 parent 41738ac commit ce49ec9

3 files changed

Lines changed: 44 additions & 7 deletions

File tree

docs/colors.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,27 @@ which contains values for these options which might go well together in a monoch
8989

9090
To apply the theme to a element you simply add the `neversink-{name}-scheme` class to the element and then add another class which binds the CSS vars as you like.
9191

92+
There is one built-in one called `.ns-c-mixin` which applies the color to the background, text, and border of the element. It's definition looks like this:
93+
94+
```css
95+
.ns-c-mixin {
96+
background-color: var(--neversink-bg-color);
97+
color: var(--neversink-text-color);
98+
border-color: var(--neversink-border-color);
99+
}
100+
```
101+
92102
For example, to apply the `red` scheme from above to a `div` element you would add the following classes:
93103

94104
```html
95-
<div class="neversink-red-scheme colorbinding">This is a red div</div>
105+
<div class="neversink-red-scheme ns-c-mixin">This is a red div</div>
96106
```
97107

98-
and then define the color binding class
108+
You can also define you own custom binding classes if you want to map the colors from the theme in a different way. For example, you could define a class like this:
99109

100110
```css
101-
.colorbinding {
102-
background-color: var(--neversink-bg-color);
103-
color: var(--neversink-text-color);
104-
border-color: var(--neversink-border-color);
111+
.mymixin {
112+
background-color: var(--neversink-text-color);
105113
}
106114
```
107115

docs/styling.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,30 @@ In addition to the main color [schemes](/colors) there are some additional short
2020
| `ns-c-COLOR-scheme` | `neversink-COLOR-scheme` |
2121
| `ns-c-COLOR-lt-scheme` | `neversink-COLOR-light-scheme` |
2222

23-
where color can be any of the [colors](/colors) in the project.
23+
where color is the **first two letters** of the [colors](/colors) in the project (e.g., `ns-c-pi-scheme` for `neversink-pink-scheme`).
24+
25+
## Color mixin
26+
27+
When you want to apply a theme color to an element on a page you can use the
28+
`ns-c-mixin` class. This will apply the color to the text and the background.
29+
30+
It has a definition like this:
31+
32+
```css
33+
.ns-c-mixin {
34+
background-color: var(--neversink-bg-color);
35+
color: var(--neversink-text-color);
36+
border-color: var(--neversink-border-color);
37+
}
38+
```
39+
40+
so to bind the color to a `div` element you can do this:
41+
42+
```md
43+
<div class="ns-c-mixin ns-c-sk-scheme">
44+
This is a with the `ns-c-sk-scheme` (i.e., `neversink-sky-scheme`) color applied.
45+
</div>
46+
```
2447

2548
## Tight bullets
2649

styles/neversink-c.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,9 @@
153153
opacity: 0.3;
154154
pointer-events: none;
155155
}
156+
157+
.ns-c-mixin {
158+
background-color: var(--neversink-bg-color);
159+
color: var(--neversink-text-color);
160+
border-color: var(--neversink-border-color);
161+
}

0 commit comments

Comments
 (0)