@macawkit/theme 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The Space Grotesk Project Authors (https://github.com/floriankarsten/space-grotesk)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file
package/src/general.js ADDED
@@ -0,0 +1,75 @@
1
+ function select (list, tab) {
2
+ for (const candidate of list.querySelectorAll('[role="tab"]')) {
3
+ const selected = candidate === tab;
4
+ candidate.setAttribute('aria-selected', String(selected));
5
+ candidate.tabIndex = selected ? 0 : -1;
6
+
7
+ const id = candidate.getAttribute('aria-controls');
8
+ const panel = document.getElementById(id);
9
+ if (panel)
10
+ panel.hidden = !selected;
11
+ }
12
+ }
13
+
14
+ for (const list of document.querySelectorAll('[role="tablist"]')) {
15
+ list.addEventListener('click', event => {
16
+ const tab = event.target.closest('[role="tab"]');
17
+ if (tab)
18
+ select(list, tab);
19
+ });
20
+
21
+ list.addEventListener('keydown', event => {
22
+ const current = event.target.closest('[role="tab"]');
23
+ if (!current)
24
+ return;
25
+
26
+ const tabs = [...list.querySelectorAll('[role="tab"]')];
27
+ const index = tabs.indexOf(current);
28
+ let next;
29
+
30
+ if (event.key === 'ArrowRight')
31
+ next = tabs[(index + 1) % tabs.length];
32
+ else if (event.key === 'ArrowLeft')
33
+ next = tabs[(index - 1 + tabs.length) % tabs.length];
34
+ else if (event.key === 'Home')
35
+ next = tabs[0];
36
+ else if (event.key === 'End')
37
+ next = tabs.at(-1);
38
+ else
39
+ return;
40
+
41
+ event.preventDefault();
42
+ select(list, next);
43
+ next.focus();
44
+ });
45
+ }
46
+
47
+ for (const spark of document.querySelectorAll('.spark')) {
48
+ const valuesString = spark.dataset.values;
49
+ if (!valuesString)
50
+ continue;
51
+
52
+ const values = valuesString.split(',').map(Number);
53
+ const maxValue = Math.max(...values);
54
+
55
+ spark.replaceChildren();
56
+
57
+ for (const value of values) {
58
+ const bar = document.createElement('i');
59
+ bar.style.height = `${value / maxValue * 100}%`;
60
+ spark.append(bar);
61
+ }
62
+ }
63
+
64
+ for (const meter of document.querySelectorAll('div[role="meter"]')) {
65
+ const value = meter.getAttribute('aria-valuenow');
66
+ if (!value)
67
+ continue;
68
+
69
+ const min = meter.getAttribute('aria-valuemin') || 0;
70
+ const max = meter.getAttribute('aria-valuemax') || 100;
71
+ const range = max - min;
72
+ const percentage = (value - min) / range * 100;
73
+
74
+ meter.style.setProperty('--value', `${percentage}%`);
75
+ }
@@ -0,0 +1,57 @@
1
+ /*
2
+ Glow bar: a thin shining strip along an edge of an element.
3
+ Colored by --glow-source.
4
+ */
5
+ .alert::after,
6
+ :is(button, .button).ghost::after,
7
+ nav:not(.tabs) a::after,
8
+ nav.tabs > a::after,
9
+ :is(button, .button)[role=tab]::after {
10
+ content: "";
11
+ position: absolute;
12
+ left: 0;
13
+ pointer-events: none;
14
+ background-color: var(--glow-source);
15
+ box-shadow:
16
+ 0 0 var(--shine-radius) var(--glow-source),
17
+ 0 0 var(--glow-radius) var(--glow-color);
18
+ }
19
+
20
+ /* along the left edge */
21
+ .alert::after,
22
+ :is(button, .button).ghost::after,
23
+ nav:not(.tabs) a::after {
24
+ top: 0;
25
+ width: var(--highlight-thickness);
26
+ height: 100%;
27
+ }
28
+
29
+ /* along the bottom edge */
30
+ nav.tabs > a::after,
31
+ :is(button, .button)[role=tab]::after {
32
+ bottom: 0;
33
+ width: 100%;
34
+ height: var(--highlight-thickness);
35
+ }
36
+
37
+ /* hidden until the element is hovered or current, see button.css */
38
+ :is(button, .button).ghost::after,
39
+ nav:not(.tabs) a::after,
40
+ nav.tabs > a::after,
41
+ :is(button, .button)[role=tab]::after {
42
+ opacity: 0;
43
+ transition: opacity var(--transition);
44
+ }
45
+
46
+ .alert::after {
47
+ --glow-source: var(--color);
48
+ }
49
+
50
+ :is(button, .button).ghost::after {
51
+ --glow-source: var(--mtt-color-text-decorated);
52
+ }
53
+
54
+ nav a::after,
55
+ :is(button, .button)[role=tab]::after {
56
+ --glow-source: var(--mtt-color-main-highlight);
57
+ }
@@ -0,0 +1,154 @@
1
+ @font-face {
2
+ font-family: 'Space Grotesk';
3
+ src: url('../../font/spacegrotesk.woff2') format('woff2');
4
+ font-weight: 300 700;
5
+ font-display: swap;
6
+ }
7
+
8
+ @font-face {
9
+ font-family: 'JetBrains Mono';
10
+ src: url('../../font/jetbrainsmono.woff2') format('woff2');
11
+ font-weight: 100 800;
12
+ font-display: swap;
13
+ }
14
+
15
+ :root {
16
+ --font: 'Space Grotesk', sans-serif;
17
+ --mono: 'JetBrains Mono', monospace;
18
+ --line-height: 1.5em;
19
+ --heading-line-height: 1.15em;
20
+ --letter-spacing-wide: 0.08em;
21
+ --chip: 10px;
22
+ --chip-small: 8px;
23
+ --highlight-thickness: 2px;
24
+ --bar-thickness: 8px;
25
+ --bar-thickness-small: 4px;
26
+ --element-inner-margin: 4px;
27
+ --element-inner-margin-small: 3px;
28
+ --margin: 20px;
29
+ --margin-tight: calc(var(--margin) / 2);
30
+ --margin-minimal: calc(var(--margin) / 4);
31
+ --decrease-font-size: 75%;
32
+ --element-height: 40px;
33
+ --element-height-small: 30px;
34
+ --element-height-tiny: 20px;
35
+ --box-size: 16px;
36
+ --animation-duration: 200ms;
37
+ --animation-duration-fast: 100ms;
38
+ --animation-ease: cubic-bezier(.4, 0, .2, 1);
39
+ --transition: var(--animation-duration) var(--animation-ease);
40
+ --transition-fast: var(--animation-duration-fast) var(--animation-ease);
41
+ --press-scale: 0.99;
42
+ --press-translate: 1px;
43
+ --chipped-corner: polygon(
44
+ 0 0,
45
+ 100% 0,
46
+ 100% calc(100% - var(--chip)),
47
+ calc(100% - var(--chip)) 100%,
48
+ 0 100%
49
+ );
50
+ --chipped-corner-small: polygon(
51
+ 0 0,
52
+ 100% 0,
53
+ 100% calc(100% - var(--chip-small)),
54
+ calc(100% - var(--chip-small)) 100%,
55
+ 0 100%
56
+ );
57
+ }
58
+
59
+ /*
60
+ Mixins. These are declared on every element, so each of them is computed
61
+ from the inputs of the element it is used on:
62
+
63
+ --glow-source -> --glow-color, a soft halo of that color
64
+ --tick-color, --tick-size -> --ticks, a background of four corner marks
65
+ */
66
+ *, ::before, ::after {
67
+ --glow-color: color-mix(in srgb, var(--glow-source) var(--glow-strength), #0000);
68
+ --tick: linear-gradient(var(--tick-color), var(--tick-color));
69
+ --ticks:
70
+ var(--tick) 0 0 / var(--tick-size) 1px,
71
+ var(--tick) 0 0 / 1px var(--tick-size),
72
+ var(--tick) 100% 0 / var(--tick-size) 1px,
73
+ var(--tick) 100% 0 / 1px var(--tick-size),
74
+ var(--tick) 0 100% / var(--tick-size) 1px,
75
+ var(--tick) 0 100% / 1px var(--tick-size),
76
+ var(--tick) 100% 100% / var(--tick-size) 1px,
77
+ var(--tick) 100% 100% / 1px var(--tick-size);
78
+ }
79
+
80
+ th {
81
+ text-align: left;
82
+ }
83
+ .label {
84
+ color: var(--mtt-color-text-decorated);
85
+ }
86
+ th, .note, fieldset, .small, small {
87
+ color: var(--mtt-color-text-muted);
88
+ }
89
+ th, .note, .label, fieldset {
90
+ font-family: var(--mono);
91
+ font-size: var(--decrease-font-size);
92
+ font-weight: 400;
93
+ letter-spacing: var(--letter-spacing-wide);
94
+ text-transform: uppercase;
95
+ }
96
+ th, td {
97
+ padding: var(--margin-tight);
98
+ }
99
+ dt, dd {
100
+ padding: var(--margin-tight) 0;
101
+ }
102
+ table {
103
+ border-collapse: collapse;
104
+ }
105
+ tr:not(:last-of-type) {
106
+ border-bottom: 1px solid var(--mtt-color-line-dimmed);
107
+ }
108
+ thead {
109
+ border-bottom: 1px solid var(--mtt-color-line-dimmed);
110
+ }
111
+
112
+ fieldset small {
113
+ font-family: var(--font);
114
+ font-size: inherit;
115
+ font-weight: normal;
116
+ letter-spacing: normal;
117
+ text-transform: none;
118
+ }
119
+
120
+ table tbody tr:hover {
121
+ background: linear-gradient(
122
+ 100deg, #0000,
123
+ color-mix(in srgb, var(--mtt-color-button) calc(var(--glow-strength) / 2), #0000)
124
+ 50%, #0000
125
+ );
126
+ }
127
+
128
+ dt:not(:last-of-type), dd:not(:last-of-type) {
129
+ border-bottom: 1px solid var(--mtt-color-line-dimmed);
130
+ }
131
+
132
+ .well {
133
+ box-shadow: inset 0 0 0 1px var(--mtt-color-line-dimmed);
134
+ }
135
+
136
+ label:has(input:disabled, [aria-disabled=true]),
137
+ :is(:disabled, [aria-disabled=true]) {
138
+ cursor: not-allowed;
139
+ filter: var(--disabled-filter);
140
+ }
141
+
142
+ fieldset {
143
+ display: grid;
144
+ gap: var(--margin);
145
+ align-items: start;
146
+ }
147
+ fieldset label {
148
+ display: grid;
149
+ gap: var(--margin-minimal);
150
+ }
151
+ fieldset label i {
152
+ vertical-align: middle;
153
+ margin: 0 var(--margin-minimal);
154
+ }
@@ -0,0 +1,235 @@
1
+ nav.tabs > a,
2
+ :is(button, .button) {
3
+ --background-color: var(--mtt-color-button);
4
+ background-color: transparent;
5
+ transition:
6
+ transform var(--transition-fast),
7
+ background-color var(--transition),
8
+ filter var(--transition),
9
+ color var(--transition),
10
+ border-color var(--transition),
11
+ translate var(--transition);
12
+ }
13
+
14
+ :is(button, .button) {
15
+ /* chipped body */
16
+ &:not(.alt, [role=tab])::before {
17
+ clip-path: var(--chipped-corner);
18
+ pointer-events: none;
19
+ z-index: -1;
20
+ content: "";
21
+ position: absolute;
22
+ top: 0;
23
+ left: 0;
24
+ width: 100%;
25
+ height: 100%;
26
+ background-color: var(--background-color);
27
+ transition: background-color var(--transition);
28
+ }
29
+
30
+ /* halo behind the body, shown on hover */
31
+ &:not(.ghost, [role=tab])::after {
32
+ z-index: -2;
33
+ content: "";
34
+ position: absolute;
35
+ top: var(--chip);
36
+ left: var(--chip);
37
+ width: calc(100% - 2 * var(--chip));
38
+ height: calc(100% - 2 * var(--chip));
39
+ pointer-events: none;
40
+ opacity: 0;
41
+ background-color: var(--background-color);
42
+ filter: drop-shadow(0 0 calc(var(--glow-radius) + var(--chip)) var(--glow-color));
43
+ transition: opacity var(--transition);
44
+ }
45
+
46
+ &:is(.hover, :hover):not(:disabled, [aria-disabled=true], .ghost, [role=tab])::after {
47
+ opacity: 1;
48
+ }
49
+ }
50
+
51
+ nav.tabs > a[aria-current=page],
52
+ :is(button, .button)[role=tab][aria-selected=true],
53
+ :is(button, .button):not(.ghost, :disabled, [aria-disabled=true], [role=tab]):is(.hover, :hover) {
54
+ --background-color: var(--mtt-color-main-highlight);
55
+ --glow-source: var(--background-color);
56
+ color: var(--mtt-color-text-brightest);
57
+ text-shadow: 0 0 calc(var(--shine-radius) / 2) var(--mtt-color-text-bright);
58
+ }
59
+
60
+ :is(button, .button):not(.alt, .ghost, :disabled, [aria-disabled=true]):is(.hover, :hover) {
61
+ --background-color: var(--mtt-color-main-highlight);
62
+ filter: drop-shadow(0 0 var(--shine-radius) var(--background-color));
63
+ }
64
+
65
+ nav.tabs > a:is(.hover, :hover),
66
+ :is(button, .button) > * {
67
+ transition: filter var(--transition);
68
+ }
69
+
70
+ :is(button, .button) {
71
+ &:is(.hover, :hover):not(:disabled, [aria-disabled=true], .ghost) > * {
72
+ filter: drop-shadow(0 0 calc(var(--shine-radius)) var(--mtt-color-text-bright));
73
+ }
74
+
75
+ &:is(:active, .active):not(:disabled, [aria-disabled=true], [role=tab]) {
76
+ transform: translateY(var(--press-translate)) scale(var(--press-scale));
77
+ }
78
+
79
+ &:is(:active, .active):not(:disabled, [aria-disabled=true], .ghost, [role=tab])::after {
80
+ transition: opacity var(--transition-fast);
81
+ opacity: 0;
82
+ }
83
+
84
+ &:not(.alt, [role=tab]).small::before {
85
+ clip-path: var(--chipped-corner-small);
86
+ }
87
+ }
88
+
89
+ /* Alt: a flat body with corner ticks, shared with .box */
90
+ :is(button, .button).alt,
91
+ .box {
92
+ background-color: var(--mtt-color-main-dimmed);
93
+ border: 1px solid var(--mtt-color-line);
94
+ }
95
+
96
+ :is(button, .button).alt {
97
+ --background-color: var(--mtt-color-main-dimmed);
98
+ background-color: var(--background-color);
99
+
100
+ &:is(.hover, :hover):not(:disabled, [aria-disabled=true]) {
101
+ --background-color: var(--mtt-color-button);
102
+ border-color: var(--mtt-color-line-highlight);
103
+ }
104
+ }
105
+
106
+ :is(button, .button).alt::before,
107
+ .box::before {
108
+ --tick-color: var(--mtt-color-line-highlight);
109
+ --tick-size: calc(var(--chip) / 2);
110
+ content: "";
111
+ position: absolute;
112
+ inset: -1px;
113
+ z-index: -1;
114
+ pointer-events: none;
115
+ background: var(--ticks);
116
+ background-repeat: no-repeat;
117
+ transition:
118
+ filter var(--transition),
119
+ background var(--transition);
120
+ }
121
+
122
+ :is(button, .button).alt:is(.hover, :hover):not(:disabled, [aria-disabled=true])::before,
123
+ .box.active::before {
124
+ --tick-color: var(--mtt-color-line-decorated);
125
+ --tick-size: var(--chip);
126
+ filter: drop-shadow(0 0 calc(var(--shine-radius)) var(--tick-color));
127
+ }
128
+
129
+ :is(button, .button) {
130
+ &.alt {
131
+ &:is(:active, .active):not(:disabled, [aria-disabled=true])::before {
132
+ --tick-size: calc(var(--chip-small) / 2);
133
+ transition:
134
+ filter var(--transition-fast),
135
+ background var(--transition-fast);
136
+ }
137
+
138
+ &::after {
139
+ top: 0;
140
+ left: 0;
141
+ width: 100%;
142
+ height: 100%;
143
+ }
144
+ }
145
+
146
+ &.danger {
147
+ --background-color: var(--color-danger);
148
+ color: var(--color-danger-text);
149
+
150
+ &:is(.hover, :hover):not(:disabled, [aria-disabled=true]) {
151
+ --background-color: var(--color-danger-highlight);
152
+ color: var(--mtt-color-text-brightest);
153
+ }
154
+ }
155
+
156
+ /* Ghost: no body, a glow bar on hover, see bar.css */
157
+ &.ghost {
158
+ --background-color: transparent;
159
+ color: var(--mtt-color-text);
160
+
161
+ &:is(.hover, :hover):not(:disabled, [aria-disabled=true]) {
162
+ --background-color: var(--background);
163
+ color: var(--mtt-color-text-bright);
164
+ }
165
+ }
166
+ }
167
+
168
+ :is(button, .button).ghost:is(.hover, :hover):not(:disabled, [aria-disabled=true])::after,
169
+ nav:not(.tabs) a[aria-current]::after {
170
+ transition: opacity var(--transition-fast);
171
+ opacity: 1;
172
+ }
173
+
174
+ :is(.info, .signature, .success, .priority, .warning, .danger) :is(button, .button).ghost::after,
175
+ :is(button, .button).ghost:is(.info, .signature, .success, .priority, .warning, .danger)::after {
176
+ --glow-source: var(--color);
177
+ }
178
+
179
+ /* Tabs: a glow bar under the current one, see bar.css */
180
+ nav.tabs > a,
181
+ :is(button, .button)[role=tab] {
182
+ color: var(--mtt-color-text);
183
+ }
184
+
185
+ nav.tabs > a[aria-current=page],
186
+ nav.tabs > a:is(.hover, :hover),
187
+ :is(button, .button)[role=tab][aria-selected=true],
188
+ :is(button, .button)[role=tab]:is(.hover, :hover):not(:disabled, [aria-disabled=true]) {
189
+ background-color: var(--mtt-color-main-dimmed);
190
+ color: var(--mtt-color-text-bright);
191
+ filter: none;
192
+ }
193
+
194
+ nav.tabs > a[aria-current=page]::after,
195
+ :is(button, .button)[role=tab][aria-selected=true]::after {
196
+ opacity: 1;
197
+ }
198
+
199
+ /* Navigation list: a glow bar next to the current one, see bar.css */
200
+ nav:not(.tabs) a {
201
+ transition:
202
+ background-color var(--transition),
203
+ color var(--transition);
204
+
205
+ &::before {
206
+ content: "";
207
+ position: absolute;
208
+ inset: 0;
209
+ z-index: -1;
210
+ pointer-events: none;
211
+ background-color: transparent;
212
+ transition: background-color var(--transition);
213
+ }
214
+
215
+ &:is(.hover, :hover) {
216
+ color: var(--mtt-color-text-bright);
217
+ }
218
+
219
+ &:not([aria-current]):is(.hover, :hover) {
220
+ background-color: color-mix(in srgb, var(--mtt-color-main-dimmed) calc(var(--glow-strength) / 2), #0000);
221
+ }
222
+
223
+ &[aria-current] {
224
+ color: var(--mtt-color-text-bright);
225
+
226
+ &::before {
227
+ clip-path: var(--chipped-corner);
228
+ background-color: var(--mtt-color-main-dimmed);
229
+ }
230
+
231
+ small {
232
+ color: var(--mtt-color-text-decorated);
233
+ }
234
+ }
235
+ }