teachable-design-system 0.1.15 → 0.2.0
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/index.cjs.js +108 -78
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.esm.js +108 -78
- package/dist/index.esm.js.map +1 -1
- package/dist/types/components/Button/Button.d.ts.map +1 -1
- package/dist/types/components/Button/index.d.ts +1 -1
- package/dist/types/components/Button/index.d.ts.map +1 -1
- package/dist/types/components/Input/Input.d.ts +2 -2
- package/dist/types/components/Input/Input.d.ts.map +1 -1
- package/dist/types/components/Input/index.d.ts.map +1 -1
- package/dist/types/components/Input/style.d.ts +34 -4
- package/dist/types/components/Input/style.d.ts.map +1 -1
- package/dist/types/types/input.types.d.ts +6 -2
- package/dist/types/types/input.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/Button.stories.tsx +1 -0
- package/src/components/Button/Button.tsx +1 -0
- package/src/components/Button/index.ts +1 -1
- package/src/components/Input/Input.stories.tsx +242 -113
- package/src/components/Input/Input.tsx +54 -27
- package/src/components/Input/index.ts +1 -1
- package/src/components/Input/style.ts +127 -83
- package/src/types/input.types.ts +12 -8
|
@@ -1,91 +1,135 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { css } from "@emotion/react";
|
|
3
|
+
import { colors } from "../../style/theme/colors";
|
|
4
|
+
import { typography } from "../../style/theme/typography";
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
interface InputWrapperProps {
|
|
7
|
+
width?: string;
|
|
8
|
+
}
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
case 'large':
|
|
15
|
-
height = '56px';
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
10
|
+
interface StyledInputProps {
|
|
11
|
+
width?: string;
|
|
12
|
+
height?: string;
|
|
13
|
+
inputSize?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
isPassword?: boolean;
|
|
16
|
+
}
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
gap: '8px',
|
|
23
|
-
width: '306px',
|
|
24
|
-
height: height,
|
|
25
|
-
};
|
|
26
|
-
};
|
|
18
|
+
interface IconButtonProps {
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
}
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
const getInputSizeStyle = (size?: string) => {
|
|
23
|
+
switch (size) {
|
|
24
|
+
case "small":
|
|
25
|
+
return css`
|
|
26
|
+
height: 40px;
|
|
27
|
+
font-size: ${typography.label.small.fontSize};
|
|
28
|
+
line-height: ${typography.label.small.lineHeight};
|
|
29
|
+
font-weight: ${typography.label.small.fontWeight};
|
|
30
|
+
`;
|
|
31
|
+
case "medium":
|
|
32
|
+
return css`
|
|
33
|
+
height: 48px;
|
|
34
|
+
font-size: ${typography.label.medium.fontSize};
|
|
35
|
+
line-height: ${typography.label.medium.lineHeight};
|
|
36
|
+
font-weight: ${typography.label.medium.fontWeight};
|
|
37
|
+
`;
|
|
38
|
+
case "large":
|
|
39
|
+
return css`
|
|
40
|
+
height: 56px;
|
|
41
|
+
font-size: ${typography.label.large.fontSize};
|
|
42
|
+
line-height: ${typography.label.large.lineHeight};
|
|
43
|
+
font-weight: ${typography.label.large.fontWeight};
|
|
44
|
+
`;
|
|
45
|
+
default:
|
|
46
|
+
return css`
|
|
47
|
+
height: 48px;
|
|
48
|
+
font-size: ${typography.label.medium.fontSize};
|
|
49
|
+
line-height: ${typography.label.medium.lineHeight};
|
|
50
|
+
font-weight: ${typography.label.medium.fontWeight};
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
34
53
|
};
|
|
35
54
|
|
|
36
|
-
export const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
export const InputWrapper = styled.div<InputWrapperProps>`
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
gap: 8px;
|
|
59
|
+
width: ${(props) => props.width || "306px"};
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
export const Label = styled.label`
|
|
63
|
+
display: flex;
|
|
64
|
+
justify-content: flex-start;
|
|
65
|
+
font-size: ${typography.label.small.fontSize};
|
|
66
|
+
line-height: ${typography.label.small.lineHeight};
|
|
67
|
+
font-weight: ${typography.label.small.fontWeight};
|
|
68
|
+
font-family: ${typography.fontFamily.primary};
|
|
69
|
+
color: ${colors.text.subtle};
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
export const InputContainer = styled.div`
|
|
73
|
+
position: relative;
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
width: 100%;
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
export const StyledInput = styled.input<StyledInputProps>`
|
|
80
|
+
width: ${(props) => props.width || "306px"};
|
|
81
|
+
padding: ${(props) => (props.isPassword ? "0px 48px 0px 16px" : "0px 16px")};
|
|
82
|
+
font-family: ${typography.fontFamily.primary};
|
|
83
|
+
border: 1px solid ${colors.input.border};
|
|
84
|
+
border-radius: 4px;
|
|
85
|
+
outline: none;
|
|
86
|
+
transition: all 0.2s ease;
|
|
87
|
+
background-color: ${(props) =>
|
|
88
|
+
props.disabled ? colors.input["surface-disabled"] : colors.input.surface};
|
|
89
|
+
cursor: ${(props) => (props.disabled ? "not-allowed" : "text")};
|
|
90
|
+
color: ${colors.text.basic};
|
|
91
|
+
box-sizing: border-box;
|
|
92
|
+
|
|
93
|
+
${(props) => getInputSizeStyle(props.inputSize)}
|
|
94
|
+
|
|
95
|
+
${(props) =>
|
|
96
|
+
props.height &&
|
|
97
|
+
css`
|
|
98
|
+
height: ${props.height};
|
|
99
|
+
`}
|
|
100
|
+
|
|
101
|
+
&:focus {
|
|
102
|
+
border: 1px solid ${colors.input["border-active"]};
|
|
103
|
+
box-shadow: 0 0 0 3px ${colors.light.primary["5"]};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&:disabled {
|
|
107
|
+
border: 1px solid ${colors.input["border-disabled"]};
|
|
108
|
+
color: ${colors.text.disabled};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&::placeholder {
|
|
112
|
+
color: ${colors.text.disabled};
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
47
115
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
fontSize = typography.label.large.fontSize;
|
|
63
|
-
lineHeight = typography.label.large.lineHeight;
|
|
64
|
-
fontWeight = typography.label.large.fontWeight;
|
|
65
|
-
height = '56px';
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
116
|
+
export const IconButton = styled.button<IconButtonProps>`
|
|
117
|
+
position: absolute;
|
|
118
|
+
right: 12px;
|
|
119
|
+
top: 50%;
|
|
120
|
+
transform: translateY(-50%);
|
|
121
|
+
background: none;
|
|
122
|
+
border: none;
|
|
123
|
+
cursor: ${(props) => (props.disabled ? "not-allowed" : "pointer")};
|
|
124
|
+
padding: 4px;
|
|
125
|
+
display: flex;
|
|
126
|
+
align-items: center;
|
|
127
|
+
justify-content: center;
|
|
128
|
+
opacity: ${(props) => (props.disabled ? 0.5 : 1)};
|
|
129
|
+
transition: opacity 0.2s ease;
|
|
68
130
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
padding,
|
|
75
|
-
fontSize,
|
|
76
|
-
lineHeight,
|
|
77
|
-
fontWeight,
|
|
78
|
-
fontFamily: typography.fontFamily.primary,
|
|
79
|
-
border: isFocused ? '1px solid #4a90e2' : '1px solid #ddd',
|
|
80
|
-
borderRadius: '4px',
|
|
81
|
-
outline: 'none',
|
|
82
|
-
transition: 'all 0.2s ease',
|
|
83
|
-
boxShadow: isFocused ? '0 0 0 3px rgba(74, 144, 226, 0.1)' : 'none',
|
|
84
|
-
backgroundColor: disabled ? '#f5f5f5' : '#fff',
|
|
85
|
-
cursor: disabled ? 'not-allowed' : 'text',
|
|
86
|
-
color: '#333',
|
|
87
|
-
boxSizing: 'border-box',
|
|
88
|
-
display: 'flex',
|
|
89
|
-
alignItems: 'center',
|
|
90
|
-
};
|
|
91
|
-
};
|
|
131
|
+
svg {
|
|
132
|
+
color: ${(props) =>
|
|
133
|
+
props.disabled ? colors.icon.disabled : colors.icon.gray};
|
|
134
|
+
}
|
|
135
|
+
`;
|
package/src/types/input.types.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
export interface InputProps {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
id?: string;
|
|
3
|
+
width?: string;
|
|
4
|
+
height?: string;
|
|
5
|
+
size?: "small" | "medium" | "large";
|
|
6
|
+
label?: boolean;
|
|
7
|
+
labelText?: string;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
value?: string;
|
|
10
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
isPassword?: boolean;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
export type InputSize =
|
|
15
|
+
export type InputSize = "small" | "medium" | "large";
|