Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ab 219 support right components in sectionheader #322

Merged
merged 4 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/components/section/SectionHeader/SectionHeader.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs'
import { SectionHeader } from './SectionHeader'
import { Button } from "../../button";

<Meta title="Components/Section/SectionHeader" component={SectionHeader} />

# SectionHeader

This component can be used to create a section header swiftly.

It leverages the components [SectionHeaderArea](/docs/components-section-sectionheaderara--docs) and [SectionHeaderTitle](/docs/components-section-sectionheadertitle--docs).
It leverages the components [SectionHeaderArea](/docs/components-section-sectionheaderara--docs), [SectionHeaderRow](/docs/components-section-sectionheaderrow--docs) and [SectionHeaderTitle](/docs/components-section-sectionheadertitle--docs).

export const Template = ({ ...args }) => <SectionHeader {...args} />

Expand All @@ -17,6 +18,18 @@ export const Template = ({ ...args }) => <SectionHeader {...args} />
</Story>
</Canvas>

<Canvas>
<Story name="With right element" args={{ title: 'Header Title', right: <Button>Right</Button> }}>
{Template.bind({})}
</Story>
</Canvas>

<Canvas>
<Story name="Long title with right element" args={{ title: 'Very Long Title: lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet', right: <Button>Right</Button> }}>
{Template.bind({})}
</Story>
</Canvas>

### Props

<ArgsTable story="Default" />
<ArgsTable story="With right element" />
9 changes: 7 additions & 2 deletions src/components/section/SectionHeader/SectionHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { ReactNode } from 'react'
import { SectionHeaderArea } from './SectionHeaderArea'
import { SectionHeaderRow, SectionHeaderRowLayout } from './SectionHeaderRow'
import { SectionHeaderTitle } from './SectionHeaderTitle'

export type SectionHeaderProps = {
title: ReactNode
className?: string
right?: ReactNode
SirCotare marked this conversation as resolved.
Show resolved Hide resolved
}

export function SectionHeader({ className, title }: SectionHeaderProps) {
export function SectionHeader({ className, title, right }: SectionHeaderProps) {
return (
<SectionHeaderArea className={className}>
<SectionHeaderTitle>{title}</SectionHeaderTitle>
<SectionHeaderRow layout={SectionHeaderRowLayout.SpaceBetween}>
<SectionHeaderTitle>{title}</SectionHeaderTitle>
{right}
SirCotare marked this conversation as resolved.
Show resolved Hide resolved
</SectionHeaderRow>
</SectionHeaderArea>
)
}