From 84ba1e3ce39b2ee4a101e996b1fd7aaeb5419b3a Mon Sep 17 00:00:00 2001 From: Eric Crowell Date: Sat, 15 Jun 2024 11:38:39 +0200 Subject: [PATCH] dev: Adding additional features and components --- .storybook/main.ts | 14 ++++++ .../ui/src/Navigation/Navigation.stories.tsx | 20 +++++++++ packages/ui/src/Navigation/Navigation.tsx | 2 +- .../ui/src/Navigation/NavigationIsland.tsx | 2 +- .../ui/src/Navigation/NavigationStandard.tsx | 2 +- .../Navigation/parts/NavigationPart_Links.tsx | 44 +++++++++++++++++-- packages/ui/src/SearchInput/SearchInput.tsx | 34 ++++++++++++++ 7 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 packages/ui/src/SearchInput/SearchInput.tsx diff --git a/.storybook/main.ts b/.storybook/main.ts index 6b84524..7186a40 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -1,4 +1,6 @@ import type { StorybookConfig } from '@storybook/react-vite'; +import { resolve } from 'node:path'; +import { mergeConfig } from 'vite'; const config: StorybookConfig = { stories: [ @@ -17,5 +19,17 @@ const config: StorybookConfig = { name: '@storybook/react-vite', options: {}, }, + viteFinal: (config) => { + return mergeConfig(config, { + resolve: { + alias: [ + { + find: /^@do-ob\/ui(\/?.*)/, + replacement: resolve('packages/ui/src$1'), + }, + ], + }, + }); + }, }; export default config; diff --git a/packages/ui/src/Navigation/Navigation.stories.tsx b/packages/ui/src/Navigation/Navigation.stories.tsx index c2f53dc..98baf5a 100644 --- a/packages/ui/src/Navigation/Navigation.stories.tsx +++ b/packages/ui/src/Navigation/Navigation.stories.tsx @@ -30,6 +30,26 @@ const links: Link[] = [ { title: 'Location', url: '#location', + links: [ + { + title: 'Address', + url: '#address', + }, + { + title: 'Map', + url: '#map', + links: [ + { + title: 'Google Map', + url: '#google-map', + }, + { + title: 'Apple Map', + url: '#apple-map', + }, + ] + }, + ], }, { title: 'Email', diff --git a/packages/ui/src/Navigation/Navigation.tsx b/packages/ui/src/Navigation/Navigation.tsx index 8edc383..c4912de 100644 --- a/packages/ui/src/Navigation/Navigation.tsx +++ b/packages/ui/src/Navigation/Navigation.tsx @@ -1,4 +1,4 @@ -import type { Link, ThemeColor } from '../types'; +import type { Link, ThemeColor } from '@do-ob/ui/types'; import { NavigationStandard } from './NavigationStandard'; import { NavigationIsland } from './NavigationIsland'; diff --git a/packages/ui/src/Navigation/NavigationIsland.tsx b/packages/ui/src/Navigation/NavigationIsland.tsx index c110927..83ac14a 100644 --- a/packages/ui/src/Navigation/NavigationIsland.tsx +++ b/packages/ui/src/Navigation/NavigationIsland.tsx @@ -21,7 +21,7 @@ export function NavigationIsland({
- +
diff --git a/packages/ui/src/Navigation/NavigationStandard.tsx b/packages/ui/src/Navigation/NavigationStandard.tsx index aeaa221..e40fd56 100644 --- a/packages/ui/src/Navigation/NavigationStandard.tsx +++ b/packages/ui/src/Navigation/NavigationStandard.tsx @@ -20,7 +20,7 @@ export function NavigationStandard({ - + diff --git a/packages/ui/src/Navigation/parts/NavigationPart_Links.tsx b/packages/ui/src/Navigation/parts/NavigationPart_Links.tsx index b16de1b..6b8e719 100644 --- a/packages/ui/src/Navigation/parts/NavigationPart_Links.tsx +++ b/packages/ui/src/Navigation/parts/NavigationPart_Links.tsx @@ -1,6 +1,7 @@ import { NavbarMenuItem, Link, Button, Popover, PopoverTrigger, PopoverContent } from '@nextui-org/react'; import { ChevronDownIcon } from '@heroicons/react/24/solid'; import { Link as LinkType } from '@do-ob/ui/types'; +import { clsx } from '@do-ob/core'; /** * Navigation Brand properties @@ -10,6 +11,11 @@ export interface NavigationPart_LinksProps { * The branding title to display. */ links?: LinkType[]; + + /** + * bg and text colors + */ + colors?: string; } function LinkLeaf({ link }: { link: LinkType }) { @@ -27,7 +33,35 @@ function LinkLeaf({ link }: { link: LinkType }) { ); } -function LinkBranch({ link }: { link: LinkType }) { +function LinkBranch({ links, level }: { links: LinkType[], level: number }) { + + const classes: string[] = []; + if (level === 1) { + classes.push('font-bold'); + classes.push('text-sm'); + } + + if (level === 2) { + classes.push('text-sm'); + } + + if(level > 2) { + classes.push('text-xs'); + } + + return links.map((link) => (<> + + {link.title} + + {link.links?.length && ( +
+ +
+ )} + )); +} + +function LinkTrunk({ link, colors }: { link: LinkType, colors?: string }) { return ( - - + + {link.title} + ); @@ -57,11 +92,12 @@ function LinkBranch({ link }: { link: LinkType }) { */ export function NavigationPart_Links({ links = [], + colors, }: NavigationPart_LinksProps) { return links.length ? links.map((link) => !link.links?.length ? ( ) : ( - + )) : (   diff --git a/packages/ui/src/SearchInput/SearchInput.tsx b/packages/ui/src/SearchInput/SearchInput.tsx new file mode 100644 index 0000000..f27e25e --- /dev/null +++ b/packages/ui/src/SearchInput/SearchInput.tsx @@ -0,0 +1,34 @@ +import { Input } from '@nextui-org/react'; +import { MagnifyingGlassIcon } from '@heroicons/react/24/solid'; + +/** + * SearchInput properties + */ +export interface SearchInputProps { + /** + * The placeholder text to display. + */ + placeholder?: string; +} + +/** + * SearchInput component + */ +export function SearchInput({ + placeholder = 'Type to search...', +}: SearchInputProps) { + return ( + } + type="search" + /> + ); +}