Skip to content

Commit

Permalink
Merge pull request #17 from hjcdg1/cdg/feature/#16
Browse files Browse the repository at this point in the history
Construct the template for list pages (#16)
  • Loading branch information
hjcdg1 committed Oct 12, 2023
2 parents 5267509 + da2bcd4 commit f4a6425
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lite/app/(auth)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Image from 'next/image';

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<main className="flex flex-col justify-center items-center gap-y-6 min-h-screen py-8 bg-charcol">
<main className="flex flex-col justify-center items-center gap-y-6 min-h-screen py-8 bg-charcoal">
<div className="flex items-center gap-x-3">
<div className="w-10 h-10 p-2 bg-white rounded-full">
<div className="relative w-6 h-6">
Expand Down
37 changes: 36 additions & 1 deletion lite/app/(main)/database/oss/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
import ListFilters from '@/components/list-filters';
import ListTable from '@/components/list-table';
import ExcelIcon from '@/public/images/excel.png';
import Image from 'next/image';

export default function OSSList() {
return <div>Database &gt; OSS List</div>;
return (
<>
{/* Breadcrumb */}
<h2 className="pb-2 text-xl font-black">
Database
<i className="mx-2 text-sm fa-solid fa-angle-right"></i>
OSS List
</h2>

{/* Description */}
<h3 className="pb-8">
List of OSS(= Open Source Software) information registered in the database.
</h3>

{/* Filters */}
<ListFilters />

{/* Button(s) */}
<div className="flex justify-end gap-x-2 mt-8 mb-4">
<button className="flex items-center gap-x-1.5 px-2 py-0.5 border border-gray rounded">
<div className="relative w-4 h-4">
<Image src={ExcelIcon} fill sizes="32px" alt="export" />
</div>
Export
</button>
</div>

{/* Table */}
<ListTable />
</>
);
}
4 changes: 2 additions & 2 deletions lite/app/(main)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
{/* Hamburger button (PC) or Top bar (Mobile) */}
{view === 'pc' ? (
<button
className="w-6 h-6 text-xl text-charcol"
className="w-6 h-6 text-xl text-charcoal"
onClick={() => setIsSideBarShown(!isSideBarShown)}
>
<i className="fa-solid fa-bars"></i>
Expand All @@ -57,7 +57,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
<div
className={clsx(
'mx-4 overflow-x-auto no-scrollbar',
view === 'pc' ? 'mb-8' : 'mt-4 mb-24'
view === 'pc' ? 'pb-8' : 'pt-4 pb-24'
)}
>
{children}
Expand Down
12 changes: 6 additions & 6 deletions lite/components/bottom-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export default function BottomBar() {
});

return (
<div className="fixed right-0 bottom-0 left-0 flex h-16 bg-charcol text-semiwhite">
<div className="fixed right-0 bottom-0 left-0 flex h-16 bg-charcoal text-semiwhite">
<Link
className={clsx('flex-1 pt-2.5 text-center', pathname === '/' && 'bg-semicharcol/20')}
className={clsx('flex-1 pt-2.5 text-center', pathname === '/' && 'bg-semicharcoal/20')}
href="/"
>
<i className={clsx('text-lg', rootMenu.icon)}></i>
Expand All @@ -42,7 +42,7 @@ export default function BottomBar() {
key={menu.name}
className={clsx(
'flex-1 pt-2.5 text-center',
pathname.startsWith(menu.path) && 'bg-semicharcol/20'
pathname.startsWith(menu.path) && 'bg-semicharcoal/20'
)}
href={menu.path}
>
Expand All @@ -57,7 +57,7 @@ export default function BottomBar() {
key={menu.name}
className={clsx(
'menu relative flex-1 pt-2.5 text-center cursor-pointer no-tap-highlight',
pathname.startsWith(menu.path) && 'bg-semicharcol/20'
pathname.startsWith(menu.path) && 'bg-semicharcoal/20'
)}
onClick={() => {
const newIsMenuShown = {
Expand All @@ -71,7 +71,7 @@ export default function BottomBar() {
<div className="text-sm">{menu.short}</div>
<div
className={clsx(
'absolute right-0 bottom-16 left-0 flex flex-col bg-charcol border-b border-darkgray rounded-t-md text-semiwhite overflow-y-hidden transition-[max-height,opacity] duration-[500ms] z-50',
'absolute right-0 bottom-16 left-0 flex flex-col bg-charcoal border-b border-darkgray rounded-t-md text-semiwhite overflow-y-hidden transition-[max-height,opacity] duration-[500ms] z-50',
!isMenuShown[menu.name] ? 'max-h-0 opacity-0' : 'max-h-40 opacity-100'
)}
>
Expand All @@ -80,7 +80,7 @@ export default function BottomBar() {
key={subMenu.name}
className={clsx(
'leading-9',
pathname.startsWith(menu.path + subMenu.path) && 'bg-semicharcol/20'
pathname.startsWith(menu.path + subMenu.path) && 'bg-semicharcoal/20'
)}
href={menu.path + subMenu.path}
>
Expand Down
83 changes: 83 additions & 0 deletions lite/components/list-filters.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
export default function ListFilters() {
return (
<form className="w-[calc(100%-4px)] p-4 border border-darkgray rounded-lg shadow-[2px_2px_4px_0_rgba(0,0,0,0.2)]">
<div className="grid grid-cols-1 gap-x-8 gap-y-2 text-sm lg:grid-cols-2">
<div className="flex items-start gap-x-4">
<div className="flex-shrink-0 w-20">Text</div>
<div className="flex-1">
<div className="flex gap-x-2">
<input className="flex-1 w-0 px-2 py-1 border border-darkgray outline-none" />
</div>
</div>
</div>
<div className="flex items-start gap-x-4">
<div className="flex-shrink-0 w-20">Text + Check</div>
<div className="flex-1">
<div className="flex gap-x-2">
<input className="flex-1 w-0 px-2 py-1 border border-darkgray outline-none" />
<label className="flex items-center gap-x-1.5">
<input className="w-4 h-4" type="checkbox" />
Exact
</label>
</div>
</div>
</div>
<div className="flex items-start gap-x-4">
<div className="flex-shrink-0 w-20">Select</div>
<div className="flex-1">
<select className="w-full px-2 py-1 border border-darkgray outline-none">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
</div>
</div>
<div className="flex items-start gap-x-4">
<div className="flex-shrink-0 w-20">Check</div>
<div className="flex-1">
<div className="flex flex-wrap gap-x-4 gap-y-1">
<label className="flex items-center gap-x-1.5">
<input className="w-4 h-4" type="checkbox" />
Label 1
</label>
<label className="flex items-center gap-x-1.5">
<input className="w-4 h-4" type="checkbox" />
Label 2
</label>
<label className="flex items-center gap-x-1.5">
<input className="w-4 h-4" type="checkbox" />
Label 3
</label>
<label className="flex items-center gap-x-1.5">
<input className="w-4 h-4" type="checkbox" />
Label 4
</label>
</div>
</div>
</div>
<div className="flex items-start gap-x-4">
<div className="flex-shrink-0 w-20">Date</div>
<div className="flex-1">
<div className="flex gap-x-2">
<input className="flex-1 w-0 px-2 py-1 border border-darkgray outline-none" />
~
<input className="flex-1 w-0 px-2 py-1 border border-darkgray outline-none" />
</div>
</div>
</div>
<div className="flex items-start gap-x-4">
<div className="flex-shrink-0 w-20">TextArea</div>
<div className="flex-1">
<textarea
className="block w-full px-2 py-1 border border-darkgray outline-none resize-none"
rows={3}
></textarea>
</div>
</div>
</div>
<div className="mt-2 text-right">
<button className="px-2 py-1 bg-crimson rounded text-semiwhite">Search</button>
</div>
</form>
);
}
102 changes: 102 additions & 0 deletions lite/components/list-table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
'use client';

import { viewState } from '@/lib/atoms';
import { insertCommas } from '@/lib/commons';
import clsx from 'clsx';
import { useRecoilValue } from 'recoil';

export default function ListTable() {
const view = useRecoilValue(viewState);
const countPerPage = 10;
const totalCount = 30924;
const pages = [1, 2, 3, -1, 7, 8, 9];
const currentPage = 2;

return (
<>
<div className="overflow-x-auto no-scrollbar">
<table className="w-full text-sm">
<thead>
<tr className="border-b-2 border-charcoal/80 text-center whitespace-nowrap">
<th className="p-2 text-left">
ID<i className="ml-2 text-semigray fa-solid fa-sort"></i>
</th>
<th className="p-2 text-left">
Type<i className="ml-2 text-semigray fa-solid fa-sort"></i>
</th>
<th className="p-2 text-left">
Name<i className="ml-2 text-semigray fa-solid fa-sort"></i>
</th>
<th className="p-2 text-left">
Ver<i className="ml-2 text-semigray fa-solid fa-sort"></i>
</th>
<th className="p-2 text-left">
License(s)<i className="ml-2 text-semigray fa-solid fa-sort"></i>
</th>
<th className="p-2 text-left">
Obligation(s)<i className="ml-2 text-semigray fa-solid fa-sort"></i>
</th>
<th className="p-2 text-left">
Download<i className="ml-2 text-semigray fa-solid fa-sort"></i>
</th>
<th className="p-2 text-left">
Vuln<i className="ml-2 text-semigray fa-solid fa-sort"></i>
</th>
<th className="w-8 p-2">
<i className="fa-solid fa-eye"></i>
</th>
</tr>
</thead>
<tbody>
{Array.from(Array(10)).map((_, idx) => (
<tr key={idx} className="border-b border-semigray">
<td className="px-2 py-1.5">Data</td>
<td className="px-2 py-1.5">Data</td>
<td className="px-2 py-1.5">Data</td>
<td className="px-2 py-1.5">Data</td>
<td className="px-2 py-1.5">Data</td>
<td className="px-2 py-1.5">Data</td>
<td className="px-2 py-1.5">Data</td>
<td className="px-2 py-1.5">Data</td>
<td></td>
</tr>
))}
</tbody>
</table>
</div>
{view !== 'none' && (
<div
className={clsx(
'flex mt-4 items-center',
view === 'pc' ? 'justify-between' : 'flex-col-reverse gap-y-4'
)}
>
<div className="text-darkgray">
{countPerPage} entries (total {insertCommas(totalCount)} entries)
</div>
<div className="flex items-center gap-x-2">
{pages.map((page) => {
if (page === -1) {
return <i key={page} className="fa-solid fa-ellipsis"></i>;
}

return (
<button
key={page}
className={clsx(
'px-2 py-0.5 border',
page === currentPage
? 'bg-charcoal border-charcoal text-semiwhite'
: 'border-darkgray'
)}
>
{page}
</button>
);
})}
</div>
</div>
)}
</>
);
}
16 changes: 8 additions & 8 deletions lite/components/side-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export default function SideBar({ isShown }: { isShown: boolean }) {
return (
<div
className={clsx(
'sticky top-0 shrink-0 h-screen bg-charcol shadow-[0_0_6px_2px_rgba(0,0,0,0.5)] text-semiwhite transition-[width] duration-300 z-10',
'sticky top-0 shrink-0 h-screen bg-charcoal shadow-[0_0_6px_2px_rgba(0,0,0,0.5)] text-semiwhite transition-[width] duration-300 z-10',
isShown ? 'w-56' : 'w-0'
)}
>
<div className="absolute top-0 right-0 bottom-0 w-56 overflow-y-auto no-scrollbar">
<div className="sticky top-0 bg-charcol">
<div className="sticky top-0 bg-charcoal">
<div className="flex justify-center items-center gap-x-4 py-4">
<div className="w-12 h-12 p-3 bg-white rounded-full">
<div className="relative w-6 h-6">
Expand All @@ -58,8 +58,8 @@ export default function SideBar({ isShown }: { isShown: boolean }) {
<div className="flex flex-col gap-y-4 py-8">
<Link
className={clsx(
'px-4 text-lg font-semibold leading-loose hover:bg-semicharcol/50',
pathname === '/' && 'bg-semicharcol/20'
'px-4 text-lg font-semibold leading-loose hover:bg-semicharcoal/50',
pathname === '/' && 'bg-semicharcoal/20'
)}
href="/"
>
Expand All @@ -71,8 +71,8 @@ export default function SideBar({ isShown }: { isShown: boolean }) {
<Link
key={menu.name}
className={clsx(
'px-4 text-lg font-semibold leading-loose hover:bg-semicharcol/50',
pathname.startsWith(menu.path) && 'bg-semicharcol/20'
'px-4 text-lg font-semibold leading-loose hover:bg-semicharcoal/50',
pathname.startsWith(menu.path) && 'bg-semicharcoal/20'
)}
href={menu.path}
>
Expand Down Expand Up @@ -110,8 +110,8 @@ export default function SideBar({ isShown }: { isShown: boolean }) {
<Link
key={subMenu.name}
className={clsx(
'px-4 leading-loose cursor-pointer hover:bg-semicharcol/50',
pathname.startsWith(menu.path + subMenu.path) && 'bg-semicharcol/20'
'px-4 leading-loose cursor-pointer hover:bg-semicharcoal/50',
pathname.startsWith(menu.path + subMenu.path) && 'bg-semicharcoal/20'
)}
href={menu.path + subMenu.path}
>
Expand Down
3 changes: 3 additions & 0 deletions lite/lib/commons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function insertCommas(number: number) {
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
Binary file added lite/public/images/excel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions lite/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const config: Config = {
theme: {
extend: {
colors: {
charcol: '#34393f',
semicharcol: '#68727e',
charcoal: '#34393f',
semicharcoal: '#68727e',
crimson: '#b02a42',
semiwhite: '#eeeeee',
semiblack: '#222222',
Expand Down

0 comments on commit f4a6425

Please sign in to comment.