-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(redmine 1257478): added ResponsiveTabs component (#42)
- Loading branch information
1 parent
599cf01
commit 83ffae5
Showing
10 changed files
with
703 additions
and
113 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@smile/react-front-kit': minor | ||
--- | ||
|
||
Added `ResponsiveTabs` component |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
33 changes: 33 additions & 0 deletions
33
packages/react-front-kit/src/Components/ResponsiveTabs/ResponsiveTabs.mock.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,33 @@ | ||
import { Tabs } from '@mantine/core'; | ||
|
||
export const contents = ( | ||
<> | ||
<Tabs.Panel value="1">First Content</Tabs.Panel> | ||
<Tabs.Panel value="2">Second Content</Tabs.Panel> | ||
<Tabs.Panel value="3">Third Content</Tabs.Panel> | ||
<Tabs.Panel value="4">Fourth Content</Tabs.Panel> | ||
<Tabs.Panel value="5">Overflow 1 Content</Tabs.Panel> | ||
<Tabs.Panel value="6">Overflow 2 Content</Tabs.Panel> | ||
</> | ||
); | ||
|
||
export const tabs = [ | ||
<Tabs.Tab key={1} id="tab-1" value="1"> | ||
First | ||
</Tabs.Tab>, | ||
<Tabs.Tab key={2} data-testid="test-tab" id="tab-1" value="2"> | ||
Second | ||
</Tabs.Tab>, | ||
<Tabs.Tab key={3} value="3"> | ||
Third | ||
</Tabs.Tab>, | ||
<Tabs.Tab key={4} value="4"> | ||
Fourth | ||
</Tabs.Tab>, | ||
<Tabs.Tab key={5} value="5"> | ||
Overflow 1 | ||
</Tabs.Tab>, | ||
<Tabs.Tab key={6} value="6"> | ||
Overflow 2 | ||
</Tabs.Tab>, | ||
]; |
57 changes: 57 additions & 0 deletions
57
packages/react-front-kit/src/Components/ResponsiveTabs/ResponsiveTabs.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,57 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import type { ReactNode } from 'react'; | ||
|
||
import { sleep } from '@smile/react-front-kit-shared/src/storybook-utils'; | ||
import { expect } from '@storybook/jest'; | ||
import { userEvent, within } from '@storybook/testing-library'; | ||
|
||
import { ResponsiveTabs as Cmp } from './ResponsiveTabs'; | ||
import { contents, tabs } from './ResponsiveTabs.mock'; | ||
|
||
const meta = { | ||
component: Cmp, | ||
tags: ['autodocs'], | ||
title: '3-custom/Components/ResponsiveTabs', | ||
} satisfies Meta<typeof Cmp>; | ||
|
||
export default meta; | ||
type IStory = StoryObj<typeof meta>; | ||
|
||
function Wrapper({ children }: { children: ReactNode }): ReactNode { | ||
return ( | ||
<div | ||
style={{ | ||
border: '1px solid darkgrey', | ||
boxSizing: 'content-box', | ||
height: 250, | ||
margin: 'auto', | ||
overflow: 'hidden', | ||
padding: 30, | ||
resize: 'both', | ||
width: 300, | ||
}} | ||
> | ||
{children} | ||
</div> | ||
); | ||
} | ||
|
||
export const ResponsiveTabs: IStory = { | ||
args: { | ||
children: contents, | ||
defaultValue: '1', | ||
tabs, | ||
}, | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
await expect(canvas.getByText('First Content')).toBeVisible(); | ||
await userEvent.click(canvas.getAllByTestId('test-tab')[1]); | ||
await sleep(200); | ||
await expect(canvas.getByText('Second Content')).toBeVisible(); | ||
}, | ||
render: ({ children, ...props }) => ( | ||
<Wrapper> | ||
<Cmp {...props}>{children}</Cmp> | ||
</Wrapper> | ||
), | ||
}; |
Oops, something went wrong.