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

[FE] issue256: atomic css 방식을 css props에 적용하는 유틸 함수 생성 #259

Merged
merged 5 commits into from
Aug 13, 2022
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
14 changes: 3 additions & 11 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
} from '@pages';
import { Navigate, Route, Routes } from 'react-router-dom';

import { css } from '@emotion/react';

import { PATH } from '@constants';

import tw from '@utils/tw';
Copy link
Collaborator

Choose a reason for hiding this comment

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

utils/index.ts 파일에 추가해서 import하는 건 어떨까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

intellisense 가 @utils/tw 키워드를 인식하도록 설정되어 있어서 이게 필요합니다

Copy link
Collaborator

Choose a reason for hiding this comment

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

@utils/tw가 해당 파일에 있어야지만 자동완성 인식이 되는 건가요??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

네 맞습니다


import { useAuth } from '@hooks/useAuth';

import { Footer, Header, Main } from '@layout';
Expand All @@ -22,15 +22,7 @@ const App = () => {

return (
<div>
<Header
css={css`
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 2;
`}
/>
<Header css={tw`fixed top-0 left-0 right-0 z-2`} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

<Main>
<Routes>
<Route path={PATH.MAIN} element={<MainPage />} />
Expand Down
9 changes: 3 additions & 6 deletions frontend/src/components/markdown-render/MarkdownRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { useEffect, useRef } from 'react';

import { css } from '@emotion/react';

import tw from '@utils/tw';

import markdown from '@styles/markdown';

type MarkdownRenderProps = {
Expand All @@ -20,12 +22,7 @@ const MarkdownRender = ({ markdownContent }: MarkdownRenderProps) => {
}, [contentRef, markdownContent]);

return (
<div
css={css`
overflow-y: scroll;
height: 100%;
`}
>
<div css={tw`overflow-y-scroll h-full`}>
<div
css={css`
${markdown}
Expand Down
12 changes: 2 additions & 10 deletions frontend/src/layout/footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/react';
import tw from '@utils/tw';

import * as S from '@layout/footer/Footer.style';

Expand All @@ -7,15 +7,7 @@ export type FooterProps = {
};

const Footer: React.FC<FooterProps> = ({ marginBottom }) => {
return (
<S.Footer
css={css`
margin-bottom: ${marginBottom};
`}
>
그린론 디우 베루스 병민 짱구 태태
</S.Footer>
);
return <S.Footer css={tw`mb-[${marginBottom}]`}>그린론 디우 베루스 병민 짱구 태태</S.Footer>;
};

export default Footer;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Story } from '@storybook/react';

import { css } from '@emotion/react';
import tw from '@utils/tw';

import Category from '@create-study-page/components/category/Category';
import type { CategoryProps } from '@create-study-page/components/category/Category';
Expand All @@ -11,11 +11,7 @@ export default {
};

const Template: Story<CategoryProps> = props => (
<div
css={css`
max-width: 400px;
`}
>
<div css={tw`max-w-[400px]`}>
<Category {...props} />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/react';
import tw from '@utils/tw';

import type { Tag } from '@custom-types';

Expand Down Expand Up @@ -58,27 +58,11 @@ const Category = ({ className }: CategoryProps) => {
<S.Area>
<S.Label>영역 :</S.Label>
<S.AreaCheckboxContainer>
<Checkbox
css={css`
margin-right: 4px;
`}
type="checkbox"
id="area-fe"
data-tagid={areaFE.id}
{...register('area-fe')}
/>
<Checkbox css={tw`mr-4`} type="checkbox" id="area-fe" data-tagid={areaFE.id} {...register('area-fe')} />
<label htmlFor="area-fe">FE</label>
</S.AreaCheckboxContainer>
<S.AreaCheckboxContainer>
<Checkbox
css={css`
margin-right: 4px;
`}
type="checkbox"
id="area-be"
data-tagid={areaBE.id}
{...register('area-be')}
/>
<Checkbox css={tw`mr-4`} type="checkbox" id="area-be" data-tagid={areaBE.id} {...register('area-be')} />
<label htmlFor="area-be">BE</label>
</S.AreaCheckboxContainer>
</S.Area>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Story } from '@storybook/react';

import { css } from '@emotion/react';
import tw from '@utils/tw';

import MetaBox from '@create-study-page/components/meta-box/MetaBox';

Expand All @@ -10,11 +10,7 @@ export default {
};

const Template: Story = () => (
<MetaBox
css={css`
max-width: 300px;
`}
>
<MetaBox css={tw`max-w-[300px]`}>
<MetaBox.Title>스터디 인원</MetaBox.Title>
<MetaBox.Content>Content입니다</MetaBox.Content>
</MetaBox>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/react';
import tw from '@utils/tw';

import Button from '@components/button/Button';

Expand All @@ -17,11 +17,7 @@ const Publish = ({ className, onPublishButtonClick: handlePublishButtonClick }:
<MetaBox.Title>스터디 개설</MetaBox.Title>
<MetaBox.Content>
<Button
css={css`
border-radius: 6px;
font-size: 16px;
padding: 12px 10px;
`}
css={tw`rounded-[6px] text-16 py-12 px-10`}
fluid={true}
onClick={handlePublishButtonClick}
outline={true}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/react';
import tw from '@utils/tw';

import { useFormContext } from '@hooks/useForm';

Expand All @@ -24,13 +24,7 @@ const Subject = ({ className }: SubjectProps) => {
const subjects = tags.filter(({ category }) => category.name === 'subject');

return (
<S.Select
id="subject-list"
css={css`
width: 100%;
`}
{...register('subject')}
>
<S.Select id="subject-list" css={tw`w-full`} {...register('subject')}>
{subjects.map(({ id, name, description }) => (
<option selected={name === 'Etc'} key={id} value={id}>
{description}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Link } from 'react-router-dom';

import { css } from '@emotion/react';

import { PATH } from '@constants';

import { yyyymmddTommdd } from '@utils';
import tw from '@utils/tw';

import type { StudyDetail, UserRole } from '@custom-types';

Expand Down Expand Up @@ -56,30 +55,15 @@ const StudyWideFloatBox: React.FC<StudyWideFloatBoxProps> = ({
if (userRole === 'MEMBER' || userRole === 'OWNER') {
return (
<Link to={PATH.STUDY_ROOM(studyId)}>
<Button
css={css`
height: 100%;
padding: 0 20px;
`}
fluid={true}
type="button"
>
<Button css={tw`h-full py-0 px-20`} fluid={true} type="button">
이동하기
</Button>
</Link>
);
}

return (
<Button
css={css`
height: 100%;
padding: 0 20px;
`}
fluid={true}
disabled={!isOpen}
onClick={handleRegisterButtonClick}
>
<Button css={tw`h-full py-0 px-20`} fluid={true} disabled={!isOpen} onClick={handleRegisterButtonClick}>
{isOpen ? '가입하기' : '모집 마감'}
</Button>
);
Expand Down
12 changes: 3 additions & 9 deletions frontend/src/pages/study-room-page/StudyRoomPage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Navigate } from 'react-router-dom';

import { css } from '@emotion/react';

import { PATH } from '@constants';

import tw from '@utils/tw';

import Wrapper from '@components/wrapper/Wrapper';

import * as S from '@study-room-page/StudyRoomPage.style';
Expand All @@ -28,13 +28,7 @@ const StudyRoomPage: React.FC = () => {
<Wrapper>
<S.Container>
<SideMenu
css={css`
position: sticky;
top: 100px;
left: 0;

align-self: flex-start;
`}
css={tw`sticky top-100 left-0 self-start`}
activeTabId={activeTab.id}
tabs={tabs}
onTabButtonClick={handleTabButtonClick}
Expand Down
Loading