-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Tabs): add TabAction, update core ver (#8348)
* feat(Tabs): add TabAction, update core ver * desc updates, prop update * adjust actions default order, add missing flag * update description, add classname to span
- Loading branch information
Showing
17 changed files
with
351 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import * as React from 'react'; | ||
import { css } from '@patternfly/react-styles'; | ||
import styles from '@patternfly/react-styles/css/components/Tabs/tabs'; | ||
import { Button } from '../Button'; | ||
import { getOUIAProps, OUIAProps } from '../../helpers'; | ||
|
||
export interface TabActionProps extends Omit<React.HTMLProps<HTMLButtonElement>, 'ref' | 'type'>, OUIAProps { | ||
/** Content rendered in the tab action */ | ||
children?: React.ReactNode; | ||
/** Additional classes added to the tab action span */ | ||
className?: string; | ||
/** Click callback for tab action button */ | ||
onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void; | ||
/** Flag indicating if the tab action is a help action */ | ||
isHelpAction?: boolean; | ||
/** Flag indicating if the tab action is disabled */ | ||
isDisabled?: boolean; | ||
/** Accessible label for the tab action */ | ||
'aria-label'?: string; | ||
/** @hide Callback for the section ref */ | ||
innerRef?: React.Ref<any>; | ||
} | ||
|
||
const TabActionBase: React.FunctionComponent<TabActionProps> = ({ | ||
children, | ||
className, | ||
onClick, | ||
isHelpAction, | ||
isDisabled, | ||
'aria-label': ariaLabel = 'Tab action', | ||
innerRef, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
ouiaId, | ||
ouiaSafe, | ||
...props | ||
}: TabActionProps) => ( | ||
<span className={css(styles.tabsItemAction, isHelpAction && styles.modifiers.help, className)}> | ||
<Button | ||
ref={innerRef} | ||
type="button" | ||
variant="plain" | ||
aria-label={ariaLabel} | ||
onClick={onClick} | ||
isDisabled={isDisabled} | ||
{...getOUIAProps(TabAction.displayName, ouiaId, ouiaSafe)} | ||
{...props} | ||
> | ||
<span className={css(styles.tabsItemActionIcon)}>{children}</span> | ||
</Button> | ||
</span> | ||
); | ||
|
||
export const TabAction = React.forwardRef((props: TabActionProps, ref: React.Ref<HTMLElement>) => ( | ||
<TabActionBase {...props} innerRef={ref} /> | ||
)); | ||
|
||
TabAction.displayName = 'TabAction'; |
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
45 changes: 45 additions & 0 deletions
45
packages/react-core/src/components/Tabs/__tests__/__snapshots__/Tab.test.tsx.snap
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.