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.
package/dist/index.cjs.js CHANGED
@@ -6,6 +6,7 @@ var react = require('@emotion/react');
6
6
  var React = require('react');
7
7
  var element = require('../../assets/icons/checked.png');
8
8
  var arrowDownIcon = require('../../assets/icons/arrow-down.png');
9
+ var lucideReact = require('lucide-react');
9
10
  var icon = require('../../assets/icons/icon_size.png');
10
11
 
11
12
  const colors = {
@@ -1076,87 +1077,117 @@ function Dropdown({ size, options, onSelect, label, placeholder }) {
1076
1077
  return (jsxRuntime.jsxs("div", { style: { position: 'relative' }, children: [jsxRuntime.jsx(StyledLabel, { children: label }), jsxRuntime.jsx(StyledDropDown, { onClick: () => setOpen((prev) => !prev), size: size, isOpen: open, children: jsxRuntime.jsxs(StyledBox, { children: [jsxRuntime.jsx(StyledText, { size: size, isOpen: open, children: selected ?? placeholder }), jsxRuntime.jsx(StyledIcon$1, { size: size, children: jsxRuntime.jsx("img", { src: arrowDownIcon, alt: "dropdown icon", style: { width: '100%', height: '100%' } }) })] }) }), open && (jsxRuntime.jsx(StyledOptions, { ref: ref, size: size, children: options?.map((option) => (jsxRuntime.jsx(StyledOption, { onClick: () => handleSelect(option), size: size, isSelected: option === selected, children: option }, option))) }))] }));
1077
1078
  }
1078
1079
 
1079
- const getInputWrapperStyle = (size) => {
1080
- let height = '48px';
1080
+ const getInputSizeStyle = (size) => {
1081
1081
  switch (size) {
1082
- case 'small':
1083
- height = '41px';
1084
- break;
1085
- case 'medium':
1086
- height = '48px';
1087
- break;
1088
- case 'large':
1089
- height = '56px';
1090
- break;
1091
- }
1092
- return {
1093
- display: 'flex',
1094
- flexDirection: 'column',
1095
- gap: '8px',
1096
- width: '306px',
1097
- height: height,
1098
- };
1099
- };
1100
- const labelStyle = {
1101
- display: 'flex',
1102
- justifyContent: 'flex-start',
1103
- ...typography.label.small,
1104
- color: '#333',
1105
- };
1106
- const getInputStyle = (inputSize, disabled, isFocused) => {
1107
- let padding = '0px 16px';
1108
- let fontSize = typography.label.medium.fontSize;
1109
- let lineHeight = typography.label.medium.lineHeight;
1110
- let fontWeight = typography.label.medium.fontWeight;
1111
- let height = '48px';
1112
- let width = '306px';
1113
- switch (inputSize) {
1114
- case 'small':
1115
- fontSize = typography.label.small.fontSize;
1116
- lineHeight = typography.label.small.lineHeight;
1117
- fontWeight = typography.label.small.fontWeight;
1118
- height = '40px';
1119
- break;
1120
- case 'medium':
1121
- fontSize = typography.label.medium.fontSize;
1122
- lineHeight = typography.label.medium.lineHeight;
1123
- fontWeight = typography.label.medium.fontWeight;
1124
- height = '48px';
1125
- break;
1126
- case 'large':
1127
- fontSize = typography.label.large.fontSize;
1128
- lineHeight = typography.label.large.lineHeight;
1129
- fontWeight = typography.label.large.fontWeight;
1130
- height = '56px';
1131
- break;
1082
+ case "small":
1083
+ return react.css `
1084
+ height: 40px;
1085
+ font-size: ${typography.label.small.fontSize};
1086
+ line-height: ${typography.label.small.lineHeight};
1087
+ font-weight: ${typography.label.small.fontWeight};
1088
+ `;
1089
+ case "medium":
1090
+ return react.css `
1091
+ height: 48px;
1092
+ font-size: ${typography.label.medium.fontSize};
1093
+ line-height: ${typography.label.medium.lineHeight};
1094
+ font-weight: ${typography.label.medium.fontWeight};
1095
+ `;
1096
+ case "large":
1097
+ return react.css `
1098
+ height: 56px;
1099
+ font-size: ${typography.label.large.fontSize};
1100
+ line-height: ${typography.label.large.lineHeight};
1101
+ font-weight: ${typography.label.large.fontWeight};
1102
+ `;
1103
+ default:
1104
+ return react.css `
1105
+ height: 48px;
1106
+ font-size: ${typography.label.medium.fontSize};
1107
+ line-height: ${typography.label.medium.lineHeight};
1108
+ font-weight: ${typography.label.medium.fontWeight};
1109
+ `;
1132
1110
  }
1133
- return {
1134
- width,
1135
- height,
1136
- minHeight: height,
1137
- maxHeight: height,
1138
- padding,
1139
- fontSize,
1140
- lineHeight,
1141
- fontWeight,
1142
- fontFamily: typography.fontFamily.primary,
1143
- border: isFocused ? '1px solid #4a90e2' : '1px solid #ddd',
1144
- borderRadius: '4px',
1145
- outline: 'none',
1146
- transition: 'all 0.2s ease',
1147
- boxShadow: isFocused ? '0 0 0 3px rgba(74, 144, 226, 0.1)' : 'none',
1148
- backgroundColor: disabled ? '#f5f5f5' : '#fff',
1149
- cursor: disabled ? 'not-allowed' : 'text',
1150
- color: '#333',
1151
- boxSizing: 'border-box',
1152
- display: 'flex',
1153
- alignItems: 'center',
1154
- };
1155
1111
  };
1112
+ const InputWrapper = styled.div `
1113
+ display: flex;
1114
+ flex-direction: column;
1115
+ gap: 8px;
1116
+ width: ${(props) => props.width || "306px"};
1117
+ `;
1118
+ const Label = styled.label `
1119
+ display: flex;
1120
+ justify-content: flex-start;
1121
+ font-size: ${typography.label.small.fontSize};
1122
+ line-height: ${typography.label.small.lineHeight};
1123
+ font-weight: ${typography.label.small.fontWeight};
1124
+ font-family: ${typography.fontFamily.primary};
1125
+ color: ${colors.text.subtle};
1126
+ `;
1127
+ const InputContainer = styled.div `
1128
+ position: relative;
1129
+ display: flex;
1130
+ align-items: center;
1131
+ width: 100%;
1132
+ `;
1133
+ const StyledInput = styled.input `
1134
+ width: ${(props) => props.width || "306px"};
1135
+ padding: ${(props) => (props.isPassword ? "0px 48px 0px 16px" : "0px 16px")};
1136
+ font-family: ${typography.fontFamily.primary};
1137
+ border: 1px solid ${colors.input.border};
1138
+ border-radius: 4px;
1139
+ outline: none;
1140
+ transition: all 0.2s ease;
1141
+ background-color: ${(props) => props.disabled ? colors.input["surface-disabled"] : colors.input.surface};
1142
+ cursor: ${(props) => (props.disabled ? "not-allowed" : "text")};
1143
+ color: ${colors.text.basic};
1144
+ box-sizing: border-box;
1145
+
1146
+ ${(props) => getInputSizeStyle(props.inputSize)}
1147
+
1148
+ ${(props) => props.height &&
1149
+ react.css `
1150
+ height: ${props.height};
1151
+ `}
1152
+
1153
+ &:focus {
1154
+ border: 1px solid ${colors.input["border-active"]};
1155
+ box-shadow: 0 0 0 3px ${colors.light.primary["5"]};
1156
+ }
1157
+
1158
+ &:disabled {
1159
+ border: 1px solid ${colors.input["border-disabled"]};
1160
+ color: ${colors.text.disabled};
1161
+ }
1162
+
1163
+ &::placeholder {
1164
+ color: ${colors.text.disabled};
1165
+ }
1166
+ `;
1167
+ const IconButton = styled.button `
1168
+ position: absolute;
1169
+ right: 12px;
1170
+ top: 50%;
1171
+ transform: translateY(-50%);
1172
+ background: none;
1173
+ border: none;
1174
+ cursor: ${(props) => (props.disabled ? "not-allowed" : "pointer")};
1175
+ padding: 4px;
1176
+ display: flex;
1177
+ align-items: center;
1178
+ justify-content: center;
1179
+ opacity: ${(props) => (props.disabled ? 0.5 : 1)};
1180
+ transition: opacity 0.2s ease;
1181
+
1182
+ svg {
1183
+ color: ${(props) => props.disabled ? colors.icon.disabled : colors.icon.gray};
1184
+ }
1185
+ `;
1156
1186
 
1157
- const Input = ({ size = 'medium', label = false, labelText = '', placeholder = '', value, onChange, disabled = false, }) => {
1158
- const [isFocused, setIsFocused] = React.useState(false);
1159
- return (jsxRuntime.jsxs("div", { style: getInputWrapperStyle(size), children: [label && labelText && jsxRuntime.jsx("label", { style: labelStyle, children: labelText }), jsxRuntime.jsx("input", { style: getInputStyle(size, disabled, isFocused), placeholder: placeholder, value: value, onChange: onChange, disabled: disabled, onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false) })] }));
1187
+ const Input = ({ id, width, height, size = "medium", label = false, labelText = "", placeholder = "", value, onChange, disabled = false, isPassword = false, }) => {
1188
+ const [showPassword, setShowPassword] = React.useState(false);
1189
+ const inputType = isPassword ? (showPassword ? "text" : "password") : "text";
1190
+ return (jsxRuntime.jsxs(InputWrapper, { width: width, children: [label && labelText && jsxRuntime.jsx(Label, { htmlFor: id, children: labelText }), jsxRuntime.jsxs(InputContainer, { children: [jsxRuntime.jsx(StyledInput, { id: id, type: inputType, inputSize: size, width: width, height: height, disabled: disabled, isPassword: isPassword, placeholder: placeholder, value: value, onChange: onChange }), isPassword && (jsxRuntime.jsx(IconButton, { type: "button", disabled: disabled, onClick: () => setShowPassword(!showPassword), "aria-label": showPassword ? "Hide password" : "Show password", children: showPassword ? jsxRuntime.jsx(lucideReact.Eye, { size: 20 }) : jsxRuntime.jsx(lucideReact.EyeOff, { size: 20 }) }))] })] }));
1160
1191
  };
1161
1192
 
1162
1193
  const StyledIcon = styled.img `