Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] 모각코 게시글 작성 페이지 퍼블리싱 #137

Merged
merged 13 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions app/frontend/src/components/MogacoPost/index.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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%',
});

export const title = style([
fontStyle.sansBold24,
{
padding: '0.8rem',
height: '4rem',
color: vars.color.grayscale500,
borderBottom: '2px solid transparent',

selectors: {
'&:focus': {
outline: 'none',
borderBottom: `2px solid ${vars.color.morakGreen}`,
},
'&::placeholder': {
color: vars.color.grayscale200,
},
},
},
]);
61 changes: 61 additions & 0 deletions app/frontend/src/components/MogacoPost/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import dayjs from 'dayjs';

import { Input, Button, Textarea } from '@/components';

import * as styles from './index.css';

export function MogacoPostPage() {
const date = dayjs(new Date()).format('YYYY-MM-DD HH:mm');

return (
<form className={styles.container}>
<div className={styles.formContent}>
<input
type="text"
className={styles.title}
placeholder="모각코 함께해요"
required
/>
</div>
<div className={styles.formContent}>
<Input
label="작성자"
maxLength={64}
required
disabled
defaultValue="user"
/>
<Input label="그룹" placeholder="그룹을 선택해주세요" required />
<Input
label="최대 인원 수"
type="number"
placeholder="20"
min={1}
max={20}
required
/>
<Input label="장소" placeholder="장소를 검색해주세요" required />
<Input
label="날짜 및 시간"
type="datetime-local"
required
defaultValue={date}
min={date}
LEEJW1953 marked this conversation as resolved.
Show resolved Hide resolved
/>
<Textarea label="설명" maxLength={1000} rows={6} />
</div>
<div className={styles.formContent}>
<Button
type="submit"
theme="primary"
shape="fill"
size="large"
fullWidth
onClick={() => {}}
>
등록하기
</Button>
</div>
</form>
);
}
20 changes: 19 additions & 1 deletion app/frontend/src/components/commons/Input/Textarea.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useRef, useState } from 'react';

import * as styles from './Textarea.css';

type TextareaProps = {
Expand All @@ -8,6 +10,7 @@ type TextareaProps = {
disabled?: boolean;
required?: boolean;
fullWidth?: boolean;
rows?: number;
};

export function Textarea({
Expand All @@ -18,7 +21,17 @@ export function Textarea({
maxLength,
required = false,
fullWidth = false,
rows = 2,
}: TextareaProps) {
const [textCount, setTextCount] = useState<number>(0);
const textRef = useRef<HTMLTextAreaElement | null>(null);

const handleInput = () => {
if (textRef && textRef.current) {
setTextCount(textRef.current.value.length);
}
};

return (
<div
className={`${styles.container} ${errorMessage && styles.error} ${
Expand All @@ -30,14 +43,19 @@ export function Textarea({
{label}
{required && <span className={styles.required}>*</span>}
</span>
<span className={styles.count}>0/{maxLength}</span>
<span className={styles.count}>
{textCount}/{maxLength}
</span>
</div>
<textarea
rows={rows}
ref={textRef}
className={styles.textarea}
placeholder={placeholder}
disabled={disabled}
maxLength={maxLength}
required={required}
onChange={handleInput}
/>
{!disabled && errorMessage && (
<p className={styles.errorMessage}>{errorMessage}</p>
Expand Down
5 changes: 5 additions & 0 deletions app/frontend/src/components/commons/Input/index.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export const input = style([
border: `2px solid ${vars.color.grayscale200}`,
cursor: 'not-allowed',
},
'&::-webkit-inner-spin-button': {
appearance: 'none',
MozAppearance: 'none',
WebkitAppearance: 'none',
},
ttaerrim marked this conversation as resolved.
Show resolved Hide resolved
},
},
]);
Expand Down
30 changes: 27 additions & 3 deletions app/frontend/src/components/commons/Input/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HTMLInputTypeAttribute } from 'react';
import { useState, useRef, HTMLInputTypeAttribute } from 'react';

import * as styles from './index.css';

Expand All @@ -8,8 +8,11 @@ type InputProps = {
errorMessage?: string;
type?: HTMLInputTypeAttribute;
disabled?: boolean;
maxLength: number;
maxLength?: number;
min?: number | string;
max?: number;
LEEJW1953 marked this conversation as resolved.
Show resolved Hide resolved
required?: boolean;
Comment on lines +12 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3; input type이 여러 가지가 될 수 있으니 props가 복잡해질 수도 있겠군요. 타입스크립트를 잘 적용할 수 있다면 type에 따라서도 props를 활용할 수 있지 않을까 싶네요. 한번 찾아봐야겠어요

defaultValue?: string;
};

export function Input({
Expand All @@ -19,8 +22,20 @@ export function Input({
errorMessage = '',
disabled = false,
maxLength,
min,
max,
required = false,
defaultValue,
}: InputProps) {
const [inputCount, setInputCount] = useState<number>(0);
const inputRef = useRef<HTMLInputElement | null>(null);

const handleInput = () => {
if (inputRef && inputRef.current) {
setInputCount(inputRef.current.value.length);
}
};

return (
Comment on lines +30 to +38
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3; 이 부분도 아마 react-hook-form 적용하면서 props로 받아서 처리할 수 있게 바뀔 것 같네요!

<div
className={`${styles.container} ${errorMessage && styles.error} ${
Expand All @@ -32,15 +47,24 @@ export function Input({
{label}
{required && <span className={styles.required}>*</span>}
</span>
<span className={styles.count}>0/{maxLength}</span>
{maxLength && (
<span className={styles.count}>
{inputCount}/{maxLength}
</span>
)}
</div>
<input
ref={inputRef}
className={styles.input}
type={type}
placeholder={placeholder}
disabled={disabled}
maxLength={maxLength}
min={min}
max={max}
required={required}
defaultValue={defaultValue}
onChange={handleInput}
/>
{!disabled && errorMessage && (
<p className={styles.errorMessage}>{errorMessage}</p>
Expand Down
1 change: 1 addition & 0 deletions app/frontend/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './Mogaco';
export * from './MogacoDetail';
export * from './MogacoPost';
export * from './commons/Button';
export * from './commons/Chatting';
export * from './commons/Header';
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/hooks/useRouter.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createBrowserRouter } from 'react-router-dom';

import { Layout } from '@/components';
import { Main, Mogaco, MogacoDetail } from '@/pages';
import { Main, Mogaco, MogacoDetail, MogacoPost } from '@/pages';

export const useRouter = () =>
createBrowserRouter([
Expand All @@ -18,6 +18,7 @@ export const useRouter = () =>
path: 'mogaco/:id',
element: <MogacoDetail />,
},
{ path: 'post', element: <MogacoPost /> },
{
path: 'calendar',
element: <>캘린더</>,
Expand Down
5 changes: 5 additions & 0 deletions app/frontend/src/pages/MogacoPost/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { MogacoPostPage } from '@/components';

export function MogacoPost() {
return <MogacoPostPage />;
}
7 changes: 4 additions & 3 deletions app/frontend/src/pages/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { Main } from './Main';
export { Mogaco } from './Mogaco';
export { MogacoDetail } from './MogacoDetail';
export * from './Main';
export * from './Mogaco';
export * from './MogacoDetail';
export * from './MogacoPost';
Loading