From 1c4cf198770d02bf34ff7c996d3b0b16c8d19363 Mon Sep 17 00:00:00 2001 From: blue Date: Thu, 10 Oct 2024 15:54:12 +0900 Subject: [PATCH 1/2] feat. refactor button component. add type and input style --- example/src/Home/index.tsx | 15 ++++++++-- src/components/Input/index.tsx | 50 +++++++++++++++++----------------- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/example/src/Home/index.tsx b/example/src/Home/index.tsx index 5287ea7..3ed7219 100644 --- a/example/src/Home/index.tsx +++ b/example/src/Home/index.tsx @@ -169,17 +169,20 @@ const Home = ({ value: value, onChangeText: setValue, }} - />{' '} + /> Confirm} @@ -209,6 +214,8 @@ const Home = ({ /> diff --git a/src/components/Input/index.tsx b/src/components/Input/index.tsx index c46ab40..78dfee5 100644 --- a/src/components/Input/index.tsx +++ b/src/components/Input/index.tsx @@ -1,6 +1,6 @@ import { ReactElement, useState } from 'react' import styled from '@emotion/styled' -import { themeFunc } from '../../styles' +import { font, themeFunc } from '../../styles' import { KaText } from '../Text/Text' import { useKaTheme } from '../../hooks' import MathClose from '../../icons/MathClose.svg' @@ -16,11 +16,11 @@ const StyledContainer = styled.div` border-radius: var(--Radius-6, 360px); box-sizing: border-box; outline: ${({ isError }) => (isError ? '1px' : '4px')} solid; - outline-color: ${({ theme, isFocused, isError }): string => + outline-color: ${({ isFocused, isError }) => isError - ? theme.danger['6'] + ? themeFunc('danger', '6') : isFocused - ? theme.elevation['8'] + ? themeFunc('elevation', '8') : 'transparent'}; transition: border-color 0.3s ease; ` @@ -52,25 +52,20 @@ const StyledClose = styled.div` const StyledInput = styled.input<{ isError?: boolean }>` flex: 1; - width: 100%; - font-size: 14px; - font-weight: 400; + ${font['body/md_600'].styles}; height: var(--Sizing-8, 40px); background-color: transparent; text-overflow: ellipsis; - color: ${themeFunc('gray', '0')}; + color: ${({ disabled }) => + disabled ? themeFunc('elevation', '6') : themeFunc('gray', '0')}; border: none; box-sizing: border-box; ::placeholder { - font-size: 14px; - font-family: Manrope; - line-height: 20px; - font-weight: 600; - color: ${(props) => - props.isError + color: ${({ isError, disabled }) => + isError ? themeFunc('danger', '6') - : props.disabled + : disabled ? themeFunc('elevation', '6') : themeFunc('elevation', '5')}; } @@ -83,10 +78,12 @@ const StyledInput = styled.input<{ isError?: boolean }>` ` export interface KaTextInputProps { - inputProps?: { + inputProps: { + type?: 'text' | 'email' | 'password' | 'number' placeholder?: string - value?: string - onChangeText?: (value: string) => void + value: string + onChangeText: (value: string) => void + style?: React.CSSProperties } leftComponent?: ReactElement rightComponent?: ReactElement @@ -102,7 +99,12 @@ export const KaTextInput = ({ rightComponent, leftUnit, rightUnit, - inputProps, + inputProps = { + type: 'text', + placeholder: '', + value: '', + onChangeText: () => {}, + }, disabled, isError, containerStyle, @@ -141,7 +143,7 @@ export const KaTextInput = ({ }} isError={isError} onChange={({ target: { value } }): void => { - inputProps?.onChangeText?.(value) + inputProps.onChangeText?.(value) }} disabled={disabled} {...inputProps} @@ -158,10 +160,10 @@ export const KaTextInput = ({ {rightUnit} )} - {inputProps?.value && ( + {inputProps.value && !disabled && ( { - inputProps?.onChangeText?.('') + inputProps.onChangeText?.('') }} > )} From 29d03975967f04aaa09fb48fed38e37986eb85f6 Mon Sep 17 00:00:00 2001 From: blue Date: Thu, 10 Oct 2024 15:54:29 +0900 Subject: [PATCH 2/2] Update version to v0.1.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 33540d6..86981fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kaiachain/kaia-design-system", - "version": "0.1.12", + "version": "0.1.13", "license": "MIT", "type": "module", "main": "dist/index.js",