@soul-refiner/design-system 0.2.13 → 0.2.14
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/components/actions/upload/upload.d.ts +3 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/input/text_input/index.d.ts +2 -0
- package/dist/components/input/text_input/index.js +1 -0
- package/dist/components/input/text_input/text_input.d.ts +35 -0
- package/dist/components/input/text_input/text_input.js +91 -0
- package/package.json +1 -1
|
@@ -2,6 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { COLORS } from '../../../common';
|
|
3
3
|
type UploadTypes = 'audio' | 'image' | 'file' | 'video';
|
|
4
4
|
export interface UploadProps extends React.PropsWithChildren {
|
|
5
|
+
/**
|
|
6
|
+
* @param background one of the defined colors e.g. grey-1 or a user defined color
|
|
7
|
+
*/
|
|
5
8
|
background: (typeof COLORS)[number] | string;
|
|
6
9
|
borderColor: (typeof COLORS)[number];
|
|
7
10
|
iconColor: (typeof COLORS)[number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TextInput } from './text_input';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type TextInputSize = 'small' | 'large';
|
|
3
|
+
export type Props = {
|
|
4
|
+
disabled: boolean | never;
|
|
5
|
+
successful: boolean | never;
|
|
6
|
+
warning: boolean | never;
|
|
7
|
+
bg?: string;
|
|
8
|
+
icon?: React.ReactElement;
|
|
9
|
+
helperText?: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
maxCharacters?: number;
|
|
12
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
size?: TextInputSize;
|
|
15
|
+
sx?: string;
|
|
16
|
+
value: string;
|
|
17
|
+
};
|
|
18
|
+
interface DisabledProps extends Props {
|
|
19
|
+
disabled: true;
|
|
20
|
+
successful: false | never;
|
|
21
|
+
warning: false | never;
|
|
22
|
+
}
|
|
23
|
+
interface SuccessfulProps extends Props {
|
|
24
|
+
disabled: false | never;
|
|
25
|
+
successful: true;
|
|
26
|
+
warning: false | never;
|
|
27
|
+
}
|
|
28
|
+
interface WarningProps extends Props {
|
|
29
|
+
disabled: false | never;
|
|
30
|
+
successful: false | never;
|
|
31
|
+
warning: true;
|
|
32
|
+
}
|
|
33
|
+
export type TextInputProps = DisabledProps | SuccessfulProps | WarningProps;
|
|
34
|
+
export declare const TextInput: ({ bg, disabled, helperText, icon, label, maxCharacters, onChange, placeholder, size, successful, sx, value, warning, }: TextInputProps) => React.JSX.Element;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { CheckmarkCircle, AlertCircle } from 'icons';
|
|
5
|
+
export const TextInput = ({ bg = 'var(--color-blue-10)', disabled, helperText, icon, label, maxCharacters, onChange, placeholder, size = 'large', successful, sx, value, warning, }) => {
|
|
6
|
+
return (React.createElement(Label, { "$disabled": disabled, "$size": size, "$sx": sx },
|
|
7
|
+
label,
|
|
8
|
+
React.createElement(InputWrapper, { "$bg": bg, "$size": size, "$successful": successful, "$warning": warning },
|
|
9
|
+
icon,
|
|
10
|
+
React.createElement(Input, { disabled: disabled, onChange: onChange, placeholder: placeholder, value: maxCharacters ? value.slice(0, maxCharacters - 1) : value, "$size": size }),
|
|
11
|
+
maxCharacters && (React.createElement(MaxCharactersText, { "$size": size },
|
|
12
|
+
value.length,
|
|
13
|
+
" / ",
|
|
14
|
+
maxCharacters)),
|
|
15
|
+
successful && React.createElement(CheckmarkCircle, { color: "green-3" }),
|
|
16
|
+
warning && React.createElement(AlertCircle, { color: "red-4" })),
|
|
17
|
+
helperText && React.createElement(HelperText, { "$size": size }, helperText)));
|
|
18
|
+
};
|
|
19
|
+
const Label = styled.label `
|
|
20
|
+
width: 100%;
|
|
21
|
+
display: flex;
|
|
22
|
+
gap: 4px;
|
|
23
|
+
flex-flow: column nowrap;
|
|
24
|
+
color: var(--color-grey-2);
|
|
25
|
+
font-family: Inter;
|
|
26
|
+
font-size: ${({ $size }) => ($size === 'small' ? 16 : 18)}px;
|
|
27
|
+
font-weight: 500;
|
|
28
|
+
line-height: ${({ $size }) => ($size === 'small' ? 24 : 26)}px;
|
|
29
|
+
|
|
30
|
+
${({ $disabled }) => $disabled
|
|
31
|
+
? `
|
|
32
|
+
color: var(--color-grey-7) !important;
|
|
33
|
+
& > * {
|
|
34
|
+
color: var(--color-grey-7) !important;
|
|
35
|
+
}
|
|
36
|
+
& > div {
|
|
37
|
+
background-color: var(--color-grey-9) !important;
|
|
38
|
+
}`
|
|
39
|
+
: ''}
|
|
40
|
+
|
|
41
|
+
${({ $sx }) => ($sx ? $sx : '')}
|
|
42
|
+
`;
|
|
43
|
+
const InputWrapper = styled.div `
|
|
44
|
+
display: flex;
|
|
45
|
+
gap: 8px;
|
|
46
|
+
align-items: center;
|
|
47
|
+
box-sizing: border-box;
|
|
48
|
+
padding: ${({ $size }) => ($size === 'small' ? '6px 12px' : '12px')};
|
|
49
|
+
background-color: ${({ $bg }) => $bg};
|
|
50
|
+
border-radius: 8px;
|
|
51
|
+
border: 1px solid transparent;
|
|
52
|
+
|
|
53
|
+
&:hover {
|
|
54
|
+
border-color: var(--color-grey-8);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:focus-within {
|
|
58
|
+
border-color: var(--color-primary-blue-2);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
${({ $successful }) => $successful ? 'border-color: var(--color-green-3) !important;' : ''}
|
|
62
|
+
${({ $warning }) => $warning ? 'border-color: var(--color-red-4) !important;' : ''}
|
|
63
|
+
`;
|
|
64
|
+
const Input = styled.input `
|
|
65
|
+
flex: 1;
|
|
66
|
+
font-family: Inter;
|
|
67
|
+
font-size: ${({ $size }) => ($size === 'small' ? 14 : 16)}px;
|
|
68
|
+
line-height: ${({ $size }) => ($size === 'small' ? 20 : 24)}px;
|
|
69
|
+
border: none;
|
|
70
|
+
outline: none;
|
|
71
|
+
border-radius: 8px;
|
|
72
|
+
background-color: transparent;
|
|
73
|
+
|
|
74
|
+
&::placeholder {
|
|
75
|
+
color: var(--color-grey-6);
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
const HelperText = styled.span `
|
|
79
|
+
color: var(--color-grey-4);
|
|
80
|
+
font-family: Inter;
|
|
81
|
+
font-size: ${({ $size }) => ($size === 'small' ? 12 : 14)}px;
|
|
82
|
+
line-height: ${({ $size }) => ($size === 'small' ? 16 : 20)}px;
|
|
83
|
+
`;
|
|
84
|
+
const MaxCharactersText = styled.span `
|
|
85
|
+
color: var(--color-grey-6);
|
|
86
|
+
font-family: Inter;
|
|
87
|
+
font-size: 14px;
|
|
88
|
+
font-style: normal;
|
|
89
|
+
font-weight: 400;
|
|
90
|
+
line-height: 20px;
|
|
91
|
+
`;
|