Skip to content

Commit

Permalink
Merge branch 'Style/#1504-responsive-css' of github.com:42organizatio…
Browse files Browse the repository at this point in the history
…n/42gg.client into Style/#1504-responsive-css
  • Loading branch information
irenee-14 committed Aug 30, 2024
2 parents 2ba9081 + 223165d commit c3c9b19
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 57 deletions.
80 changes: 61 additions & 19 deletions components/agenda/Home/AgendaList.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,84 @@
import Link from 'next/link';
import React from 'react';
import { useRouter } from 'next/router';
import React, { useState } from 'react';
import { AgendaDataProps } from 'types/agenda/agendaDetail/agendaTypes';
import AgendaDeadLine from 'components/agenda/Home/AgendaDeadLine';
import AgendaInfo from 'components/agenda/Home/AgendaInfo';
import styles from 'styles/agenda/Home/AgendaList.module.scss';

const AgendaList = ({ agendaList }: { agendaList: AgendaDataProps[] }) => {
const [selectedItem, setSelectedItem] = useState<number | null>(0);

return (
<div className={styles.agendaListContainer}>
<div className={styles.agendaListItemContainer}>
{!agendaList || !agendaList.length ? (
<div>
<div className={styles.emptyContainer}>일정이 없습니다.</div>
</div>
) : (
agendaList.map((agendaInfo, idx) => (
<AgendaListItem agendaInfo={agendaInfo} key={idx} />
))
)}
<div className={styles.container}>
<div className={styles.agendaListContainer}>
<div className={styles.agendaListItemContainer}>
{!agendaList || !agendaList.length ? (
<div>
<div className={styles.emptyContainer}>일정이 없습니다.</div>
</div>
) : (
agendaList.map((agendaInfo, idx) => {
agendaInfo.idx = idx;
return (
<AgendaListItem
agendaInfo={agendaInfo}
key={idx}
type='list'
className={idx === selectedItem ? styles.selected : ''}
setSelectedItem={setSelectedItem}
/>
);
})
)}
</div>
</div>
{agendaList.length && (
<AgendaListItem
agendaInfo={agendaList[selectedItem || 0]}
key={selectedItem || 0}
type='big'
/>
)}
</div>
);
};

const AgendaListItem = ({
agendaInfo,
key,
type,
className,
setSelectedItem,
}: {
agendaInfo: AgendaDataProps;
key: number;
type?: string;
className?: string;
setSelectedItem?: (key: number) => void;
}) => {
const router = useRouter();
const href = `/agenda/${agendaInfo.agendaKey}`;
return (
<Link href={`/agenda/${agendaInfo.agendaKey}`}>
<button className={styles.agendaListItemBtn} key={key}>
<AgendaInfo agendaInfo={agendaInfo} key={key} />
<AgendaDeadLine />
</button>
</Link>
<button
className={`${styles.agendaListItemBtn} ${
type === 'list' && styles.listType
} ${type === 'big' && styles.listBig}
${className && className}`}
onClick={() => {
if (window.innerWidth < 961) {
router.push(href);
return;
}
if (type === 'list' && setSelectedItem && agendaInfo.idx) {
setSelectedItem(agendaInfo.idx);
return;
}
router.push(href);
}}
>
<AgendaInfo agendaInfo={agendaInfo} key={key} />
<AgendaDeadLine />
</button>
);
};

