@geoinsight/react-components 0.2.1 → 0.2.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/index.js +3 -2
- package/dist/esm/index.js +3 -2
- package/geoinsight-react-components-0.2.1.tgz +0 -0
- package/package.json +1 -1
- package/.babelrc.json +0 -16
- package/.storybook/main.js +0 -11
- package/.storybook/preview.js +0 -43
- package/rollup.config.js +0 -40
- package/src/components/accordion/index.css +0 -40
- package/src/components/accordion/index.stories.tsx +0 -55
- package/src/components/accordion/index.tsx +0 -78
- package/src/components/accordion/index.types.ts +0 -44
- package/src/components/button/index.css +0 -80
- package/src/components/button/index.stories.tsx +0 -46
- package/src/components/button/index.tsx +0 -58
- package/src/components/button/index.types.ts +0 -43
- package/src/components/input/index.css +0 -31
- package/src/components/input/index.stories.tsx +0 -34
- package/src/components/input/index.tsx +0 -25
- package/src/components/input/index.types.ts +0 -29
- package/src/components/loading/index.css +0 -8
- package/src/components/loading/index.stories.tsx +0 -20
- package/src/components/loading/index.tsx +0 -14
- package/src/components/loading/index.types.ts +0 -12
- package/src/components/text-area/index.css +0 -54
- package/src/components/text-area/index.stories.tsx +0 -30
- package/src/components/text-area/index.tsx +0 -62
- package/src/components/text-area/index.types.ts +0 -37
- package/src/context/loading/index.stories.tsx +0 -37
- package/src/context/loading/index.tsx +0 -111
- package/src/context/themeContext.tsx +0 -93
- package/src/decorators/withColorScheme.tsx +0 -29
- package/src/decorators/withLoading.tsx +0 -31
- package/src/decorators/withWrapper.tsx +0 -9
- package/src/index.ts +0 -7
- package/src/stories/Introduction.stories.mdx +0 -211
- package/src/stories/assets/code-brackets.svg +0 -1
- package/src/stories/assets/colors.svg +0 -1
- package/src/stories/assets/comments.svg +0 -1
- package/src/stories/assets/direction.svg +0 -1
- package/src/stories/assets/flow.svg +0 -1
- package/src/stories/assets/loading.gif +0 -0
- package/src/stories/assets/plugin.svg +0 -1
- package/src/stories/assets/repo.svg +0 -1
- package/src/stories/assets/spinner_2.png +0 -0
- package/src/stories/assets/stackalt.svg +0 -1
- package/src/styles/variables.css +0 -115
- package/src/types/palette-theme.d.ts +0 -5
- package/src/utils/themes.ts +0 -1
- package/tsconfig.json +0 -21
package/dist/cjs/index.js
CHANGED
|
@@ -5,8 +5,9 @@ var clsx = require('clsx');
|
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var tb = require('react-icons/tb');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const Anchor = ({ Custom, children, ...rest }) => Custom ? jsxRuntime.jsx(Custom, { ...rest, children: children }) : jsxRuntime.jsx("a", { ...rest, children: children });
|
|
9
|
+
function Button({ children = "Click me", className = "", icon = undefined, isNewWindow = false, mode = "primary", size = "medium", as = "button", CustomAnchor, ...rest }) {
|
|
10
|
+
return as === "link" ? (jsxRuntime.jsxs(Anchor, { Custom: CustomAnchor, ...(isNewWindow && { target: "_blank" }), className: clsx(className, "button", mode === "secondary" ? `button button__${mode}` : "button__link", `button__${size}`), ...rest, children: [children, icon] })) : (jsxRuntime.jsxs("button", { className: clsx(className, "button", `button__${mode}`, `button__${size}`), ...rest, children: [children, icon] }));
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
function Input({ className = "", classNameGroup = "", errorMessage = "", inputRef, styleGroup, ...rest }) {
|
package/dist/esm/index.js
CHANGED
|
@@ -3,8 +3,9 @@ import clsx from 'clsx';
|
|
|
3
3
|
import { useRef, useState, createContext, useEffect, useContext } from 'react';
|
|
4
4
|
import { TbArrowsDiagonal2 } from 'react-icons/tb';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const Anchor = ({ Custom, children, ...rest }) => Custom ? jsx(Custom, { ...rest, children: children }) : jsx("a", { ...rest, children: children });
|
|
7
|
+
function Button({ children = "Click me", className = "", icon = undefined, isNewWindow = false, mode = "primary", size = "medium", as = "button", CustomAnchor, ...rest }) {
|
|
8
|
+
return as === "link" ? (jsxs(Anchor, { Custom: CustomAnchor, ...(isNewWindow && { target: "_blank" }), className: clsx(className, "button", mode === "secondary" ? `button button__${mode}` : "button__link", `button__${size}`), ...rest, children: [children, icon] })) : (jsxs("button", { className: clsx(className, "button", `button__${mode}`, `button__${size}`), ...rest, children: [children, icon] }));
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
function Input({ className = "", classNameGroup = "", errorMessage = "", inputRef, styleGroup, ...rest }) {
|
|
Binary file
|
package/package.json
CHANGED
package/.babelrc.json
DELETED
package/.storybook/main.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"stories": ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
|
|
3
|
-
"addons": ["@storybook/addon-links", "@storybook/addon-essentials", "@storybook/addon-interactions", "@storybook/addon-mdx-gfm"],
|
|
4
|
-
"framework": {
|
|
5
|
-
name: "@storybook/react-webpack5",
|
|
6
|
-
options: {}
|
|
7
|
-
},
|
|
8
|
-
docs: {
|
|
9
|
-
autodocs: true
|
|
10
|
-
}
|
|
11
|
-
};
|
package/.storybook/preview.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import "../src/styles/variables.css";
|
|
2
|
-
|
|
3
|
-
export const parameters = {
|
|
4
|
-
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
5
|
-
controls: {
|
|
6
|
-
matchers: {
|
|
7
|
-
color: /(background|color)$/i,
|
|
8
|
-
date: /Date$/,
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const globalTypes = {
|
|
14
|
-
theme: {
|
|
15
|
-
name: 'Theme',
|
|
16
|
-
description: 'Global theme for components',
|
|
17
|
-
defaultValue: 'light',
|
|
18
|
-
toolbar: {
|
|
19
|
-
icon: 'circlehollow',
|
|
20
|
-
// Array of plain string values or MenuItem shape (see below)
|
|
21
|
-
items: ['light', 'dark'],
|
|
22
|
-
// Property that specifies if the name of the item will be displayed
|
|
23
|
-
showName: true,
|
|
24
|
-
// Change title based on selected value
|
|
25
|
-
dynamicTitle: true,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
palette: {
|
|
29
|
-
name: 'Palette',
|
|
30
|
-
description: 'Global theme for components',
|
|
31
|
-
defaultValue: 'water',
|
|
32
|
-
toolbar: {
|
|
33
|
-
icon: 'circlehollow',
|
|
34
|
-
// Array of plain string values or MenuItem shape (see below)
|
|
35
|
-
items: ['water', 'forest', 'earth'],
|
|
36
|
-
// Property that specifies if the name of the item will be displayed
|
|
37
|
-
showName: true,
|
|
38
|
-
// Change title based on selected value
|
|
39
|
-
dynamicTitle: true,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
}
|
|
43
|
-
|
package/rollup.config.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// rollup.config.js
|
|
2
|
-
import resolve from "@rollup/plugin-node-resolve";
|
|
3
|
-
import commonjs from "@rollup/plugin-commonjs";
|
|
4
|
-
import typescript from "@rollup/plugin-typescript";
|
|
5
|
-
import pkg from "./package.json";
|
|
6
|
-
import css from "rollup-plugin-import-css";
|
|
7
|
-
|
|
8
|
-
export default [
|
|
9
|
-
{
|
|
10
|
-
input: "src/index.ts",
|
|
11
|
-
output: {
|
|
12
|
-
name: "mapinsight",
|
|
13
|
-
file: pkg.browser,
|
|
14
|
-
format: "umd",
|
|
15
|
-
},
|
|
16
|
-
plugins: [
|
|
17
|
-
resolve(),
|
|
18
|
-
commonjs(),
|
|
19
|
-
typescript({ tsconfig: "./tsconfig.json" }),
|
|
20
|
-
css()
|
|
21
|
-
],
|
|
22
|
-
external: ["react", "react-dom"]
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
// CommonJS (for Node) and ES module (for bundlers) build.
|
|
26
|
-
// (We could have three entries in the configuration array
|
|
27
|
-
// instead of two, but it's quicker to generate multiple
|
|
28
|
-
// builds from a single configuration where possible, using
|
|
29
|
-
// an array for the `output` option, where we can specify
|
|
30
|
-
// `file` and `format` for each target)
|
|
31
|
-
{
|
|
32
|
-
input: "src/index.ts",
|
|
33
|
-
output: [
|
|
34
|
-
{ file: pkg.main, format: "cjs" },
|
|
35
|
-
{ file: pkg.module, format: "es" },
|
|
36
|
-
],
|
|
37
|
-
plugins: [typescript({ tsconfig: "./tsconfig.json" }),
|
|
38
|
-
css()],
|
|
39
|
-
}
|
|
40
|
-
];
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
.accordion {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
gap: var(--spacing-4)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.accordion__title {
|
|
8
|
-
border-radius: var(--spacing-8);
|
|
9
|
-
background-color: var(--color-neutral-700);
|
|
10
|
-
color: var(--color-neutral-100);
|
|
11
|
-
justify-content: flex-end;
|
|
12
|
-
gap: 8px;
|
|
13
|
-
padding: var(--spacing-8) var(--spacing-8) var(--spacing-8) var(--spacing-16);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.accordion__menu {
|
|
17
|
-
display: flex;
|
|
18
|
-
flex-direction: column;
|
|
19
|
-
gap: var(--spacing-4);
|
|
20
|
-
padding: 0 0 var(--spacing-8) var(--spacing-16);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.accordion__child {
|
|
24
|
-
border-radius: var(--spacing-8);
|
|
25
|
-
background-color: var(--color-neutral-200);
|
|
26
|
-
color: var(--color-neutral-900);
|
|
27
|
-
/* background: none !important; */
|
|
28
|
-
font-size: var(--font-size-14);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.accordion__child--active {
|
|
32
|
-
background-color: var(--color-neutral-500);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.accordion__check {
|
|
36
|
-
color: var(--color-neutral-500);
|
|
37
|
-
margin-right: calc(var(--spacing-24)*-1);
|
|
38
|
-
position: absolute;
|
|
39
|
-
right: 0;
|
|
40
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { ComponentStory, ComponentMeta } from "@storybook/react";
|
|
2
|
-
import { Accordion } from "./index";
|
|
3
|
-
|
|
4
|
-
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
5
|
-
export default {
|
|
6
|
-
title: "Example/Accordion",
|
|
7
|
-
component: Accordion,
|
|
8
|
-
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
|
|
9
|
-
argTypes: {
|
|
10
|
-
backgroundColor: { control: "color" },
|
|
11
|
-
},
|
|
12
|
-
} as ComponentMeta<typeof Accordion>;
|
|
13
|
-
|
|
14
|
-
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
15
|
-
const Template: ComponentStory<typeof Accordion> = (args) => (
|
|
16
|
-
<Accordion {...args} />
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
export const Primary = Template.bind({});
|
|
20
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
21
|
-
Primary.args = {
|
|
22
|
-
menu: {
|
|
23
|
-
water: {
|
|
24
|
-
label: "Water",
|
|
25
|
-
isExpanded: true,
|
|
26
|
-
dataTheme: "water",
|
|
27
|
-
children: [
|
|
28
|
-
{
|
|
29
|
-
id: "water_1",
|
|
30
|
-
label: "Water 1",
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
id: "water_2",
|
|
34
|
-
label: "Water 1",
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
fire: {
|
|
39
|
-
label: "Fire",
|
|
40
|
-
dataTheme: "earth",
|
|
41
|
-
children: [
|
|
42
|
-
{
|
|
43
|
-
id: "fire_1",
|
|
44
|
-
label: "Fire 1",
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
id: "fire_2",
|
|
48
|
-
label: "Fire 2",
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
defaultValue: "fire_1",
|
|
54
|
-
allExpanded: true
|
|
55
|
-
};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import Button from "../button";
|
|
3
|
-
import "./index.css";
|
|
4
|
-
import { TfiAngleUp, TfiAngleDown } from "react-icons/tfi";
|
|
5
|
-
import { BsCheckLg } from "react-icons/bs";
|
|
6
|
-
import { Accordion as AccordionProps } from "./index.types";
|
|
7
|
-
|
|
8
|
-
export function Accordion({
|
|
9
|
-
menu,
|
|
10
|
-
allExpanded,
|
|
11
|
-
defaultValue,
|
|
12
|
-
selectValue,
|
|
13
|
-
}: AccordionProps) {
|
|
14
|
-
const [toggle, setToggle] = useState<{ [key: string]: boolean | undefined }>(
|
|
15
|
-
Object.fromEntries(
|
|
16
|
-
Object.entries(menu).map(([key, { isExpanded = false }]) => [
|
|
17
|
-
key,
|
|
18
|
-
allExpanded !== undefined ? allExpanded : isExpanded,
|
|
19
|
-
])
|
|
20
|
-
)
|
|
21
|
-
);
|
|
22
|
-
const [selected, setSelected] = useState<string>(defaultValue);
|
|
23
|
-
|
|
24
|
-
const handleToggle = (name: string) => {
|
|
25
|
-
setToggle((prev) => {
|
|
26
|
-
return { ...prev, [name]: !prev[name] };
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className={"accordion"}>
|
|
32
|
-
{Object.keys(menu).map((item) => (
|
|
33
|
-
<>
|
|
34
|
-
<Button
|
|
35
|
-
className={"accordion__title"}
|
|
36
|
-
data-theme={menu[item].dataTheme}
|
|
37
|
-
icon={toggle[item] ? <TfiAngleDown /> : <TfiAngleUp />}
|
|
38
|
-
handleClick={() => handleToggle(item)}
|
|
39
|
-
>
|
|
40
|
-
{menu[item].label}
|
|
41
|
-
</Button>
|
|
42
|
-
{toggle[item] && (
|
|
43
|
-
<div className="accordion__menu">
|
|
44
|
-
{menu[item].children.map((child) => (
|
|
45
|
-
<Button
|
|
46
|
-
mode="secondary"
|
|
47
|
-
data-theme={menu[item].dataTheme}
|
|
48
|
-
className={`accordion__child ${
|
|
49
|
-
child.id === selected &&
|
|
50
|
-
` accordion__child--active`
|
|
51
|
-
}`}
|
|
52
|
-
handleClick={() => {
|
|
53
|
-
setSelected(child.id);
|
|
54
|
-
selectValue && selectValue(item, child);
|
|
55
|
-
}}
|
|
56
|
-
>
|
|
57
|
-
<>
|
|
58
|
-
{child.label}
|
|
59
|
-
{child.id === selected ? (
|
|
60
|
-
<BsCheckLg
|
|
61
|
-
className={"accordion__check"}
|
|
62
|
-
size={"1rem"}
|
|
63
|
-
/>
|
|
64
|
-
) : (
|
|
65
|
-
""
|
|
66
|
-
)}
|
|
67
|
-
</>
|
|
68
|
-
</Button>
|
|
69
|
-
))}
|
|
70
|
-
</div>
|
|
71
|
-
)}
|
|
72
|
-
</>
|
|
73
|
-
))}
|
|
74
|
-
</div>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export default Accordion;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {dataTheme} from "data-theme";
|
|
2
|
-
|
|
3
|
-
export interface Accordion {
|
|
4
|
-
/**
|
|
5
|
-
* What to put inside the menu
|
|
6
|
-
*/
|
|
7
|
-
menu: layers;
|
|
8
|
-
/**
|
|
9
|
-
* Default value that is chosen. Must use on the of the children ids on the menu prop.
|
|
10
|
-
*/
|
|
11
|
-
defaultValue: string;
|
|
12
|
-
/**
|
|
13
|
-
* Callback function for extra leg work outside the component. It takes two arguments:
|
|
14
|
-
* - item - parent ID.
|
|
15
|
-
* - object with the child ID and label.
|
|
16
|
-
*/
|
|
17
|
-
selectValue?: (
|
|
18
|
-
parentId: string,
|
|
19
|
-
child: {
|
|
20
|
-
id: string;
|
|
21
|
-
label: string;
|
|
22
|
-
// field: string;
|
|
23
|
-
// tempValue: number;
|
|
24
|
-
// description: (value: number | string | undefined) => string;
|
|
25
|
-
// style: any;
|
|
26
|
-
}
|
|
27
|
-
) => void;
|
|
28
|
-
|
|
29
|
-
allExpanded?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface layer {
|
|
33
|
-
id: string;
|
|
34
|
-
label: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface layers {
|
|
38
|
-
[key: string]: {
|
|
39
|
-
label: string;
|
|
40
|
-
isExpanded?: boolean;
|
|
41
|
-
dataTheme?: dataTheme;
|
|
42
|
-
children: layer[];
|
|
43
|
-
};
|
|
44
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
.button {
|
|
2
|
-
align-items: center;
|
|
3
|
-
border-radius: var(--spacing-32);
|
|
4
|
-
border: none;
|
|
5
|
-
cursor: pointer;
|
|
6
|
-
display: flex;
|
|
7
|
-
justify-content: center;
|
|
8
|
-
gap: var(--spacing-8);
|
|
9
|
-
font-size: var(--font-size-16);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
.button--active {
|
|
14
|
-
background-color: var(--color-neutral-500) !important;
|
|
15
|
-
} */
|
|
16
|
-
|
|
17
|
-
.button:disabled {
|
|
18
|
-
cursor: unset;
|
|
19
|
-
opacity: 0.5;
|
|
20
|
-
pointer-events: none;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.button:hover {
|
|
24
|
-
background-color: var(--color-primary);
|
|
25
|
-
transition: var(--transition-bg-cubic-bezier);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.button__link {
|
|
29
|
-
background-color: unset !important;
|
|
30
|
-
color: var(--color-neutral-100);
|
|
31
|
-
text-decoration: underline transparent;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.button__link:hover {
|
|
35
|
-
color: var(--color-primary);
|
|
36
|
-
text-decoration: underline 0.1rem var(--color-primary);
|
|
37
|
-
text-underline-offset: var(--spacing-8);
|
|
38
|
-
transition: var(--transition-color-cubic-bezier),
|
|
39
|
-
var(--transition-text-decoration-cubic-bezier);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.button__primary {
|
|
43
|
-
background-color: var(--color-secondary);
|
|
44
|
-
border: 3px solid var(--color-primary);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.button__primary:hover {
|
|
48
|
-
box-shadow: 0 4px 4px 0 var(--color-neutral-400);
|
|
49
|
-
transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic-bezier);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.button__secondary {
|
|
53
|
-
background-color: var(--color-neutral-900);
|
|
54
|
-
border: 3px solid var(--color-primary);
|
|
55
|
-
color: var(--color-neutral-100);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.button__secondary:hover {
|
|
59
|
-
background-color: var(--color-primary);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.button__icon {
|
|
63
|
-
background-color: unset;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.button__icon:hover {
|
|
67
|
-
box-shadow: unset;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.button__small {
|
|
71
|
-
padding: var(--spacing-4);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.button__medium {
|
|
75
|
-
padding: var(--spacing-8) var(--spacing-24);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.button__large {
|
|
79
|
-
padding: var(--spacing-16);
|
|
80
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
-
|
|
3
|
-
import { Button } from "./index";
|
|
4
|
-
import { withColorScheme } from "../../decorators/withColorScheme";
|
|
5
|
-
|
|
6
|
-
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
7
|
-
const meta: Meta<typeof Button> = {
|
|
8
|
-
title: "Example/Button",
|
|
9
|
-
component: Button,
|
|
10
|
-
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
|
|
11
|
-
argTypes: {
|
|
12
|
-
backgroundColor: { control: "color" },
|
|
13
|
-
mode: {
|
|
14
|
-
options: ["primary", "secondary", "icon"],
|
|
15
|
-
control: {
|
|
16
|
-
type: "select",
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
size: {
|
|
20
|
-
options: ["small", "medium", "large"],
|
|
21
|
-
control: {
|
|
22
|
-
type: "select",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
decorators: [withColorScheme],
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default meta;
|
|
30
|
-
|
|
31
|
-
type Story = StoryObj<typeof Button>;
|
|
32
|
-
|
|
33
|
-
export const Primary: Story = {
|
|
34
|
-
args: {
|
|
35
|
-
children: "Click here",
|
|
36
|
-
mode: "primary",
|
|
37
|
-
size: "medium",
|
|
38
|
-
as: "button",
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const Secondary: Story = {
|
|
43
|
-
args: {
|
|
44
|
-
mode: "secondary",
|
|
45
|
-
},
|
|
46
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import clsx from "clsx";
|
|
2
|
-
import { ButtonAsButton, ButtonAsLink } from "./index.types";
|
|
3
|
-
import "./index.css";
|
|
4
|
-
import { ReactNode } from "react";
|
|
5
|
-
|
|
6
|
-
const Anchor = ({
|
|
7
|
-
Custom,
|
|
8
|
-
children,
|
|
9
|
-
...rest
|
|
10
|
-
}: {
|
|
11
|
-
Custom?: React.ComponentClass<any>;
|
|
12
|
-
children?: ReactNode;
|
|
13
|
-
}) =>
|
|
14
|
-
Custom ? <Custom {...rest}>{children}</Custom> : <a {...rest}>{children}</a>;
|
|
15
|
-
|
|
16
|
-
export function Button({
|
|
17
|
-
children = "Click me",
|
|
18
|
-
className = "",
|
|
19
|
-
icon = undefined,
|
|
20
|
-
isNewWindow = false,
|
|
21
|
-
mode = "primary",
|
|
22
|
-
size = "medium",
|
|
23
|
-
as = "button",
|
|
24
|
-
CustomAnchor,
|
|
25
|
-
...rest
|
|
26
|
-
}: ButtonAsButton | ButtonAsLink): JSX.Element {
|
|
27
|
-
return as === "link" ? (
|
|
28
|
-
<Anchor
|
|
29
|
-
Custom={CustomAnchor}
|
|
30
|
-
{...(isNewWindow && { target: "_blank" })}
|
|
31
|
-
className={clsx(
|
|
32
|
-
className,
|
|
33
|
-
"button",
|
|
34
|
-
mode === "secondary" ? `button button__${mode}` : "button__link",
|
|
35
|
-
`button__${size}`
|
|
36
|
-
)}
|
|
37
|
-
{...(rest as React.AnchorHTMLAttributes<HTMLAnchorElement>)}
|
|
38
|
-
>
|
|
39
|
-
{children}
|
|
40
|
-
{icon}
|
|
41
|
-
</Anchor>
|
|
42
|
-
) : (
|
|
43
|
-
<button
|
|
44
|
-
className={clsx(
|
|
45
|
-
className,
|
|
46
|
-
"button",
|
|
47
|
-
`button__${mode}`,
|
|
48
|
-
`button__${size}`
|
|
49
|
-
)}
|
|
50
|
-
{...(rest as React.ButtonHTMLAttributes<HTMLButtonElement>)}
|
|
51
|
-
>
|
|
52
|
-
{children}
|
|
53
|
-
{icon}
|
|
54
|
-
</button>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default Button;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
type Mode = "primary" | "secondary" | "icon";
|
|
2
|
-
type Size = "small" | "medium" | "large";
|
|
3
|
-
export type ButtonAsButton = Base &
|
|
4
|
-
Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof Base> & {
|
|
5
|
-
as?: "button";
|
|
6
|
-
};
|
|
7
|
-
export type ButtonAsLink = Base &
|
|
8
|
-
Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof Base> & {
|
|
9
|
-
as?: "link";
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export interface Base {
|
|
13
|
-
/**
|
|
14
|
-
* What to put inside the button (string or html elements)
|
|
15
|
-
*/
|
|
16
|
-
children?: JSX.Element | string;
|
|
17
|
-
/**
|
|
18
|
-
* Custom css class name
|
|
19
|
-
*/
|
|
20
|
-
className?: string;
|
|
21
|
-
/**
|
|
22
|
-
* If you want to add an icon image next to the children. Needs to be an react html element.
|
|
23
|
-
*/
|
|
24
|
-
icon?: JSX.Element;
|
|
25
|
-
/**
|
|
26
|
-
* If you want to open a new window on the browser when you click the button. Only applies to html anchor elements.
|
|
27
|
-
*/
|
|
28
|
-
isNewWindow?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Css mode used to style the button.
|
|
31
|
-
*/
|
|
32
|
-
mode?: Mode;
|
|
33
|
-
/**
|
|
34
|
-
* Button size.
|
|
35
|
-
*/
|
|
36
|
-
size?: Size;
|
|
37
|
-
/**
|
|
38
|
-
* Button type.
|
|
39
|
-
*/
|
|
40
|
-
as?: "button" | "link";
|
|
41
|
-
|
|
42
|
-
CustomAnchor?: React.ComponentClass<any>;
|
|
43
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
.input-group {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
align-items: flex-start;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.input {
|
|
8
|
-
background-color: var(--color-white);
|
|
9
|
-
border-radius: var(--spacing-8);
|
|
10
|
-
border: 2px solid var(--color-primary);
|
|
11
|
-
color: var(--color-black);
|
|
12
|
-
padding: var(--spacing-16) var(--spacing-24);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.input:hover {
|
|
16
|
-
border: 3px solid var(--color-primary-700);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.input:focus {
|
|
20
|
-
border: 3px solid var(--color-primary-700);
|
|
21
|
-
outline: none;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.input--error {
|
|
25
|
-
border: 3px solid var(--color-danger);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.error {
|
|
29
|
-
font-size: 12px;
|
|
30
|
-
color: var(--color-danger);
|
|
31
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
|
|
3
|
-
import { Input } from "./index";
|
|
4
|
-
import { withColorScheme } from "../../decorators/withColorScheme";
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Input> = {
|
|
7
|
-
title: "Example/Input",
|
|
8
|
-
component: Input,
|
|
9
|
-
argTypes: {
|
|
10
|
-
backgroundColor: { control: "color" },
|
|
11
|
-
},
|
|
12
|
-
decorators: [withColorScheme]
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default meta;
|
|
16
|
-
|
|
17
|
-
type Story = StoryObj<typeof Input>;
|
|
18
|
-
|
|
19
|
-
export const Primary: Story = {
|
|
20
|
-
args: {
|
|
21
|
-
className: "",
|
|
22
|
-
classNameGroup: "",
|
|
23
|
-
placeholder: "Insert a value",
|
|
24
|
-
errorMessage: "",
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const Error: Story = {
|
|
29
|
-
args: {
|
|
30
|
-
className: "",
|
|
31
|
-
classNameGroup: "",
|
|
32
|
-
errorMessage: "Insert a value",
|
|
33
|
-
},
|
|
34
|
-
};
|