generated from gravity-ui/package-example
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove extra prop, add storybook case
- Loading branch information
1 parent
3017810
commit 3e472a7
Showing
3 changed files
with
127 additions
and
67 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
55 changes: 55 additions & 0 deletions
55
src/components/AdaptiveTabs/__stories__/AdaptiveTabsItems.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,55 @@ | ||
import {SquarePlus, SquareXmark} from '@gravity-ui/icons'; | ||
import {Button, Icon} from '@gravity-ui/uikit'; | ||
import {AdaptiveTabsProps} from '../AdaptiveTabs'; | ||
import React from 'react'; | ||
|
||
const RenderTitleWithWrap = (props: {title: string | React.ReactNode}) => { | ||
const {title} = props; | ||
return ( | ||
<div> | ||
<Button size="xs" view="flat"> | ||
<Icon data={SquarePlus} size="xs" /> | ||
</Button> | ||
|
||
<span | ||
style={{ | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
maxWidth: 'calc(100px - 20px - 20px)', // minus icons width | ||
display: 'inline-block', | ||
verticalAlign: 'top', | ||
}} | ||
title={typeof title === 'string' ? title : undefined} | ||
> | ||
{title} | ||
</span> | ||
<Button size="xs"> | ||
<Icon data={SquareXmark} size="xs" /> | ||
</Button> | ||
</div> | ||
); | ||
}; | ||
|
||
export const adaptiveTabsItems: AdaptiveTabsProps<{}>['items'] = [ | ||
{ | ||
id: 'first', | ||
title: <RenderTitleWithWrap title="First Tab" />, | ||
}, | ||
{ | ||
id: 'active', | ||
title: <RenderTitleWithWrap title="Active Tab" />, | ||
}, | ||
{ | ||
id: 'disabled', | ||
title: <RenderTitleWithWrap title="Disabled With Long Text Tab" />, | ||
disabled: true, | ||
}, | ||
{ | ||
id: 'fourth', | ||
title: <RenderTitleWithWrap title="Fourth Long Text To Show Tab" />, | ||
}, | ||
{ | ||
id: 'fifth', | ||
title: <RenderTitleWithWrap title="One More Long Text Tab To Show" />, | ||
}, | ||
]; |