Skip to content

Commit

Permalink
refactor(next.js): migrate to next.js 13 app/ directory
Browse files Browse the repository at this point in the history
  • Loading branch information
tulup-conner committed Apr 20, 2023
1 parent 088a82c commit fb96f6f
Show file tree
Hide file tree
Showing 84 changed files with 428 additions and 910 deletions.
15 changes: 7 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/.next": true,
"**/.vercel": true,
"**/build": true,
"**/coverage": true,
"**/lib": true,
"**/node_modules": true
}
}
"**/node_modules": true,
"**/.DS_Store": true,
"**/Thumbs.db": true
},
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
28 changes: 28 additions & 0 deletions app/components/code-preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { ComponentProps, FC, PropsWithChildren } from 'react';
import { Card } from '~/src';

const CodePreviewContainer: FC<PropsWithChildren> = function ({ children }) {
return <div className="flex flex-col gap-2">{children}</div>;
};

const CodePreviewCard: FC<PropsWithChildren & ComponentProps<'div'>> = function ({ children, className }) {
return (
<div className={className}>
<Card>{children}</Card>
</div>
);
};

const CodePreviewContent: FC<PropsWithChildren> = function ({ children }) {
return <div className="py-4">{children}</div>;
};

const CodePreviewTitle: FC<PropsWithChildren> = function ({ children }) {
return <span className="text-2xl font-bold">{children}</span>;
};

export const CodePreview = Object.assign(CodePreviewContainer, {
Card: CodePreviewCard,
Content: CodePreviewContent,
Title: CodePreviewTitle,
});
100 changes: 100 additions & 0 deletions app/docs/components/accordion/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
'use client';

import type { FC } from 'react';
import { CodePreview } from '~/app/components/code-preview';
import type { AccordionProps } from '~/src';
import { Accordion } from '~/src';

const AccordionPage: FC = () => {
return (
<div className="grid grid-cols-1 gap-y-9">
<CodePreview>
<CodePreview.Title>Default accordion</CodePreview.Title>
<CodePreview.Card className="dark:!bg-gray-900">
<ExampleAccordion />
</CodePreview.Card>
</CodePreview>
<CodePreview>
<CodePreview.Title>Collapse all</CodePreview.Title>
<CodePreview.Card className="dark:!bg-gray-900">
<ExampleAccordion collapseAll />
</CodePreview.Card>
</CodePreview>
</div>
);
};

const ExampleAccordion: FC<Omit<AccordionProps, 'children'>> = (props) => {
return (
<Accordion {...props}>
<Accordion.Panel>
<Accordion.Title>What is Flowbite?</Accordion.Title>
<Accordion.Content>
<p className="mb-2 text-gray-500 dark:text-gray-400">
Flowbite is an open-source library of interactive components built on top of Tailwind CSS including buttons,
dropdowns, modals, navbars, and more.
</p>
<p className="text-gray-500 dark:text-gray-400">
Check out this guide to learn how to&nbsp;
<a
href="https://flowbite.com/docs/getting-started/introduction/"
className="text-blue-600 hover:underline dark:text-blue-500"
>
get started
</a>
and start developing websites even faster with components on top of Tailwind CSS.
</p>
</Accordion.Content>
</Accordion.Panel>
<Accordion.Panel>
<Accordion.Title>Is there a Figma file available?</Accordion.Title>
<Accordion.Content>
<p className="mb-2 text-gray-500 dark:text-gray-400">
Flowbite is first conceptualized and designed using the Figma software so everything you see in the library
has a design equivalent in our Figma file.
</p>
<p className="text-gray-500 dark:text-gray-400">
Check out the
<a href="https://flowbite.com/figma/" className="text-blue-600 hover:underline dark:text-blue-500">
Figma design system
</a>
based on the utility classes from Tailwind CSS and components from Flowbite.
</p>
</Accordion.Content>
</Accordion.Panel>
<Accordion.Panel>
<Accordion.Title>What are the differences between Flowbite and Tailwind UI?</Accordion.Title>
<Accordion.Content>
<p className="mb-2 text-gray-500 dark:text-gray-400">
The main difference is that the core components from Flowbite are open source under the MIT license, whereas
Tailwind UI is a paid product. Another difference is that Flowbite relies on smaller and standalone
components, whereas Tailwind UI offers sections of pages.
</p>
<p className="mb-2 text-gray-500 dark:text-gray-400">
However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as there is no
technical reason stopping you from using the best of two worlds.
</p>
<p className="mb-2 text-gray-500 dark:text-gray-400">Learn more about these technologies:</p>
<ul className="list-disc pl-5 text-gray-500 dark:text-gray-400">
<li>
<a href="https://flowbite.com/pro/" className="text-blue-600 hover:underline dark:text-blue-500">
Flowbite Pro
</a>
</li>
<li>
<a
href="https://tailwindui.com/"
rel="nofollow"
className="text-blue-600 hover:underline dark:text-blue-500"
>
Tailwind UI
</a>
</li>
</ul>
</Accordion.Content>
</Accordion.Panel>
</Accordion>
);
};

