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

게시판 state 리코일로 변경 #27

Merged
merged 3 commits into from
Jul 2, 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
4 changes: 3 additions & 1 deletion src/page/forum/layouts/Categories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Row from "@/components/Flex/Row";
import { categoriesStore } from "@/store/categories.store";
import color from "@/styles/color";
import { font } from "@/styles/font";
import forum from "@/utils/constants/forum.constant";
import React from "react";
import { useRecoilState } from "recoil";
import styled, { css } from "styled-components";

const categories = [
Expand All @@ -25,7 +27,7 @@ const categories = [
];

const Categories = () => {
const [checked, setChecked] = React.useState(forum.category.all.type);
const [checked, setChecked] = useRecoilState(categoriesStore);

const onCheckCategory = (e: React.ChangeEvent<HTMLInputElement>) => {
setChecked(e.target.id);
Expand Down
18 changes: 16 additions & 2 deletions src/page/forum/layouts/ForumFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Row from "@/components/Flex/Row";
import { forumFilterStore } from "@/store/forumType.store";
import color from "@/styles/color";
import { font } from "@/styles/font";
import forum from "@/utils/constants/forum.constant";
import React from "react";
import styled, { css } from "styled-components";
import { useRecoilState } from "recoil";
import styled, { css, keyframes } from "styled-components";

const filters = [
{
Expand All @@ -17,7 +19,7 @@ const filters = [
];

const ForumFilter = () => {
const [checked, setChecked] = React.useState(forum.student.type);
const [checked, setChecked] = useRecoilState(forumFilterStore);

const onCheckFilter = (e: React.ChangeEvent<HTMLInputElement>) => {
setChecked(e.target.id);
Expand Down Expand Up @@ -46,6 +48,12 @@ const ForumRadio = styled.input`
display: none;
`;

const selected = keyframes`
to {
${font.H2};
}
`;

const ForumLabel = styled.label<{ checked: boolean }>`
${({ checked }) =>
checked
Expand All @@ -60,6 +68,12 @@ const ForumLabel = styled.label<{ checked: boolean }>`
&:after {
content: "게시판";
}

&:hover {
animation-fill-mode: forwards;
animation-duration: 0.1s;
animation-name: ${selected};
}
`;

export default ForumFilter;
7 changes: 7 additions & 0 deletions src/store/categories.store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import forum from "@/utils/constants/forum.constant";
import { atom } from "recoil";

export const categoriesStore = atom<string>({
key: "categoriesStore",
default: forum.category.all.type,
});
7 changes: 7 additions & 0 deletions src/store/forumType.store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import forum from "@/utils/constants/forum.constant";
import { atom } from "recoil";

export const forumFilterStore = atom<string>({
key: "forumFilterStore",
default: forum.free.type,
});