Skip to content

Commit

Permalink
dev: Hero component
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-crowell committed Jun 18, 2024
1 parent 0e069c6 commit 5fa19ba
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 11 deletions.
15 changes: 15 additions & 0 deletions packages/ui/src/components/Hero/Hero.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Meta, StoryObj } from '@storybook/react';

import { Hero } from './Hero';

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

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {}
};

Check failure on line 15 in packages/ui/src/components/Hero/Hero.stories.tsx

View workflow job for this annotation

GitHub Actions / release / integrity / Test

Newline required at end of file but not found
21 changes: 21 additions & 0 deletions packages/ui/src/components/Hero/Hero.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import { HeroProps, HeroProvider } from './data/HeroProvider';
import { clsx, clmg } from '@do-ob/core';

export function Hero(props: HeroProps) {

const { title, subtitle, className } = props;

return (
<HeroProvider {...props}>
<section
aria-label="Introduction"
className={clmg(clsx('flex w-full flex-col items-center justify-center', className))}>
<div>
<h1 className="text-center text-4xl font-bold">{title}</h1>
<p className="text-center text-lg">{subtitle}</p>
</div>
</section>
</HeroProvider>
);
};
40 changes: 40 additions & 0 deletions packages/ui/src/components/Hero/data/HeroProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use client';

import React from 'react';

/**
* Hero section props
*/
export interface HeroProps {
/**
* The title of the hero section
*/
title?: string;
/**
* The subtitle of the hero section
*/
subtitle?: string;

/**
* Custom class name
*/
className?: string;
}

/**
* Hero context
*/
export const HeroContext = React.createContext<HeroProps>({});

/**
* Hero provider
*/
export function HeroProvider({
children, ...props
}: React.PropsWithChildren<HeroProps>) {
return (
<HeroContext.Provider value={props}>
{children}
</HeroContext.Provider>
);
}
7 changes: 4 additions & 3 deletions packages/ui/src/components/Navigation/NavigationExtended.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import React from 'react';
import { Navbar, NavbarContent, NavbarMenuToggle } from '@nextui-org/react';
import { Navbar, NavbarContent } from '@nextui-org/react';
import { clsx, clmg } from '@do-ob/core';
import type { NavigationProps } from './data/NavigationContext';
import { NavigationPart_Brand } from './parts/NavigationPart_Brand';
Expand All @@ -10,6 +10,7 @@ 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';
import { NavigationPart_MenuToggle } from './parts/NavigationPart_MenuToggle';

