@propellerads/tokens 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,229 @@
1
+ # @propellerads/tokens
2
+
3
+ Design tokens for the PropellerAds group's brands, as plain CSS. There is no build
4
+ step and no source format: the published files are the tokens.
5
+
6
+ ## Install
7
+
8
+ ```sh
9
+ bun add @propellerads/tokens
10
+ ```
11
+
12
+ ```js
13
+ import '@propellerads/tokens/common.css'
14
+ import '@propellerads/tokens/propellerads.css' // or monetag / propush / zeydoo
15
+ ```
16
+
17
+ Two files: the shared one and one brand. Both define variables on `:root`, they
18
+ define different names, and neither uses `@import` — so the order between them
19
+ does not matter.
20
+
21
+ `common.css` holds what every brand shares: shades, status accents, overlays, the
22
+ spacing and type scales, breakpoints and shadows. A brand file holds three things:
23
+ its palette, its action colour and its typeface.
24
+
25
+ ## What components read
26
+
27
+ Semantic names only — `--color-action`, `--color-shade-contour`,
28
+ `--color-accent-danger`, `--space-16`. Raw greys have no token of their own on
29
+ purpose: if they did, changing one border colour in one brand would drag along
30
+ every other place that grey is used.
31
+
32
+ Roles point at the brand palette through `var()`, so overriding `--color-action`
33
+ also moves everything built on it: `--color-info` and its pads follow on their own.
34
+
35
+ ## In CSS and SCSS
36
+
37
+ Write the variable where the value goes. The browser resolves it against whatever
38
+ `:root` the page has, so one rule follows both the brand and the theme:
39
+
40
+ ```css
41
+ .card {
42
+ background: var(--color-shade-white-inverter);
43
+ color: var(--color-shade-black-inverter);
44
+ border: 1px solid var(--color-shade-contour);
45
+ padding: var(--space-16);
46
+ box-shadow: var(--shadow-middle);
47
+ }
48
+ ```
49
+
50
+ In SCSS the same applies, with one exception: Sass colour functions such as
51
+ `color.adjust()` run at build time and cannot see through `var()`. Use
52
+ `color-mix()`, which runs in the browser.
53
+
54
+ Two things fail quietly:
55
+
56
+ ```css
57
+ @media (max-width: var(--breakpoint-mobile)) { } /* a media query cannot read var() */
58
+ color: var(--over-bg-mix); /* not a colour — see Overlays */
59
+ ```
60
+
61
+ ## In styled-components
62
+
63
+ The same string inside the template literal. Don't import a JavaScript constant
64
+ for a colour: it is baked in when the component renders and cannot follow a theme
65
+ switch.
66
+
67
+ A component with several states declares its own variables once at the top, with
68
+ the current value as a fallback, and reads only those below:
69
+
70
+ ```ts
71
+ const Button = styled.button`
72
+ --button-bg: var(--color-action, hsl(210 100% 50%));
73
+ --button-bg-hover: color-mix(in srgb, var(--over-contour-mix), var(--button-bg));
74
+ --button-fg: var(--color-shade-white, hsl(0 0% 100%));
75
+
76
+ background: var(--button-bg);
77
+ color: var(--button-fg);
78
+
79
+ &:hover { background: var(--button-bg-hover); }
80
+ `;
81
+ ```
82
+
83
+ There is no `--color-action-hover`. A state is derived from the colour with the
84
+ same overlay the status pads use, so a brand supplies one action colour and its
85
+ hover follows.
86
+
87
+ That block is also the component's override API, and needs no context — any
88
+ ancestor can set it:
89
+
90
+ ```css
91
+ .checkout button { --button-bg: var(--color-accent-success); }
92
+ ```
93
+
94
+ A prop may still decide *which* token applies; what it must not do is carry the
95
+ colour itself.
96
+
97
+ ## In plain JavaScript
98
+
99
+ Setting is straightforward — a custom property is a property:
100
+
101
+ ```js
102
+ document.documentElement.style.setProperty('--color-action', '#0080ff');
103
+ document.documentElement.dataset.theme = 'dark'; // delete it to follow the system
104
+ ```
105
+
106
+ Reading has one trap. A custom property computes to its text with `var()`
107
+ substituted and nothing else evaluated, so anything built with `color-mix()` reads
108
+ back as the expression itself:
109
+
110
+ ```js
111
+ const styles = getComputedStyle(document.documentElement);
112
+ styles.getPropertyValue('--breakpoint-mobile'); // '481px'
113
+ styles.getPropertyValue('--color-accent-danger-bg');
114
+ // 'color-mix(in srgb, hsl(0 0% 100%) 90%, hsl(0 85% 55%))'
115
+ ```
116
+
117
+ When a real colour is needed — a canvas, a chart, an inline SVG — put the token on
118
+ a real property first and read that back:
119
+
120
+ ```js
121
+ const probe = document.createElement('span');
122
+ probe.style.backgroundColor = 'var(--color-accent-danger-bg)';
123
+ document.body.append(probe);
124
+ const colour = getComputedStyle(probe).backgroundColor; // 'rgb(253, 234, 234)'
125
+ probe.remove();
126
+ ```
127
+
128
+ Reach for this only when the value has to leave CSS. To style an element, a class
129
+ and a rule that reads the token survives a theme switch; a value copied into
130
+ JavaScript does not.
131
+
132
+ ## Colours
133
+
134
+ `--color-shade-white` is always the light end — text and icons on a coloured
135
+ surface, in both themes. `--color-shade-white-inverter` is the page surface and
136
+ goes dark. Same pair for black: `--color-shade-black` is for overlays and stays
137
+ black, `--color-shade-black-inverter` is body text and flips.
138
+
139
+ | Token | Light | Dark |
140
+ |--------------------------------|-----------|-----------|
141
+ | `--color-shade-white` | `#FFFFFF` | `#E6E6E6` |
142
+ | `--color-shade-white-inverter` | `#FFFFFF` | `#212121` |
143
+ | `--color-shade-light` | `#FAFAFA` | `#333333` |
144
+ | `--color-shade-contour` | `#E6E6E6` | `#1A1A1A` |
145
+ | `--color-shade-graphic` | `#B3B3B3` | `#737373` |
146
+ | `--color-shade-dark` | `#808080` | `#999999` |
147
+ | `--color-shade-black` | `#000000` | `#000000` |
148
+ | `--color-shade-black-inverter` | `#000000` | `#E6E6E6` |
149
+
150
+ A status is a triple — the accent itself, the pad it sits on (`-bg`) and the
151
+ content on that pad (`-contour`):
152
+
153
+ ```css
154
+ .error {
155
+ background: var(--color-accent-danger-bg);
156
+ color: var(--color-accent-danger-contour);
157
+ }
158
+ ```
159
+
160
+ | Accent | Value |
161
+ |---------------------------|---------------------|
162
+ | `--color-accent-success` | `#00B359` |
163
+ | `--color-accent-warning` | `#FFAA00` |
164
+ | `--color-accent-danger` | `#EE2B2B` |
165
+ | `--color-info` | `--color-action` |
166
+
167
+ The pads are the accent with an overlay baked in through `color-mix`, and that
168
+ overlay changes with the theme — so one formula covers both themes.
169
+
170
+ Per brand, `--color-action` is what buttons and links use; the palette is for
171
+ illustration and marketing surfaces. Propush has no palette of its own yet, so
172
+ give `--color-brand-primary` a fallback if you read it.
173
+
174
+ | Token | PropellerAds | Monetag | Propush | Zeydoo |
175
+ |---------------------------|--------------|-----------|-----------|-----------|
176
+ | `--color-action` | `#0080FF` | `#4A3795` | `#0080FF` | `#0080FF` |
177
+ | `--color-brand-primary` | `#D9D926` | `#4A3795` | — | `#5C10DD` |
178
+ | `--color-brand-secondary` | `#14B082` | `#A4D65E` | — | `#28C8D2` |
179
+ | `--font-family` | Roboto | Gilroy | Roboto | Roboto |
180
+
181
+ ## Overlays
182
+
183
+ `--over-fullscreen`, `--over-contour` and `--over-bg` are colours with alpha, laid
184
+ over something else rather than replacing it:
185
+
186
+ ```css
187
+ .card:hover {
188
+ background-image: linear-gradient(var(--over-contour), var(--over-contour));
189
+ }
190
+ ```
191
+
192
+ `--over-contour-mix` and `--over-bg-mix` are the same overlays written as
193
+ colour + amount, for baking into a colour with `color-mix()` instead of laying on
194
+ a second layer. They are not colours, so `color: var(--over-bg-mix)` does nothing.
195
+
196
+ ## Dark theme
197
+
198
+ `common.css` switches on the operating system setting, and on `data-theme`:
199
+
200
+ ```html
201
+ <html data-theme="dark"> <!-- always dark, whatever the system says -->
202
+ <html data-theme="light"> <!-- always light -->
203
+ <html> <!-- follows the system -->
204
+ ```
205
+
206
+ Only the shades, the overlays and the shadows move; the brand palette and the
207
+ accents are the same in both themes. The overrides are listed twice in the file,
208
+ once per switch, because a media query and a plain selector cannot share a rule —
209
+ **change a dark value in both blocks.**
210
+
211
+ ## Sizes
212
+
213
+ A type size is named desktop-mobile: `--font-size-28-20` is 28px, and 20px below
214
+ the mobile breakpoint, which `common.css` applies on its own. Equal halves are the
215
+ common case. The scale is in pixels, not `em` or `rem`, so a root font size cannot
216
+ move it behind the page's back.
217
+
218
+ | Group | Tokens |
219
+ |--------------|--------------------------------------------------------------------------------------------|
220
+ | Font size | `--font-size-100-100`, `-52-52`, `-28-20`, `-20-20`, `-20-18`, `-16-16`, `-14-14`, `-12-12`, `-10-10` |
221
+ | Line height | `--line-height-20-20`, `--line-height-16-16` |
222
+ | Font weight | `--font-weight-title` (700), `--font-weight-basic` (400) |
223
+ | Space | `--space-0`, `-1`, `-2`, `-4`, `-8`, `-12`, `-16`, `-24`, `-32`, `-40`, `-80` — the number is the pixel value |
224
+ | Shadow | `--shadow-little`, `--shadow-middle`, `--shadow-big` |
225
+ | Breakpoint | `--breakpoint-mobile` (481px), `--breakpoint-tablet` (769px), `--breakpoint-desktop` (1025px) |
226
+
227
+ A breakpoint token is the first width *above* the range it names, so the queries
228
+ in `common.css` read `max-width: 480px`. Media queries cannot read `var()`, so
229
+ those numbers are written out there; the tokens exist for JavaScript.
package/common.css ADDED
@@ -0,0 +1,158 @@
1
+ /* Tokens shared by every brand.
2
+ A product imports this file plus exactly one brand file; the order between the
3
+ two does not matter, because the brand file only defines its own names and
4
+ everything pointing at them goes through var(). */
5
+
6
+ :root {
7
+ /* Shades ------------------------------------------------------------------
8
+ `-inverter` means the token flips with the theme. --color-shade-white is
9
+ always the light end (text and icons on a coloured surface);
10
+ --color-shade-white-inverter is the page surface and goes dark in the dark
11
+ theme. Same pair for black. */
12
+ --color-shade-white: hsl(0 0% 100%); /* #FFFFFF — on a coloured surface, stays light */
13
+ --color-shade-white-inverter: hsl(0 0% 100%); /* #FFFFFF — the page surface, flips with the theme */
14
+ --color-shade-light: hsl(0 0% 98%); /* #FAFAFA */
15
+ --color-shade-contour: hsl(0 0% 90%); /* #E6E6E6 */
16
+ --color-shade-graphic: hsl(0 0% 70%); /* #B3B3B3 */
17
+ --color-shade-dark: hsl(0 0% 50%); /* #808080 */
18
+ --color-shade-black: hsl(0 0% 0%); /* #000000 — overlays, stays black */
19
+ --color-shade-black-inverter: hsl(0 0% 0%); /* #000000 — body text, flips with the theme */
20
+
21
+ /* Accents -----------------------------------------------------------------
22
+ Each status is a triple: the accent itself, the pad it sits on (-bg) and the
23
+ content on that pad (-contour). The pads are the accent with an overlay baked
24
+ in through color-mix, so one formula covers both themes. */
25
+ --color-accent-success: hsl(150 100% 35%); /* #00B359 */
26
+ --color-accent-success-bg: color-mix(in srgb, var(--over-bg-mix), var(--color-accent-success));
27
+ --color-accent-success-contour: color-mix(in srgb, var(--over-contour-mix), var(--color-accent-success));
28
+ --color-accent-warning: hsl(40 100% 50%); /* #FFAA00 */
29
+ --color-accent-warning-bg: color-mix(in srgb, var(--over-bg-mix), var(--color-accent-warning));
30
+ --color-accent-warning-contour: color-mix(in srgb, var(--over-contour-mix), var(--color-accent-warning));
31
+ --color-accent-danger: hsl(0 85% 55%); /* #EE2B2B */
32
+ --color-accent-danger-bg: color-mix(in srgb, var(--over-bg-mix), var(--color-accent-danger));
33
+ --color-accent-danger-contour: color-mix(in srgb, var(--over-contour-mix), var(--color-accent-danger));
34
+
35
+ /* The informational status is the brand's action colour, so it is defined here
36
+ and gets its value from the brand file. */
37
+ --color-info: var(--color-action);
38
+ --color-info-bg: color-mix(in srgb, var(--over-bg-mix), var(--color-info));
39
+ --color-info-contour: color-mix(in srgb, var(--over-contour-mix), var(--color-info));
40
+
41
+ /* Overlays ----------------------------------------------------------------
42
+ Colours with alpha, laid over something else rather than replacing it. The
43
+ `-mix` pair is the same overlay written as colour + amount, so it can be
44
+ baked into a colour with color-mix instead of laid on as a second layer. */
45
+ --over-fullscreen: hsl(0 0% 0% / 50%); /* Dimming behind modals and drawers */
46
+ --over-contour: hsl(0 0% 0% / 10%); /* Darkening layer over a colour */
47
+ --over-bg: hsl(0 0% 100% / 90%); /* Washing layer over a colour: turns it into a tint */
48
+ --over-contour-mix: hsl(0 0% 0%) 10%;
49
+ --over-bg-mix: hsl(0 0% 100%) 90%;
50
+
51
+ /* Typography --------------------------------------------------------------
52
+ A size is named desktop-mobile: --font-size-28-20 is 28px, and 20px below the
53
+ mobile breakpoint. The two halves being equal is the common case. */
54
+ --font-weight-title: 700;
55
+ --font-weight-basic: 400;
56
+
57
+ --font-size-100-100: 100px;
58
+ --font-size-52-52: 52px;
59
+ --font-size-28-20: 28px;
60
+ --font-size-20-20: 20px;
61
+ --font-size-20-18: 20px;
62
+ --font-size-16-16: 16px;
63
+ --font-size-14-14: 14px;
64
+ --font-size-12-12: 12px;
65
+ --font-size-10-10: 10px;
66
+
67
+ --line-height-20-20: 20px;
68
+ --line-height-16-16: 16px;
69
+
70
+ /* Spacing */
71
+ --space-0: 0px;
72
+ --space-1: 1px;
73
+ --space-2: 2px;
74
+ --space-4: 4px;
75
+ --space-8: 8px;
76
+ --space-12: 12px;
77
+ --space-16: 16px;
78
+ --space-24: 24px;
79
+ --space-32: 32px;
80
+ --space-40: 40px;
81
+ --space-80: 80px;
82
+
83
+ /* Breakpoints -------------------------------------------------------------
84
+ Readable from JavaScript; a media query cannot use var(), so the queries in
85
+ this file repeat the number. */
86
+ --breakpoint-mobile: 481px;
87
+ --breakpoint-tablet: 769px;
88
+ --breakpoint-desktop: 1025px;
89
+
90
+ /* Shadows */
91
+ --shadow-little: 0 1px 0 hsl(0 0% 0% / 0.05), 0 1px 4px hsl(0 0% 0% / 0.1); /* Small containers */
92
+ --shadow-middle: 0 1px 1px hsl(0 0% 0% / 0.05), 0 2px 8px hsl(0 0% 0% / 0.1); /* Default container shadow */
93
+ --shadow-big:
94
+ 0 0 3px hsl(0 0% 0% / 0.06), 0 4px 4px hsl(0 0% 0% / 0.05), 0 12px 16px hsl(0 0% 0% / 0.1); /* Large containers over an overlay, promo blocks */
95
+ }
96
+
97
+ /* Dark theme --------------------------------------------------------------
98
+ Only the shades, the overlays and the shadows move; the brand palette and the
99
+ accents are the same in both themes.
100
+
101
+ The same list appears twice on purpose. The first block follows the operating
102
+ system, the second follows an explicit choice the product writes onto <html>
103
+ as data-theme="dark". `:not([data-theme="light"])` is what lets a product opt
104
+ a page back into the light theme against the system setting. There is no way
105
+ to put a media query and a plain selector in one rule, so when a value here
106
+ changes, change it in both blocks. */
107
+
108
+ @media (prefers-color-scheme: dark) {
109
+ :root:not([data-theme="light"]) {
110
+ color-scheme: dark;
111
+
112
+ --color-shade-white: hsl(0 0% 90%); /* #E6E6E6 */
113
+ --color-shade-white-inverter: hsl(0 0% 13%); /* #212121 */
114
+ --color-shade-light: hsl(0 0% 20%); /* #333333 */
115
+ --color-shade-contour: hsl(0 0% 10%); /* #1A1A1A */
116
+ --color-shade-graphic: hsl(0 0% 45%); /* #737373 */
117
+ --color-shade-dark: hsl(0 0% 60%); /* #999999 */
118
+ --color-shade-black-inverter: hsl(0 0% 90%); /* #E6E6E6 */
119
+
120
+ --over-fullscreen: hsl(0 0% 0% / 80%);
121
+ --over-bg: hsl(0 0% 0% / 80%); /* Inverts in the dark theme */
122
+ --over-bg-mix: hsl(0 0% 0%) 80%; /* Inverts too — and the pads built on it follow without being repeated */
123
+
124
+ --shadow-little: 0 1px 0 hsl(0 0% 0% / 0.25), 0 1px 4px hsl(0 0% 0% / 0.6);
125
+ --shadow-middle: 0 1px 1px hsl(0 0% 0% / 0.35), 0 2px 8px hsl(0 0% 0% / 0.6);
126
+ --shadow-big: 0 0 3px hsl(0 0% 0% / 0.26), 0 4px 4px hsl(0 0% 0% / 0.35), 0 12px 16px hsl(0 0% 0% / 0.6);
127
+ }
128
+ }
129
+
130
+ :root[data-theme="dark"] {
131
+ color-scheme: dark;
132
+
133
+ --color-shade-white: hsl(0 0% 90%); /* #E6E6E6 */
134
+ --color-shade-white-inverter: hsl(0 0% 13%); /* #212121 */
135
+ --color-shade-light: hsl(0 0% 20%); /* #333333 */
136
+ --color-shade-contour: hsl(0 0% 10%); /* #1A1A1A */
137
+ --color-shade-graphic: hsl(0 0% 45%); /* #737373 */
138
+ --color-shade-dark: hsl(0 0% 60%); /* #999999 */
139
+ --color-shade-black-inverter: hsl(0 0% 90%); /* #E6E6E6 */
140
+
141
+ --over-fullscreen: hsl(0 0% 0% / 80%);
142
+ --over-bg: hsl(0 0% 0% / 80%); /* Inverts in the dark theme */
143
+ --over-bg-mix: hsl(0 0% 0%) 80%; /* Inverts too — and the pads built on it follow without being repeated */
144
+
145
+ --shadow-little: 0 1px 0 hsl(0 0% 0% / 0.25), 0 1px 4px hsl(0 0% 0% / 0.6);
146
+ --shadow-middle: 0 1px 1px hsl(0 0% 0% / 0.35), 0 2px 8px hsl(0 0% 0% / 0.6);
147
+ --shadow-big: 0 0 3px hsl(0 0% 0% / 0.26), 0 4px 4px hsl(0 0% 0% / 0.35), 0 12px 16px hsl(0 0% 0% / 0.6);
148
+ }
149
+
150
+ /* Below the mobile breakpoint ---------------------------------------------
151
+ Only the sizes whose desktop and mobile halves differ appear here. */
152
+
153
+ @media (max-width: 480px) {
154
+ :root {
155
+ --font-size-28-20: 20px;
156
+ --font-size-20-18: 18px;
157
+ }
158
+ }
package/monetag.css ADDED
@@ -0,0 +1,12 @@
1
+ /* Monetag. Import together with common.css. */
2
+
3
+ :root {
4
+ --color-brand-primary: hsl(252.1 46.1% 40%); /* #4A3795 */
5
+ --color-brand-secondary: hsl(85 59.4% 60.4%); /* #A4D65E */
6
+
7
+ --color-action: var(
8
+ --color-brand-primary
9
+ ); /* Monetag has no separate action colour — the primary brand colour plays that role */
10
+
11
+ --font-family: "Gilroy", "Helvetica Neue", Helvetica, Arial, sans-serif;
12
+ }
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@propellerads/tokens",
3
+ "version": "0.0.1",
4
+ "exports": {
5
+ "./common.css": "./common.css",
6
+ "./propellerads.css": "./propellerads.css",
7
+ "./monetag.css": "./monetag.css",
8
+ "./propush.css": "./propush.css",
9
+ "./zeydoo.css": "./zeydoo.css"
10
+ },
11
+ "files": [
12
+ "*.css"
13
+ ],
14
+ "repository": "https://github.com/propellerads/ui-components.git",
15
+ "author": "i.pasyuk@propellerads.net",
16
+ "license": "MIT",
17
+ "bugs": {
18
+ "url": "https://github.com/propellerads/ui-components/issues"
19
+ },
20
+ "homepage": "https://github.com/propellerads/ui-components#readme",
21
+ "private": false
22
+ }
@@ -0,0 +1,12 @@
1
+ /* PropellerAds. Import together with common.css. The brand palette is the only
2
+ place where brands differ in colour; shades, accents, sizes and shadows are
3
+ shared. */
4
+
5
+ :root {
6
+ --color-brand-primary: hsl(60 70.2% 50%); /* #D9D926 — not used for buttons */
7
+ --color-brand-secondary: hsl(162.3 79.6% 38.4%); /* #14B082 */
8
+
9
+ --color-action: hsl(210 100% 50%); /* #0080FF */
10
+
11
+ --font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
12
+ }
package/propush.css ADDED
@@ -0,0 +1,10 @@
1
+ /* Propush. Import together with common.css.
2
+
3
+ No brand palette yet: add --color-brand-primary and --color-brand-secondary
4
+ here once they are settled. */
5
+
6
+ :root {
7
+ --color-action: hsl(210 100% 50%); /* #0080FF */
8
+
9
+ --font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
10
+ }
package/zeydoo.css ADDED
@@ -0,0 +1,10 @@
1
+ /* Zeydoo. Import together with common.css. */
2
+
3
+ :root {
4
+ --color-brand-primary: hsl(262.2 86.5% 46.5%); /* #5C10DD */
5
+ --color-brand-secondary: hsl(183.5 68% 49%); /* #28C8D2 */
6
+
7
+ --color-action: hsl(210 100% 50%); /* #0080FF */
8
+
9
+ --font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
10
+ }