Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions packages/lib/src/card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import styled from "@emotion/styled";
import { spaces } from "../common/variables";
import CardPropsType from "./types";

const Card = styled.div<{
hasAction: boolean;
margin: CardPropsType["margin"];
shadowDepth: 0 | 1 | 2;
href?: string;
}>`
const Card = styled.div<
{
hasAction: boolean;
margin: CardPropsType["margin"];
shadowDepth: 0 | 1 | 2;
} & React.AnchorHTMLAttributes<HTMLAnchorElement>
>`
display: flex;
cursor: ${({ hasAction }) => (hasAction ? "pointer" : "unset")};
outline: ${({ hasAction }) => !hasAction && "none"};
Expand Down
23 changes: 13 additions & 10 deletions packages/lib/src/nav-tabs/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ const TabContainer = styled.div`
flex-direction: column;
`;

const TabLink = styled.a<{
disabled: TabProps["disabled"];
iconPosition: NavTabsPropsType["iconPosition"];
}>`
const TabLink = styled.div<
{
disabled: TabProps["disabled"];
iconPosition: NavTabsPropsType["iconPosition"];
} & React.AnchorHTMLAttributes<HTMLAnchorElement>
>`
box-sizing: border-box;
display: flex;
flex-direction: ${({ iconPosition }) => (iconPosition === "top" ? "column" : "row")};
Expand Down Expand Up @@ -96,11 +98,11 @@ const Tab = forwardRef(
notificationNumber = false,
...otherProps
}: TabProps,
ref: Ref<HTMLAnchorElement>
ref: Ref<HTMLAnchorElement | HTMLDivElement>
) => {
const { iconPosition, tabIndex, focusedLabel } = useContext(NavTabsContext) ?? {};
const tabRef = useRef<HTMLAnchorElement>();
const innerRef = useRef<HTMLAnchorElement | null>(null);
const tabRef = useRef<HTMLAnchorElement | HTMLDivElement | null>();
const innerRef = useRef<HTMLAnchorElement | HTMLDivElement | null>(null);
useImperativeHandle(ref, () => innerRef.current!, []);

useEffect(() => {
Expand All @@ -109,7 +111,7 @@ const Tab = forwardRef(
}
}, [children, focusedLabel]);

const handleOnKeyDown = (event: KeyboardEvent<HTMLAnchorElement>) => {
const handleOnKeyDown = (event: KeyboardEvent<HTMLDivElement | HTMLAnchorElement>) => {
switch (event.key) {
case " ":
case "Enter":
Expand All @@ -128,11 +130,12 @@ const Tab = forwardRef(
aria-disabled={disabled}
aria-selected={active}
disabled={disabled}
as={href ? "a" : onClick ? "button" : "div"}
href={!disabled ? href : undefined}
onClick={!disabled ? onClick : undefined}
iconPosition={iconPosition}
onClick={onClick}
onKeyDown={handleOnKeyDown}
ref={(anchorRef: HTMLAnchorElement) => {
ref={(anchorRef: HTMLAnchorElement | HTMLDivElement | null) => {
tabRef.current = anchorRef;
if (ref) {
if (typeof ref === "function") ref(anchorRef);
Expand Down