Skip to content

Commit

Permalink
avoid nested ternary
Browse files Browse the repository at this point in the history
  • Loading branch information
HalvorHaugan committed Oct 8, 2024
1 parent 455236c commit 93016b7
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions @navikt/core/react/src/list/List.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import cl from "clsx";
import React, { forwardRef, useContext } from "react";
import { BodyLong, BodyShort, Heading } from "../typography";
import { BodyLong, BodyShort, Heading, HeadingProps } from "../typography";
import { ListItem } from "./ListItem";
import { ListContext } from "./context";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type { ListItemProps, ListProps } from "./types";

const headingSizeMap: Record<
Exclude<ListProps["size"], undefined>,
HeadingProps["size"]
> = {
small: "xsmall",
medium: "small",
large: "medium",
};

export interface ListComponent
extends React.ForwardRefExoticComponent<
ListProps & React.RefAttributes<HTMLDivElement>
Expand Down Expand Up @@ -63,16 +72,7 @@ export const List = forwardRef<HTMLDivElement, ListProps>(
className={cl("navds-list", `navds-list--${listSize}`, className)}
>
{title && (
<Heading
size={
listSize === "large"
? "medium"
: listSize === "medium"
? "small"
: "xsmall"
}
as={headingTag}
>
<Heading size={headingSizeMap[listSize]} as={headingTag}>
{title}
</Heading>
)}
Expand Down

0 comments on commit 93016b7

Please sign in to comment.