@kth/style 0.0.12 → 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.
Files changed (60) hide show
  1. package/dist/cjs/components/Button.d.ts +4 -4
  2. package/dist/cjs/components/ModalNavigationPanel.d.ts +4 -0
  3. package/dist/cjs/components/NavigationPanel.d.ts +7 -0
  4. package/dist/cjs/components/Radio.d.ts +2 -2
  5. package/dist/cjs/components/Select.d.ts +3 -5
  6. package/dist/cjs/components/Tabs.d.ts +1 -34
  7. package/dist/cjs/components/react/PersonalMenuPanel.d.ts +19 -0
  8. package/dist/cjs/components/react/Tabs.d.ts +34 -0
  9. package/dist/cjs/icons/400/ArrowBack.d.ts +2 -1
  10. package/dist/cjs/icons/400/Check.d.ts +2 -1
  11. package/dist/cjs/icons/500/ArrowForward.d.ts +2 -1
  12. package/dist/cjs/index.d.ts +3 -5
  13. package/dist/cjs/index.js +128 -157
  14. package/dist/cjs/react.d.ts +5 -0
  15. package/dist/cjs/react.js +179 -0
  16. package/dist/cjs/stories/ContentTabs.stories.d.ts +1 -2
  17. package/dist/esm/components/Button.d.ts +4 -4
  18. package/dist/esm/components/ModalNavigationPanel.d.ts +4 -0
  19. package/dist/esm/components/NavigationPanel.d.ts +7 -0
  20. package/dist/esm/components/Radio.d.ts +2 -2
  21. package/dist/esm/components/Select.d.ts +3 -5
  22. package/dist/esm/components/Tabs.d.ts +1 -34
  23. package/dist/esm/components/react/PersonalMenuPanel.d.ts +19 -0
  24. package/dist/esm/components/react/Tabs.d.ts +34 -0
  25. package/dist/esm/icons/400/ArrowBack.d.ts +2 -1
  26. package/dist/esm/icons/400/Check.d.ts +2 -1
  27. package/dist/esm/icons/500/ArrowForward.d.ts +2 -1
  28. package/dist/esm/index.d.ts +3 -5
  29. package/dist/esm/index.js +126 -129
  30. package/dist/esm/react.d.ts +5 -0
  31. package/dist/esm/react.js +149 -0
  32. package/dist/esm/stories/ContentTabs.stories.d.ts +1 -2
  33. package/package.json +14 -4
  34. package/scss/components/button.scss +41 -51
  35. package/scss/components/checkbox.scss +63 -0
  36. package/scss/components/details.scss +40 -0
  37. package/scss/components/fieldset.scss +60 -0
  38. package/scss/components/form-control.scss +25 -0
  39. package/scss/components/header-menu-item.scss +38 -0
  40. package/scss/components/input.scss +21 -0
  41. package/scss/components/main-header.scss +105 -0
  42. package/scss/components/search.scss +52 -0
  43. package/scss/components/select.scss +46 -0
  44. package/scss/tokens/colors.scss +63 -0
  45. package/scss/tokens/icons.scss +68 -0
  46. package/scss/tokens/{_spacing.scss → spacing.scss} +15 -0
  47. package/scss/tokens/typography.scss +35 -0
  48. package/scss/utils/mixins.scss +14 -0
  49. package/scss/utils/prose.scss +83 -76
  50. package/scss/utils/reset.scss +53 -255
  51. package/scss/components/content-tabs.scss +0 -68
  52. package/scss/components/filter-tabs.scss +0 -31
  53. package/scss/components/form.scss +0 -48
  54. package/scss/components/inline-icon.scss +0 -7
  55. package/scss/globals.scss +0 -5
  56. package/scss/tokens/_colors.scss +0 -20
  57. package/scss/tokens/_spacing.en.md +0 -40
  58. package/scss/tokens/_typography.scss +0 -71
  59. package/scss/tokens/index.scss +0 -6
  60. package/scss/utils/sizes.scss +0 -22
