diff --git a/app/frontend/src/components/MogacoPost/MogacoPostTitle.tsx b/app/frontend/src/components/MogacoPost/MogacoPostTitle.tsx new file mode 100644 index 000000000..ff453792b --- /dev/null +++ b/app/frontend/src/components/MogacoPost/MogacoPostTitle.tsx @@ -0,0 +1,43 @@ +import { Controller, Control } from 'react-hook-form'; + +import { MOGACO_POST } from '@/constants'; +import { MogacoPostForm } from '@/types'; + +import * as styles from './index.css'; + +type MogacoPostTitleProps = { + control: Control; +}; + +export function MogacoPostTitle({ control }: MogacoPostTitleProps) { + return ( + ( +
+
+ +
+ {value?.length || 0}/{MOGACO_POST.TITLE.MAX_LENGTH} +
+
+ {error &&
{error.message}
} +
+ )} + /> + ); +} diff --git a/app/frontend/src/components/MogacoPost/index.css.ts b/app/frontend/src/components/MogacoPost/index.css.ts index caf97125d..b9b2b6003 100644 --- a/app/frontend/src/components/MogacoPost/index.css.ts +++ b/app/frontend/src/components/MogacoPost/index.css.ts @@ -2,34 +2,20 @@ import { style } from '@vanilla-extract/css'; import { vars, fontStyle } from '@/styles'; -export const container = style({ - display: 'flex', - flexDirection: 'column', - gap: '24px', - maxWidth: '75rem', - margin: '0 auto', - padding: '1.5rem', -}); - -export const formContent = style({ - display: 'flex', - flexDirection: 'column', - gap: '1.6rem', - width: '100%', -}); +const error = style({}); -export const title = style([ +const title = style([ fontStyle.sansBold24, { padding: '0.8rem', height: '4rem', + width: '100%', color: vars.color.grayscale500, borderBottom: '2px solid transparent', selectors: { '&:focus': { outline: 'none', - borderBottom: `2px solid ${vars.color.morakGreen}`, }, '&::placeholder': { color: vars.color.grayscale200, @@ -37,3 +23,67 @@ export const title = style([ }, }, ]); + +const titleContent = style([ + fontStyle.sansRegular12, + { + display: 'flex', + flex: '1 0 0', + alignItems: 'center', + gap: '1.6rem', + borderBottom: '2px solid transparent', + + selectors: { + '&:focus-within': { + borderBottom: `2px solid ${vars.color.morakGreen}`, + }, + [`${error} &`]: { + borderBottom: `2px solid ${vars.color.morakRed}`, + }, + }, + }, +]); + +export const container = style({ + display: 'flex', + flexDirection: 'column', + gap: '24px', + maxWidth: '75rem', + margin: '0 auto', + padding: '1.5rem', +}); + +export const count = style([ + fontStyle.sansRegular12, + { + visibility: 'hidden', + + selectors: { + [`${titleContent}:focus-within &`]: { + visibility: 'visible', + }, + }, + }, +]); + +export { error, title, titleContent }; + +export const errorMessage = style([ + fontStyle.sansRegular12, + { + color: vars.color.morakRed, + }, +]); + +export const formContent = style({ + display: 'flex', + flexDirection: 'column', + gap: '1.6rem', + width: '100%', +}); + +export const titleContainer = style({ + display: 'flex', + flexDirection: 'column', + gap: '0.4rem', +}); diff --git a/app/frontend/src/components/MogacoPost/index.tsx b/app/frontend/src/components/MogacoPost/index.tsx index 8ac97c602..72304e728 100644 --- a/app/frontend/src/components/MogacoPost/index.tsx +++ b/app/frontend/src/components/MogacoPost/index.tsx @@ -1,48 +1,141 @@ +import { useForm, Controller } from 'react-hook-form'; + import dayjs from 'dayjs'; import { Input, Button, Textarea } from '@/components'; +import { MOGACO_POST } from '@/constants'; +import { MogacoPostForm } from '@/types'; import * as styles from './index.css'; +import { MogacoPostTitle } from './MogacoPostTitle'; export function MogacoPostPage() { const date = dayjs(new Date()).format('YYYY-MM-DD HH:mm'); + const { control, handleSubmit } = useForm(); + + // POST 요청으로 수정 예정 + const onSubmit = () => {}; return ( -
+ +
- ( + + )} /> -
-
- ( + + )} + /> + ( + + )} + /> + ( + + )} /> - - ( + + )} /> - - ( +