teachable-design-system 0.1.16 → 0.2.1

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.
@@ -1,90 +1,135 @@
1
- import React from 'react';
2
- import { typography } from '../../style';
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
- export const getInputWrapperStyle = (size: 'small' | 'medium' | 'large'): React.CSSProperties => {
5
- let height = '48px';
6
+ interface InputWrapperProps {
7
+ width?: string;
8
+ }
6
9
 
7
- switch (size) {
8
- case 'small':
9
- height = '41px';
10
- break;
11
- case 'medium':
12
- height = '48px';
13
- break;
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
- return {
20
- display: 'flex',
21
- flexDirection: 'column',
22
- gap: '8px',
23
- width: '306px',
24
- height: height,
25
- };
26
- };
18
+ interface IconButtonProps {
19
+ disabled?: boolean;
20
+ }
27
21
 
28
- export const labelStyle: React.CSSProperties = {
29
- display:'flex',
30
- justifyContent:'flex-start',
31
- ...typography.label.small,
32
- color: '#333',
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
+ }
33
53
  };
34
54
 
35
- export const getInputStyle = (
36
- inputSize: 'small' | 'medium' | 'large',
37
- disabled: boolean,
38
- isFocused: boolean
39
- ): React.CSSProperties => {
40
- let padding = '0px 16px';
41
- let fontSize = typography.label.medium.fontSize;
42
- let lineHeight = typography.label.medium.lineHeight;
43
- let fontWeight = typography.label.medium.fontWeight;
44
- let height = '48px';
45
- let width = '306px';
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
+ `;
46
115
 
47
- switch (inputSize) {
48
- case 'small':
49
- fontSize = typography.label.small.fontSize;
50
- lineHeight = typography.label.small.lineHeight;
51
- fontWeight = typography.label.small.fontWeight;
52
- height = '40px';
53
- break;
54
- case 'medium':
55
- fontSize = typography.label.medium.fontSize;
56
- lineHeight = typography.label.medium.lineHeight;
57
- fontWeight = typography.label.medium.fontWeight;
58
- height = '48px';
59
- break;
60
- case 'large':
61
- fontSize = typography.label.large.fontSize;
62
- lineHeight = typography.label.large.lineHeight;
63
- fontWeight = typography.label.large.fontWeight;
64
- height = '56px';
65
- break;
66
- }
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;
67
130
 
68
- return {
69
- width,
70
- height,
71
- minHeight: height,
72
- maxHeight: height,
73
- padding,
74
- fontSize,
75
- lineHeight,
76
- fontWeight,
77
- fontFamily: typography.fontFamily.primary,
78
- border: isFocused ? '1px solid #4a90e2' : '1px solid #ddd',
79
- borderRadius: '4px',
80
- outline: 'none',
81
- transition: 'all 0.2s ease',
82
- boxShadow: isFocused ? '0 0 0 3px rgba(74, 144, 226, 0.1)' : 'none',
83
- backgroundColor: disabled ? '#f5f5f5' : '#fff',
84
- cursor: disabled ? 'not-allowed' : 'text',
85
- color: '#333',
86
- boxSizing: 'border-box',
87
- display: 'flex',
88
- alignItems: 'center',
89
- };
90
- };
131
+ svg {
132
+ color: ${(props) =>
133
+ props.disabled ? colors.icon.disabled : colors.icon.gray};
134
+ }
135
+ `;
@@ -1,11 +1,15 @@
1
1
  export interface InputProps {
2
- size?: 'small' | 'medium' | 'large';
3
- label?: boolean;
4
- labelText?: string;
5
- placeholder?: string;
6
- value?: string;
7
- onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
8
- disabled?: boolean;
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 = 'small' | 'medium' | 'large';
15
+ export type InputSize = "small" | "medium" | "large";