-
+
{topLeftText}
-
+
{topRightText}
{children}
-
+
{bottomLeftText}
-
+
{bottomRightText}
diff --git a/HDesign/src/components/ExpenseList/ExpenseList.style.ts b/HDesign/src/components/ExpenseList/ExpenseList.style.ts
index dd05c067f..8dbd227aa 100644
--- a/HDesign/src/components/ExpenseList/ExpenseList.style.ts
+++ b/HDesign/src/components/ExpenseList/ExpenseList.style.ts
@@ -19,11 +19,6 @@ export const expenseItemLeftStyle = () =>
gap: '1rem',
});
-export const TextStyle = (theme: Theme) =>
- css({
- color: theme.colors.onTertiary,
- });
-
export const expenseListStyle = (theme: Theme) =>
css({
width: '100%',
diff --git a/HDesign/src/components/ExpenseList/ExpenseList.tsx b/HDesign/src/components/ExpenseList/ExpenseList.tsx
index 3cc5e8354..1f57810e5 100644
--- a/HDesign/src/components/ExpenseList/ExpenseList.tsx
+++ b/HDesign/src/components/ExpenseList/ExpenseList.tsx
@@ -6,7 +6,7 @@ import Icon from '@components/Icon/Icon';
import {useTheme} from '@theme/HDesignProvider';
import {ExpenseItemProps, ExpenseListProps} from './ExpenseList.type';
-import {expenseItemStyle, expenseListStyle, expenseItemLeftStyle, TextStyle} from './ExpenseList.style';
+import {expenseItemStyle, expenseListStyle, expenseItemLeftStyle} from './ExpenseList.style';
// TODO: (@soha) 따로 파일 분리할까 고민중.. 여기서만 사용할 것 같긴 한데.. 흠
// TODO: (@todari) : 추후 클릭 시 상호작용이 생기면 iconButton으로 변경할 수 있음
@@ -14,11 +14,9 @@ function ExpenseItem({name, price, ...buttonProps}: ExpenseItemProps) {
const {theme} = useTheme();
return (
diff --git a/HDesign/src/components/Input/Input.stories.tsx b/HDesign/src/components/Input/Input.stories.tsx
index 31a226771..dc46e022f 100644
--- a/HDesign/src/components/Input/Input.stories.tsx
+++ b/HDesign/src/components/Input/Input.stories.tsx
@@ -3,6 +3,8 @@ import type {Meta, StoryObj} from '@storybook/react';
import React, {useEffect, useState} from 'react';
import Input from '@components/Input/Input';
+import Flex from '@components/Flex/Flex';
+import Button from '@components/Button/Button';
const meta = {
title: 'Components/Input',
@@ -26,21 +28,29 @@ type Story = StoryObj
;
export const Playground: Story = {
render: ({...args}) => {
+ const regex = /^[ㄱ-ㅎ가-힣]*$/;
const [value, setValue] = useState('');
const [isError, setIsError] = useState(false);
+
const handleChange = (event: React.ChangeEvent) => {
- if (event.target.value.length < 4) {
- setValue(event.target.value);
+ const newValue = event.target.value;
+ if (regex.test(newValue)) {
+ setValue(newValue);
setIsError(false);
} else {
- event.target.value = value;
setIsError(true);
}
};
- const handleBlur = () => {
- console.log('blur');
+
+ const changeRandomValue = () => {
+ setValue('외부에서 값 변경됨');
};
- return handleChange(e)} isError={isError} onBlur={handleBlur} {...args} />;
+ return (
+
+
+
+
+ );
},
};
diff --git a/HDesign/src/components/Input/Input.tsx b/HDesign/src/components/Input/Input.tsx
index a1b495afd..37945e434 100644
--- a/HDesign/src/components/Input/Input.tsx
+++ b/HDesign/src/components/Input/Input.tsx
@@ -13,7 +13,6 @@ export const Input: React.FC = forwardRef inputRef.current!);
const {theme} = useTheme();
const inputRef = useRef(null);
const {value, handleChange, hasFocus, handleClickDelete, handleBlur, handleFocus, handleKeyDown} = useInput({
@@ -24,6 +23,7 @@ export const Input: React.FC = forwardRef inputRef.current!);
return (
diff --git a/HDesign/src/components/Input/useInput.ts b/HDesign/src/components/Input/useInput.ts
index 0ff7206c4..a9e531a07 100644
--- a/HDesign/src/components/Input/useInput.ts
+++ b/HDesign/src/components/Input/useInput.ts
@@ -9,17 +9,20 @@ interface UseInputProps
{
autoFocus?: boolean;
}
-export const useInput = ({propsValue, onChange, onBlur, onFocus, inputRef}: UseInputProps) => {
+export const useInput = ({propsValue, onChange, onBlur, onFocus, autoFocus, inputRef}: UseInputProps) => {
const [value, setValue] = useState(propsValue);
const [hasFocus, setHasFocus] = useState(inputRef.current === document.activeElement);
useEffect(() => {
- setHasFocus(inputRef.current === document.activeElement);
- }, []);
+ if (autoFocus && inputRef.current) {
+ inputRef.current.focus();
+ setHasFocus(true);
+ }
+ }, [autoFocus, inputRef]);
useEffect(() => {
setValue(propsValue);
- }, [value]);
+ }, [propsValue, value]);
const handleClickDelete = (event: React.MouseEvent) => {
event.preventDefault();
diff --git a/HDesign/src/components/ListButton/ListButton.style.ts b/HDesign/src/components/ListButton/ListButton.style.ts
index ca6a686ff..fcca0ca01 100644
--- a/HDesign/src/components/ListButton/ListButton.style.ts
+++ b/HDesign/src/components/ListButton/ListButton.style.ts
@@ -14,8 +14,3 @@ export const listButtonStyle = (theme: Theme) =>
boxShadow: `0 1px 0 0 ${theme.colors.grayContainer} inset `,
});
-
-export const textStyle = (theme: Theme) =>
- css({
- color: theme.colors.gray,
- });
diff --git a/HDesign/src/components/ListButton/ListButton.tsx b/HDesign/src/components/ListButton/ListButton.tsx
index c90bbd122..10c417310 100644
--- a/HDesign/src/components/ListButton/ListButton.tsx
+++ b/HDesign/src/components/ListButton/ListButton.tsx
@@ -9,7 +9,7 @@ import Icon from '@components/Icon/Icon';
import {useTheme} from '@theme/HDesignProvider';
import {ListButtonProps} from './ListButton.type';
-import {listButtonStyle, textStyle} from './ListButton.style';
+import {listButtonStyle} from './ListButton.style';
export const ListButton: React.FC = forwardRef(function Button(
{prefix, suffix, ...htmlProps}: ListButtonProps,
@@ -18,11 +18,11 @@ export const ListButton: React.FC = forwardRef
-
+
{prefix}
-
+
{suffix}
diff --git a/HDesign/src/components/Search/Search.stories.tsx b/HDesign/src/components/Search/Search.stories.tsx
index 2ce93f3a5..6b5d821cd 100644
--- a/HDesign/src/components/Search/Search.stories.tsx
+++ b/HDesign/src/components/Search/Search.stories.tsx
@@ -11,20 +11,17 @@ const meta = {
parameters: {
// layout: 'centered',
},
- argTypes: {
- value: {
- description: '',
- control: {type: 'text'},
- },
- inputType: {
- control: {type: 'radio'},
- },
- },
+ decorators: [
+ Story => (
+
+
+
+ ),
+ ],
args: {
- disabled: false,
- placeholder: 'placeholder',
- searchTerms: ['todari', 'cookie'],
- setState: keyword => console.log(keyword),
+ isShowTargetInput: true,
+ matchItems: ['todari', 'cookie'],
+ onMatchItemClick: keyword => alert(keyword),
},
} satisfies Meta;
diff --git a/HDesign/src/components/Search/Search.style.ts b/HDesign/src/components/Search/Search.style.ts
index 0c5203aed..d75e8fe25 100644
--- a/HDesign/src/components/Search/Search.style.ts
+++ b/HDesign/src/components/Search/Search.style.ts
@@ -12,21 +12,23 @@ export const searchTermsStyle = (theme: Theme) =>
css({
position: 'absolute',
top: '3.5rem',
+ zIndex: 1,
- width: 'calc(100% - 2rem)',
- margin: '0 1rem',
- padding: '0.5rem 0',
+ width: '100%',
+ padding: '0.5rem 1rem',
borderRadius: '1rem',
backgroundColor: theme.colors.white,
+
+ boxShadow: '0 0.25rem 0.5rem 0 rgba(0, 0, 0, 0.12)',
});
export const searchTermStyle = (theme: Theme) =>
css(
{
width: '100%',
- padding: '0.5rem 1rem',
+ padding: '0.5rem',
color: theme.colors.onTertiary,
diff --git a/HDesign/src/components/Search/Search.tsx b/HDesign/src/components/Search/Search.tsx
index cecdffa52..410a0bc97 100644
--- a/HDesign/src/components/Search/Search.tsx
+++ b/HDesign/src/components/Search/Search.tsx
@@ -3,34 +3,27 @@ import Flex from '@components/Flex/Flex';
import {useTheme} from '@theme/HDesignProvider';
-import Input from '../Input/Input';
-import {InputProps} from '../Input/Input.type';
-
import {searchStyle, searchTermsStyle, searchTermStyle} from './Search.style';
-import useSearch from './useSearch';
-export interface SearchProps extends InputProps {
- searchTerms: string[];
- setState: React.Dispatch>;
+export interface SearchProps {
+ isShowTargetInput: boolean;
+ matchItems: string[];
+ onMatchItemClick: (term: string) => void;
}
-const Search: React.FC = ({searchTerms, setState, ...inputProps}: SearchProps) => {
+const Search = ({isShowTargetInput, matchItems, onMatchItemClick, children}: React.PropsWithChildren) => {
const {theme} = useTheme();
- const {value, showSearchTerms, handleOnChange, handleOnClick, filterSearchTerms} = useSearch({
- searchTerms,
- setState,
- });
return (