Skip to content

Commit

Permalink
style: 드롭다운 & 표 overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
minSsan committed Jun 3, 2024
1 parent 332e77b commit 5383fcf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
45 changes: 26 additions & 19 deletions src/components/dataset-table/dataset-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
import { DatasetTableType } from "../../shared/types/dataset";
import styles from "./dataset-table.module.css";
import { getDatasetTable } from "../../shared/api/dataset-visual/getDatasetTable";
import styled from "@emotion/styled";

interface Props {
datasetId: number;
Expand Down Expand Up @@ -31,28 +32,34 @@ export function DatasetTable({ datasetId }: Props) {
return (
<>
{dataset && (
<table className={styles.table}>
<colgroup>
{new Array(dataset.label.length).fill(0).map((value, index) => (
<col key={`cg${index}`} width={`${colWidthPercent}%`} />
))}
</colgroup>
{/* 1번 행 - 라벨 표시 */}
<tr>
{dataset.label.map((label, index) => (
<th key={index}>{label}</th>
))}
</tr>
{/* 데이터 표시 영역 */}
{dataset.dataList.map((_, index) => (
<tr key={`row${index}`}>
{dataset.dataList[index].map((value, index) => (
<td key={`col${index}`}>{value}</td>
<Wrapper>
<table className={styles.table}>
<colgroup>
{new Array(dataset.label.length).fill(0).map((value, index) => (
<col key={`cg${index}`} width={`${colWidthPercent}%`} />
))}
</colgroup>
{/* 1번 행 - 라벨 표시 */}
<tr>
{dataset.label.map((label, index) => (
<th key={index}>{label}</th>
))}
</tr>
))}
</table>
{/* 데이터 표시 영역 */}
{dataset.dataList.map((_, index) => (
<tr key={`row${index}`}>
{dataset.dataList[index].map((value, index) => (
<td key={`col${index}`}>{value}</td>
))}
</tr>
))}
</table>
</Wrapper>
)}
</>
);
}

const Wrapper = styled.div`
overflow-x: scroll;
`;
7 changes: 6 additions & 1 deletion src/components/drop-down/search-sort-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface Props {
defaultText?: string;
style?: CSSProperties;
width?: string | number;
maxHeight?: string;
}

export const SearchSortDropdown = ({
Expand All @@ -22,6 +23,7 @@ export const SearchSortDropdown = ({
defaultText,
style,
width,
maxHeight = "20rem",
}: Props) => {
const dropdownRef = useRef(null);

Expand Down Expand Up @@ -60,7 +62,10 @@ export const SearchSortDropdown = ({
</div>

{isActive && (
<ul className={styles.listContainer} style={{ width: itemsWidth }}>
<ul
className={styles.listContainer}
style={{ width: itemsWidth, maxHeight: maxHeight, overflowY: "scroll" }}
>
{items?.length ? (
items.map((value, index) => (
<li
Expand Down

0 comments on commit 5383fcf

Please sign in to comment.