Skip to content

Commit

Permalink
feat: implement comp Filter at the expense of SidebarLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
zerinoid committed Jul 6, 2023
1 parent f380dcc commit 7f8072e
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 30 deletions.
6 changes: 5 additions & 1 deletion src/components/layouts/primary/PrimaryLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Head from 'next/head';
import { ReactElement } from 'react';
import styles from './PrimaryLayout.module.css';
import { Inter } from 'next/font/google';
import Filter from '../../sections/filter/Filter';

const inter = Inter({ subsets: ['latin'] });

Expand Down Expand Up @@ -37,7 +38,10 @@ const PrimaryLayout: React.FC<IPrimaryLayout> = ({
<link rel="manifest" href="/site.webmanifest" />
<title>{title}</title>
</Head>
<main className={`${styles.main} ${inter.className}`}>{children}</main>
<main className={`${styles.main} ${inter.className}`}>
<Filter />
{children}
</main>
</>
);
};
Expand Down
16 changes: 0 additions & 16 deletions src/components/layouts/sidebar/SidebarLayout.stories.tsx

This file was deleted.

9 changes: 9 additions & 0 deletions src/components/sections/filter/Filter.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { IFilter } from './Filter';

const base: IFilter = {
sampleTextProp: 'Hello world!'
};

export const filterData = {
base
};
19 changes: 19 additions & 0 deletions src/components/sections/filter/Filter.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Meta, StoryObj } from '@storybook/react';
import Filter from './Filter';
import { filterData } from './Filter.data';

const meta: Meta<typeof Filter> = {
title: 'sections/Filter',
component: Filter,
tags: ['autodocs'],
argTypes: {}
};

export default meta;
type Story = StoryObj<typeof Filter>;

export const Base: Story = {
args: {
...filterData.base
}
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import Link from 'next/link';
import styles from './SidebarLayout.module.css';
import styles from './Filter.module.css';

const SidebarLayout: React.FC = () => {
export interface IFilter {
sampleTextProp: string;
}

const Filter: React.FC<IFilter> = ({ sampleTextProp }) => {
return (
<nav className={styles.nav}>
<input className={styles.input} placeholder="Search..." />
Expand All @@ -12,4 +16,4 @@ const SidebarLayout: React.FC = () => {
);
};

export default SidebarLayout;
export default Filter;
12 changes: 2 additions & 10 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import Gallery from '@/components/sections/gallery/Gallery';
import PrimaryLayout from '../components/layouts/primary/PrimaryLayout';
import SidebarLayout from '../components/layouts/sidebar/SidebarLayout';
import styles from '../styles/Home.module.css';
import { NextPageWithLayout } from './_app';

const Home: NextPageWithLayout = () => {
return (
<section className={styles.main}>
<h1 className={styles.title}>
Welcome to <a href="https://nextjs.org">Next.js!</a>
</h1>
<h1 className={styles.title}>Search and Filter</h1>
<Gallery />
</section>
);
Expand All @@ -18,10 +15,5 @@ const Home: NextPageWithLayout = () => {
export default Home;

Home.getLayout = page => {
return (
<PrimaryLayout title="Search and Filter">
<SidebarLayout />
{page}
</PrimaryLayout>
);
return <PrimaryLayout title="Search and Filter">{page}</PrimaryLayout>;
};

0 comments on commit 7f8072e

Please sign in to comment.