File tree Expand file tree Collapse file tree 4 files changed +60
-13
lines changed
Expand file tree Collapse file tree 4 files changed +60
-13
lines changed Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+
3+ import { TStringOrComponent , PolymorphicProps } from './Types' ;
4+
5+ type AriaProps = {
6+ 'aria-label' ?: string ;
7+ 'aria-labelledby' ?: string ;
8+ 'aria-describedby' ?: string ;
9+ role ?: string ;
10+ } ;
11+
12+ type AccessibleButtonProps < T extends TStringOrComponent = 'button' > =
13+ PolymorphicProps <
14+ T ,
15+ {
16+ /** required for accessibility */
17+ label : string ;
18+ isToggleButton ?: boolean ;
19+ } & AriaProps
20+ > ;
21+
22+ export const AccessibleButton : React . FC < AccessibleButtonProps > = ( {
23+ label,
24+ } ) => {
25+ return < button > { label } </ button > ;
26+ } ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+
3+ import { TStringOrComponent , PolymorphicProps } from './Types' ;
4+
5+ type SecondaryIconButtonOwnProps = {
6+ icon : React . ReactElement ;
7+ type ?: 'button' | 'submit' | 'reset' ;
8+ color ?: 'solid' | 'neutral' | 'warning' ;
9+ } ;
10+
11+ type SecondaryIconButtonProps < T extends TStringOrComponent = 'button' > =
12+ PolymorphicProps < T , SecondaryIconButtonOwnProps > ;
13+
14+ export const SecondaryIconButton : React . FC < SecondaryIconButtonProps > = ( {
15+ color,
16+ } ) => {
17+ return < button > { color } </ button > ;
18+ } ;
Original file line number Diff line number Diff line change 11import React , { JSX } from 'react' ;
22
3- type TStringOrComponent = string | React . JSXElementConstructor < any > ;
4-
5- type PolymorphicProps <
6- T extends TStringOrComponent ,
7- Props = { }
8- > = Props &
9- ( T extends React . JSXElementConstructor < infer P >
10- ? P
11- : T extends keyof JSX . IntrinsicElements
12- ? JSX . IntrinsicElements [ T ]
13- : { } ) & {
14- as ?: T ;
15- } ;
3+ import { TStringOrComponent , PolymorphicProps } from './Types' ;
164
175type TooltipTargetOwnProps = {
186 isDisabled ?: boolean ;
Original file line number Diff line number Diff line change 1+ import { JSX } from 'react' ;
2+
3+ export type TStringOrComponent = string | React . JSXElementConstructor < any > ;
4+
5+ export type PolymorphicProps <
6+ T extends TStringOrComponent ,
7+ Props = { }
8+ > = Props &
9+ ( T extends React . JSXElementConstructor < infer P >
10+ ? P
11+ : T extends keyof JSX . IntrinsicElements
12+ ? JSX . IntrinsicElements [ T ]
13+ : { } ) & {
14+ as ?: T ;
15+ } ;
You can’t perform that action at this time.
0 commit comments