export function NavigationExtended(props: NavigationProps) {

Expand Down Expand Up @@ -40,8 +41,8 @@ export function NavigationExtended(props: NavigationProps) {
<div className="hidden max-w-64 p-2 md:block">
<NavigationPart_Actions />
</div>
<NavbarMenuToggle
aria-label={isMenuOpen ? 'Close menu' : 'Open menu'}
<NavigationPart_MenuToggle
isMenuOpen={isMenuOpen}
className="md:hidden"
/>
</NavbarContent>
Expand Down
9 changes: 5 additions & 4 deletions packages/ui/src/components/Navigation/NavigationIsland.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

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

import type { NavigationProps } from './data/NavigationContext';
Expand All @@ -11,6 +11,7 @@ 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';
import { NavigationPart_MenuToggle } from './parts/NavigationPart_MenuToggle';

export function NavigationIsland(props: NavigationProps) {

Expand Down Expand Up @@ -43,9 +44,9 @@ export function NavigationIsland(props: NavigationProps) {
<div className="hidden max-w-64 lg:block">
<NavigationPart_Actions />
</div>
<NavbarMenuToggle
aria-label={isMenuOpen ? 'Close menu' : 'Open menu'}
className="lg:hidden"
<NavigationPart_MenuToggle
isMenuOpen={isMenuOpen}
className="md:hidden"
/>
</NavbarContent>

Expand Down
9 changes: 5 additions & 4 deletions packages/ui/src/components/Navigation/NavigationStandard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import React from 'react';
import { Navbar, NavbarContent, NavbarMenuToggle } from '@nextui-org/react';
import { Navbar, NavbarContent } from '@nextui-org/react';
import { clsx, clmg } from '@do-ob/core';
import type { NavigationProps } from './data/NavigationContext';
import { NavigationProvider } from './data/NavigationProvider';
Expand All @@ -10,6 +10,7 @@ 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';
import { NavigationPart_MenuToggle } from './parts/NavigationPart_MenuToggle';

export function NavigationStandard(props: NavigationProps) {

Expand Down Expand Up @@ -37,9 +38,9 @@ export function NavigationStandard(props: NavigationProps) {
<div className="hidden max-w-64 lg:block">
<NavigationPart_Actions />
</div>
<NavbarMenuToggle
aria-label={isMenuOpen ? 'Close menu' : 'Open menu'}
className="lg:hidden"
<NavigationPart_MenuToggle
isMenuOpen={isMenuOpen}
className="md:hidden"
/>
</NavbarContent>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { NavbarMenuToggle } from "@nextui-org/react";

Check failure on line 1 in packages/ui/src/components/Navigation/parts/NavigationPart_MenuToggle.tsx

View workflow job for this annotation

GitHub Actions / release / integrity / Test

Strings must use singlequote

export function NavigationPart_MenuToggle({
isMenuOpen = false,

Check failure on line 4 in packages/ui/src/components/Navigation/parts/NavigationPart_MenuToggle.tsx

View workflow job for this annotation

GitHub Actions / release / integrity / Test

'isMenuOpen' is missing in props validation
className = '',

Check failure on line 5 in packages/ui/src/components/Navigation/parts/NavigationPart_MenuToggle.tsx

View workflow job for this annotation

GitHub Actions / release / integrity / Test

'className' is missing in props validation
}) {

return (
<NavbarMenuToggle
aria-label={isMenuOpen ? 'Close manu' : 'Open menu'}
className={className}
/>
);
}

Check failure on line 14 in packages/ui/src/components/Navigation/parts/NavigationPart_MenuToggle.tsx

View workflow job for this annotation

GitHub Actions / release / integrity / Test

Newline required at end of file but not found
52 changes: 52 additions & 0 deletions packages/ui/src/locale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Locale, LocaleCode } from '@do-ob/ui/types';

import {enUs} from './locale/en-us';

Check failure on line 3 in packages/ui/src/locale.ts

View workflow job for this annotation

GitHub Actions / release / integrity / Test

A space is required after '{'

Check failure on line 3 in packages/ui/src/locale.ts

View workflow job for this annotation

GitHub Actions / release / integrity / Test

A space is required before '}'

const library: Record<LocaleCode, Locale> = {
'en-US': enUs,
'fr-FR': {},
'fr-CA': {},
'de-DE': {},
'en-GB': {},
'ja-JP': {},
'da-DK': {},
'nl-NL': {},
'fi-FI': {},
'it-IT': {},
'nb-NO': {},
'es-ES': {},
'sv-SE': {},
'pt-BR': {},
'zh-CN': {},
'zh-TW': {},
'ko-KR': {},
'bg-BG': {},
'hr-HR': {},
'cs-CZ': {},
'et-EE': {},
'hu-HU': {},
'lv-LV': {},
'lt-LT': {},
'pl-PL': {},
'ro-RO': {},
'ru-RU': {},
'sr-SP': {},
'sk-SK': {},
'sl-SI': {},
'tr-TR': {},
'uk-UA': {},
'ar-AE': {},
'ar-DZ': {},
'AR-EG': {},
'ar-SA': {},
'el-GR': {},
'he-IL': {},
'fa-AF': {},
'am-ET': {},
'hi-IN': {},
'th-TH': {}
}

Check failure on line 48 in packages/ui/src/locale.ts

View workflow job for this annotation

GitHub Actions / release / integrity / Test

Missing semicolon

export function localeLibrary(code: LocaleCode) {
return library[code]

Check failure on line 51 in packages/ui/src/locale.ts

View workflow job for this annotation

GitHub Actions / release / integrity / Test

Missing semicolon
}

Check failure on line 52 in packages/ui/src/locale.ts

View workflow job for this annotation

GitHub Actions / release / integrity / Test

Newline required at end of file but not found
7 changes: 7 additions & 0 deletions packages/ui/src/locale/en-us.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Locale } from '@do-ob/ui/types';

export const enUs: Locale = {
navigation_menu_open_aria_label: 'Open navigation menu',
navigation_menu_close_aria_label: 'Close navigation menu',
hero_aria_label: 'Hero section',
};
2 changes: 2 additions & 0 deletions packages/ui/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './types/locale';

/**
* Theme mode.
*/
Expand Down
24 changes: 24 additions & 0 deletions packages/ui/src/types/locale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export type LocaleCode = 'fr-FR' | 'fr-CA' | 'de-DE' | 'en-US' | 'en-GB' | 'ja-JP' |
'da-DK' | 'nl-NL' | 'fi-FI' | 'it-IT' | 'nb-NO' | 'es-ES' |
'sv-SE' | 'pt-BR' | 'zh-CN' | 'zh-TW' | 'ko-KR' | 'bg-BG' |
'hr-HR' | 'cs-CZ' | 'et-EE' | 'hu-HU' | 'lv-LV' | 'lt-LT' |
'pl-PL' | 'ro-RO' | 'ru-RU' | 'sr-SP' | 'sk-SK' | 'sl-SI' |
'tr-TR' | 'uk-UA' | 'ar-AE' | 'ar-DZ' | 'AR-EG' | 'ar-SA' |
'el-GR' | 'he-IL' | 'fa-AF' | 'am-ET' | 'hi-IN' | 'th-TH';

export interface Locale {
/**
* The navigation menu open button aria label.
*/
navigation_menu_open_aria_label?: string;

/**
* The navigation menu close button aria label.
*/
navigation_menu_close_aria_label?: string;

/**
* Aria label for the Hero section.
*/
hero_aria_label?: string;
}
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5fa19ba

Please sign in to comment.