(react) add Input component

Finally the first form component of the design system. It wraps and enhance
the native input element.
This commit is contained in:
Nathan Vasse
2023-04-14 16:38:58 +02:00
committed by NathanVss
parent 4f1168463f
commit feea284ec8
18 changed files with 1121 additions and 32 deletions

View File

@@ -0,0 +1,5 @@
---
"@openfun/cunningham-react": minor
---
Add Input component

View File

@@ -1,23 +1,116 @@
.c__input {
height: 2rem;
padding: 0 14px;
box-sizing: border-box;
border-radius: 2px;
border: 1px var(--c--theme--colors--greyscale-300) solid;
.c__input__wrapper {
border-radius: var(--c--components--forms-input--border-radius);
border-width: var(--c--components--forms-input--border-width);
border-color: var(--c--components--forms-input--border-color);
border-style: var(--c--components--forms-input--border-style);
display: flex;
align-items: center;
transition: border var(--c--theme--transitions--duration) var(--c--theme--transitions--ease-out);
color: var(--c--theme--colors--greyscale-800);
font-size: var(--c--theme--font--sizes--m);
padding: 0 1rem;
gap: 1rem;
cursor: text;
color: var(--c--components--forms-input--color);
box-sizing: border-box;
height: 3.5rem;
&:focus {
outline: 0;
border: 1px var(--c--theme--colors--greyscale-500) solid;
%text-style {
font-size: var(--c--components--forms-input--font-size);
font-weight: var(--c--components--forms-input--font-weight);
}
&--medium {
min-width: 150px;
.c__input__inner {
position: relative;
flex-grow: 1;
display: flex;
height: 100%;
.c__input {
box-sizing: border-box;
outline: 0;
border: none;
padding: 1rem 0 0 0;
color: var(--c--theme--colors--greyscale-800);
flex-grow: 1;
text-overflow: ellipsis;
background-color: transparent;
@extend %text-style;
&--medium {
min-width: 150px;
}
&--nano {
min-width: 10px;
}
}
label {
position: absolute;
font-size: var(--c--theme--font--sizes--s);
left: 0;
top: 0.75rem;
transition: all var(--c--theme--transitions--duration) var(--c--theme--transitions--ease-out);
color: var(--c--theme--colors--greyscale-600);
&.placeholder {
@extend %text-style;
top: 18px;
}
}
}
&--nano {
min-width: 10px;
&:hover {
border-radius: var(--c--components--forms-input--border-radius--hover);
border-color: var(--c--components--forms-input--border-color--hover);
}
}
/** Modifiers. */
&--full-width {
width: 100%;
}
&:focus-within {
border-radius: var(--c--components--forms-input--border-radius--focus);
border-color: var(--c--components--forms-input--border-color--focus) !important;
}
&--disabled {
cursor: default;
color: var(--c--theme--colors--greyscale-400);
border-color: var(--c--theme--colors--greyscale-200);
.c__input__inner {
.c__input, label {
color: var(--c--theme--colors--greyscale-600);
}
}
&:hover {
border-color: var(--c--theme--colors--greyscale-200);
}
}
&--success {
border-color: var(--c--theme--colors--success-600);
&:not(.c__input__wrapper--disabled) {
&:hover {
border-color: var(--c--theme--colors--success-400);
}
}
}
&--error {
border-color: var(--c--theme--colors--danger-600);
&:not(.c__input__wrapper--disabled) {
&:hover {
border-color: var(--c--theme--colors--danger-200);
}
}
}
}

View File

@@ -0,0 +1,184 @@
import { render, screen } from "@testing-library/react";
import React, { useRef } from "react";
import userEvent from "@testing-library/user-event";
import { expect } from "vitest";
import { Input, InputRefType } from "components/Forms/Input/index";
import { Button } from "components/Button";
describe("<Input/>", () => {
it("renders and can type", async () => {
const user = userEvent.setup();
render(<Input label="First name" />);
const input: HTMLInputElement = screen.getByRole("textbox", {
name: "First name",
});
expect(input.value).toEqual("");
await user.type(input, "John");
expect(input.value).toEqual("John");
});
it("renders with default value and can type", async () => {
const user = userEvent.setup();
render(<Input label="First name" defaultValue="John" />);
const input: HTMLInputElement = screen.getByRole("textbox", {
name: "First name",
});
expect(input.value).toEqual("John");
await user.clear(input);
expect(input.value).toEqual("");
await user.type(input, "Paul");
expect(input.value).toEqual("Paul");
});
it("renders with moving label", async () => {
const user = userEvent.setup();
render(
<div>
<Input label="First name" />
<Input label="Second name" />
</div>
);
const input: HTMLInputElement = screen.getByRole("textbox", {
name: "First name",
});
const input2: HTMLInputElement = screen.getByRole("textbox", {
name: "Second name",
});
const label = screen.getByText("First name");
expect(Array.from(label.classList)).toContain("placeholder");
// Clicking on the input should remove the placeholder class.
await user.click(input);
expect(Array.from(label.classList)).not.toContain("placeholder");
// Writing something should remove the placeholder class too.
await user.type(input, "John");
expect(Array.from(label.classList)).not.toContain("placeholder");
// Clearing the input and focus out should add the placeholder class
await user.clear(input);
await user.click(input2);
expect(Array.from(label.classList)).toContain("placeholder");
});
it("renders with state=success", async () => {
render(<Input label="First name" state="success" />);
expect(document.querySelector(".c__field--success")).toBeInTheDocument();
expect(
document.querySelector(".c__input__wrapper--success")
).toBeInTheDocument();
});
it("renders with state=error", async () => {
render(<Input label="First name" state="error" />);
expect(document.querySelector(".c__field--error")).toBeInTheDocument();
expect(
document.querySelector(".c__input__wrapper--error")
).toBeInTheDocument();
});
it("renders disabled", async () => {
const user = userEvent.setup();
render(<Input label="First name" disabled={true} />);
const input: HTMLInputElement = screen.getByRole("textbox", {
name: "First name",
});
expect(
document.querySelector(".c__input__wrapper--disabled")
).toBeInTheDocument();
expect(input.value).toEqual("");
// Disabled inputs should not be able to type.
await user.type(input, "John");
expect(input.value).toEqual("");
});
it("renders with left icon", async () => {
render(
<Input
label="First name"
icon={<span className="material-icons">apartment</span>}
/>
);
expect(document.querySelector(".material-icons")).toBeInTheDocument();
});
it("renders with right icon", async () => {
render(
<Input
label="First name"
rightIcon={<span className="material-icons">apartment</span>}
/>
);
expect(document.querySelector(".material-icons")).toBeInTheDocument();
});
it("renders with text", async () => {
render(
<Input
label="First name"
rightIcon={<span className="material-icons">apartment</span>}
text="Some text"
/>
);
screen.getByText("Some text");
});
it("renders with text and text right", async () => {
render(
<Input
label="First name"
rightIcon={<span className="material-icons">apartment</span>}
rightText="Some text right"
/>
);
screen.getByText("Some text right");
});
it("renders with char counter", async () => {
const user = userEvent.setup();
render(<Input label="First name" charCounter={true} charCounterMax={15} />);
const input: HTMLInputElement = screen.getByRole("textbox", {
name: "First name",
});
screen.getByText("0/15");
await user.type(input, "Jo");
screen.getByText("2/15");
await user.type(input, "hn");
screen.getByText("4/15");
await user.clear(input);
screen.getByText("0/15");
});
it("forwards ref", async () => {
const user = userEvent.setup();
const Wrapper = () => {
const ref = useRef<InputRefType>(null);
return (
<div>
<Input label="First name" ref={ref} />
<Button onClick={() => ref.current?.input?.focus()}>Focus</Button>
</div>
);
};
render(<Wrapper />);
const input: HTMLInputElement = screen.getByRole("textbox", {
name: "First name",
});
expect(input).not.toHaveFocus();
await user.click(screen.getByRole("button", { name: "Focus" }));
expect(input).toHaveFocus();
});
it("works controlled", async () => {
const Wrapper = () => {
const [value, setValue] = React.useState("I am controlled");
return (
<div>
<div>Value: {value}.</div>
<Input
label="First name"
value={value}
onChange={(e) => setValue(e.target.value)}
/>
<Button onClick={() => setValue("")}>Reset</Button>
</div>
);
};
const user = userEvent.setup();
render(<Wrapper />);
const input: HTMLInputElement = screen.getByRole("textbox", {
name: "First name",
});
screen.getByText("Value: I am controlled.");
await user.type(input, "John");
screen.getByText("Value: I am controlledJohn.");
await user.clear(input);
screen.getByText("Value: .");
});
});

View File

@@ -0,0 +1,160 @@
import { Canvas, Meta, Story, Source, ArgsTable } from '@storybook/addon-docs';
import { Input } from "./index";
<Meta title="Components/Forms/Input/Doc" component={Input}/>
export const Template = (args) => <Input {...args} />;
# Input
Cunningham provides a versatile Input component that you can use in your forms.
<Canvas>
<Story id="components-forms-input--default"/>
</Canvas>
<Source
language='ts'
dark
format={false}
code={`import { Input } from "@openfun/cunningham-react";`}
/>
## States
You can use the following props to change the state of the Input component by using the `state` props.
<Canvas withSource="open">
<Story id="components-forms-input--default"/>
</Canvas>
<Canvas withSource="open">
<Story id="components-forms-input--success"/>
</Canvas>
<Canvas withSource="open">
<Story id="components-forms-input--error"/>
</Canvas>
## Disabled
As a regular input, you can disable it by using the `disabled` props.
<Canvas withSource="open">
<Story id="components-forms-input--disabled-empty"/>
<Story id="components-forms-input--disabled-filled"/>
</Canvas>
## Icons
You can define an icon that will appear on the left side of the input by using the `icon` props.
<Canvas withSource="open">
<Story id="components-forms-input--icon"/>
</Canvas>
You can also independently add an icon on the right side by using the `rightIcon` props.
<Canvas withSource="open">
<Story id="components-forms-input--icon-right"/>
</Canvas>
## Texts
You can define a text that will appear below the input by using the `text` props.
<Canvas withSource="open">
<Story id="components-forms-input--with-text"/>
</Canvas>
You can also independently add a text on the right side by using the `rightText` props.
<Canvas withSource="open">
<Story id="components-forms-input--with-both-texts"/>
</Canvas>
## Width
By default, the input has a default width, like all inputs. But you can force it to take the full width of its container by using the `fullWidth` props.
<Canvas withSource="open">
<Story id="components-forms-input--full-width"/>
</Canvas>
## Chars Counter
You can display a counter of the number of characters entered in the input by using the `charsCounter` props. Please bare
in mind to also define `charCounterMax`.
<Canvas withSource="open">
<Story id="components-forms-input--char-counter"/>
</Canvas>
## Controlled / Non Controlled
Like a native input, you can use the Input component in a controlled or non controlled way. You can see the example below
using the component in a controlled way.
<Canvas withSource="open">
<Story id="components-forms-input--controlled"/>
</Canvas>
## Ref
You can use the `ref` props to get a reference to the input element. The ref to the native input is nested inside the `input` attribute.
<Canvas withSource="open">
<Story id="components-forms-input--with-ref"/>
</Canvas>
## Props
You can use all the props of the native html `<input>` element props plus the following.
<ArgsTable of={Input} />
## Design tokens
Here are the custom design tokens defined by the button.
| Token | Description |
|--------------- |----------------------------- |
| font-weight | Value font weight |
| font-size | Value font size |
| color | Value color |
| border-radius | Border radius of the input |
| border-radius--hover | Border radius of the input on mouse hover |
| border-radius--focus | Border radius of the input when focused |
| border-width | Border width of the input |
| border-color | Border color of the input |
| border-color--hover | Border color of the input on mouse hover |
| border-color--focus | Border color of the input when focus |
| border-style | Border style of the input |
See also [Field](?path=/story/components-forms-field-doc--page)
## Form Example
<Canvas>
<Story id="components-forms-input--form-example"/>
</Canvas>
##
<img src="components/Forms/Input/resources/dd_1.svg"/>
##
<img src="components/Forms/Input/resources/dd_2.svg"/>
##
<img src="components/Forms/Input/resources/dd_3.svg"/>
##
<img src="components/Forms/Input/resources/dd_4.svg"/>
##
<img src="components/Forms/Input/resources/dd_5.svg"/>

View File

@@ -1,17 +1,208 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import React from "react";
import { Input } from "components/Forms/Input/index";
import React, { useRef } from "react";
import { Input, InputRefType } from "components/Forms/Input/index";
import { Button } from "components/Button";
export default {
title: "Components/Forms (WIP)/Input",
title: "Components/Forms/Input",
component: Input,
} as ComponentMeta<typeof Input>;
const Template: ComponentStory<typeof Input> = (args) => (
<Input {...args} aria-label="Input" />
);
const Template: ComponentStory<typeof Input> = (args) => <Input {...args} />;
export const Default = Template.bind({});
Default.args = {
defaultValue: "Hello world",
label: "Your name",
};
export const Success = Template.bind({});
Success.args = {
defaultValue: "Hello world",
label: "Your name",
state: "success",
icon: <span className="material-icons">person</span>,
text: "This is an optional success message",
};
export const Error = Template.bind({});
Error.args = {
defaultValue: "Hello world",
label: "Your name",
state: "error",
icon: <span className="material-icons">person</span>,
text: "This is an optional error message",
};
export const DisabledEmpty = Template.bind({});
DisabledEmpty.args = {
label: "Your name",
icon: <span className="material-icons">person</span>,
disabled: true,
};
export const DisabledFilled = Template.bind({});
DisabledFilled.args = {
label: "Your name",
defaultValue: "John Doe",
icon: <span className="material-icons">person</span>,
disabled: true,
};
export const Empty = Template.bind({});
Empty.args = {
label: "Your email",
};
export const Icon = Template.bind({});
Icon.args = {
label: "Account balance",
icon: <span className="material-icons">attach_money</span>,
defaultValue: "1000",
};
export const IconRight = Template.bind({});
IconRight.args = {
label: "Account balance",
rightIcon: <span className="material-icons">attach_money</span>,
defaultValue: "1000",
};
export const IconBoth = Template.bind({});
IconBoth.args = {
label: "Not a recommended use",
icon: <span className="material-icons">attach_money</span>,
rightIcon: <span className="material-icons">attach_money</span>,
defaultValue: "Is isn't recommended to use both icons",
};
export const OverflowingText = Template.bind({});
OverflowingText.args = {
label: "Your name",
icon: <span className="material-icons">attach_money</span>,
defaultValue: "John Dave Mike Smith Doe Junior Senior Yoda Skywalker",
};
export const WithText = Template.bind({});
WithText.args = {
defaultValue: "Hello world",
label: "Your name",
text: "This is a text, you can display anything you want here like warnings, informations or errors.",
};
export const WithTextRight = Template.bind({});
WithTextRight.args = {
defaultValue: "Hello world",
label: "Your name",
rightText: "0/300",
};
export const WithBothTexts = Template.bind({});
WithBothTexts.args = {
defaultValue: "Hello world",
label: "Your name",
text: "This is a text, you can display anything you want here like warnings, informations or errors.",
rightText: "0/300",
};
export const FullWidth = Template.bind({});
FullWidth.args = {
defaultValue: "Hello world",
label: "Your name",
fullWidth: true,
text: "This is a text, you can display anything you want here like warnings, informations or errors.",
rightText: "0/300",
};
export const CharCounter = Template.bind({});
CharCounter.args = {
defaultValue: "CEO",
label: "Job title",
text: "This is a text, you can display anything you want here like warnings, informations or errors.",
charCounter: true,
charCounterMax: 30,
};
export const Controlled = () => {
const [value, setValue] = React.useState("I am controlled");
return (
<div>
<div>
Value: <span>{value}</span>
</div>
<Input
label="Your identity"
value={value}
onChange={(e) => setValue(e.target.value)}
/>
<Button onClick={() => setValue("")}>Reset</Button>
</div>
);
};
export const NonControlled = () => {
return <Input defaultValue="john.doe@example.com" label="Your email" />;
};
export const WithRef = () => {
const ref = useRef<InputRefType>(null);
return (
<div>
<Input label="Your identity" ref={ref} />
<Button onClick={() => ref.current?.input?.focus()}>Focus</Button>
</div>
);
};
export const FormExample = () => {
return (
<div>
<form>
<div>
<Input label="First name" defaultValue="John" />
</div>
<div className="mt-s">
<Input label="Last name" defaultValue="Smith" />
</div>
<div className="mt-s">
<Input
label="Job Title"
defaultValue="Project Manager"
text="Your position in the company"
charCounter={true}
charCounterMax={30}
/>
</div>
<div className="mt-s">
<Input label="Code" defaultValue="XIJZ81" disabled={true} />
</div>
<div className="mt-s">
<Input
label="Address"
defaultValue="1 Infinite Loop"
state="error"
text="Address not found"
icon={<span className="material-icons">apartment</span>}
/>
</div>
<div className="mt-s">
<Input
label="Zip"
defaultValue="96020"
text="Five numbers format"
state="success"
icon={<span className="material-icons">location_on</span>}
/>
</div>
<div className="mt-s">
<Input
label="City"
defaultValue="Palo Alto"
state="success"
icon={<span className="material-icons">map</span>}
/>
</div>
</form>
</div>
);
};

View File

@@ -1,11 +1,144 @@
import React, { InputHTMLAttributes } from "react";
import React, {
forwardRef,
InputHTMLAttributes,
ReactNode,
useEffect,
useImperativeHandle,
useRef,
useState,
} from "react";
import classNames from "classnames";
import { randomString } from "utils";
import { Field, FieldProps } from "components/Forms/Field";
type Props = InputHTMLAttributes<HTMLInputElement>;
export interface InputRefType {
input: HTMLInputElement | null;
}
export const Input = ({ className, ...props }: Props) => {
const classes = ["c__input"];
if (className) {
classes.push(className);
type Props = InputHTMLAttributes<HTMLInputElement> &
FieldProps & {
label?: string;
icon?: ReactNode;
rightIcon?: ReactNode;
charCounter?: boolean;
charCounterMax?: number;
};
export const Input = forwardRef<InputRefType, Props>(
(
{
className,
defaultValue,
label,
id,
icon,
rightIcon,
state = "default",
text,
rightText,
fullWidth,
charCounter,
charCounterMax,
...props
}: Props,
ref
) => {
const classes = ["c__input"];
if (className) {
classes.push(className);
}
const inputRef = useRef<HTMLInputElement>(null);
const [inputFocus, setInputFocus] = useState(false);
const [value, setValue] = useState(defaultValue || props.value || "");
const [labelAsPlaceholder, setLabelAsPlaceholder] = useState(!value);
const idToUse = useRef(id || randomString());
const rightTextToUse = charCounter
? `${value.toString().length}/${charCounterMax}`
: rightText;
const updateLabel = () => {
if (inputFocus) {
setLabelAsPlaceholder(false);
return;
}
setLabelAsPlaceholder(!value);
};
useEffect(() => {
updateLabel();
}, [inputFocus, value]);
// If the input is used as a controlled component, we need to update the local value.
useEffect(() => {
if (defaultValue !== undefined) {
return;
}
setValue(props.value || "");
}, [props.value]);
useImperativeHandle(ref, () => ({
get input() {
return inputRef.current;
},
}));
return (
<Field
state={state}
text={text}
rightText={rightTextToUse}
fullWidth={fullWidth}
>
{/* We disabled linting for this specific line because we consider that the onClick props is only used for */}
{/* mouse users, so this do not engender any issue for accessibility. */}
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
<div
className={classNames(
"c__input__wrapper",
"c__input__wrapper--" + state,
{
"c__input__wrapper--disabled": props.disabled,
}
)}
onClick={() => {
inputRef.current?.focus();
}}
>
{!!icon && icon}
<div className="c__input__inner">
<input
type="text"
className={classes.join(" ")}
{...props}
id={idToUse.current}
value={value}
onFocus={(e) => {
setInputFocus(true);
props.onFocus?.(e);
}}
onBlur={(e) => {
setInputFocus(false);
props.onBlur?.(e);
}}
onChange={(e) => {
setValue(e.target.value);
props.onChange?.(e);
}}
ref={inputRef}
/>
{label && (
<label
className={labelAsPlaceholder ? "placeholder" : ""}
htmlFor={idToUse.current}
>
{label}
</label>
)}
</div>
{!!rightIcon && rightIcon}
</div>
</Field>
);
}
return <input type="text" className={classes.join(" ")} {...props} />;
};
);

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 244 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 271 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 312 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 377 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 118 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 144 KiB

View File

@@ -0,0 +1,15 @@
import { DefaultTokens } from "@openfun/cunningham-tokens";
export const tokens = (defaults: DefaultTokens) => ({
"font-weight": defaults.theme.font.weights.medium,
"font-size": defaults.theme.font.sizes.l,
"border-radius": "8px",
"border-radius--hover": "2px",
"border-radius--focus": "2px",
"border-width": "2px",
"border-color": defaults.theme.colors["greyscale-300"],
"border-color--hover": defaults.theme.colors["greyscale-500"],
"border-color--focus": defaults.theme.colors["primary-600"],
"border-style": "solid",
color: defaults.theme.colors["greyscale-800"],
});

View File

@@ -96,6 +96,20 @@
--c--theme--transitions--ease-out: cubic-bezier(0.33, 1, 0.68, 1);
--c--theme--transitions--ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
--c--theme--transitions--duration: 250ms;
--c--components--forms-input--font-weight: 400;
--c--components--forms-input--font-size: 1rem;
--c--components--forms-input--border-radius: 8px;
--c--components--forms-input--border-radius--hover: 2px;
--c--components--forms-input--border-radius--focus: 2px;
--c--components--forms-input--border-width: 2px;
--c--components--forms-input--border-color: #E7E8EA;
--c--components--forms-input--border-color--hover: #9EA3AA;
--c--components--forms-input--border-color--focus: #0556BF;
--c--components--forms-input--border-style: solid;
--c--components--forms-input--color: #303C4B;
--c--components--forms-field--width: 292px;
--c--components--forms-field--font-size: 0.6875rem;
--c--components--forms-field--color: #79818A;
--c--components--button--border-radius: 8px;
--c--components--button--border-radius--active: 2px;
--c--components--button--medium-height: 48px;

View File

@@ -1 +1 @@
export const tokens = {"theme":{"colors":{"primary-text":"#FFFFFF","primary-100":"#EBF2FC","primary-200":"#8CB5EA","primary-300":"#5894E1","primary-400":"#377FDB","primary-500":"#055FD2","primary-600":"#0556BF","primary-700":"#044395","primary-800":"#033474","primary-900":"#022858","secondary-text":"#555F6B","secondary-100":"#F2F7FC","secondary-200":"#EBF3FA","secondary-300":"#E2EEF8","secondary-400":"#DDEAF7","secondary-500":"#D4E5F5","secondary-600":"#C1D0DF","secondary-700":"#97A3AE","secondary-800":"#757E87","secondary-900":"#596067","greyscale-000":"#FFFFFF","greyscale-100":"#FAFAFB","greyscale-200":"#F3F4F4","greyscale-300":"#E7E8EA","greyscale-400":"#C2C6CA","greyscale-500":"#9EA3AA","greyscale-600":"#79818A","greyscale-700":"#555F6B","greyscale-800":"#303C4B","greyscale-900":"#0C1A2B","success-text":"#FFFFFF","success-100":"#EFFCD3","success-200":"#DBFAA9","success-300":"#BEF27C","success-400":"#A0E659","success-500":"#76D628","success-600":"#5AB81D","success-700":"#419A14","success-800":"#2C7C0C","success-900":"#1D6607","info-text":"#FFFFFF","info-100":"#EBF2FC","info-200":"#8CB5EA","info-300":"#5894E1","info-400":"#377FDB","info-500":"#055FD2","info-600":"#0556BF","info-700":"#044395","info-800":"#033474","info-900":"#022858","warning-text":"#FFFFFF","warning-100":"#FFF8CD","warning-200":"#FFEF9B","warning-300":"#FFE469","warning-400":"#FFDA43","warning-500":"#FFC805","warning-600":"#DBA603","warning-700":"#B78702","warning-800":"#936901","warning-900":"#7A5400","danger-text":"#FFFFFF","danger-100":"#F4B0B0","danger-200":"#EE8A8A","danger-300":"#E65454","danger-400":"#E13333","danger-500":"#DA0000","danger-600":"#C60000","danger-700":"#9B0000","danger-800":"#780000","danger-900":"#5C0000"},"font":{"sizes":{"h1":"1.75rem","h2":"1.375rem","h3":"1.125rem","h4":"0.8125rem","h5":"0.625rem","h6":"0.5rem","l":"1rem","m":"0.8125rem","s":"0.6875rem"},"weights":{"thin":100,"regular":300,"medium":400,"bold":500,"extrabold":700,"black":900},"families":{"base":"Roboto","accent":"Roboto"}},"spacings":{"xl":"4rem","l":"3rem","b":"1.625rem","s":"1rem","t":"0.5rem","st":"0.25rem"},"transitions":{"ease-in":"cubic-bezier(0.32, 0, 0.67, 0)","ease-out":"cubic-bezier(0.33, 1, 0.68, 1)","ease-in-out":"cubic-bezier(0.65, 0, 0.35, 1)","duration":"250ms"}},"components":{"button":{"border-radius":"8px","border-radius--active":"2px","medium-height":"48px","small-height":"32px","medium-font-size":"1rem","small-font-size":"0.8125rem","font-weight":400}}};
export const tokens = {"theme":{"colors":{"primary-text":"#FFFFFF","primary-100":"#EBF2FC","primary-200":"#8CB5EA","primary-300":"#5894E1","primary-400":"#377FDB","primary-500":"#055FD2","primary-600":"#0556BF","primary-700":"#044395","primary-800":"#033474","primary-900":"#022858","secondary-text":"#555F6B","secondary-100":"#F2F7FC","secondary-200":"#EBF3FA","secondary-300":"#E2EEF8","secondary-400":"#DDEAF7","secondary-500":"#D4E5F5","secondary-600":"#C1D0DF","secondary-700":"#97A3AE","secondary-800":"#757E87","secondary-900":"#596067","greyscale-000":"#FFFFFF","greyscale-100":"#FAFAFB","greyscale-200":"#F3F4F4","greyscale-300":"#E7E8EA","greyscale-400":"#C2C6CA","greyscale-500":"#9EA3AA","greyscale-600":"#79818A","greyscale-700":"#555F6B","greyscale-800":"#303C4B","greyscale-900":"#0C1A2B","success-text":"#FFFFFF","success-100":"#EFFCD3","success-200":"#DBFAA9","success-300":"#BEF27C","success-400":"#A0E659","success-500":"#76D628","success-600":"#5AB81D","success-700":"#419A14","success-800":"#2C7C0C","success-900":"#1D6607","info-text":"#FFFFFF","info-100":"#EBF2FC","info-200":"#8CB5EA","info-300":"#5894E1","info-400":"#377FDB","info-500":"#055FD2","info-600":"#0556BF","info-700":"#044395","info-800":"#033474","info-900":"#022858","warning-text":"#FFFFFF","warning-100":"#FFF8CD","warning-200":"#FFEF9B","warning-300":"#FFE469","warning-400":"#FFDA43","warning-500":"#FFC805","warning-600":"#DBA603","warning-700":"#B78702","warning-800":"#936901","warning-900":"#7A5400","danger-text":"#FFFFFF","danger-100":"#F4B0B0","danger-200":"#EE8A8A","danger-300":"#E65454","danger-400":"#E13333","danger-500":"#DA0000","danger-600":"#C60000","danger-700":"#9B0000","danger-800":"#780000","danger-900":"#5C0000"},"font":{"sizes":{"h1":"1.75rem","h2":"1.375rem","h3":"1.125rem","h4":"0.8125rem","h5":"0.625rem","h6":"0.5rem","l":"1rem","m":"0.8125rem","s":"0.6875rem"},"weights":{"thin":100,"regular":300,"medium":400,"bold":500,"extrabold":700,"black":900},"families":{"base":"Roboto","accent":"Roboto"}},"spacings":{"xl":"4rem","l":"3rem","b":"1.625rem","s":"1rem","t":"0.5rem","st":"0.25rem"},"transitions":{"ease-in":"cubic-bezier(0.32, 0, 0.67, 0)","ease-out":"cubic-bezier(0.33, 1, 0.68, 1)","ease-in-out":"cubic-bezier(0.65, 0, 0.35, 1)","duration":"250ms"}},"components":{"forms-input":{"font-weight":400,"font-size":"1rem","border-radius":"8px","border-radius--hover":"2px","border-radius--focus":"2px","border-width":"2px","border-color":"#E7E8EA","border-color--hover":"#9EA3AA","border-color--focus":"#0556BF","border-style":"solid","color":"#303C4B"},"forms-field":{"width":"292px","font-size":"0.6875rem","color":"#79818A"},"button":{"border-radius":"8px","border-radius--active":"2px","medium-height":"48px","small-height":"32px","medium-font-size":"1rem","small-font-size":"0.8125rem","font-weight":400}}};

View File

@@ -1 +1 @@
export const tokens = {"theme":{"colors":{"primary-text":"#FFFFFF","primary-100":"#EBF2FC","primary-200":"#8CB5EA","primary-300":"#5894E1","primary-400":"#377FDB","primary-500":"#055FD2","primary-600":"#0556BF","primary-700":"#044395","primary-800":"#033474","primary-900":"#022858","secondary-text":"#555F6B","secondary-100":"#F2F7FC","secondary-200":"#EBF3FA","secondary-300":"#E2EEF8","secondary-400":"#DDEAF7","secondary-500":"#D4E5F5","secondary-600":"#C1D0DF","secondary-700":"#97A3AE","secondary-800":"#757E87","secondary-900":"#596067","greyscale-000":"#FFFFFF","greyscale-100":"#FAFAFB","greyscale-200":"#F3F4F4","greyscale-300":"#E7E8EA","greyscale-400":"#C2C6CA","greyscale-500":"#9EA3AA","greyscale-600":"#79818A","greyscale-700":"#555F6B","greyscale-800":"#303C4B","greyscale-900":"#0C1A2B","success-text":"#FFFFFF","success-100":"#EFFCD3","success-200":"#DBFAA9","success-300":"#BEF27C","success-400":"#A0E659","success-500":"#76D628","success-600":"#5AB81D","success-700":"#419A14","success-800":"#2C7C0C","success-900":"#1D6607","info-text":"#FFFFFF","info-100":"#EBF2FC","info-200":"#8CB5EA","info-300":"#5894E1","info-400":"#377FDB","info-500":"#055FD2","info-600":"#0556BF","info-700":"#044395","info-800":"#033474","info-900":"#022858","warning-text":"#FFFFFF","warning-100":"#FFF8CD","warning-200":"#FFEF9B","warning-300":"#FFE469","warning-400":"#FFDA43","warning-500":"#FFC805","warning-600":"#DBA603","warning-700":"#B78702","warning-800":"#936901","warning-900":"#7A5400","danger-text":"#FFFFFF","danger-100":"#F4B0B0","danger-200":"#EE8A8A","danger-300":"#E65454","danger-400":"#E13333","danger-500":"#DA0000","danger-600":"#C60000","danger-700":"#9B0000","danger-800":"#780000","danger-900":"#5C0000"},"font":{"sizes":{"h1":"1.75rem","h2":"1.375rem","h3":"1.125rem","h4":"0.8125rem","h5":"0.625rem","h6":"0.5rem","l":"1rem","m":"0.8125rem","s":"0.6875rem"},"weights":{"thin":100,"regular":300,"medium":400,"bold":500,"extrabold":700,"black":900},"families":{"base":"Roboto","accent":"Roboto"}},"spacings":{"xl":"4rem","l":"3rem","b":"1.625rem","s":"1rem","t":"0.5rem","st":"0.25rem"},"transitions":{"ease-in":"cubic-bezier(0.32, 0, 0.67, 0)","ease-out":"cubic-bezier(0.33, 1, 0.68, 1)","ease-in-out":"cubic-bezier(0.65, 0, 0.35, 1)","duration":"250ms"}},"components":{"button":{"border-radius":"8px","border-radius--active":"2px","medium-height":"48px","small-height":"32px","medium-font-size":"1rem","small-font-size":"0.8125rem","font-weight":400}}};
export const tokens = {"theme":{"colors":{"primary-text":"#FFFFFF","primary-100":"#EBF2FC","primary-200":"#8CB5EA","primary-300":"#5894E1","primary-400":"#377FDB","primary-500":"#055FD2","primary-600":"#0556BF","primary-700":"#044395","primary-800":"#033474","primary-900":"#022858","secondary-text":"#555F6B","secondary-100":"#F2F7FC","secondary-200":"#EBF3FA","secondary-300":"#E2EEF8","secondary-400":"#DDEAF7","secondary-500":"#D4E5F5","secondary-600":"#C1D0DF","secondary-700":"#97A3AE","secondary-800":"#757E87","secondary-900":"#596067","greyscale-000":"#FFFFFF","greyscale-100":"#FAFAFB","greyscale-200":"#F3F4F4","greyscale-300":"#E7E8EA","greyscale-400":"#C2C6CA","greyscale-500":"#9EA3AA","greyscale-600":"#79818A","greyscale-700":"#555F6B","greyscale-800":"#303C4B","greyscale-900":"#0C1A2B","success-text":"#FFFFFF","success-100":"#EFFCD3","success-200":"#DBFAA9","success-300":"#BEF27C","success-400":"#A0E659","success-500":"#76D628","success-600":"#5AB81D","success-700":"#419A14","success-800":"#2C7C0C","success-900":"#1D6607","info-text":"#FFFFFF","info-100":"#EBF2FC","info-200":"#8CB5EA","info-300":"#5894E1","info-400":"#377FDB","info-500":"#055FD2","info-600":"#0556BF","info-700":"#044395","info-800":"#033474","info-900":"#022858","warning-text":"#FFFFFF","warning-100":"#FFF8CD","warning-200":"#FFEF9B","warning-300":"#FFE469","warning-400":"#FFDA43","warning-500":"#FFC805","warning-600":"#DBA603","warning-700":"#B78702","warning-800":"#936901","warning-900":"#7A5400","danger-text":"#FFFFFF","danger-100":"#F4B0B0","danger-200":"#EE8A8A","danger-300":"#E65454","danger-400":"#E13333","danger-500":"#DA0000","danger-600":"#C60000","danger-700":"#9B0000","danger-800":"#780000","danger-900":"#5C0000"},"font":{"sizes":{"h1":"1.75rem","h2":"1.375rem","h3":"1.125rem","h4":"0.8125rem","h5":"0.625rem","h6":"0.5rem","l":"1rem","m":"0.8125rem","s":"0.6875rem"},"weights":{"thin":100,"regular":300,"medium":400,"bold":500,"extrabold":700,"black":900},"families":{"base":"Roboto","accent":"Roboto"}},"spacings":{"xl":"4rem","l":"3rem","b":"1.625rem","s":"1rem","t":"0.5rem","st":"0.25rem"},"transitions":{"ease-in":"cubic-bezier(0.32, 0, 0.67, 0)","ease-out":"cubic-bezier(0.33, 1, 0.68, 1)","ease-in-out":"cubic-bezier(0.65, 0, 0.35, 1)","duration":"250ms"}},"components":{"forms-input":{"font-weight":400,"font-size":"1rem","border-radius":"8px","border-radius--hover":"2px","border-radius--focus":"2px","border-width":"2px","border-color":"#E7E8EA","border-color--hover":"#9EA3AA","border-color--focus":"#0556BF","border-style":"solid","color":"#303C4B"},"forms-field":{"width":"292px","font-size":"0.6875rem","color":"#79818A"},"button":{"border-radius":"8px","border-radius--active":"2px","medium-height":"48px","small-height":"32px","medium-font-size":"1rem","small-font-size":"0.8125rem","font-weight":400}}};

View File

@@ -4,6 +4,7 @@ export * from "./components/Button";
export * from "./components/DataGrid";
export * from "./components/DataGrid/SimpleDataGrid";
export * from "./components/Forms/Field";
export * from "./components/Forms/Input";
export * from "./components/Loader";
export * from "./components/Pagination";
export * from "./components/Provider";

View File

@@ -3,3 +3,12 @@ export const noop = () => undefined;
export function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
export function randomString(length: number = 8): string {
const chars =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
let result = "";
for (let i = length; i > 0; --i)
result += chars[Math.floor(Math.random() * chars.length)];
return result;
}