Expand Down
1 change: 0 additions & 1 deletion components/agenda/Home/MyAgendaBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const MyAgendaBtn = () => {
<Link
href={`/agenda/${myTeamInfo.agendaKey}/${myTeamInfo.teamKey}`}
key={idx}
style={{ width: '100%' }}
>
<div className={styles.myagendaItemContainer} key={idx}>
<MyTeamInfo myTeamInfo={myTeamInfo} key={idx} />
Expand Down
63 changes: 31 additions & 32 deletions pages/agenda/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { AgendaDataProps } from 'types/agenda/agendaDetail/agendaTypes';
import type { NextPage } from 'next';
import AgendaList from 'components/agenda/Home/AgendaList';
import AgendaTitle from 'components/agenda/Home/AgendaTitle';
import { TestModal, TestModal2 } from 'components/agenda/modal/testModal';
import PageNation from 'components/Pagination';
import useFetchGet from 'hooks/agenda/useFetchGet';
import usePageNation from 'hooks/agenda/usePageNation';
Expand All @@ -29,40 +28,40 @@ const Agenda: NextPage = () => {
return (
<div className={styles.agendaPageContainer}>
<AgendaTitle />
<div className={listStyles.agendaListTextWrapper}>
<h2>AGENDA LIST</h2>
<div>
<button
className={`${listStyles.agendaListStatus} ${
showCurrent ? listStyles.selectedStatus : ''
}`}
name='ongoing'
onClick={toggleStatus}
>
진행중
</button>
{' | '}
<button
className={`${listStyles.agendaListStatus}
<div className={styles.agendaContainer}>
<div className={listStyles.agendaListTextWrapper}>
<h2>AGENDA LIST</h2>
<div>
<button
className={`${listStyles.agendaListStatus} ${
showCurrent ? listStyles.selectedStatus : ''
}`}
name='ongoing'
onClick={toggleStatus}
>
진행중
</button>
{' | '}
<button
className={`${listStyles.agendaListStatus}
${showCurrent ? '' : listStyles.selectedStatus}`}
name='closed'
onClick={toggleStatus}
>
종료된
</button>
name='closed'
onClick={toggleStatus}
>
종료된
</button>
</div>
</div>
</div>

{showCurrent ? (
<AgendaList agendaList={currentData || []} />
) : (
<>
<AgendaList agendaList={historyData || []} />
<PageNation {...PagaNationElementProps} />{' '}
</>
)}
<TestModal />
<TestModal2 />
{showCurrent ? (
<AgendaList agendaList={currentData || []} />
) : (
<>
<AgendaList agendaList={historyData || []} />
<PageNation {...PagaNationElementProps} />{' '}
</>
)}
</div>
</div>
);
};
Expand Down
10 changes: 10 additions & 0 deletions styles/agenda/Home/Agenda.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
@import 'styles/agenda/common.scss';

.agendaContainer {
width: calc(100% - 2rem);
margin: 0 auto;
@media screen and (min-width: 961px) {
@include container(2);
width: 100%;
max-width: 100%;
margin: 0;
}
}
.agendaPageContainer {
@include layout;
display: flex;
Expand Down
1 change: 1 addition & 0 deletions styles/agenda/Home/AgendaDeadLine.module.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import 'styles/agenda/common.scss';

.agendaItemDeadLineBox {
@include gridHidden(mobile);
position: absolute;
right: 1rem;
bottom: 1rem;
Expand Down
58 changes: 56 additions & 2 deletions styles/agenda/Home/AgendaList.module.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
@import 'styles/agenda/common.scss';

.container {
display: flex;
justify-content: center;
width: 100%;
@media screen and (min-width: 961px) {
display: grid;
grid-template: 'list big' 1fr / auto 1fr;
}
}
.agendaListContainer {
display: flex;
width: 100%;
flex-direction: column;
padding: 0 1rem;
gap: 0.5rem;
@media screen and (min-width: 961px) {
width: 26rem;
height: 70vh;
padding: 0 1rem 0 0;
overflow-y: auto;
grid-area: list;
}
}

.agendaListTextWrapper {
Expand Down Expand Up @@ -39,7 +54,17 @@
display: flex;
width: 100%;
flex-direction: column;
gap: 1rem;
margin-top: 1.5rem;
gap: 1.5rem;
align-items: center;
a {
display: flex;
width: 100%;
}
@media screen and (min-width: 961px) {
gap: 0.5rem;
margin-top: 0;
}
}

.agendaListItemBtn {
Expand All @@ -58,6 +83,27 @@
box-shadow: var(--default-box-shadow);
justify-content: center;
align-items: flex-start;
@media screen and (min-width: 961px) {
max-width: 100%;
max-height: 100%;
}
}
.listBig {
@include gridHidden(web);
width: 100%;
grid-area: big;
@media screen and (min-width: 961px) {
width: 100%;
height: 100%;
}
}
.listType {
@media screen and (min-width: 961px) {
width: 100%;
height: 6rem;
min-height: 6rem;
background: var(--box-bg-1);
}
}

.emptyContainer {
Expand All @@ -72,3 +118,11 @@
@include text('description');
@include container(1);
}

.selected {
@media screen and (min-width: 961px) {
border-color: var(--highlight-violet);
border-width: 2px;
box-shadow: 2px 2px 0 2px var(--highlight-violet);
}
}
22 changes: 20 additions & 2 deletions styles/agenda/Home/MyAgendaBtn.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@

.myAgendaContainer.expandedHeight {
height: 28rem;
overflow-y: auto;
@include gridHead;
@media screen and (min-width: 961px) {
height: max-content;
}
}

.myAgendaContainer.expandedWidth {
width: 23rem;
// width: 23rem;
width: max-content;
@include gridHead;
@media screen and (min-width: 961px) {
width: 100%;
}
}

.myAgendaBtnToggle {
Expand Down Expand Up @@ -71,17 +79,27 @@
overflow-y: scroll;
align-items: flex-start;
gap: 1rem;
@media screen and (min-width: 961px) {
display: flex;
width: auto;
height: auto;
flex-direction: row;
flex-wrap: wrap;
}
}

.myagendaItemContainer {
display: flex;
justify-content: flex-start;
align-items: center;
width: 100%;
width: max-content;
min-height: 5.5rem;
padding: 0 1.2rem;
background-color: var(--box-bg-1);
border: var(--default-border);
border-radius: $radius-big;
box-shadow: var(--default-box-shadow);
@media screen and (min-width: 961px) {
width: max-content;
}
}
2 changes: 1 addition & 1 deletion styles/agenda/responsive.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
// 각 페이지 내에서 그리드 템플릿 세팅 필요
@mixin layout {
@include action;
width: 100%;
@media screen and (max-width: 480px) {
display: flex;
flex-direction: column;
Expand All @@ -39,7 +40,6 @@
}
@media screen and (min-width: 961px) {
display: grid;
max-width: 1200px;
padding: 0 5rem;
border: 2px solid yellow;
}
Expand Down
4 changes: 4 additions & 0 deletions styles/color-theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
--highlight-violet-light: #af71ff;
--highlight-yellow-dark: #fff78a;
--highlight-violet-dark: #af71ff;
--highlight-bg-dark: #af71ff;
--highlight-bg-light: #cda7fc;

--box-bg-1-light: #f8f8f8;
--box-bg-2-light: #c8c8c8ec;
Expand All @@ -47,6 +49,7 @@ html[data-theme='light'] {
--highlight-border: var(--border-highlight-light);
--default-box-shadow: var(--box-shadow-light);
--highlight-yellow: var(--highlight-yellow-light);
--highlight-bg: var(--highlight-bg-light);
--highlight-violet: var(--highlight-violet-light);
--box-bg-1: var(--box-bg-1-light);
--box-bg-2: var(--box-bg-2-light);
Expand All @@ -64,6 +67,7 @@ html[data-theme='dark'] {
--default-box-shadow: var(--box-shadow-dark);
--highlight-yellow: var(--highlight-yellow-dark);
--highlight-violet: var(--highlight-violet-dark);
--highlight-bg: var(--highlight-bg-dark);
--box-bg-1: var(--box-bg-1-dark);
--box-bg-2: var(--box-bg-2-dark);
--box-bg-3: var(--box-bg-3-dark);
Expand Down
Loading

0 comments on commit c3c9b19

Please sign in to comment.