Skip to content

Commit

Permalink
Add cards page (#5)
Browse files Browse the repository at this point in the history
* Update Plan

* Work on header.

* Adjust search

* Adjust colors.

* Extract primary header.

* Make cards list scrollable.

* Adjust colors.

* Add more dummy pages.

* Navigate with query

* Adjust plan

* Fix error.
  • Loading branch information
lukasbicus authored Oct 24, 2024
1 parent 05084b0 commit e77c26e
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 17 deletions.
56 changes: 55 additions & 1 deletion app/(homescreens)/add-cards/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@
import { PredefinedCompanies, Routes } from '@/app/lib/shared';
import { PrimaryHeader } from '@/app/ui/primary-header';
import {
IconGift,
IconLayoutGrid,
IconPlus,
IconSearch,
} from '@tabler/icons-react';
import Link from 'next/link';

export default function Page() {
return <main>Add cards</main>;
return (
<div className="h-full flex flex-col">
<PrimaryHeader
title="Add cards"
actions={
<Link href={Routes.ScanCard}>
<button className="btn btn-primary">
<IconPlus className="w-6 h-6" />
Add card
</button>
</Link>
}
>
<>
<div className="form-control flex-1">
<label className="input input-bordered flex items-center gap-2 w-full">
<input type="text" className="grow w-full" placeholder="Search" />
<IconSearch className="h-4 w-4 opacity-70"></IconSearch>
</label>
</div>
<button className="btn btn-circle btn-ghost">
<IconLayoutGrid className="w-6 h-6" />
</button>
</>
</PrimaryHeader>
<main className="overflow-y-auto flex-1 bg-base-100">
<ul className="menu menu-lg rounded-box text-base-content">
{Object.values(PredefinedCompanies).map(company => (
<li key={company}>
<Link
href={{
pathname: Routes.ScanCard,
query: { predefinedCompany: company },
}}
prefetch={false}
>
<IconGift className="w-8 h-8" />
{company}
</Link>
</li>
))}
</ul>
</main>
</div>
);
}
6 changes: 6 additions & 0 deletions app/(homescreens)/layout.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.bottomBarNavHeight {
height: var(--bottom-bar-height);
}
.childrenHeight {
height: calc(100vh - var(--bottom-bar-height));
}
13 changes: 10 additions & 3 deletions app/(homescreens)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import BottomNavigationLinks from '@/app/ui/bottom-navigation-links';
import clsx from 'clsx';
import styles from './layout.module.css';

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div className="flex h-screen flex-col">
<div>{children}</div>
<div className="btm-nav btm-nav-lg text-primary">
<div className="h-screen">
<div className={styles.childrenHeight}>{children}</div>
<div
className={clsx(
`btm-nav btm-nav-lg text-base-content bg-base-200`,
styles.bottomBarNavHeight
)}
>
<BottomNavigationLinks />
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions app/add-card/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <div>Scan card page</div>;
}
9 changes: 2 additions & 7 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@
:root {
--background: #ffffff;
--foreground: #171717;
}

@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
}
--bottom-bar-height: 5rem;
/*--primary: #fc9581;*/
}

body {
Expand Down
24 changes: 24 additions & 0 deletions app/lib/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,34 @@ export enum Routes {
MyCards = '/my-cards',
Settings = '/settings',
Offline = '/offline',
AddCard = '/add-card',
ScanCard = '/scan-card',
}

export enum Cookies {
LandingPage = 'LandingPage',
}

export const ICON_COLOR = '#db924b';

export enum PredefinedCompanies {
TESCO = 'Tesco',
DM = 'Dm',
IKEA = 'Ikea',
BILLA = 'Billa',
LIDL = 'Lidl',
TERNO = 'Terno',
PET_CENTER = 'Pet center',
ALBERT = 'Albert',
GLOBUS = 'Globus',
ROSSMANN = 'Rossmann',
AUPARK = 'Aupark',
DATART = 'Datart',
KAUFLAND = 'Kaufland',
MALL = 'Mall',
NOTINO = 'Notino',
O2 = 'O2',
SPORTISIMO = 'Sportisimo',
TETA = 'Teta',
ZOOT = 'Zoot',
}
3 changes: 3 additions & 0 deletions app/scan-card/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <div>Scan card page</div>;
}
1 change: 1 addition & 0 deletions app/ui/bottom-navigation-links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function BottomNavigationLinks() {
href={link.href}
className={clsx({
active: pathname === link.href,
['text-primary']: pathname === link.href,
})}
>
<LinkIcon className="w-6" />
Expand Down
34 changes: 34 additions & 0 deletions app/ui/primary-header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Image from 'next/image';

export function PrimaryHeader({
title,
actions,
children,
}: {
title: string;
actions?: React.ReactNode;
children?: React.ReactNode;
}) {
return (
<header>
<div className="navbar bg-base-200 text-base-content">
<div className="navbar-start">
<Image
src="/logo.svg"
alt="Tilda logo"
className="w-8 rounded-lg bg-base-content"
width={24}
height={24}
/>
<h1 className="btn btn-ghost text-lg">{title}</h1>
</div>
{actions && <div className="navbar-end">{actions}</div>}
</div>
{children && (
<div className="navbar bg-base-100 text-base-content gap-2">
{children}
</div>
)}
</header>
);
}
10 changes: 5 additions & 5 deletions plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ Features:
3. optional are with normal font

- [ ] **Welcome page**
- [ ] **add navigation to my cards page**
- [x] **add navigation to add cards page**
- [ ] **add navigation to about page**
- [ ] Utils
- [ ] add theme switching
- [ ] **implement PWA**
- [x] **implement PWA**
- [x] **add homescreen menu**
- [ ] **create a general search component**
- [ ] **implement primary header**
Expand All @@ -21,11 +21,11 @@ Features:
- [ ] _fe unit tests_
- [ ] e2e tests
- [ ] **Add cards page**
- [ ] **display list of predefined companies**
- [x] **display list of predefined companies**
- [ ] display grid of predefined companies + switch to grid
- [ ] _implement search in predefined companies_
- [ ] **implement add card button + navigation to scan code page**
- [ ] _implement click on predefined company + navigation to create card page_
- [x] **implement add card button + navigation to scan code page**
- [x] _implement click on predefined company + navigation to create card page_
- [ ] _Scan code page_
- [ ] _implement barcode scan_
- [ ] _implement navigation to qrcode scan + scan itself_
Expand Down
2 changes: 1 addition & 1 deletion tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const config: Config = {
},
plugins: [daisyui],
daisyui: {
themes: ['coffee', 'sunset', 'acid', 'light', 'dark'],
themes: ['coffee'],
},
};
export default config;

0 comments on commit e77c26e

Please sign in to comment.