@kth/style 0.0.3 → 0.0.5
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/Radio.d.ts +20 -0
- package/dist/cjs/components/Select.d.ts +29 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +20 -0
- package/dist/{esm/stories/NavigationTabs.stories.d.ts → cjs/stories/FilterTabs.stories.d.ts} +3 -3
- package/dist/cjs/stories/Select.stories.d.ts +13 -0
- package/dist/esm/components/Radio.d.ts +20 -0
- package/dist/esm/components/Select.d.ts +29 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +18 -1
- package/dist/{cjs/stories/NavigationTabs.stories.d.ts → esm/stories/FilterTabs.stories.d.ts} +3 -3
- package/dist/esm/stories/Select.stories.d.ts +13 -0
- package/package.json +3 -2
- package/scss/components/filter-tabs.scss +31 -0
- package/scss/components/select.scss +24 -0
- package/dist/cjs/components/Button.d.ts +0 -29
- package/dist/cjs/components/Something.d.ts +0 -1
- package/dist/esm/components/Button.d.ts +0 -29
- package/dist/esm/components/Something.d.ts +0 -1
- package/scss/components/navigation-tabs.scss +0 -53
|
@@ -0,0 +1,20 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface SelectProps {
|
|
3
|
+
/** HTML form `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.ReactElement<OptionProps | OptionGroupProps> | React.ReactElement<OptionProps | OptionGroupProps>[];
|
|
15
|
+
}
|
|
16
|
+
interface OptionProps {
|
|
17
|
+
/** The value for the option */
|
|
18
|
+
value: string;
|
|
19
|
+
/** Human-readable label for the option */
|
|
20
|
+
children: string;
|
|
21
|
+
}
|
|
22
|
+
interface OptionGroupProps {
|
|
23
|
+
label: string;
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
export declare function Select({ name, label, description, value, onChange, children, }: SelectProps): JSX.Element;
|
|
27
|
+
export declare function OptionGroup({ label, children }: OptionGroupProps): JSX.Element;
|
|
28
|
+
export declare function Option({ value, children }: OptionProps): JSX.Element;
|
|
29
|
+
export {};
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -107,6 +107,26 @@ function Tab({ children }) {
|
|
|
107
107
|
return React.createElement(React.Fragment, null, children);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
const SelectContext = React.createContext("");
|
|
111
|
+
function Select({ name, label, description, value, onChange, children, }) {
|
|
112
|
+
const id = `select-${name}`;
|
|
113
|
+
return (React.createElement(SelectContext.Provider, { value: value },
|
|
114
|
+
React.createElement("div", { className: "kth-select" },
|
|
115
|
+
React.createElement("label", { htmlFor: id }, label),
|
|
116
|
+
description && React.createElement("p", { id: `${id}-description` }, description),
|
|
117
|
+
React.createElement("select", { id: id, "aria-describedby": description && `${id}-description`, name: name, value: value, onChange: (e) => onChange(e.target.value) }, children))));
|
|
118
|
+
}
|
|
119
|
+
function OptionGroup({ label, children }) {
|
|
120
|
+
return React.createElement("optgroup", { label: label }, children);
|
|
121
|
+
}
|
|
122
|
+
function Option({ value, children }) {
|
|
123
|
+
const selectedValue = React.useContext(SelectContext);
|
|
124
|
+
return (React.createElement("option", { value: value, selected: value === selectedValue }, children));
|
|
125
|
+
}
|
|
126
|
+
|
|
110
127
|
exports.ContentTabs = ContentTabs;
|
|
111
128
|
exports.NavigationTabs = NavigationTabs;
|
|
129
|
+
exports.Option = Option;
|
|
130
|
+
exports.OptionGroup = OptionGroup;
|
|
131
|
+
exports.Select = Select;
|
|
112
132
|
exports.Tab = Tab;
|
package/dist/{esm/stories/NavigationTabs.stories.d.ts → cjs/stories/FilterTabs.stories.d.ts}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { StoryObj } from "@storybook/react";
|
|
2
|
-
import {
|
|
2
|
+
import { FilterTabs } from "../components/Radio";
|
|
3
3
|
import "../../scss/globals.scss";
|
|
4
|
-
import "../../scss/components/
|
|
4
|
+
import "../../scss/components/filter-tabs.scss";
|
|
5
5
|
declare const meta: {
|
|
6
6
|
title: string;
|
|
7
|
-
component: typeof
|
|
7
|
+
component: typeof FilterTabs;
|
|
8
8
|
tags: string[];
|
|
9
9
|
};
|
|
10
10
|
export default meta;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react";
|
|
2
|
+
import { Select } from "../components/Select";
|
|
3
|
+
import "../../scss/globals.scss";
|
|
4
|
+
import "../../scss/components/select.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;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface SelectProps {
|
|
3
|
+
/** HTML form `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.ReactElement<OptionProps | OptionGroupProps> | React.ReactElement<OptionProps | OptionGroupProps>[];
|
|
15
|
+
}
|
|
16
|
+
interface OptionProps {
|
|
17
|
+
/** The value for the option */
|
|
18
|
+
value: string;
|
|
19
|
+
/** Human-readable label for the option */
|
|
20
|
+
children: string;
|
|
21
|
+
}
|
|
22
|
+
interface OptionGroupProps {
|
|
23
|
+
label: string;
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
export declare function Select({ name, label, description, value, onChange, children, }: SelectProps): JSX.Element;
|
|
27
|
+
export declare function OptionGroup({ label, children }: OptionGroupProps): JSX.Element;
|
|
28
|
+
export declare function Option({ value, children }: OptionProps): JSX.Element;
|
|
29
|
+
export {};
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -105,4 +105,21 @@ function Tab({ children }) {
|
|
|
105
105
|
return React.createElement(React.Fragment, null, children);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
const SelectContext = React.createContext("");
|
|
109
|
+
function Select({ name, label, description, value, onChange, children, }) {
|
|
110
|
+
const id = `select-${name}`;
|
|
111
|
+
return (React.createElement(SelectContext.Provider, { value: value },
|
|
112
|
+
React.createElement("div", { className: "kth-select" },
|
|
113
|
+
React.createElement("label", { htmlFor: id }, label),
|
|
114
|
+
description && React.createElement("p", { id: `${id}-description` }, description),
|
|
115
|
+
React.createElement("select", { id: id, "aria-describedby": description && `${id}-description`, name: name, value: value, onChange: (e) => onChange(e.target.value) }, children))));
|
|
116
|
+
}
|
|
117
|
+
function OptionGroup({ label, children }) {
|
|
118
|
+
return React.createElement("optgroup", { label: label }, children);
|
|
119
|
+
}
|
|
120
|
+
function Option({ value, children }) {
|
|
121
|
+
const selectedValue = React.useContext(SelectContext);
|
|
122
|
+
return (React.createElement("option", { value: value, selected: value === selectedValue }, children));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { ContentTabs, NavigationTabs, Option, OptionGroup, Select, Tab };
|
package/dist/{cjs/stories/NavigationTabs.stories.d.ts → esm/stories/FilterTabs.stories.d.ts}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { StoryObj } from "@storybook/react";
|
|
2
|
-
import {
|
|
2
|
+
import { FilterTabs } from "../components/Radio";
|
|
3
3
|
import "../../scss/globals.scss";
|
|
4
|
-
import "../../scss/components/
|
|
4
|
+
import "../../scss/components/filter-tabs.scss";
|
|
5
5
|
declare const meta: {
|
|
6
6
|
title: string;
|
|
7
|
-
component: typeof
|
|
7
|
+
component: typeof FilterTabs;
|
|
8
8
|
tags: string[];
|
|
9
9
|
};
|
|
10
10
|
export default meta;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react";
|
|
2
|
+
import { Select } from "../components/Select";
|
|
3
|
+
import "../../scss/globals.scss";
|
|
4
|
+
import "../../scss/components/select.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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kth/style",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -46,5 +46,6 @@
|
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": "*"
|
|
49
|
-
}
|
|
49
|
+
},
|
|
50
|
+
"gitHead": "27fc1ecc1982cbb162ddc6dbab504ced561af7d3"
|
|
50
51
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@use "../tokens/" as t;
|
|
2
|
+
|
|
3
|
+
@layer kth-style {
|
|
4
|
+
.kth-select {
|
|
5
|
+
margin-block: t.$space-24;
|
|
6
|
+
|
|
7
|
+
label {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
font-weight: 600;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
p {
|
|
13
|
+
margin: t.$space-4 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
select {
|
|
17
|
+
margin-top: t.$space-8;
|
|
18
|
+
padding-inline: var(--kth-0-clickable-padding-inline);
|
|
19
|
+
padding-block: calc(var(--kth-0-clickable-padding-block) - 1px);
|
|
20
|
+
border-radius: t.$space-4;
|
|
21
|
+
border-block: 1px solid t.$color-neutral-10;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,29 +0,0 @@
|
|
|
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 {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function hello2(): void;
|
|
@@ -1,29 +0,0 @@
|
|
|
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 {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function hello2(): void;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
@use "../tokens/" as t;
|
|
2
|
-
|
|
3
|
-
$border-secondary: 1px solid t.$color-neutral-10;
|
|
4
|
-
|
|
5
|
-
@layer kth-style {
|
|
6
|
-
.kth-navigation-tabs {
|
|
7
|
-
overflow: auto;
|
|
8
|
-
|
|
9
|
-
[role="tablist"] {
|
|
10
|
-
list-style: none;
|
|
11
|
-
padding: 0;
|
|
12
|
-
margin: 0;
|
|
13
|
-
display: inline-flex;
|
|
14
|
-
flex-wrap: nowrap;
|
|
15
|
-
align-items: end;
|
|
16
|
-
gap: t.$space-4;
|
|
17
|
-
min-width: 100%;
|
|
18
|
-
border-block-end: $border-secondary;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
[role="tab"] {
|
|
22
|
-
font: inherit;
|
|
23
|
-
background: none;
|
|
24
|
-
border: none;
|
|
25
|
-
box-sizing: border-box;
|
|
26
|
-
padding-inline: var(--kth-0-clickable-padding-inline);
|
|
27
|
-
padding-block: var(--kth-0-clickable-padding-block);
|
|
28
|
-
white-space: nowrap;
|
|
29
|
-
display: block;
|
|
30
|
-
text-decoration: none;
|
|
31
|
-
color: t.$color-neutral-10;
|
|
32
|
-
margin-block-end: -1px;
|
|
33
|
-
|
|
34
|
-
&:focus {
|
|
35
|
-
outline-offset: -#{t.$space-4};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
&:hover {
|
|
39
|
-
text-decoration: underline;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&[aria-selected="false"] {
|
|
43
|
-
color: t.$color-neutral-10;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&[aria-selected="true"] {
|
|
47
|
-
color: t.$color-primary-5;
|
|
48
|
-
padding-block-end: calc(var(--kth-0-clickable-padding-block) - 3px);
|
|
49
|
-
border-block-end: 3px t.$color-primary-5 solid;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|