export default AccordionPage;
100 changes: 100 additions & 0 deletions app/docs/components/alert/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
'use client';

import type { FC } from 'react';
import { HiEye, HiInformationCircle } from 'react-icons/hi';
import { CodePreview } from '~/app/components/code-preview';
import type { AlertProps } from '~/src';
import { Alert } from '~/src';

const AlertPage: FC = () => {
return (
<>
<CodePreview>
<CodePreview.Title>Default alert</CodePreview.Title>
<CodePreview.Card>
<ExampleAlert color="info" />
</CodePreview.Card>
</CodePreview>
<CodePreview>
<CodePreview.Title>Alert with icon</CodePreview.Title>
<CodePreview.Card>
<ExampleAlert color="failure" icon={HiInformationCircle} />
</CodePreview.Card>
</CodePreview>
<CodePreview>
<CodePreview.Title>Dismissable alert</CodePreview.Title>
<CodePreview.Card>
<ExampleAlert color="success" onDismiss={() => alert('Alert dismissed!')} />
</CodePreview.Card>
</CodePreview>
<CodePreview>
<CodePreview.Title>Rounded</CodePreview.Title>
<CodePreview.Card>
<ExampleAlert color="warning" rounded />
</CodePreview.Card>
</CodePreview>
<CodePreview>
<CodePreview.Title>Border accent</CodePreview.Title>
<CodePreview.Card>
<ExampleAlert color="warning" withBorderAccent />
</CodePreview.Card>
</CodePreview>
<CodePreview>
<CodePreview.Title>Additional content</CodePreview.Title>
<CodePreview.Card>
<ExampleAlert additionalContent={<ExampleAdditionalContent />} color="warning" icon={HiInformationCircle} />
</CodePreview.Card>
</CodePreview>
<CodePreview>
<CodePreview.Title>All options</CodePreview.Title>
<CodePreview.Card>
<ExampleAlert
additionalContent={<ExampleAdditionalContent />}
color="success"
icon={HiInformationCircle}
onDismiss={() => alert('Alert dismissed!')}
rounded
/>
</CodePreview.Card>
</CodePreview>
</>
);
};

const ExampleAlert: FC<AlertProps> = (props) => {
return (
<Alert {...props}>
<span>
<span className="font-medium">Info alert!</span> Change a few things up and try submitting again.
</span>
</Alert>
);
};

const ExampleAdditionalContent: FC = () => {
return (
<>
<div className="mt-2 mb-4 text-sm text-blue-700 dark:text-blue-800">
More info about this info alert goes here. This example text is going to run a bit longer so that you can see
how spacing within an alert works with this kind of content.
</div>
<div className="flex">
<button
type="button"
className="mr-2 inline-flex items-center rounded-lg bg-blue-700 px-3 py-1.5 text-center text-xs font-medium text-white hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 dark:bg-blue-800 dark:hover:bg-blue-900"
>
<HiEye className="-ml-0.5 mr-2 h-4 w-4" />
View more
</button>
<button
type="button"
className="rounded-lg border border-blue-700 bg-transparent px-3 py-1.5 text-center text-xs font-medium text-blue-700 hover:bg-blue-800 hover:text-white focus:ring-4 focus:ring-blue-300 dark:border-blue-800 dark:text-blue-800 dark:hover:text-white"
>
Dismiss
</button>
</div>
</>
);
};

