-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(fuselage): Split
TopBar
components (#1304)
- Loading branch information
1 parent
168ff5b
commit b55322e
Showing
15 changed files
with
441 additions
and
137 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 was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
packages/fuselage/src/components/Sidebar/TopBar/TopBar.spec.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,31 @@ | ||
import { composeStories } from '@storybook/testing-react'; | ||
import { render } from '@testing-library/react'; | ||
import { axe } from 'jest-axe'; | ||
import React from 'react'; | ||
|
||
import * as stories from './TopBar.stories'; | ||
|
||
const testCases = Object.values(composeStories(stories)).map((Story) => [ | ||
Story.storyName || 'Story', | ||
Story, | ||
]); | ||
|
||
describe('[TopBar Rendering]', () => { | ||
test.each(testCases)( | ||
`renders %s without crashing`, | ||
async (_storyname, Story) => { | ||
const tree = render(<Story />); | ||
expect(tree.baseElement).toMatchSnapshot(); | ||
} | ||
); | ||
|
||
test.each(testCases)( | ||
'%s should have no a11y violations', | ||
async (_storyname, Story) => { | ||
const { container } = render(<Story />); | ||
|
||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
} | ||
); | ||
}); |
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
16 changes: 16 additions & 0 deletions
16
packages/fuselage/src/components/Sidebar/TopBar/TopBar.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,16 @@ | ||
import type { ReactNode } from 'react'; | ||
import React from 'react'; | ||
|
||
type TopBarProps = { | ||
children?: ReactNode; | ||
className?: string; | ||
}; | ||
|
||
export const TopBar = ({ className, ...props }: TopBarProps) => ( | ||
<div | ||
className={['rc-box rc-box--full rcx-sidebar-topbar', className] | ||
.filter(Boolean) | ||
.join(' ')} | ||
{...props} | ||
/> | ||
); |
13 changes: 13 additions & 0 deletions
13
packages/fuselage/src/components/Sidebar/TopBar/TopBarAction.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,13 @@ | ||
import type { ComponentProps, Ref } from 'react'; | ||
import React, { forwardRef } from 'react'; | ||
|
||
import { SidebarAction } from '../SidebarActions'; | ||
|
||
type TopBarActionProps = ComponentProps<typeof SidebarAction>; | ||
|
||
export const TopBarAction = forwardRef(function TopBarAction( | ||
props: TopBarActionProps, | ||
ref: Ref<HTMLElement> | ||
) { | ||
return <SidebarAction ref={ref} {...props} />; | ||
}); |
13 changes: 13 additions & 0 deletions
13
packages/fuselage/src/components/Sidebar/TopBar/TopBarActions.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,13 @@ | ||
import type { ComponentProps, Ref } from 'react'; | ||
import React, { forwardRef } from 'react'; | ||
|
||
import { SidebarActions } from '../SidebarActions'; | ||
|
||
type TopBarActionsProps = ComponentProps<typeof SidebarActions>; | ||
|
||
export const TopBarActions = forwardRef(function TopBarActions( | ||
props: TopBarActionsProps, | ||
ref: Ref<HTMLDivElement> | ||
) { | ||
return <SidebarActions ref={ref} {...props} />; | ||
}); |
26 changes: 26 additions & 0 deletions
26
packages/fuselage/src/components/Sidebar/TopBar/TopBarSection.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,26 @@ | ||
import React from 'react'; | ||
|
||
import { SidebarDivider } from '../SidebarDivider'; | ||
import { TopBar } from './TopBar'; | ||
import { TopBarWrapper } from './TopBarWrapper'; | ||
|
||
type TopBarSectionProps = { | ||
children?: React.ReactNode; | ||
className?: string; | ||
}; | ||
|
||
export const TopBarSection = ({ | ||
className, | ||
children, | ||
...props | ||
}: TopBarSectionProps) => ( | ||
<TopBar | ||
className={['rcx-sidebar-topbar--section', className] | ||
.filter(Boolean) | ||
.join(' ')} | ||
{...props} | ||
> | ||
<TopBarWrapper children={children} /> | ||
<SidebarDivider /> | ||
</TopBar> | ||
); |
12 changes: 12 additions & 0 deletions
12
packages/fuselage/src/components/Sidebar/TopBar/TopBarTitle.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,12 @@ | ||
import type { ReactNode } from 'react'; | ||
import React from 'react'; | ||
|
||
import Box from '../../Box'; | ||
|
||
type TopBarTitleProps = { | ||
children?: ReactNode; | ||
}; | ||
|
||
export const TopBarTitle = (props: TopBarTitleProps) => ( | ||
<Box className='rcx-sidebar-topbar__title' withTruncatedText {...props} /> | ||
); |
27 changes: 27 additions & 0 deletions
27
packages/fuselage/src/components/Sidebar/TopBar/TopBarToolBox.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,27 @@ | ||
import type { ReactNode } from 'react'; | ||
import React from 'react'; | ||
|
||
import { SidebarDivider } from '../SidebarDivider'; | ||
import { TopBar } from './TopBar'; | ||
import { TopBarWrapper } from './TopBarWrapper'; | ||
|
||
type TopBarToolBoxProps = { | ||
children?: ReactNode; | ||
className?: string; | ||
}; | ||
|
||
export const TopBarToolBox = ({ | ||
children, | ||
className, | ||
...props | ||
}: TopBarToolBoxProps) => ( | ||
<TopBar | ||
className={['rcx-sidebar-topbar--toolbox', className] | ||
.filter(Boolean) | ||
.join(' ')} | ||
{...props} | ||
> | ||
<TopBarWrapper children={children} /> | ||
<SidebarDivider /> | ||
</TopBar> | ||
); |
13 changes: 13 additions & 0 deletions
13
packages/fuselage/src/components/Sidebar/TopBar/TopBarWrapper.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,13 @@ | ||
import type { ReactNode } from 'react'; | ||
import React from 'react'; | ||
|
||
type TopBarWrapperProps = { | ||
children?: ReactNode; | ||
}; | ||
|
||
export const TopBarWrapper = ({ children }: TopBarWrapperProps) => ( | ||
<div | ||
className='rc-box rc-box--full rcx-sidebar-topbar__wrapper' | ||
children={children} | ||
/> | ||
); |
Oops, something went wrong.