From 0c6395de6cc5df337b64cd0431643b331a35eb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Curda?= Date: Mon, 2 Dec 2024 16:03:13 +0100 Subject: [PATCH] fixup! Feat(web-react): Navigation in React #DS-1524 --- .../components/Navigation/NavigationItem.tsx | 8 +- .../src/components/Navigation/README.md | 128 ++++++++++++++++-- 2 files changed, 116 insertions(+), 20 deletions(-) diff --git a/packages/web-react/src/components/Navigation/NavigationItem.tsx b/packages/web-react/src/components/Navigation/NavigationItem.tsx index 2b79f5841e..ab50a70622 100644 --- a/packages/web-react/src/components/Navigation/NavigationItem.tsx +++ b/packages/web-react/src/components/Navigation/NavigationItem.tsx @@ -4,14 +4,8 @@ import React from 'react'; import { useStyleProps } from '../../hooks'; import { SpiritNavigationProps } from '../../types'; -const defaultProps: Partial = { - isMain: false, - position: undefined, -}; - const NavigationItem = (props: SpiritNavigationProps): JSX.Element => { - const propsWithDefaults = { ...defaultProps, ...props }; - const { children, ...restProps } = propsWithDefaults; + const { children, ...restProps } = props; const { styleProps } = useStyleProps(restProps); diff --git a/packages/web-react/src/components/Navigation/README.md b/packages/web-react/src/components/Navigation/README.md index 7eea484c65..9b2251c9c8 100644 --- a/packages/web-react/src/components/Navigation/README.md +++ b/packages/web-react/src/components/Navigation/README.md @@ -1,31 +1,133 @@ # Navigation +The `Navigation` component provides a versatile and accessible way to build navigation menus. + +The Navigation component consists of the following building blocks: + +- [Navigation](#navigation) + - [NavigationItem](#navigationitem) + - [NavigationLink](#navigationlink) + +## Navigation + +The `Navigation` component is a container for navigation items. + +### Usage + ```jsx -import { Navigation } from '@lmc-eu/spirit-web-react'; +import { Navigation, NavigationItem, NavigationLink } from '@lmc-eu/spirit-web-react'; -
  • - + + Home - -
  • -
  • - Not Home -
  • + + + + About Us + + + Contact +
    ; ``` -## API +### Main Navigation + +The `isMain` prop is used to indicate that the navigation is the main navigation. + +```jsx +{/* NavigationItems go here */} +``` + +### Position -| Name | Type | Default | Required | Description | -| ---------- | ----------------------- | ----------- | -------- | ------------------------------ | -| `children` | `string` \| `ReactNode` | `null` | ✓ | Content of the UNSTABLE_Header | -| `position` | `start` \| `end` | `undefined` | ✕ | position | +The `position` prop is used to specify the position of the navigation. It can be set to `start` or `end`. + +```jsx +{/* NavigationItems go here */} +``` + +### API + +| Name | Type | Default | Required | Description | +| ---------- | ----------------------- | ----------- | -------- | ------------------------------------- | +| `children` | `string` \| `ReactNode` | `null` | ✓ | Content of the Navigation | +| `isMain` | `boolean` | `false` | ✕ | Whether Navigation is main navigation | +| `position` | `start` \| `end` | `undefined` | ✕ | Position of navigation | The components accept [additional attributes][readme-additional-attributes]. If you need more control over the styling of a component, you can use [style props][readme-style-props] and [escape hatches][readme-escape-hatches]. +## NavigationItem + +The `NavigationItem` component is a container for navigation links. + +### Usage + +```jsx +import { NavigationItem, NavigationLink } from '@lmc-eu/spirit-web-react'; + + + + Home + +; +``` + +### API + +| Name | Type | Default | Required | Description | +| ---------- | ----------------------- | ------- | -------- | ----------------------------- | +| `children` | `string` \| `ReactNode` | `null` | ✓ | Content of the NavigationItem | + +## NavigationLink + +The `NavigationLink` component is a link in the navigation. + +### Usage + +```jsx +import { NavigationLink } from '@lmc-eu/spirit-web-react'; + + + Home +; +``` + +### Selected + +The `isSelected` prop is used to indicate that the link is selected. + +```jsx + + Home + +``` + +### Disabled + +The `isDisabled` prop is used to indicate that the link is disabled. + +```jsx + + Home + +``` + +### API + +| Name | Type | Default | Required | Description | +| ------------- | --------------------------------- | ------- | -------- | ----------------------------- | +| `children` | `string` \| `ReactNode` | `null` | ✓ | Content of the NavigationLink | +| `elementType` | `ElementType` | `a` | ✕ | Type of element used as | +| `href` | `string` | - | ✕ | URL of the link | +| `isSelected` | `boolean` | `false` | ✕ | Whether the link is selected | +| `isDisabled` | `boolean` | `false` | ✕ | Whether the link is disabled | +| `ref` | `ForwardedRef` | — | ✕ | Anchor element reference | +| `target` | `string` | `null` | ✕ | Link target | + [readme-additional-attributes]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-react/README.md#additional-attributes [readme-escape-hatches]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-react/README.md#escape-hatches [readme-style-props]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-react/README.md#style-props