export default AlertPage;
Original file line number Diff line number Diff line change
@@ -1,54 +1,51 @@
import Image from 'next/image';
import type { FC } from 'react';
import type { CodeExample } from '~/pages/docs/components/demo';
import DemoPage from '~/pages/docs/components/demo';
import { CodePreview } from '~/app/components/code-preview';
import { Avatar, Dropdown } from '~/src';

const AvatarPage: FC = () => {
const examples: CodeExample[] = [
{
title: 'Default Avatar',
code: (
return (
<>
<CodePreview>
<CodePreview.Title>Default avatar</CodePreview.Title>
<CodePreview.Card>
<div className="flex flex-wrap gap-2">
<Avatar img="/images/people/profile-picture-5.jpg" rounded />
<Avatar img="/images/people/profile-picture-5.jpg" />
</div>
),
},
{
title: 'Bordered Avatar',
code: (
</CodePreview.Card>
</CodePreview>
<CodePreview>
<CodePreview.Title>Bordered avatar</CodePreview.Title>
<CodePreview.Card>
<div className="flex flex-wrap gap-2">
<Avatar img="/images/people/profile-picture-5.jpg" rounded bordered />
<Avatar img="/images/people/profile-picture-5.jpg" bordered />
</div>
),
},
{
title: 'Colored Avatar',
code: (
<>
<div className="flex flex-wrap gap-2">
</CodePreview.Card>
</CodePreview>
<CodePreview>
<CodePreview.Title>Colored avatar</CodePreview.Title>
<CodePreview.Card>
<div className="flex flex-wrap gap-2">
<Avatar img="/images/people/profile-picture-5.jpg" rounded bordered color="gray" />
<Avatar img="/images/people/profile-picture-5.jpg" rounded bordered color="light" />
<Avatar img="/images/people/profile-picture-5.jpg" rounded bordered color="purple" />
<Avatar img="/images/people/profile-picture-5.jpg" rounded bordered color="success" />
<Avatar img="/images/people/profile-picture-5.jpg" rounded bordered color="pink" />
</div>

<div className="flex flex-wrap gap-2">
<Avatar img="/images/people/profile-picture-5.jpg" bordered color="gray" />
<Avatar img="/images/people/profile-picture-5.jpg" bordered color="light" />
<Avatar img="/images/people/profile-picture-5.jpg" bordered color="purple" />
<Avatar img="/images/people/profile-picture-5.jpg" bordered color="success" />
<Avatar img="/images/people/profile-picture-5.jpg" bordered color="pink" />
</div>
</>
),
},
{
title: 'Override Image Element',
code: (
</CodePreview.Card>
</CodePreview>
<CodePreview>
<CodePreview.Title>Override image element</CodePreview.Title>
<CodePreview.Card>
<div className="flex flex-wrap gap-2">
<Avatar
img={(props) => (
Expand All @@ -72,37 +69,9 @@ const AvatarPage: FC = () => {
)}
/>
</div>
),
rawCode: `<div className="flex flex-wrap gap-2">
<Avatar
img={(props) => (
<img
referrerPolicy="no-referrer"
src="/images/people/profile-picture-5.jpg"
{...props}
/>
)}
/>
<Avatar
img={(props) => (
<picture>
<source
media="(min-width: 900px)"
srcSet="/images/people/profile-picture-3.jpg"
/>
<source
media="(min-width: 480px)"
srcSet="/images/people/profile-picture-4.jpg"
/>
<img
src="/images/people/profile-picture-5.jpg"
{...props}
/>
</picture>
)}
/>
</div>`,
},
</CodePreview.Card>
</CodePreview>
</>
{
title: 'Placeholder',
code: (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions app/docs/components/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { FC, PropsWithChildren } from 'react';

const ComponentDocsLayout: FC<PropsWithChildren> = ({ children }) => {
return <div className="mx-auto flex flex-col gap-8 dark:text-white">{children}</div>;
};

export default ComponentDocsLayout;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FC } from 'react';
import type { CodeExample } from '~/pages/docs/components/demo';
import DemoPage from '~/pages/docs/components/demo';
import { Progress } from '~/src';
import type { CodeExample } from './demo';
import DemoPage from './demo';

const ProgressPage: FC = () => {
const examples: CodeExample[] = [
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit fb96f6f

Please sign in to comment.