-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6489805
commit 2fa66e1
Showing
12 changed files
with
477 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/app/ui/components/bullet-separator/bullet-separator.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Caption } from '../typography/caption'; | ||
import { Title } from '../typography/title'; | ||
import { BulletSeparator as Component } from './bullet-separator'; | ||
|
||
/** | ||
* Note that the BulletSeparator component doesn't bring it's own margins, these | ||
* should be appiled separately | ||
*/ | ||
const meta: Meta<typeof Component> = { | ||
component: Component, | ||
tags: ['autodocs'], | ||
title: 'BulletSeparator', | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Component>; | ||
|
||
export const BulletSeparator: Story = { | ||
render: () => ( | ||
<Component> | ||
<span style={{ margin: '0 8px' }}>Item 1</span> | ||
<span style={{ margin: '0 8px' }}>Item 2</span> | ||
<span style={{ margin: '0 8px' }}>Item 3</span> | ||
</Component> | ||
), | ||
}; | ||
|
||
export const WithCaption: Story = { | ||
render: () => ( | ||
<Caption> | ||
<Component> | ||
<span style={{ margin: '0 6px' }}>Item 1</span> | ||
<span style={{ margin: '0 6px' }}>Item 2</span> | ||
<span style={{ margin: '0 6px' }}>Item 3</span> | ||
</Component> | ||
</Caption> | ||
), | ||
}; | ||
|
||
export const WithTitle: Story = { | ||
render: () => ( | ||
<Title> | ||
<Component> | ||
<span style={{ margin: '0 6px' }}>Item 1</span> | ||
<span style={{ margin: '0 6px' }}>Item 2</span> | ||
<span style={{ margin: '0 6px' }}>Item 3</span> | ||
</Component> | ||
</Title> | ||
), | ||
}; |
32 changes: 32 additions & 0 deletions
32
src/app/ui/components/bullet-separator/bullet-separator.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { cloneElement, isValidElement } from 'react'; | ||
|
||
import { Circle, CircleProps } from 'leather-styles/jsx'; | ||
|
||
export function BulletOperator(props: CircleProps) { | ||
return ( | ||
<Circle | ||
display="inline-block" | ||
verticalAlign="middle" | ||
backgroundColor="currentColor" | ||
size="3px" | ||
// Visual adjustment for correct centering on retina displays | ||
transform="translateY(-0.5px)" | ||
{...props} | ||
/> | ||
); | ||
} | ||
|
||
interface BulletSeparatorSeparatorProps { | ||
children: React.ReactNode; | ||
} | ||
export function BulletSeparator({ children }: BulletSeparatorSeparatorProps) { | ||
const parsedChildren = Array.isArray(children) ? children : [children]; | ||
const content = parsedChildren | ||
.flatMap((child, index) => { | ||
if (!isValidElement(child)) return null; | ||
return [cloneElement(child, { key: index }), <BulletOperator key={index + 'dot'} />]; | ||
}) | ||
.filter(val => val !== null) | ||
.slice(0, -1); | ||
return <>{content}</>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.