-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20783 from storybookjs/valentin/ui-improvements
Tab UI Improvements
- Loading branch information
Showing
28 changed files
with
609 additions
and
213 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { styled } from '@storybook/theming'; | ||
import type { ReactElement } from 'react'; | ||
import React, { Children } from 'react'; | ||
|
||
export interface VisuallyHiddenProps { | ||
active?: boolean; | ||
} | ||
|
||
export const VisuallyHidden = styled.div<VisuallyHiddenProps>(({ active }) => | ||
active ? { display: 'block' } : { display: 'none' } | ||
); | ||
|
||
export const childrenToList = (children: any, selected: string) => | ||
Children.toArray(children).map( | ||
({ props: { title, id, color, children: childrenOfChild } }: ReactElement, index) => { | ||
const content = Array.isArray(childrenOfChild) ? childrenOfChild[0] : childrenOfChild; | ||
return { | ||
active: selected ? id === selected : index === 0, | ||
title, | ||
id, | ||
color, | ||
render: | ||
typeof content === 'function' | ||
? content | ||
: ({ active, key }: any) => ( | ||
<VisuallyHidden key={key} active={active} role="tabpanel"> | ||
{content} | ||
</VisuallyHidden> | ||
), | ||
}; | ||
} | ||
); | ||
|
||
export type ChildrenList = ReturnType<typeof childrenToList>; |
Oops, something went wrong.