Skip to content

Commit

Permalink
feat: Added responsiveness to user interface components
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-crowell committed Jun 17, 2024
1 parent e7e1054 commit ca7eec1
Show file tree
Hide file tree
Showing 13 changed files with 327 additions and 59 deletions.
40 changes: 25 additions & 15 deletions packages/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,37 @@ A TailwindCSS and NextUI-(Open Source) components library for React projects. Th

Indended for use with modern ESM TypeScript in other do-ob projects. Documentation is limited at this time.

## Installation

To use the components from this library in your project, follow these steps:

1. Install TailwindCSS and NextUI:

Make sure you have TailwindCSS and NextUI set up in your project. If not, follow their respective installation guides:
# Libraries Leveraged

* [TailwindCSS Installation Guide](https://tailwindcss.com/docs/installation)
* [NextUI Installation Guide](https://nextui.org/docs/guide/installation)

2. Install the component library:
## Installation

```bash
npm install @do-ob/ui
```
1. Install the required dependencies using `npm`, `pnpm`, or `yarn`:

```bash
pnpm add @do-ob/ui
```
'@do-ob/ui' 'react' 'react-dom' '@nextui-org/react' 'framer-motion' 'tailwindcss' 'tailwindcss' '@tailwindcss/typography' '@heroicons/react'
```

```bash
yarn add @do-ob/ui
2. Add the following to your `tailwind.config.ts` file:

```typescript
import type { Config } from 'tailwindcss';
import { nextui } from '@nextui-org/react';
import tailwindTypography from '@tailwindcss/typography';

const config: Config = {
darkMode: 'class',
content: [
'./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}',
'./node_modules/@do-ob/ui/dist/**/*.{js,ts,jsx,tsx}',
'./app/**/*.{js,ts,jsx,tsx,mdx}',
],
plugins: [
nextui(),
tailwindTypography,
],
};
export default config;
```
4 changes: 3 additions & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"peerDependencies": {
"@heroicons/react": "^2.1.3",
"@nextui-org/react": "^2.4.1",
"@tailwindcss/typography": "^0.5.13",
"framer-motion": "^11.2.10",
"react": "latest"
"react": "latest",
"tailwindcss": "^3.4.3"
}
}
94 changes: 94 additions & 0 deletions packages/ui/src/components/Article/Article.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import type { Meta, StoryObj } from '@storybook/react';

import { Article } from './Article';

const meta = {
component: Article,
} satisfies Meta<typeof Article>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {
render: (args) => (
<Article {...args}>
<h1>Lorem Ipsum Dolor Sit Amet</h1>
<h2>Consectetur Adipiscing Elit</h2>
<h3>Sed Do Eiusmod Tempor</h3>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam.</p>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices.</p>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum vestibulum. Cras venenatis euismod malesuada. Nulla tincidunt ligula libero, a fermentum risus ultricies ac. Maecenas non ligula nec leo hendrerit vehicula ac id libero. Integer ac risus in sem lacinia rhoncus. Donec in erat nec quam tristique tristique. Duis in orci non elit dapibus commodo ac sit amet mauris. Fusce vel dui augue. Proin et metus ac nisi laoreet scelerisque. Integer a massa dolor. Suspendisse potenti. Nullam interdum metus nisi, et scelerisque nulla dignissim ac.</p>


<ul>
<li>Lorem ipsum dolor sit amet</li>
<li>Consectetur adipiscing elit</li>
<li>Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</li>
</ul>

<ol>
<li>Lorem ipsum dolor sit amet</li>
<li>Consectetur adipiscing elit</li>
<li>Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</li>
</ol>

<blockquote>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</blockquote>

<blockquote>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</blockquote>

<p><code>&lt;Lorem ipsum&gt;</code></p>

<pre><code>
{`function loremIpsum() {
return "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
}`}
</code></pre>
<table>
<thead>
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
<th>Heading 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 Col 1</td>
<td>Row 1 Col 2</td>
<td>Row 1 Col 3</td>
</tr>
<tr>
<td>Row 2 Col 1</td>
<td>Row 2 Col 2</td>
<td>Row 2 Col 3</td>
</tr>
<tr>
<td>Row 3 Col 1</td>
<td>Row 3 Col 2</td>
<td>Row 3 Col 3</td>
</tr>
</tbody>
</table>

<p><img src="https://via.placeholder.com/150" alt="Lorem Ipsum Image" /></p>

<p><a href="https://www.lipsum.com">Lorem Ipsum</a></p>

<p><a href="https://www.lipsum.com">Lorem Ipsum</a></p>

<hr />

<ul>
<li><input type="checkbox" /> Lorem ipsum dolor sit amet</li>
<li><input type="checkbox" checked /> Consectetur adipiscing elit</li>
<li><input type="checkbox" /> Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</li>
</ul>
</Article>
),
};
10 changes: 10 additions & 0 deletions packages/ui/src/components/Article/Article.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { HTMLAttributes, PropsWithChildren } from 'react';
import { clsx, clmg } from '@do-ob/core';

export function Article({ children, className, ...props }: PropsWithChildren<HTMLAttributes<HTMLDivElement>>) {
return (
<article className={clmg(clsx('prose dark:prose-invert', className))} {...props}>
{children}
</article>
);
}
5 changes: 5 additions & 0 deletions packages/ui/src/components/Navigation/Navigation.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export default meta;

type Story = StoryObj<typeof meta>;

const logo = 'https://via.placeholder.com/100';

const links: Link[] = [
{
title: 'Home',
Expand Down Expand Up @@ -99,6 +101,7 @@ const socials: SocialLinks = [
export const Standard: Story = {
args: {
title: 'Navigation',
logo,
links,
search: '#search',
modeToggle: true,
Expand All @@ -109,6 +112,7 @@ export const Standard: Story = {
export const Island: Story = {
args: {
title: 'Navigation',
logo,
variant: 'island',
links,
search: '#search',
Expand All @@ -120,6 +124,7 @@ export const Island: Story = {
export const Extended: Story = {
args: {
title: 'Navigation',
logo,
variant: 'extended',
links,
search: '#search',
Expand Down
31 changes: 24 additions & 7 deletions packages/ui/src/components/Navigation/NavigationExtended.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,53 @@
import { Navbar, NavbarContent } from '@nextui-org/react';
'use client';

import React from 'react';
import { Navbar, NavbarContent, NavbarMenuToggle } from '@nextui-org/react';
import { clsx, clmg } from '@do-ob/core';
import type { NavigationProps } from './data/NavigationContext';
import { NavigationPart_Brand } from './parts/NavigationPart_Brand';
import { NavigationPart_Links } from './parts/NavigationPart_Links';
import { NavigationPart_Actions } from './parts/NavigationPart_Actions';
import { NavigationProvider } from './data/NavigationProvider';
import { twColors } from '@do-ob/ui/utility';
import { NavigationPart_Menu } from './parts/NavigationPart_Menu';

export function NavigationExtended(props: NavigationProps) {

const [ isMenuOpen, setIsMenuOpen ] = React.useState(false);

const colors = twColors(props.color);

return (
<NavigationProvider {...props}>
<Navbar
position={props.position}
height="8rem"
onMenuOpenChange={setIsMenuOpen}
className={clmg(clsx(props.color && colors, 'relative border-b-1 border-b-foreground-200/50', props.className))}
height="4rem"

>
<NavbarContent justify="start">
<NavigationPart_Brand />
<NavbarContent justify="start" className="md:items-start md:pt-2">
<div className="relative z-10">
<NavigationPart_Brand />
</div>
</NavbarContent>

<NavbarContent justify="start">
<NavbarContent justify="start" className="absolute hidden items-end md:flex">
<NavigationPart_Links />
</NavbarContent>

<NavbarContent justify="end">
<div className="max-w-64">
<NavbarContent justify="end" className="items-start pt-2">
<div className="hidden max-w-64 p-2 md:block">
<NavigationPart_Actions />
</div>
<NavbarMenuToggle
aria-label={isMenuOpen ? 'Close menu' : 'Open menu'}
className="md:hidden"
/>
</NavbarContent>

<NavigationPart_Menu />

</Navbar>
</NavigationProvider>
);
Expand Down
41 changes: 33 additions & 8 deletions packages/ui/src/components/Navigation/NavigationIsland.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { Navbar, NavbarContent } from '@nextui-org/react';
'use client';

import React from 'react';
import { Navbar, NavbarContent, NavbarMenuToggle } from '@nextui-org/react';
import { clsx, clmg } from '@do-ob/core';

import type { NavigationProps } from './data/NavigationContext';
Expand All @@ -7,25 +10,47 @@ import { NavigationPart_Brand } from './parts/NavigationPart_Brand';
import { NavigationPart_Links } from './parts/NavigationPart_Links';
import { NavigationPart_Actions } from './parts/NavigationPart_Actions';
import { twColors } from '@do-ob/ui/utility';
import { NavigationPart_Menu } from './parts/NavigationPart_Menu';

export function NavigationIsland(props: NavigationProps) {

const [ isMenuOpen, setIsMenuOpen ] = React.useState(false);

const colors = twColors(props.color);

return (
<NavigationProvider {...props}>
<Navbar className="items-center justify-center bg-transparent backdrop-blur-none backdrop-filter-none" height="5rem">
<Navbar
position={props.position}
isBlurred={false}
onMenuOpenChange={setIsMenuOpen}
className="items-center justify-center"
height="5rem"
>
<NavbarContent justify="start" className="flex items-center">
<NavigationPart_Brand />
</NavbarContent>
<NavbarContent justify="center">
<div className={clmg(clsx(props.color && colors, 'flex rounded-full border-1 border-foreground-200/50 px-4', props.className))}>
<NavigationPart_Links />
</div>
</NavbarContent>

{props.links && props.links.length > 0 && (
<NavbarContent justify="center" className="hidden lg:flex">
<div className={clmg(clsx(props.color && colors, 'flex rounded-full border-1 border-foreground-200/50 px-4', props.className))}>
<NavigationPart_Links />
</div>
</NavbarContent>
)}

<NavbarContent justify="end">
<NavigationPart_Actions />
<div className="hidden max-w-64 lg:block">
<NavigationPart_Actions />
</div>
<NavbarMenuToggle
aria-label={isMenuOpen ? 'Close menu' : 'Open menu'}
className="lg:hidden"
/>
</NavbarContent>

<NavigationPart_Menu />

</Navbar>
</NavigationProvider>
);
Expand Down
22 changes: 18 additions & 4 deletions packages/ui/src/components/Navigation/NavigationStandard.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,50 @@
import { Navbar, NavbarContent } from '@nextui-org/react';
'use client';

import React from 'react';
import { Navbar, NavbarContent, NavbarMenuToggle } from '@nextui-org/react';
import { clsx, clmg } from '@do-ob/core';
import type { NavigationProps } from './data/NavigationContext';
import { NavigationProvider } from './data/NavigationProvider';
import { NavigationPart_Brand } from './parts/NavigationPart_Brand';
import { NavigationPart_Links } from './parts/NavigationPart_Links';
import { NavigationPart_Actions } from './parts/NavigationPart_Actions';
import { twColors } from '@do-ob/ui/utility';
import { NavigationPart_Menu } from './parts/NavigationPart_Menu';

export function NavigationStandard(props: NavigationProps) {

const [ isMenuOpen, setIsMenuOpen ] = React.useState(false);

const colors = twColors(props.color);

return (
<NavigationProvider {...props}>
<Navbar
className={clmg(clsx(props.color && colors, 'border-b-1 border-b-foreground-200/50', props.className))}
position={props.position}
height="4rem"
onMenuOpenChange={setIsMenuOpen}
className={clmg(clsx(props.color && colors, 'border-b-1 border-b-foreground-200/50', props.className))}
>
<NavbarContent justify="start">
<NavigationPart_Brand />
</NavbarContent>

<NavbarContent justify="center">
<NavbarContent justify="center" className="hidden lg:flex">
<NavigationPart_Links />
</NavbarContent>

<NavbarContent justify="end">
<div className="max-w-64">
<div className="hidden max-w-64 lg:block">
<NavigationPart_Actions />
</div>
<NavbarMenuToggle
aria-label={isMenuOpen ? 'Close menu' : 'Open menu'}
className="lg:hidden"
/>
</NavbarContent>

<NavigationPart_Menu />

</Navbar>
</NavigationProvider>
);
Expand Down
Loading

0 comments on commit ca7eec1

Please sign in to comment.