@@ -1,263 +1,61 @@
1
- @use "../tokens/index.scss" as t;
2
-
3
- /// Adaptation of normalize.css v8.0.1
4
- /// github.com/necolas/normalize.css
5
- ///
6
- /// This mixin normalizes all browsers and provides basic global styles for all
7
- /// HTML elements. This mixin only styles elements in isolation
8
- @mixin reset {
9
- @layer kth-style {
10
- // HTML
11
- // 1. Prevent adjustments of font size after orientation changes in iOS.
12
- html {
13
- line-height: t.$font-lh-base;
14
- -webkit-text-size-adjust: 100%; /* 1 */
15
- }
16
-
17
- /* Sections
18
- ========================================================================== */
19
-
20
- // Body
21
- // 1. Remove the margin in all browsers
22
- // 2. Default fonts
23
- body {
24
- margin: 0;
25
- font-family: t.$font-family-sans;
26
- font-weight: t.$font-weight-normal;
27
- line-height: t.$font-lh-base;
28
- }
29
-
30
- h1 {
31
- @include t.font-h1();
32
- }
33
-
34
- h2 {
35
- @include t.font-h2();
36
- }
37
-
38
- h3 {
39
- @include t.font-h3();
40
- }
41
-
42
- h4 {
43
- @include t.font-h4();
44
- }
45
-
46
- h5,
47
- h6 {
48
- @include t.font-h5();
49
- }
50
-
51
- /* Grouping content
52
- ========================================================================== */
53
-
54
- // 1. Add the correct box sizing in Firefox.
55
- // 2. Show the overflow in Edge and IE.
56
- hr {
57
- box-sizing: content-box; /* 1 */
58
- height: 0; /* 1 */
59
- border: 0;
60
- border-top: 1px t.$color-neutral-2 solid;
61
- margin: t.$space-32 0;
62
- overflow: visible; /* 2 */
63
- }
64
-
65
- // 1. Correct the inheritance and scaling of font size in all browsers.
66
- // 2. Correct the odd `em` font sizing in all browsers.
67
- pre {
68
- font-family: monospace, monospace; /* 1 */
69
- font-size: 1em; /* 2 */
70
- }
71
-
72
- iframe {
73
- border: none;
74
- }
75
-
76
- img {
77
- max-width: 100%;
78
- height: auto;
79
- }
80
-
81
- figure {
82
- margin: t.$space-32 0;
83
- }
84
-
85
- figcaption {
86
- max-width: 70ch;
87
- font-style: italic;
88
- margin-block-start: t.$space-12;
89
- font-size: 1rem;
90
- }
91
-
92
- /* Text-level semantics
93
- ========================================================================== */
94
- a {
95
- // color: t.$color-blue-5;
96
- text-decoration: none;
97
-
98
- &:hover {
99
- text-decoration: underline;
100
- }
101
- }
102
-
103
- // 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
104
- abbr[title] {
105
- text-decoration: underline; /* 2 */
106
- text-decoration: underline dotted; /* 2 */
107
- }
108
-
109
- b,
110
- strong {
111
- font-weight: t.$font-weight-bold;
112
- }
113
-
114
- // 1. Correct the inheritance and scaling of font size in all browsers.
115
- // 2. Correct the odd `em` font sizing in all browsers.
116
- code,
117
- kbd,
118
- samp {
119
- font-family: monospace, monospace; /* 1 */
120
- font-size: 1em; /* 2 */
121
- }
122
-
123
- small {
124
- // TODO: This is the default in normalize.css. Define the right one
125
- font-size: 80%;
126
- }
127
-
128
- // Prevent `sub` and `sup` elements from affecting the line height in all browsers.
129
- sub,
130
- sup {
131
- font-size: 75%;
132
- line-height: 0;
133
- position: relative;
134
- vertical-align: baseline;
135
- }
136
-
137
- sub {
138
- bottom: -0.25em;
139
- }
140
-
141
- sup {
142
- top: -0.5em;
143
- }
144
-
145
- /* Forms
146
- ========================================================================== */
147
-
148
- // 1. Change the font styles in all browsers.
149
- // 2. Remove the margin in Firefox and Safari.
150
- button,
151
- input,
152
- optgroup,
153
- select,
154
- textarea {
155
- font-family: inherit; /* 1 */
156
- font-size: 100%; /* 1 */
157
- line-height: t.$font-lh-base; /* 1 */
158
- margin: 0; /* 2 */
159
- }
160
-
161
- // Remove the inheritance of text transform in Edge, Firefox, and IE.
162
- // Remove the inheritance of text transform in Firefox.
163
- button,
164
- select {
165
- /* 1 */
166
- text-transform: none;
167
- }
168
-
169
- // Correct the inability to style clickable types in iOS and Safari.
170
- button,
171
- [type="button"],
172
- [type="reset"],
173
- [type="submit"] {
174
- -webkit-appearance: button;
175
- }
176
-
177
- // Remove the inner border and padding in Firefox.
178
- button::-moz-focus-inner,
179
- [type="button"]::-moz-focus-inner,
180
- [type="reset"]::-moz-focus-inner,
181
- [type="submit"]::-moz-focus-inner {
182
- border-style: none;
183
- padding: 0;
184
- }
185
-
186
- // Restore the focus styles unset by the previous rule.
187
- button:-moz-focusring,
188
- [type="button"]:-moz-focusring,
189
- [type="reset"]:-moz-focusring,
190
- [type="submit"]:-moz-focusring {
191
- outline: 1px dotted ButtonText;
192
- }
193
-
194
- // Correct the padding in Firefox.
195
- fieldset {
196
- // TODO: unifiy with our own values
197
- padding: 0.35em 0.75em 0.625em;
198
- }
199
-
200
- // 1. Correct the text wrapping in Edge and IE.
201
- // 2. Correct the color inheritance from `fieldset` elements in IE.
202
- // 3. Remove the padding so developers are not caught out when they zero out
203
- // `fieldset` elements in all browsers.
204
- legend {
205
- box-sizing: border-box; /* 1 */
206
- color: inherit; /* 2 */
207
- display: table; /* 1 */
208
- max-width: 100%; /* 1 */
209
- padding: 0; /* 3 */
210
- white-space: normal; /* 1 */
211
- }
212
-
213
- // Add the correct vertical alignment in Chrome, Firefox, and Opera.
214
- progress {
215
- vertical-align: baseline;
216
- }
217
-
218
- // Correct the cursor style of increment and decrement buttons in Chrome.
219
- [type="number"]::-webkit-inner-spin-button,
220
- [type="number"]::-webkit-outer-spin-button {
221
- height: auto;
222
- }
223
-
224
- // 1. Correct the odd appearance in Chrome and Safari.
225
- // 2. Correct the outline style in Safari.
226
- [type="search"] {
227
- -webkit-appearance: textfield; /* 1 */
228
- outline-offset: -2px; /* 2 */
229
- }
1
+ @use "../tokens/typography";
2
+ @use "../tokens/spacing";
3
+ @use "../tokens/colors";
4
+
5
+ /// Based on https://andy-bell.co.uk/a-more-modern-css-reset/
6
+ @layer kth-style {
7
+ *,
8
+ *::before,
9
+ *::after {
10
+ box-sizing: border-box;
11
+ }
12
+ html {
13
+ -moz-text-size-adjust: none;
14
+ -webkit-text-size-adjust: none;
15
+ text-size-adjust: none;
16
+ scrollbar-gutter: stable;
17
+ }
230
18
 
231
- // Remove the inner padding in Chrome and Safari on macOS.
232
- [type="search"]::-webkit-search-decoration {
233
- -webkit-appearance: none;
234
- }
19
+ :root {
20
+ @include colors.theme-default;
21
+ @include spacing.theme-default;
22
+ @include typography.theme-default;
23
+ }
235
24
 
236
- // 1. Correct the inability to style clickable types in iOS and Safari.
237
- // 2. Change font properties to `inherit` in Safari.
238
- ::-webkit-file-upload-button {
239
- -webkit-appearance: button; /* 1 */
240
- font: inherit; /* 2 */
241
- }
25
+ body {
26
+ color: var(--color-text);
27
+ background: var(--color-background);
28
+ font: var(--font-default);
29
+ min-height: 100vh;
30
+ margin: 0;
31
+ }
242
32
 
243
- /* Interactive
244
- ========================================================================== */
245
- // Add the correct display in Edge, IE 10+, and Firefox.
246
- details {
247
- display: block;
248
- }
33
+ h1,
34
+ h2,
35
+ h3,
36
+ h4,
37
+ p,
38
+ figure,
39
+ blockquote,
40
+ dl,
41
+ dd {
42
+ margin: 0;
43
+ }
249
44
 
250
- // Add the correct display in all browsers.
251
- summary {
252
- display: list-item;
253
- }
45
+ a {
46
+ color: var(--color-tertiary);
47
+ text-underline-offset: spacing.$space-4;
48
+ }
254
49
 
255
- /* Misc
256
- ========================================================================== */
50
+ img,
51
+ picture {
52
+ max-width: 100%;
53
+ }
257
54
 
258
- // Add the correct display
259
- [hidden] {
260
- display: none;
261
- }
55
+ input,
56
+ button,
57
+ textarea,
58
+ select {
59
+ font: inherit;
262
60
  }
263
61
  }
@@ -1,68 +0,0 @@
1
- @use "../tokens/" as t;
2
-
3
- $border-secondary: 1px solid t.$color-neutral-10;
4
-
5
- @layer kth-style {
6
- .kth-content-tabs {
7
- overflow: auto;
8
- padding-block-start: t.$space-16;
9
- position: sticky;
10
- top: calc(var(--kpm-bar-height, 0rem));
11
- background: t.$color-neutral-0;
12
-
13
- ul[role="tablist"] {
14
- list-style: none;
15
- padding: 0;
16
- margin: 0;
17
- display: inline-flex;
18
- flex-wrap: nowrap;
19
- align-items: stretch;
20
- gap: t.$space-4;
21
- min-width: 100%;
22
- border-block-end: $border-secondary;
23
- }
24
-
25
- li {
26
- display: flex;
27
- }
28
-
29
- button[role="tab"] {
30
- box-sizing: border-box;
31
- padding-inline: var(--kth-0-clickable-padding-inline);
32
- padding-block: calc(var(--kth-0-clickable-padding-block) - 1px);
33
- border-block-width: 1px;
34
- display: block;
35
- text-decoration: none;
36
- margin-block-end: -1px;
37
- color: t.$color-neutral-10;
38
- border: $border-secondary;
39
- border-radius: t.border-radius(8 8 0 0);
40
-
41
- &:focus {
42
- outline-offset: -#{t.$space-4};
43
- }
44
-
45
- &:hover {
46
- text-decoration: underline;
47
- }
48
-
49
- &[aria-selected="false"] {
50
- background: t.$color-neutral-2;
51
- margin-block-start: #{t.$space-8};
52
- }
53
-
54
- &[aria-selected="true"] {
55
- background: t.$color-neutral-0;
56
- padding-block-start: calc(
57
- var(--kth-0-clickable-padding-block) + #{t.$space-8} - 1px
58
- );
59
- border-block-end-color: transparent;
60
- }
61
- }
62
-
63
- [role="tabpanel"] {
64
- border-inline: $border-secondary;
65
- border-block-end: $border-secondary;
66
- }
67
- }
68
- }
@@ -1,31 +0,0 @@
1
- @use "../tokens/" as t;
2
-
3
- @layer kth-style {
4
- .kth-filter-tabs {
5
- border: none;
6
- margin: 0;
7
- padding: 0;
8
- display: inline-flex;
9
-
10
- input[type="radio"] {
11
- appearance: none;
12
- margin: 0;
13
- padding: 0;
14
- }
15
-
16
- label {
17
- display: inline-block;
18
- padding-inline: var(--kth-0-clickable-padding-inline);
19
- padding-block: var(--kth-0-clickable-padding-block);
20
- }
21
-
22
- input:focus + label {
23
- outline: 2px solid t.$color-primary-5;
24
- outline-offset: -#{t.$space-6};
25
- }
26
-
27
- input:checked + label {
28
- border-bottom: t.$space-2 t.$color-primary-5 solid;
29
- }
30
- }
31
- }
@@ -1,48 +0,0 @@
1
- @use "../tokens/" as t;
2
-
3
- @layer kth-style {
4
- .kth-select,
5
- .kth-input {
6
- margin-block: t.$space-24;
7
-
8
- label {
9
- display: block;
10
- font-weight: 600;
11
- }
12
-
13
- p {
14
- margin: t.$space-4 0;
15
- }
16
-
17
- select {
18
- margin-top: t.$space-8;
19
- padding-inline: var(--kth-0-clickable-padding-inline);
20
- padding-block: calc(var(--kth-0-clickable-padding-block) - 1px);
21
- border-radius: t.$space-4;
22
- border: 1px solid t.$color-neutral-10;
23
-
24
- &[aria-invalid="true"] {
25
- color: t.$color-danger-5;
26
- border-color: t.$color-danger-5;
27
- }
28
- }
29
-
30
- input {
31
- margin-top: t.$space-8;
32
- padding-inline: var(--kth-0-clickable-padding-inline);
33
- padding-block: calc(var(--kth-0-clickable-padding-block) - 1px);
34
- border-radius: t.$space-4;
35
- border: 1px solid t.$color-neutral-10;
36
-
37
- &[aria-invalid="true"] {
38
- color: t.$color-danger-5;
39
- border-color: t.$color-danger-5;
40
- }
41
- }
42
-
43
- &__error {
44
- margin-top: t.$space-8;
45
- color: t.$color-danger-5;
46
- }
47
- }
48
- }
@@ -1,7 +0,0 @@
1
- @use "../tokens/" as t;
2
- @layer kth-style {
3
- .kth-inline-icon {
4
- display: inline-block;
5
- vertical-align: -12.5%;
6
- }
7
- }
package/scss/globals.scss DELETED
@@ -1,5 +0,0 @@
1
- @use "utils/reset";
2
- @use "utils/sizes";
3
-
4
- @include reset.reset();
5
- @include sizes.sizes();
@@ -1,20 +0,0 @@
1
- // 1. Colors
2
- $color-neutral-10: #000;
3
- $color-neutral-6: #65656c;
4
- $color-neutral-2: #d4d4d4;
5
- $color-neutral-1: #f6f6f6;
6
- $color-neutral-0: #fff;
7
-
8
- $color-primary-6: #006388;
9
- $color-primary-5: #007fae;
10
-
11
- $color-success-6: #3f6600;
12
- $color-success-5: #528400;
13
- $color-success-1: #dff0d8;
14
-
15
- $color-danger-6: #b52c17;
16
- $color-danger-5: #d4351c;
17
- $color-danger-1: #f5e6e6;
18
-
19
- $color-warning-3: #fab919;
20
- $color-warning-1: #fcf8e3;
@@ -1,40 +0,0 @@
1
- ---
2
- lang: en
3
- ---
4
-
5
- # How to use
6
-
7
- We provide two ways for consuming these values:
8
-
9
- - With the utility functions `padding`, `margin` and `gap`
10
- - With the variables `$space-<number>`
11
-
12
- ## Utility functions `padding`, `margin` and `gap`
13
-
14
- All three functions accept an arbitrary number of arguments, so they can be used in shorthand and non-shorthand CSS properties.
15
-
16
- ```scss
17
- @use "@kth/style/scss/tokens" as t;
18
-
19
- .an-element {
20
- // Passing two values at the same time
21
- padding: t.padding(2 8);
22
-
23
- // Passing one value only
24
- margin-inline-end: t.margin(0);
25
- }
26
- ```
27
-
28
- All three functions will throw an error if the passed value is invalid. Accepted values are: 0, 2, 4, 6, 8, 12, 16, 20, 24, 32, 40, 48, 64 and 80.
29
-
30
- ## Variables `$space-<value>`
31
-
32
- This package also exports variables named `$space-<value>` (example: `$space-2`) which can be convenient if you need a single value.
33
-
34
- ```scss
35
- @use "@kth/style/scss/tokens" as t;
36
-
37
- .an-element {
38
- padding-top: t.$space-4;
39
- }
40
- ```
@@ -1,71 +0,0 @@
1
- @use "sass:math";
2
- // 2. Typography
3
-
4
- // Base tokens
5
- // All allowed single values for different properties
6
- // Name convention: `font-<property>-identifier`
7
- $font-family-sans: "Open Sans", sans-serif;
8
- $font-family-serif: Georgia, serif;
9
-
10
- // 2.2. Font sizes
11
- $font-size-base: 1rem;
12
- $font-size-l: 1.25rem;
13
- $font-size-xl: 1.5rem;
14
- $font-size-2xl: 1.875rem;
15
- $font-size-3xl: 2.75rem;
16
-
17
- // 2.3. Line heights
18
- $font-lh-base: 1.5rem;
19
- $font-lh-l: 2rem;
20
- $font-lh-xl: 2.25rem;
21
- $font-lh-2xl: 3rem;
22
- $font-lh-3xl: 4rem;
23
-
24
- // 2.4. Font weights
25
- $font-weight-normal: 400;
26
- $font-weight-bold: 600;
27
-
28
- // 2.5. Combinations of font size, line height and font weight
29
- @mixin font-h1 {
30
- font-weight: $font-weight-bold;
31
- font-size: $font-size-3xl;
32
- line-height: $font-lh-3xl;
33
- }
34
-
35
- @mixin font-h2 {
36
- font-weight: $font-weight-bold;
37
- font-size: $font-size-2xl;
38
- line-height: $font-lh-2xl;
39
- }
40
-
41
- @mixin font-h3 {
42
- font-weight: $font-weight-bold;
43
- font-size: $font-size-xl;
44
- line-height: $font-lh-xl;
45
- }
46
-
47
- @mixin font-h4 {
48
- font-weight: $font-weight-bold;
49
- font-size: $font-size-l;
50
- line-height: $font-lh-l;
51
- }
52
-
53
- @mixin font-h5 {
54
- font-weight: $font-weight-bold;
55
- font-size: $font-size-base;
56
- line-height: $font-lh-base;
57
- }
58
-
59
- @mixin font-body-copy {
60
- font-family: $font-family-serif;
61
- font-weight: 400;
62
- font-size: math.div(18rem, 16);
63
- line-height: math.div(28rem, 16);
64
- }
65
-
66
- @mixin font-body-lead {
67
- font-family: $font-family-sans;
68
- font-weight: 400;
69
- font-size: math.div(22rem, 16);
70
- line-height: math.div(32rem, 16);
71
- }
@@ -1,6 +0,0 @@
1
- /// List of all KTH Style Design Tokens
2
- @forward "./typography";
3
- @forward "./spacing";
4
- @forward "./colors";
5
-
6
- @use "./spacing" as spacing;
@@ -1,22 +0,0 @@
1
- @use "../tokens" as t;
2
-
3
- /// This mixin provides CSS custom properties used for sizing all UI elements
4
- @mixin sizes {
5
- @layer kth-style {
6
- :root {
7
- // Padding (block and inline axis) for clickable elements
8
- --kth-0-clickable-padding-block: #{t.$space-8};
9
- --kth-0-clickable-padding-inline: #{t.$space-16};
10
- }
11
-
12
- .kth-0-normal {
13
- --kth-0-clickable-padding-block: #{t.$space-8};
14
- --kth-0-clickable-padding-inline: #{t.$space-16};
15
- }
16
-
17
- .kth-0-small {
18
- --kth-0-clickable-padding-block: #{t.$space-4};
19
- --kth-0-clickable-padding-inline: #{t.$space-12};
20
- }
21
- }
22
- }