@kth/style 0.0.1 → 0.0.3

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 @@
1
+ export declare function hello2(): void;
@@ -0,0 +1 @@
1
+ export { Tab, ContentTabs, NavigationTabs } from "./components/Tabs";
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Tab = exports.ContentTabs = exports.NavigationTabs = exports.GenericTabs = void 0;
4
- const react_1 = require("react");
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) {
@@ -19,9 +19,9 @@ function getValueFromUrl(key) {
19
19
  * as `React.useState` if false)
20
20
  */
21
21
  function useUrlState(defaultValue = "", key = "", enableUrl = false) {
22
- const initialValue = getValueFromUrl(key) || defaultValue;
23
- const [value, _setValue] = react_1.default.useState(initialValue);
24
- react_1.default.useEffect(() => {
22
+ const initialValue = (enableUrl && getValueFromUrl(key)) || defaultValue;
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 = react_1.default.useRef(null);
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 (react_1.default.createElement(react_1.default.Fragment, null,
90
- react_1.default.createElement("div", { ref: ref, className: `${classPrefix}`, id: id },
91
- react_1.default.createElement("ul", { className: `${classPrefix}__tablist`, role: "tablist" }, children.map((child, index) => (react_1.default.createElement("li", { role: "presentation", className: `${classPrefix}__tab-element` },
92
- react_1.default.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) => {
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) => (react_1.default.createElement("div", { className: `${classPrefix}__tabpanel`, role: "tabpanel", "aria-labelledby": `${child.props.id}-tab`, id: child.props.id, key: index, hidden: index !== activeTabIndex }, child)))));
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 (react_1.default.createElement(GenericTabs, { id: id, children: children, url: url, defaultValue: defaultValue, classPrefix: "kth-navigation-tabs" }));
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 (react_1.default.createElement(GenericTabs, { id: id, children: children, url: url, defaultValue: defaultValue, classPrefix: "kth-content-tabs" }));
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 react_1.default.createElement(react_1.default.Fragment, null, children);
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 = (enableUrl && 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.1",
3
+ "version": "0.0.3",
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": "tsc",
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,6 +39,7 @@
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"
@@ -10,7 +10,7 @@ $border-secondary: 1px solid t.$color-neutral-10;
10
10
  top: calc(var(--kpm-bar-height, 0rem));
11
11
  background: t.$color-neutral-0;
12
12
 
13
- &__tablist {
13
+ ul[role="tablist"] {
14
14
  list-style: none;
15
15
  padding: 0;
16
16
  margin: 0;
@@ -22,11 +22,11 @@ $border-secondary: 1px solid t.$color-neutral-10;
22
22
  border-block-end: $border-secondary;
23
23
  }
24
24
 
25
- &__tab-element {
25
+ li {
26
26
  display: flex;
27
27
  }
28
28
 
29
- &__tab {
29
+ button[role="tab"] {
30
30
  box-sizing: border-box;
31
31
  padding-inline: var(--kth-0-clickable-padding-inline);
32
32
  padding-block: calc(var(--kth-0-clickable-padding-block) - 1px);
@@ -38,6 +38,10 @@ $border-secondary: 1px solid t.$color-neutral-10;
38
38
  border: $border-secondary;
39
39
  border-radius: t.border-radius(8 8 0 0);
40
40
 
41
+ &:focus {
42
+ outline-offset: -#{t.$space-4};
43
+ }
44
+
41
45
  &:hover {
42
46
  text-decoration: underline;
43
47
  }
@@ -56,7 +60,7 @@ $border-secondary: 1px solid t.$color-neutral-10;
56
60
  }
57
61
  }
58
62
 
59
- &__tabpanel {
63
+ [role="tabpanel"] {
60
64
  border-inline: $border-secondary;
61
65
  border-block-end: $border-secondary;
62
66
  }
@@ -6,7 +6,7 @@ $border-secondary: 1px solid t.$color-neutral-10;
6
6
  .kth-navigation-tabs {
7
7
  overflow: auto;
8
8
 
9
- &__tablist {
9
+ [role="tablist"] {
10
10
  list-style: none;
11
11
  padding: 0;
12
12
  margin: 0;
@@ -18,7 +18,7 @@ $border-secondary: 1px solid t.$color-neutral-10;
18
18
  border-block-end: $border-secondary;
19
19
  }
20
20
 
21
- &__tab {
21
+ [role="tab"] {
22
22
  font: inherit;
23
23
  background: none;
24
24
  border: none;
@@ -31,6 +31,10 @@ $border-secondary: 1px solid t.$color-neutral-10;
31
31
  color: t.$color-neutral-10;
32
32
  margin-block-end: -1px;
33
33
 
34
+ &:focus {
35
+ outline-offset: -#{t.$space-4};
36
+ }
37
+
34
38
  &:hover {
35
39
  text-decoration: underline;
36
40
  }
package/scss/globals.scss CHANGED
@@ -1,7 +1,5 @@
1
1
  @use "utils/reset";
2
2
  @use "utils/sizes";
3
3
 
4
- @layer kth-style {
5
- @include reset.reset();
6
- @include sizes.sizes();
7
- }
4
+ @include reset.reset();
5
+ @include sizes.sizes();
@@ -1,3 +1,4 @@
1
+ @use "sass:math";
1
2
  // 2. Typography
2
3
 
3
4
  // Base tokens
@@ -56,15 +57,15 @@ $font-weight-bold: 600;
56
57
  }
57
58
 
58
59
  @mixin font-body-copy {
59
- font-family: $font-serif;
60
+ font-family: $font-family-serif;
60
61
  font-weight: 400;
61
- font-size: g.rem(18);
62
- line-height: g.rem(28);
62
+ font-size: math.div(18rem, 16);
63
+ line-height: math.div(28rem, 16);
63
64
  }
64
65
 
65
66
  @mixin font-body-lead {
66
- font-family: $font-serif;
67
+ font-family: $font-family-sans;
67
68
  font-weight: 400;
68
- font-size: g.rem(22);
69
- line-height: g.rem(32);
69
+ font-size: math.div(22rem, 16);
70
+ line-height: math.div(32rem, 16);
70
71
  }
@@ -0,0 +1,109 @@
1
+ @use "../tokens" as t;
2
+
3
+ /// This mixin provides CSS for webpages with lots of prose text.
4
+ ///
5
+ /// It includes:
6
+ /// - CSS for tags like <p>, <h1-6>, <code>, <pre>, <ul> and <li>
7
+ /// - CSS classes like ".lead"
8
+ @mixin prose {
9
+ @layer kth-style {
10
+ p {
11
+ @include t.font-body-copy;
12
+ margin-block: t.$space-20;
13
+ max-width: 60ch;
14
+ }
15
+
16
+ .lead {
17
+ @include t.font-body-lead;
18
+ margin-block-start: t.$space-12;
19
+ margin-block-end: t.$space-16;
20
+ }
21
+
22
+ h1 {
23
+ margin: t.margin(32 0 16 0);
24
+ }
25
+
26
+ h2 {
27
+ margin: t.margin(32 0 16 0);
28
+ }
29
+
30
+ h3 {
31
+ margin: t.margin(32 0 8 0);
32
+ }
33
+
34
+ h4 {
35
+ margin: t.margin(32 0 4 0);
36
+ }
37
+
38
+ li {
39
+ @include t.font-body-copy;
40
+ max-width: 60ch;
41
+ margin: t.margin(8 0);
42
+ }
43
+
44
+ ol,
45
+ ul {
46
+ padding-inline-start: t.$space-32;
47
+
48
+ li {
49
+ padding-inline-start: t.$space-6;
50
+ }
51
+ }
52
+
53
+ h1 + *,
54
+ h2 + *,
55
+ h3 + * {
56
+ margin-block-start: 0;
57
+ }
58
+
59
+ table {
60
+ table-layout: auto;
61
+ text-align: left;
62
+ margin: 2rem 0;
63
+ border-collapse: collapse;
64
+
65
+ display: block;
66
+ overflow-x: auto;
67
+ }
68
+
69
+ thead {
70
+ border-bottom: 1px solid t.$color-neutral-2;
71
+
72
+ th {
73
+ padding: t.padding(0 8 8 8);
74
+ font-weight: 600;
75
+
76
+ &:first-child {
77
+ padding-left: 0;
78
+ }
79
+
80
+ &:last-child {
81
+ padding-right: 0;
82
+ }
83
+ }
84
+ }
85
+
86
+ tbody {
87
+ tr {
88
+ border-bottom: 1px solid t.$color-neutral-2;
89
+
90
+ &:last-child {
91
+ border-bottom-width: 0;
92
+ }
93
+ }
94
+
95
+ td {
96
+ vertical-align: baseline;
97
+ padding: t.$space-8;
98
+
99
+ &:first-child {
100
+ padding-left: 0;
101
+ }
102
+
103
+ &:last-child {
104
+ padding-right: 0;
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }
@@ -3,242 +3,261 @@
3
3
  /// Adaptation of normalize.css v8.0.1
4
4
  /// github.com/necolas/normalize.css
5
5
  ///
6
- /// The aim of this mixin is to normalize all browsers and at the same time
7
- /// provide basic global styles for everything
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
- // HTML
16
- // 1. Prevent adjustments of font size after orientation changes in iOS.
17
- html {
18
- line-height: t.$font-lh-base;
19
- -webkit-text-size-adjust: 100%; /* 1 */
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
- /* Sections
17
+ /* Sections
23
18
  ========================================================================== */
24
19
 
25
- // Body
26
- // 1. Remove the margin in all browsers
27
- // 2. Default fonts
28
- body {
29
- margin: 0;
30
- font-family: t.$font-family-sans;
31
- font-weight: t.$font-weight-normal;
32
- line-height: t.$font-lh-base;
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
- h1 {
36
- @include t.font-h1();
37
- }
30
+ h1 {
31
+ @include t.font-h1();
32
+ }
38
33
 
39
- h2 {
40
- @include t.font-h2();
41
- }
34
+ h2 {
35
+ @include t.font-h2();
36
+ }
42
37
 
43
- h3 {
44
- @include t.font-h3();
45
- }
38
+ h3 {
39
+ @include t.font-h3();
40
+ }
46
41
 
47
- h4 {
48
- @include t.font-h4();
49
- }
42
+ h4 {
43
+ @include t.font-h4();
44
+ }
50
45
 
51
- h5,
52
- h6 {
53
- @include t.font-h5();
54
- }
46
+ h5,
47
+ h6 {
48
+ @include t.font-h5();
49
+ }
55
50
 
56
- /* Grouping content
51
+ /* Grouping content
57
52
  ========================================================================== */
58
53
 
59
- // 1. Add the correct box sizing in Firefox.
60
- // 2. Show the overflow in Edge and IE.
61
- hr {
62
- box-sizing: content-box; /* 1 */
63
- height: 0; /* 1 */
64
- overflow: visible; /* 2 */
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
+ border: 0;
60
+ border-top: 1px t.$color-neutral-2 solid;
61
+ margin: t.$space-32 0;
62
+ overflow: visible; /* 2 */
63
+ }
66
64
 
67
- // 1. Correct the inheritance and scaling of font size in all browsers.
68
- // 2. Correct the odd `em` font sizing in all browsers.
69
- pre {
70
- font-family: monospace, monospace; /* 1 */
71
- font-size: 1em; /* 2 */
72
- }
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
+ }
73
91
 
74
- /* Text-level semantics
92
+ /* Text-level semantics
75
93
  ========================================================================== */
76
- a {
77
- // color: t.$color-blue-5;
78
- text-decoration: none;
94
+ a {
95
+ // color: t.$color-blue-5;
96
+ text-decoration: none;
79
97
 
80
- &:hover {
81
- text-decoration: underline;
98
+ &:hover {
99
+ text-decoration: underline;
100
+ }
82
101
  }
83
- }
84
102
 
85
- // 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
86
- abbr[title] {
87
- text-decoration: underline; /* 2 */
88
- text-decoration: underline dotted; /* 2 */
89
- }
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
+ }
90
108
 
91
- b,
92
- strong {
93
- font-weight: t.$font-weight-bold;
94
- }
109
+ b,
110
+ strong {
111
+ font-weight: t.$font-weight-bold;
112
+ }
95
113
 
96
- // 1. Correct the inheritance and scaling of font size in all browsers.
97
- // 2. Correct the odd `em` font sizing in all browsers.
98
- code,
99
- kbd,
100
- samp {
101
- font-family: monospace, monospace; /* 1 */
102
- font-size: 1em; /* 2 */
103
- }
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
+ }
104
122
 
105
- small {
106
- // TODO: This is the default in normalize.css. Define the right one
107
- font-size: 80%;
108
- }
123
+ small {
124
+ // TODO: This is the default in normalize.css. Define the right one
125
+ font-size: 80%;
126
+ }
109
127
 
110
- // Prevent `sub` and `sup` elements from affecting the line height in all browsers.
111
- sub,
112
- sup {
113
- font-size: 75%;
114
- line-height: 0;
115
- position: relative;
116
- vertical-align: baseline;
117
- }
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
+ }
118
136
 
119
- sub {
120
- bottom: -0.25em;
121
- }
137
+ sub {
138
+ bottom: -0.25em;
139
+ }
122
140
 
123
- sup {
124
- top: -0.5em;
125
- }
141
+ sup {
142
+ top: -0.5em;
143
+ }
126
144
 
127
- /* Forms
145
+ /* Forms
128
146
  ========================================================================== */
129
147
 
130
- // 1. Change the font styles in all browsers.
131
- // 2. Remove the margin in Firefox and Safari.
132
- button,
133
- input,
134
- optgroup,
135
- select,
136
- textarea {
137
- font-family: inherit; /* 1 */
138
- font-size: 100%; /* 1 */
139
- line-height: t.$font-lh-base; /* 1 */
140
- margin: 0; /* 2 */
141
- }
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
+ }
142
160
 
143
- // Remove the inheritance of text transform in Edge, Firefox, and IE.
144
- // Remove the inheritance of text transform in Firefox.
145
- button,
146
- select {
147
- /* 1 */
148
- text-transform: none;
149
- }
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
+ }
150
168
 
151
- // Correct the inability to style clickable types in iOS and Safari.
152
- button,
153
- [type="button"],
154
- [type="reset"],
155
- [type="submit"] {
156
- -webkit-appearance: button;
157
- }
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
+ }
158
176
 
159
- // Remove the inner border and padding in Firefox.
160
- button::-moz-focus-inner,
161
- [type="button"]::-moz-focus-inner,
162
- [type="reset"]::-moz-focus-inner,
163
- [type="submit"]::-moz-focus-inner {
164
- border-style: none;
165
- padding: 0;
166
- }
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
+ }
167
185
 
168
- // Restore the focus styles unset by the previous rule.
169
- button:-moz-focusring,
170
- [type="button"]:-moz-focusring,
171
- [type="reset"]:-moz-focusring,
172
- [type="submit"]:-moz-focusring {
173
- outline: 1px dotted ButtonText;
174
- }
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
+ }
175
193
 
176
- // Correct the padding in Firefox.
177
- fieldset {
178
- // TODO: unifiy with our own values
179
- padding: 0.35em 0.75em 0.625em;
180
- }
194
+ // Correct the padding in Firefox.
195
+ fieldset {
196
+ // TODO: unifiy with our own values
197
+ padding: 0.35em 0.75em 0.625em;
198
+ }
181
199
 
182
- // 1. Correct the text wrapping in Edge and IE.
183
- // 2. Correct the color inheritance from `fieldset` elements in IE.
184
- // 3. Remove the padding so developers are not caught out when they zero out
185
- // `fieldset` elements in all browsers.
186
- legend {
187
- box-sizing: border-box; /* 1 */
188
- color: inherit; /* 2 */
189
- display: table; /* 1 */
190
- max-width: 100%; /* 1 */
191
- padding: 0; /* 3 */
192
- white-space: normal; /* 1 */
193
- }
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
+ }
194
212
 
195
- // Add the correct vertical alignment in Chrome, Firefox, and Opera.
196
- progress {
197
- vertical-align: baseline;
198
- }
213
+ // Add the correct vertical alignment in Chrome, Firefox, and Opera.
214
+ progress {
215
+ vertical-align: baseline;
216
+ }
199
217
 
200
- // Correct the cursor style of increment and decrement buttons in Chrome.
201
- [type="number"]::-webkit-inner-spin-button,
202
- [type="number"]::-webkit-outer-spin-button {
203
- height: auto;
204
- }
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
+ }
205
223
 
206
- // 1. Correct the odd appearance in Chrome and Safari.
207
- // 2. Correct the outline style in Safari.
208
- [type="search"] {
209
- -webkit-appearance: textfield; /* 1 */
210
- outline-offset: -2px; /* 2 */
211
- }
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
+ }
212
230
 
213
- // Remove the inner padding in Chrome and Safari on macOS.
214
- [type="search"]::-webkit-search-decoration {
215
- -webkit-appearance: none;
216
- }
231
+ // Remove the inner padding in Chrome and Safari on macOS.
232
+ [type="search"]::-webkit-search-decoration {
233
+ -webkit-appearance: none;
234
+ }
217
235
 
218
- // 1. Correct the inability to style clickable types in iOS and Safari.
219
- // 2. Change font properties to `inherit` in Safari.
220
- ::-webkit-file-upload-button {
221
- -webkit-appearance: button; /* 1 */
222
- font: inherit; /* 2 */
223
- }
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
+ }
224
242
 
225
- /* Interactive
243
+ /* Interactive
226
244
  ========================================================================== */
227
- // Add the correct display in Edge, IE 10+, and Firefox.
228
- details {
229
- display: block;
230
- }
245
+ // Add the correct display in Edge, IE 10+, and Firefox.
246
+ details {
247
+ display: block;
248
+ }
231
249
 
232
- // Add the correct display in all browsers.
233
- summary {
234
- display: list-item;
235
- }
250
+ // Add the correct display in all browsers.
251
+ summary {
252
+ display: list-item;
253
+ }
236
254
 
237
- /* Misc
255
+ /* Misc
238
256
  ========================================================================== */
239
257
 
240
- // Add the correct display
241
- [hidden] {
242
- display: none;
258
+ // Add the correct display
259
+ [hidden] {
260
+ display: none;
261
+ }
243
262
  }
244
263
  }
@@ -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
- :root {
5
- // Padding (block and inline axis) for clickable elements
6
- --kth-0-clickable-padding-block: #{t.$space-8};
7
- --kth-0-clickable-padding-inline: #{t.$space-16};
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
- .kth-0-normal {
11
- --kth-0-clickable-padding-block: #{t.$space-8};
12
- --kth-0-clickable-padding-inline: #{t.$space-16};
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
- .kth-0-small {
16
- --kth-0-clickable-padding-block: #{t.$space-4};
17
- --kth-0-clickable-padding-inline: #{t.$space-12};
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