diff --git a/client/src/App.tsx b/client/src/App.tsx index 19af313..c11f7d0 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -2,11 +2,14 @@ import { ReactElement } from 'react'; import { BrowserRouter, Routes, Route } from 'react-router-dom'; import { Provider } from 'jotai'; import styled from 'styled-components'; +import { ToastContainer } from 'react-toastify'; import Header from './container/Header'; import Menubar from './container/Menubar'; -import Main from '@page/Main'; + import Todos from '@page/Todos'; +import Main from './page/Main'; +import OverLay from '@components/OverLay'; const Wrapper = styled.div` width: 100%; @@ -16,6 +19,8 @@ const App = (): ReactElement => { return ( + +
diff --git a/client/src/components/Input.tsx b/client/src/components/Input.tsx new file mode 100644 index 0000000..cef86bf --- /dev/null +++ b/client/src/components/Input.tsx @@ -0,0 +1,20 @@ +// import { ReactElement, memo, FC } from 'react'; +// import styled from 'styled-components'; + +// interface InputProps { +// type: string; +// width?: string; +// height?: string; +// onChange: Function; +// value?: any; +// } +// const StyledInput = styled.input` +// width: 100%; +// `; + +// const Input: FC = ({ value, type, width, height, onChange }: InputProps): ReactElement => { +// console.log('fjadhfdkja'); +// return ; +// }; + +// export default memo(Input); diff --git a/client/src/components/LabeledInput.tsx b/client/src/components/LabeledInput.tsx new file mode 100644 index 0000000..df0a36b --- /dev/null +++ b/client/src/components/LabeledInput.tsx @@ -0,0 +1,87 @@ +import { ReactElement, useState, memo } from 'react'; +import Text from '@components/Text'; +import { PRIMARY_COLORS } from '@util/Constants'; +import { getTodayDate } from '@util/Common'; + +import styled from 'styled-components'; +import Select from '@components/Select'; +import { toast } from 'react-toastify'; + +const { darkGray, lightGray } = PRIMARY_COLORS; + +interface InputProps { + label: string; + maxLength: number | string; + type: string; + id: string; +} + +const Wrapper = styled.div` + width: 100%; + + & { + width: 100%; + gap: 5px; + } + > *:focus { + outline: 1px solid ${darkGray}; + } + > input, + textarea, + select { + padding: 8px; + border: 1px solid ${lightGray}; + border-radius: 5px; + color: ${darkGray}; + } + > input[type='text'], + textarea { + &:last-child { + width: 100%; + } + } + > input[type='date'] { + &:last-child { + width: 30%; + } + } +`; + +const LabeledInput = ({ label, maxLength, type, id }: InputProps): ReactElement => { + const [input, setInput] = useState(''); + const [dateInput, setDateInput] = useState(getTodayDate()); + + const handleOnChangeText = (e: React.ChangeEvent): void => { + const { value } = e.target; + + if (maxLength === Number.MAX_VALUE || maxLength < 0) { + return setInput(value); + } + if (maxLength > value.length) { + return setInput(value); + } + toast.error('제목은 50자 이상 입력 불가능합니다.'); + }; + + const handleOnChangeDate = (e: React.ChangeEvent): void => { + const { value } = e.target; + + if (getTodayDate() <= value) { + return setDateInput(value); + } + + toast.error('새로 생성하는 Todo는 과거로 설정 불가능합니다.'); + }; + + return ( + + + {type === 'text' && } + {type === 'textarea' &&