Skip to content

Commit 33c7d4e

Browse files
committed
fix: element type
1 parent 7744ccf commit 33c7d4e

File tree

7 files changed

+22
-12
lines changed

7 files changed

+22
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solved-ac/ui-react",
3-
"version": "0.0.1-alpha.22",
3+
"version": "0.0.1-alpha.23",
44
"description": "React component library used by solved.ac",
55
"author": "shiftpsh",
66
"license": "MIT",

src/components/Button.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ export const Button = React.forwardRef(
106106
return (
107107
<ButtonContainer
108108
as={as}
109+
role="button"
110+
tabindex={0}
109111
ref={ref}
110112
disabled={disabled}
111113
circle={circle}
@@ -130,7 +132,7 @@ export const Button = React.forwardRef(
130132
}}
131133
{...rest}
132134
>
133-
<div>{children}</div>
135+
{children}
134136
</ButtonContainer>
135137
)
136138
}

src/components/Card.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const Card = React.forwardRef(
7070
padding = 'normal',
7171
style,
7272
children,
73-
as,
73+
as = 'div',
7474
...rest
7575
} = props
7676

@@ -80,7 +80,9 @@ export const Card = React.forwardRef(
8080
return (
8181
<CardContainer
8282
ref={ref}
83-
as={as ?? (clickable ? 'button' : 'div')}
83+
as={as}
84+
role={clickable ? 'button' : undefined}
85+
tabindex={clickable ? 0 : undefined}
8486
disabled={disabled && clickable}
8587
clickable={clickable}
8688
padding={padding}
@@ -96,7 +98,7 @@ export const Card = React.forwardRef(
9698
}}
9799
{...rest}
98100
>
99-
<div>{children}</div>
101+
{children}
100102
</CardContainer>
101103
)
102104
}

src/components/ListItem.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const ListItem = React.forwardRef(
8181
padding = 'normal',
8282
style,
8383
children,
84-
as,
84+
as = 'div',
8585
...rest
8686
} = props
8787

@@ -102,7 +102,9 @@ export const ListItem = React.forwardRef(
102102
>
103103
<ListItemContainer
104104
ref={ref}
105-
as={as ?? (clickable ? 'button' : 'div')}
105+
as={as}
106+
role={clickable ? 'button' : undefined}
107+
tabindex={clickable ? 0 : undefined}
106108
disabled={disabled && clickable}
107109
clickable={clickable}
108110
padding={padding}

src/components/PaginationItem.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const PaginationItem = React.forwardRef(
7878
hoverColor,
7979
activeColor,
8080
style,
81-
as = 'button',
81+
as = 'div',
8282
...rest
8383
} = props
8484

@@ -92,6 +92,8 @@ export const PaginationItem = React.forwardRef(
9292
<PaginationItemContainer
9393
ref={ref}
9494
as={as}
95+
role="button"
96+
tabindex={0}
9597
current={current}
9698
disabled={disabled}
9799
style={{

src/components/Tab.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const Tab = React.forwardRef(
7878
hoverColor,
7979
accentColor,
8080
style,
81-
as = 'button',
81+
as = 'div',
8282
...rest
8383
} = props
8484

@@ -93,6 +93,8 @@ export const Tab = React.forwardRef(
9393
<TabContainer
9494
ref={ref}
9595
as={as}
96+
role="button"
97+
tabindex={0}
9698
disabled={disabled}
9799
current={current}
98100
style={{

src/components/Tabs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ interface TabsContainerProps {
1010
multiline: boolean
1111
}
1212

13-
const TabsContainer = styled.div<TabsContainerProps>`
13+
const TabsContainer = styled.nav<TabsContainerProps>`
1414
overflow-x: auto;
1515
display: ${({ fullWidth }) => (fullWidth ? 'flex' : 'block')};
1616
white-space: ${({ multiline }) => (multiline ? 'nowrap' : 'normal')};
1717
flex-wrap: ${({ multiline }) => (multiline ? 'wrap' : 'nowrap')};
1818
`
1919

20-
export type TabsProps<T extends ElementType = 'div'> = {
20+
export type TabsProps<T extends ElementType = 'nav'> = {
2121
fullWidth?: boolean
2222
multiline?: boolean
2323
} & PolymorphicProps<T>
@@ -27,7 +27,7 @@ export const Tabs = React.forwardRef(
2727
props: TabsProps<T>,
2828
ref?: PolymorphicRef<T>
2929
): JSX.Element => {
30-
const { fullWidth = false, multiline = false, as = 'div', ...rest } = props
30+
const { fullWidth = false, multiline = false, as = 'nav', ...rest } = props
3131
return (
3232
<TabsContainer
3333
ref={ref}

0 commit comments

Comments
 (0)