@kth/style 0.0.12 → 0.2.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.
- package/README.md +28 -22
- package/dist/cjs/components/MenuPanel.d.ts +13 -0
- package/dist/cjs/index.d.ts +1 -5
- package/dist/cjs/index.js +63 -165
- package/dist/cjs/react.d.ts +1 -0
- package/dist/cjs/react.js +7 -0
- package/dist/esm/components/MenuPanel.d.ts +13 -0
- package/dist/esm/index.d.ts +1 -5
- package/dist/esm/index.js +63 -137
- package/dist/esm/react.d.ts +1 -0
- package/dist/esm/react.js +5 -0
- package/package.json +14 -14
- package/scss/components/a11y-nav.scss +31 -0
- package/scss/components/button.scss +20 -66
- package/scss/components/header.scss +40 -0
- package/scss/components/logotype.scss +28 -0
- package/scss/components/mega-menu.scss +33 -0
- package/scss/components/menu-item.scss +40 -0
- package/scss/components/menu-panel.scss +32 -0
- package/scss/components/search.scss +54 -0
- package/scss/components/visually-hidden.scss +11 -0
- package/scss/tokens/colors.scss +60 -0
- package/scss/tokens/icons.scss +69 -0
- package/scss/tokens/spacing.scss +31 -0
- package/scss/tokens/typography.scss +35 -0
- package/scss/utils/mixins.scss +19 -0
- package/scss/utils/prose.scss +88 -76
- package/scss/utils/reset.scss +59 -247
- package/dist/cjs/components/Button.d.ts +0 -20
- package/dist/cjs/components/Radio.d.ts +0 -20
- package/dist/cjs/components/Select.d.ts +0 -36
- package/dist/cjs/components/Tabs.d.ts +0 -34
- package/dist/cjs/icons/400/ArrowBack.d.ts +0 -3
- package/dist/cjs/icons/400/Check.d.ts +0 -3
- package/dist/cjs/icons/500/ArrowForward.d.ts +0 -3
- package/dist/cjs/stories/Button.stories.d.ts +0 -14
- package/dist/cjs/stories/ContentTabs.stories.d.ts +0 -13
- package/dist/cjs/stories/FilterTabs.stories.d.ts +0 -12
- package/dist/cjs/stories/InlineIcons.stories.d.ts +0 -9
- package/dist/cjs/stories/Select.stories.d.ts +0 -14
- package/dist/esm/components/Button.d.ts +0 -20
- package/dist/esm/components/Radio.d.ts +0 -20
- package/dist/esm/components/Select.d.ts +0 -36
- package/dist/esm/components/Tabs.d.ts +0 -34
- package/dist/esm/icons/400/ArrowBack.d.ts +0 -3
- package/dist/esm/icons/400/Check.d.ts +0 -3
- package/dist/esm/icons/500/ArrowForward.d.ts +0 -3
- package/dist/esm/stories/Button.stories.d.ts +0 -14
- package/dist/esm/stories/ContentTabs.stories.d.ts +0 -13
- package/dist/esm/stories/FilterTabs.stories.d.ts +0 -12
- package/dist/esm/stories/InlineIcons.stories.d.ts +0 -9
- package/dist/esm/stories/Select.stories.d.ts +0 -14
- package/scss/components/content-tabs.scss +0 -68
- package/scss/components/filter-tabs.scss +0 -31
- package/scss/components/form.scss +0 -48
- package/scss/components/inline-icon.scss +0 -7
- package/scss/globals.scss +0 -5
- package/scss/tokens/_colors.scss +0 -20
- package/scss/tokens/_spacing.en.md +0 -40
- package/scss/tokens/_spacing.scss +0 -81
- package/scss/tokens/_typography.scss +0 -71
- package/scss/tokens/index.scss +0 -6
- package/scss/utils/sizes.scss +0 -22
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from "@storybook/react";
|
|
2
|
-
import { FilterTabs } from "../components/Radio";
|
|
3
|
-
import "../../scss/globals.scss";
|
|
4
|
-
import "../../scss/components/filter-tabs.scss";
|
|
5
|
-
declare const meta: {
|
|
6
|
-
title: string;
|
|
7
|
-
component: typeof FilterTabs;
|
|
8
|
-
tags: string[];
|
|
9
|
-
};
|
|
10
|
-
export default meta;
|
|
11
|
-
type Story = StoryObj<typeof meta>;
|
|
12
|
-
export declare const Primary: Story;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from "@storybook/react";
|
|
2
|
-
import "../../scss/globals.scss";
|
|
3
|
-
import "../../scss/components/inline-icon.scss";
|
|
4
|
-
declare const meta: {
|
|
5
|
-
title: string;
|
|
6
|
-
tags: string[];
|
|
7
|
-
};
|
|
8
|
-
export default meta;
|
|
9
|
-
export declare const CheckIcon: StoryObj;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from "@storybook/react";
|
|
2
|
-
import { Select } from "../components/Select";
|
|
3
|
-
import "../../scss/globals.scss";
|
|
4
|
-
import "../../scss/components/form.scss";
|
|
5
|
-
declare const meta: {
|
|
6
|
-
title: string;
|
|
7
|
-
component: typeof Select;
|
|
8
|
-
tags: string[];
|
|
9
|
-
};
|
|
10
|
-
export default meta;
|
|
11
|
-
type Story = StoryObj<typeof meta>;
|
|
12
|
-
export declare const WithDescriptions: Story;
|
|
13
|
-
export declare const WithoutDescriptions: Story;
|
|
14
|
-
export declare const WithError: Story;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
interface ButtonProps {
|
|
3
|
-
/** The label of the button */
|
|
4
|
-
children?: string;
|
|
5
|
-
/** The callback function when the button is clicked */
|
|
6
|
-
onClick?: () => void;
|
|
7
|
-
/** Appearance */
|
|
8
|
-
appearance: "primary" | "secondary" | "tertiary";
|
|
9
|
-
}
|
|
10
|
-
interface IconButtonProps {
|
|
11
|
-
/** The label of the button */
|
|
12
|
-
children?: string;
|
|
13
|
-
/** The callback function when the button is clicked */
|
|
14
|
-
onClick?: () => void;
|
|
15
|
-
}
|
|
16
|
-
/** A button with just text */
|
|
17
|
-
export declare function Button({ children, onClick, appearance }: ButtonProps): JSX.Element;
|
|
18
|
-
export declare function BackButton({ children, onClick }: IconButtonProps): JSX.Element;
|
|
19
|
-
export declare function ForwardButton({ children, onClick }: IconButtonProps): JSX.Element;
|
|
20
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface RadioGroupProps {
|
|
3
|
-
/** Options */
|
|
4
|
-
children: React.ReactElement<RadioProps> | React.ReactElement<RadioProps>[];
|
|
5
|
-
/** The value of the selected radio button */
|
|
6
|
-
value: string;
|
|
7
|
-
/** The callback function when a different choice is made by the user */
|
|
8
|
-
onChange: (value: string) => void;
|
|
9
|
-
}
|
|
10
|
-
interface RadioProps {
|
|
11
|
-
/** The value of the radio button */
|
|
12
|
-
value: string;
|
|
13
|
-
/** The label of the radio button */
|
|
14
|
-
label: string;
|
|
15
|
-
}
|
|
16
|
-
/** Implemented as fancy radio buttons */
|
|
17
|
-
export declare function FilterTabs({ children, value, onChange }: RadioGroupProps): JSX.Element;
|
|
18
|
-
/** A single radio button */
|
|
19
|
-
export declare function Radio({ value, label }: RadioProps): JSX.Element;
|
|
20
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface SelectProps {
|
|
3
|
-
/** Equivalent to HTML `name` */
|
|
4
|
-
name: string;
|
|
5
|
-
/** Label for the select */
|
|
6
|
-
label: string;
|
|
7
|
-
/** Select description */
|
|
8
|
-
description?: string;
|
|
9
|
-
/** Current value of the select field */
|
|
10
|
-
value: string;
|
|
11
|
-
/** Called when the select value changes */
|
|
12
|
-
onChange(value: string): void;
|
|
13
|
-
/** Options */
|
|
14
|
-
children: React.ReactNode;
|
|
15
|
-
/**
|
|
16
|
-
* Error message if the field has errors. `undefined` here means the field
|
|
17
|
-
* contains no error.
|
|
18
|
-
*/
|
|
19
|
-
error?: string;
|
|
20
|
-
}
|
|
21
|
-
interface OptionProps {
|
|
22
|
-
/** The value for the option */
|
|
23
|
-
value: string;
|
|
24
|
-
/** Human-readable label for the option */
|
|
25
|
-
children: string;
|
|
26
|
-
/** True if the option should be disabled */
|
|
27
|
-
disabled?: boolean;
|
|
28
|
-
}
|
|
29
|
-
interface OptionGroupProps {
|
|
30
|
-
label: string;
|
|
31
|
-
children: React.ReactNode;
|
|
32
|
-
}
|
|
33
|
-
export declare function Select({ name, label, description, value, onChange, children, error, }: SelectProps): JSX.Element;
|
|
34
|
-
export declare function OptionGroup({ label, children }: OptionGroupProps): JSX.Element;
|
|
35
|
-
export declare function Option({ value, children, disabled }: OptionProps): JSX.Element;
|
|
36
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface TabProps {
|
|
3
|
-
children?: React.ReactNode;
|
|
4
|
-
id: string;
|
|
5
|
-
title: string;
|
|
6
|
-
}
|
|
7
|
-
interface GenericTabsProps {
|
|
8
|
-
classPrefix: string;
|
|
9
|
-
children: React.ReactElement<TabProps>[];
|
|
10
|
-
id: string;
|
|
11
|
-
defaultValue?: string;
|
|
12
|
-
url: "query" | "hash" | "none";
|
|
13
|
-
}
|
|
14
|
-
interface NavigationTabsProps {
|
|
15
|
-
id: string;
|
|
16
|
-
children: React.ReactElement<TabProps>[];
|
|
17
|
-
url?: "query" | "none";
|
|
18
|
-
defaultValue?: string;
|
|
19
|
-
}
|
|
20
|
-
interface ContentTabsProps {
|
|
21
|
-
id: string;
|
|
22
|
-
children: React.ReactElement<TabProps>[];
|
|
23
|
-
url?: "hash" | "none";
|
|
24
|
-
defaultValue?: string;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Highly customizable Tabs component made for testing purposes.
|
|
28
|
-
* You should use {@link NavigationTabs} or {@link ContentTabs} instead.
|
|
29
|
-
*/
|
|
30
|
-
export declare function GenericTabs({ classPrefix, children, id, defaultValue, url, }: GenericTabsProps): JSX.Element;
|
|
31
|
-
export declare function NavigationTabs({ id, children, url, defaultValue, }: NavigationTabsProps): JSX.Element;
|
|
32
|
-
export declare function ContentTabs({ id, children, url, defaultValue, }: ContentTabsProps): JSX.Element;
|
|
33
|
-
export declare function Tab({ children }: TabProps): JSX.Element;
|
|
34
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from "@storybook/react";
|
|
2
|
-
import { Button } from "../components/Button";
|
|
3
|
-
import "../../scss/globals.scss";
|
|
4
|
-
import "../../scss/components/button.scss";
|
|
5
|
-
declare const meta: {
|
|
6
|
-
title: string;
|
|
7
|
-
component: typeof Button;
|
|
8
|
-
tags: string[];
|
|
9
|
-
};
|
|
10
|
-
export default meta;
|
|
11
|
-
type Story = StoryObj<typeof meta>;
|
|
12
|
-
export declare const Primary: Story;
|
|
13
|
-
export declare const Back: StoryObj;
|
|
14
|
-
export declare const Forward: StoryObj;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from "@storybook/react";
|
|
2
|
-
import { ContentTabs } from "../components/Tabs";
|
|
3
|
-
import "../../scss/globals.scss";
|
|
4
|
-
import "../../scss/components/content-tabs.scss";
|
|
5
|
-
declare const meta: {
|
|
6
|
-
title: string;
|
|
7
|
-
component: typeof ContentTabs;
|
|
8
|
-
tags: string[];
|
|
9
|
-
};
|
|
10
|
-
export default meta;
|
|
11
|
-
type Story = StoryObj<typeof meta>;
|
|
12
|
-
export declare const Primary: Story;
|
|
13
|
-
export declare const Secondary: Story;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from "@storybook/react";
|
|
2
|
-
import { FilterTabs } from "../components/Radio";
|
|
3
|
-
import "../../scss/globals.scss";
|
|
4
|
-
import "../../scss/components/filter-tabs.scss";
|
|
5
|
-
declare const meta: {
|
|
6
|
-
title: string;
|
|
7
|
-
component: typeof FilterTabs;
|
|
8
|
-
tags: string[];
|
|
9
|
-
};
|
|
10
|
-
export default meta;
|
|
11
|
-
type Story = StoryObj<typeof meta>;
|
|
12
|
-
export declare const Primary: Story;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from "@storybook/react";
|
|
2
|
-
import "../../scss/globals.scss";
|
|
3
|
-
import "../../scss/components/inline-icon.scss";
|
|
4
|
-
declare const meta: {
|
|
5
|
-
title: string;
|
|
6
|
-
tags: string[];
|
|
7
|
-
};
|
|
8
|
-
export default meta;
|
|
9
|
-
export declare const CheckIcon: StoryObj;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from "@storybook/react";
|
|
2
|
-
import { Select } from "../components/Select";
|
|
3
|
-
import "../../scss/globals.scss";
|
|
4
|
-
import "../../scss/components/form.scss";
|
|
5
|
-
declare const meta: {
|
|
6
|
-
title: string;
|
|
7
|
-
component: typeof Select;
|
|
8
|
-
tags: string[];
|
|
9
|
-
};
|
|
10
|
-
export default meta;
|
|
11
|
-
type Story = StoryObj<typeof meta>;
|
|
12
|
-
export declare const WithDescriptions: Story;
|
|
13
|
-
export declare const WithoutDescriptions: Story;
|
|
14
|
-
export declare const WithError: Story;
|
|
@@ -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
|
-
}
|
package/scss/globals.scss
DELETED
package/scss/tokens/_colors.scss
DELETED
|
@@ -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,81 +0,0 @@
|
|
|
1
|
-
@use "sass:list";
|
|
2
|
-
@use "sass:map";
|
|
3
|
-
/// Design Tokens for spacing
|
|
4
|
-
|
|
5
|
-
$space-0: 0;
|
|
6
|
-
$space-2: 0.125rem;
|
|
7
|
-
$space-4: 0.25rem;
|
|
8
|
-
$space-6: 0.375rem;
|
|
9
|
-
$space-8: 0.5rem;
|
|
10
|
-
$space-12: 0.75rem;
|
|
11
|
-
$space-16: 1rem;
|
|
12
|
-
$space-20: 1.25rem;
|
|
13
|
-
$space-24: 1.5rem;
|
|
14
|
-
$space-32: 2rem;
|
|
15
|
-
$space-40: 2.5rem;
|
|
16
|
-
$space-48: 3rem;
|
|
17
|
-
$space-64: 4rem;
|
|
18
|
-
$space-80: 5rem;
|
|
19
|
-
|
|
20
|
-
// Convinience map that stores every value. Used internally
|
|
21
|
-
$_all_spaces: (
|
|
22
|
-
0: $space-0,
|
|
23
|
-
2: $space-2,
|
|
24
|
-
4: $space-4,
|
|
25
|
-
6: $space-6,
|
|
26
|
-
8: $space-8,
|
|
27
|
-
12: $space-12,
|
|
28
|
-
16: $space-16,
|
|
29
|
-
20: $space-20,
|
|
30
|
-
24: $space-24,
|
|
31
|
-
32: $space-32,
|
|
32
|
-
40: $space-40,
|
|
33
|
-
48: $space-48,
|
|
34
|
-
64: $space-64,
|
|
35
|
-
80: $space-80,
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
/// Converts a single KTH Style space value to rem.
|
|
39
|
-
/// Throws an Error if the argument is not part of the valid spaces
|
|
40
|
-
///
|
|
41
|
-
/// This function is used internally.
|
|
42
|
-
@function _space_to_rem($space) {
|
|
43
|
-
@if map.get($_all_spaces, $space) == null {
|
|
44
|
-
@error "#{$space} is not a valid spacing. Use one of the following instead: #{$_all_spaces}";
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@return map.get($_all_spaces, $space);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/// Converts a list of "KTH Style space" value to their rem values.
|
|
51
|
-
/// Throws an Error if any element is not valid
|
|
52
|
-
///
|
|
53
|
-
/// This function is used internally.
|
|
54
|
-
@function _spaces_to_rem($list-of-spaces) {
|
|
55
|
-
$list-of-rem: ();
|
|
56
|
-
|
|
57
|
-
@each $element in $list-of-spaces {
|
|
58
|
-
$list-of-rem: list.append($list-of-rem, _space_to_rem($element));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
@return $list-of-rem;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/// Converts a list of "KTH Style padding" values to actual CSS measurements.
|
|
65
|
-
@function padding($list) {
|
|
66
|
-
@return _spaces_to_rem($list);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/// Converts a list of "KTH Style margin" values to actual CSS measurements..
|
|
70
|
-
@function margin($list) {
|
|
71
|
-
@return _spaces_to_rem($list);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/// Converts a list of "KTH Style gap" values to actual CSS measurements..
|
|
75
|
-
@function gap($list) {
|
|
76
|
-
@return _spaces_to_rem($list);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
@function border-radius($list) {
|
|
80
|
-
@return _spaces_to_rem($list);
|
|
81
|
-
}
|
|
@@ -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
|
-
}
|
package/scss/tokens/index.scss
DELETED
package/scss/utils/sizes.scss
DELETED
|
@@ -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
|
-
}
|