@kth/style 0.0.1 → 0.0.2
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/dist/cjs/components/Something.d.ts +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/{Tabs.js → cjs/index.js} +18 -18
- package/dist/cjs/stories/ContentTabs.stories.d.ts +13 -0
- package/dist/cjs/stories/NavigationTabs.stories.d.ts +12 -0
- package/dist/esm/components/Button.d.ts +29 -0
- package/dist/esm/components/Something.d.ts +1 -0
- package/dist/esm/components/Tabs.d.ts +34 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +108 -0
- package/dist/esm/stories/ContentTabs.stories.d.ts +13 -0
- package/dist/esm/stories/NavigationTabs.stories.d.ts +12 -0
- package/package.json +10 -3
- package/scss/globals.scss +2 -4
- package/scss/utils/reset.scss +193 -193
- package/scss/utils/sizes.scss +15 -12
- package/dist/Button.js +0 -15
- /package/dist/{Button.d.ts → cjs/components/Button.d.ts} +0 -0
- /package/dist/{Tabs.d.ts → cjs/components/Tabs.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hello2(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tab, ContentTabs, NavigationTabs } from "./components/Tabs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
5
|
function getValueFromUrl(key) {
|
|
6
6
|
const url = new URL(location.href);
|
|
7
7
|
if (key) {
|
|
@@ -20,8 +20,8 @@ function getValueFromUrl(key) {
|
|
|
20
20
|
*/
|
|
21
21
|
function useUrlState(defaultValue = "", key = "", enableUrl = false) {
|
|
22
22
|
const initialValue = getValueFromUrl(key) || defaultValue;
|
|
23
|
-
const [value, _setValue] =
|
|
24
|
-
|
|
23
|
+
const [value, _setValue] = React.useState(initialValue);
|
|
24
|
+
React.useEffect(() => {
|
|
25
25
|
function updateValue() {
|
|
26
26
|
if (enableUrl) {
|
|
27
27
|
_setValue(getValueFromUrl(key) || defaultValue);
|
|
@@ -79,34 +79,34 @@ function useFocus(element) {
|
|
|
79
79
|
* You should use {@link NavigationTabs} or {@link ContentTabs} instead.
|
|
80
80
|
*/
|
|
81
81
|
function GenericTabs({ classPrefix, children, id, defaultValue, url = "none", }) {
|
|
82
|
-
const ref =
|
|
82
|
+
const ref = React.useRef(null);
|
|
83
83
|
const [activeTab, setActiveTab] = useUrlState(defaultValue, url === "query" ? id : "", url === "query" || url === "hash");
|
|
84
84
|
let activeTabIndex = children.findIndex((c) => c.props.id === activeTab);
|
|
85
85
|
if (activeTabIndex === -1) {
|
|
86
86
|
activeTabIndex = 0;
|
|
87
87
|
}
|
|
88
88
|
useFocus(ref.current?.querySelector(`#${activeTab}-tab`));
|
|
89
|
-
return (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
return (React.createElement(React.Fragment, null,
|
|
90
|
+
React.createElement("div", { ref: ref, className: `${classPrefix}`, id: id },
|
|
91
|
+
React.createElement("ul", { className: `${classPrefix}__tablist`, role: "tablist" }, children.map((child, index) => (React.createElement("li", { role: "presentation", className: `${classPrefix}__tab-element` },
|
|
92
|
+
React.createElement("button", { key: child.props.id, role: "tab", "aria-selected": index === activeTabIndex, "aria-controls": child.props.id, id: `${child.props.id}-tab`, className: `${classPrefix}__tab`, tabIndex: index === activeTabIndex ? 0 : -1, onKeyDown: (event) => {
|
|
93
93
|
handleKeyDown(event, index, children, setActiveTab);
|
|
94
94
|
}, onClick: (event) => {
|
|
95
95
|
event.preventDefault();
|
|
96
96
|
setActiveTab(child.props.id);
|
|
97
97
|
} }, child.props.title)))))),
|
|
98
|
-
children.map((child, index) => (
|
|
98
|
+
children.map((child, index) => (React.createElement("div", { className: `${classPrefix}__tabpanel`, role: "tabpanel", "aria-labelledby": `${child.props.id}-tab`, id: child.props.id, key: index, hidden: index !== activeTabIndex }, child)))));
|
|
99
99
|
}
|
|
100
|
-
exports.GenericTabs = GenericTabs;
|
|
101
100
|
function NavigationTabs({ id, children, url = "query", defaultValue, }) {
|
|
102
|
-
return (
|
|
101
|
+
return (React.createElement(GenericTabs, { id: id, children: children, url: url, defaultValue: defaultValue, classPrefix: "kth-navigation-tabs" }));
|
|
103
102
|
}
|
|
104
|
-
exports.NavigationTabs = NavigationTabs;
|
|
105
103
|
function ContentTabs({ id, children, url = "hash", defaultValue, }) {
|
|
106
|
-
return (
|
|
104
|
+
return (React.createElement(GenericTabs, { id: id, children: children, url: url, defaultValue: defaultValue, classPrefix: "kth-content-tabs" }));
|
|
107
105
|
}
|
|
108
|
-
exports.ContentTabs = ContentTabs;
|
|
109
106
|
function Tab({ children }) {
|
|
110
|
-
return
|
|
107
|
+
return React.createElement(React.Fragment, null, children);
|
|
111
108
|
}
|
|
109
|
+
|
|
110
|
+
exports.ContentTabs = ContentTabs;
|
|
111
|
+
exports.NavigationTabs = NavigationTabs;
|
|
112
112
|
exports.Tab = Tab;
|
|
@@ -0,0 +1,13 @@
|
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react";
|
|
2
|
+
import { NavigationTabs } from "../components/Tabs";
|
|
3
|
+
import "../../scss/globals.scss";
|
|
4
|
+
import "../../scss/components/navigation-tabs.scss";
|
|
5
|
+
declare const meta: {
|
|
6
|
+
title: string;
|
|
7
|
+
component: typeof NavigationTabs;
|
|
8
|
+
tags: string[];
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
export declare const Primary: Story;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import "./button.css";
|
|
3
|
+
interface ButtonProps {
|
|
4
|
+
/**
|
|
5
|
+
* Is this the principal call to action on the page?
|
|
6
|
+
*/
|
|
7
|
+
primary?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* What background color to use
|
|
10
|
+
*/
|
|
11
|
+
backgroundColor?: string;
|
|
12
|
+
/**
|
|
13
|
+
* How large should the button be?
|
|
14
|
+
*/
|
|
15
|
+
size?: "small" | "medium" | "large";
|
|
16
|
+
/**
|
|
17
|
+
* Button contents
|
|
18
|
+
*/
|
|
19
|
+
label: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional click handler
|
|
22
|
+
*/
|
|
23
|
+
onClick?: () => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Primary UI component for user interaction
|
|
27
|
+
*/
|
|
28
|
+
export declare const Button: ({ primary, size, backgroundColor, label, ...props }: ButtonProps) => JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hello2(): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tab, ContentTabs, NavigationTabs } from "./components/Tabs";
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
function getValueFromUrl(key) {
|
|
4
|
+
const url = new URL(location.href);
|
|
5
|
+
if (key) {
|
|
6
|
+
return url.searchParams.get(key);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
return url.hash === "" ? null : url.hash.slice(1);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Sync state with URL hash or query parameter.
|
|
14
|
+
* @param defaultValue Default state value
|
|
15
|
+
* @param key Query parameter to use. Hash if empty
|
|
16
|
+
* @param enableUrl Will sync with URL if true (this function behaves the same
|
|
17
|
+
* as `React.useState` if false)
|
|
18
|
+
*/
|
|
19
|
+
function useUrlState(defaultValue = "", key = "", enableUrl = false) {
|
|
20
|
+
const initialValue = getValueFromUrl(key) || defaultValue;
|
|
21
|
+
const [value, _setValue] = React.useState(initialValue);
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
function updateValue() {
|
|
24
|
+
if (enableUrl) {
|
|
25
|
+
_setValue(getValueFromUrl(key) || defaultValue);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
window.addEventListener("popstate", updateValue);
|
|
29
|
+
return () => {
|
|
30
|
+
window.removeEventListener("popstate", updateValue);
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
function setValue(value) {
|
|
34
|
+
_setValue(value);
|
|
35
|
+
const url = new URL(location.href);
|
|
36
|
+
if (key !== "") {
|
|
37
|
+
url.searchParams.set(key, value);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
url.hash = "#" + value;
|
|
41
|
+
}
|
|
42
|
+
if (enableUrl) {
|
|
43
|
+
history.pushState(undefined, "", url);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return [value, setValue];
|
|
47
|
+
}
|
|
48
|
+
function handleKeyDown(event, index, tabs, setActiveTab) {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
switch (event.key) {
|
|
51
|
+
case "ArrowLeft":
|
|
52
|
+
case "ArrowUp":
|
|
53
|
+
if (index > 0) {
|
|
54
|
+
setActiveTab(tabs[index - 1].props.id);
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
case "ArrowRight":
|
|
58
|
+
case "ArrowDown":
|
|
59
|
+
if (index < tabs.length - 1) {
|
|
60
|
+
setActiveTab(tabs[index + 1].props.id);
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
case "Home":
|
|
64
|
+
setActiveTab(tabs[0].props.id);
|
|
65
|
+
break;
|
|
66
|
+
case "End":
|
|
67
|
+
setActiveTab(tabs[tabs.length - 1].props.id);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function useFocus(element) {
|
|
72
|
+
element?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
73
|
+
element?.focus();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Highly customizable Tabs component made for testing purposes.
|
|
77
|
+
* You should use {@link NavigationTabs} or {@link ContentTabs} instead.
|
|
78
|
+
*/
|
|
79
|
+
function GenericTabs({ classPrefix, children, id, defaultValue, url = "none", }) {
|
|
80
|
+
const ref = React.useRef(null);
|
|
81
|
+
const [activeTab, setActiveTab] = useUrlState(defaultValue, url === "query" ? id : "", url === "query" || url === "hash");
|
|
82
|
+
let activeTabIndex = children.findIndex((c) => c.props.id === activeTab);
|
|
83
|
+
if (activeTabIndex === -1) {
|
|
84
|
+
activeTabIndex = 0;
|
|
85
|
+
}
|
|
86
|
+
useFocus(ref.current?.querySelector(`#${activeTab}-tab`));
|
|
87
|
+
return (React.createElement(React.Fragment, null,
|
|
88
|
+
React.createElement("div", { ref: ref, className: `${classPrefix}`, id: id },
|
|
89
|
+
React.createElement("ul", { className: `${classPrefix}__tablist`, role: "tablist" }, children.map((child, index) => (React.createElement("li", { role: "presentation", className: `${classPrefix}__tab-element` },
|
|
90
|
+
React.createElement("button", { key: child.props.id, role: "tab", "aria-selected": index === activeTabIndex, "aria-controls": child.props.id, id: `${child.props.id}-tab`, className: `${classPrefix}__tab`, tabIndex: index === activeTabIndex ? 0 : -1, onKeyDown: (event) => {
|
|
91
|
+
handleKeyDown(event, index, children, setActiveTab);
|
|
92
|
+
}, onClick: (event) => {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
setActiveTab(child.props.id);
|
|
95
|
+
} }, child.props.title)))))),
|
|
96
|
+
children.map((child, index) => (React.createElement("div", { className: `${classPrefix}__tabpanel`, role: "tabpanel", "aria-labelledby": `${child.props.id}-tab`, id: child.props.id, key: index, hidden: index !== activeTabIndex }, child)))));
|
|
97
|
+
}
|
|
98
|
+
function NavigationTabs({ id, children, url = "query", defaultValue, }) {
|
|
99
|
+
return (React.createElement(GenericTabs, { id: id, children: children, url: url, defaultValue: defaultValue, classPrefix: "kth-navigation-tabs" }));
|
|
100
|
+
}
|
|
101
|
+
function ContentTabs({ id, children, url = "hash", defaultValue, }) {
|
|
102
|
+
return (React.createElement(GenericTabs, { id: id, children: children, url: url, defaultValue: defaultValue, classPrefix: "kth-content-tabs" }));
|
|
103
|
+
}
|
|
104
|
+
function Tab({ children }) {
|
|
105
|
+
return React.createElement(React.Fragment, null, children);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { ContentTabs, NavigationTabs, Tab };
|
|
@@ -0,0 +1,13 @@
|
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react";
|
|
2
|
+
import { NavigationTabs } from "../components/Tabs";
|
|
3
|
+
import "../../scss/globals.scss";
|
|
4
|
+
import "../../scss/components/navigation-tabs.scss";
|
|
5
|
+
declare const meta: {
|
|
6
|
+
title: string;
|
|
7
|
+
component: typeof NavigationTabs;
|
|
8
|
+
tags: string[];
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
export declare const Primary: Story;
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kth/style",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"main": "dist/cjs/index.js",
|
|
5
|
+
"module": "dist/esm/index.js",
|
|
4
6
|
"scripts": {
|
|
5
7
|
"clean": "rm -rf dist",
|
|
6
8
|
"dev": "storybook dev -p 6006",
|
|
7
9
|
"build": "npm run clean && npm run build:components && npm run build:storybook",
|
|
8
|
-
"build:components": "
|
|
10
|
+
"build:components": "rollup -c",
|
|
9
11
|
"build:storybook": "storybook build -o ../../apps/style-web/public/storybook",
|
|
10
12
|
"test": "npm run test:lint",
|
|
11
13
|
"test:lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
|
|
@@ -15,6 +17,9 @@
|
|
|
15
17
|
"dist"
|
|
16
18
|
],
|
|
17
19
|
"devDependencies": {
|
|
20
|
+
"@rollup/plugin-commonjs": "^24.1.0",
|
|
21
|
+
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
22
|
+
"@rollup/plugin-typescript": "^11.1.0",
|
|
18
23
|
"@storybook/addon-essentials": "^7.0.6",
|
|
19
24
|
"@storybook/addon-interactions": "^7.0.6",
|
|
20
25
|
"@storybook/addon-links": "^7.0.6",
|
|
@@ -34,11 +39,13 @@
|
|
|
34
39
|
"prop-types": "^15.8.1",
|
|
35
40
|
"react": "^18.2.0",
|
|
36
41
|
"react-dom": "^18.2.0",
|
|
42
|
+
"rollup": "^3.21.4",
|
|
37
43
|
"storybook": "^7.0.6",
|
|
38
44
|
"typescript": "^5.0.2",
|
|
39
45
|
"vite": "^4.3.0"
|
|
40
46
|
},
|
|
41
47
|
"peerDependencies": {
|
|
42
48
|
"react": "*"
|
|
43
|
-
}
|
|
49
|
+
},
|
|
50
|
+
"gitHead": "a71425ae93ee8bcd66a82aed10b1743769b68984"
|
|
44
51
|
}
|
package/scss/globals.scss
CHANGED
package/scss/utils/reset.scss
CHANGED
|
@@ -3,242 +3,242 @@
|
|
|
3
3
|
/// Adaptation of normalize.css v8.0.1
|
|
4
4
|
/// github.com/necolas/normalize.css
|
|
5
5
|
///
|
|
6
|
-
///
|
|
7
|
-
///
|
|
8
|
-
///
|
|
9
|
-
/// Use this mixin if you wanted a **scoped** version of the mixin, i.e., if you
|
|
10
|
-
/// want the reset to be applied to a part of the document.
|
|
11
|
-
///
|
|
12
|
-
/// If you want a global version of this, use the `reset` file outside of the
|
|
13
|
-
/// `globals` directory
|
|
6
|
+
/// This mixin normalizes all browsers and provides basic global styles for all
|
|
7
|
+
/// HTML elements. This mixin only styles elements in isolation
|
|
14
8
|
@mixin reset {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
}
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
/* Sections
|
|
23
18
|
========================================================================== */
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
}
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
h1 {
|
|
31
|
+
@include t.font-h1();
|
|
32
|
+
}
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
h2 {
|
|
35
|
+
@include t.font-h2();
|
|
36
|
+
}
|
|
42
37
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
h3 {
|
|
39
|
+
@include t.font-h3();
|
|
40
|
+
}
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
h4 {
|
|
43
|
+
@include t.font-h4();
|
|
44
|
+
}
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
h5,
|
|
47
|
+
h6 {
|
|
48
|
+
@include t.font-h5();
|
|
49
|
+
}
|
|
55
50
|
|
|
56
|
-
|
|
51
|
+
/* Grouping content
|
|
57
52
|
========================================================================== */
|
|
58
53
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
+
overflow: visible; /* 2 */
|
|
60
|
+
}
|
|
66
61
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
// 1. Correct the inheritance and scaling of font size in all browsers.
|
|
63
|
+
// 2. Correct the odd `em` font sizing in all browsers.
|
|
64
|
+
pre {
|
|
65
|
+
font-family: monospace, monospace; /* 1 */
|
|
66
|
+
font-size: 1em; /* 2 */
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
iframe {
|
|
70
|
+
border: none;
|
|
71
|
+
}
|
|
73
72
|
|
|
74
|
-
|
|
73
|
+
/* Text-level semantics
|
|
75
74
|
========================================================================== */
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
a {
|
|
76
|
+
// color: t.$color-blue-5;
|
|
77
|
+
text-decoration: none;
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
&:hover {
|
|
80
|
+
text-decoration: underline;
|
|
81
|
+
}
|
|
82
82
|
}
|
|
83
|
-
}
|
|
84
83
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
// 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
|
|
85
|
+
abbr[title] {
|
|
86
|
+
text-decoration: underline; /* 2 */
|
|
87
|
+
text-decoration: underline dotted; /* 2 */
|
|
88
|
+
}
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
b,
|
|
91
|
+
strong {
|
|
92
|
+
font-weight: t.$font-weight-bold;
|
|
93
|
+
}
|
|
95
94
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
// 1. Correct the inheritance and scaling of font size in all browsers.
|
|
96
|
+
// 2. Correct the odd `em` font sizing in all browsers.
|
|
97
|
+
code,
|
|
98
|
+
kbd,
|
|
99
|
+
samp {
|
|
100
|
+
font-family: monospace, monospace; /* 1 */
|
|
101
|
+
font-size: 1em; /* 2 */
|
|
102
|
+
}
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
small {
|
|
105
|
+
// TODO: This is the default in normalize.css. Define the right one
|
|
106
|
+
font-size: 80%;
|
|
107
|
+
}
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
109
|
+
// Prevent `sub` and `sup` elements from affecting the line height in all browsers.
|
|
110
|
+
sub,
|
|
111
|
+
sup {
|
|
112
|
+
font-size: 75%;
|
|
113
|
+
line-height: 0;
|
|
114
|
+
position: relative;
|
|
115
|
+
vertical-align: baseline;
|
|
116
|
+
}
|
|
118
117
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
sub {
|
|
119
|
+
bottom: -0.25em;
|
|
120
|
+
}
|
|
122
121
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
sup {
|
|
123
|
+
top: -0.5em;
|
|
124
|
+
}
|
|
126
125
|
|
|
127
|
-
|
|
126
|
+
/* Forms
|
|
128
127
|
========================================================================== */
|
|
129
128
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
129
|
+
// 1. Change the font styles in all browsers.
|
|
130
|
+
// 2. Remove the margin in Firefox and Safari.
|
|
131
|
+
button,
|
|
132
|
+
input,
|
|
133
|
+
optgroup,
|
|
134
|
+
select,
|
|
135
|
+
textarea {
|
|
136
|
+
font-family: inherit; /* 1 */
|
|
137
|
+
font-size: 100%; /* 1 */
|
|
138
|
+
line-height: t.$font-lh-base; /* 1 */
|
|
139
|
+
margin: 0; /* 2 */
|
|
140
|
+
}
|
|
142
141
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
142
|
+
// Remove the inheritance of text transform in Edge, Firefox, and IE.
|
|
143
|
+
// Remove the inheritance of text transform in Firefox.
|
|
144
|
+
button,
|
|
145
|
+
select {
|
|
146
|
+
/* 1 */
|
|
147
|
+
text-transform: none;
|
|
148
|
+
}
|
|
150
149
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
150
|
+
// Correct the inability to style clickable types in iOS and Safari.
|
|
151
|
+
button,
|
|
152
|
+
[type="button"],
|
|
153
|
+
[type="reset"],
|
|
154
|
+
[type="submit"] {
|
|
155
|
+
-webkit-appearance: button;
|
|
156
|
+
}
|
|
158
157
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
158
|
+
// Remove the inner border and padding in Firefox.
|
|
159
|
+
button::-moz-focus-inner,
|
|
160
|
+
[type="button"]::-moz-focus-inner,
|
|
161
|
+
[type="reset"]::-moz-focus-inner,
|
|
162
|
+
[type="submit"]::-moz-focus-inner {
|
|
163
|
+
border-style: none;
|
|
164
|
+
padding: 0;
|
|
165
|
+
}
|
|
167
166
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
167
|
+
// Restore the focus styles unset by the previous rule.
|
|
168
|
+
button:-moz-focusring,
|
|
169
|
+
[type="button"]:-moz-focusring,
|
|
170
|
+
[type="reset"]:-moz-focusring,
|
|
171
|
+
[type="submit"]:-moz-focusring {
|
|
172
|
+
outline: 1px dotted ButtonText;
|
|
173
|
+
}
|
|
175
174
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
175
|
+
// Correct the padding in Firefox.
|
|
176
|
+
fieldset {
|
|
177
|
+
// TODO: unifiy with our own values
|
|
178
|
+
padding: 0.35em 0.75em 0.625em;
|
|
179
|
+
}
|
|
181
180
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
181
|
+
// 1. Correct the text wrapping in Edge and IE.
|
|
182
|
+
// 2. Correct the color inheritance from `fieldset` elements in IE.
|
|
183
|
+
// 3. Remove the padding so developers are not caught out when they zero out
|
|
184
|
+
// `fieldset` elements in all browsers.
|
|
185
|
+
legend {
|
|
186
|
+
box-sizing: border-box; /* 1 */
|
|
187
|
+
color: inherit; /* 2 */
|
|
188
|
+
display: table; /* 1 */
|
|
189
|
+
max-width: 100%; /* 1 */
|
|
190
|
+
padding: 0; /* 3 */
|
|
191
|
+
white-space: normal; /* 1 */
|
|
192
|
+
}
|
|
194
193
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
// Add the correct vertical alignment in Chrome, Firefox, and Opera.
|
|
195
|
+
progress {
|
|
196
|
+
vertical-align: baseline;
|
|
197
|
+
}
|
|
199
198
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
199
|
+
// Correct the cursor style of increment and decrement buttons in Chrome.
|
|
200
|
+
[type="number"]::-webkit-inner-spin-button,
|
|
201
|
+
[type="number"]::-webkit-outer-spin-button {
|
|
202
|
+
height: auto;
|
|
203
|
+
}
|
|
205
204
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
205
|
+
// 1. Correct the odd appearance in Chrome and Safari.
|
|
206
|
+
// 2. Correct the outline style in Safari.
|
|
207
|
+
[type="search"] {
|
|
208
|
+
-webkit-appearance: textfield; /* 1 */
|
|
209
|
+
outline-offset: -2px; /* 2 */
|
|
210
|
+
}
|
|
212
211
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
212
|
+
// Remove the inner padding in Chrome and Safari on macOS.
|
|
213
|
+
[type="search"]::-webkit-search-decoration {
|
|
214
|
+
-webkit-appearance: none;
|
|
215
|
+
}
|
|
217
216
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
217
|
+
// 1. Correct the inability to style clickable types in iOS and Safari.
|
|
218
|
+
// 2. Change font properties to `inherit` in Safari.
|
|
219
|
+
::-webkit-file-upload-button {
|
|
220
|
+
-webkit-appearance: button; /* 1 */
|
|
221
|
+
font: inherit; /* 2 */
|
|
222
|
+
}
|
|
224
223
|
|
|
225
|
-
|
|
224
|
+
/* Interactive
|
|
226
225
|
========================================================================== */
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
226
|
+
// Add the correct display in Edge, IE 10+, and Firefox.
|
|
227
|
+
details {
|
|
228
|
+
display: block;
|
|
229
|
+
}
|
|
231
230
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
231
|
+
// Add the correct display in all browsers.
|
|
232
|
+
summary {
|
|
233
|
+
display: list-item;
|
|
234
|
+
}
|
|
236
235
|
|
|
237
|
-
|
|
236
|
+
/* Misc
|
|
238
237
|
========================================================================== */
|
|
239
238
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
239
|
+
// Add the correct display
|
|
240
|
+
[hidden] {
|
|
241
|
+
display: none;
|
|
242
|
+
}
|
|
243
243
|
}
|
|
244
244
|
}
|
package/scss/utils/sizes.scss
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
@use "../tokens" as t;
|
|
2
2
|
|
|
3
|
+
/// This mixin provides CSS custom properties used for sizing all UI elements
|
|
3
4
|
@mixin sizes {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
}
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
.kth-0-normal {
|
|
13
|
+
--kth-0-clickable-padding-block: #{t.$space-8};
|
|
14
|
+
--kth-0-clickable-padding-inline: #{t.$space-16};
|
|
15
|
+
}
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
.kth-0-small {
|
|
18
|
+
--kth-0-clickable-padding-block: #{t.$space-4};
|
|
19
|
+
--kth-0-clickable-padding-inline: #{t.$space-12};
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
}
|
package/dist/Button.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Button = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
require("./button.css");
|
|
6
|
-
/**
|
|
7
|
-
* Primary UI component for user interaction
|
|
8
|
-
*/
|
|
9
|
-
const Button = ({ primary = false, size = "medium", backgroundColor, label, ...props }) => {
|
|
10
|
-
const mode = primary
|
|
11
|
-
? "storybook-button--primary"
|
|
12
|
-
: "storybook-button--secondary";
|
|
13
|
-
return (react_1.default.createElement("button", { type: "button", className: ["storybook-button", `storybook-button--${size}`, mode].join(" "), style: { backgroundColor }, ...props }, label));
|
|
14
|
-
};
|
|
15
|
-
exports.Button = Button;
|
|
File without changes
|
|
File without changes
|