Merged in fix/3697-prettier-configs (pull request #3396)
fix(SW-3691): Setup one prettier config for whole repo * Setup prettierrc in root and remove other configs Approved-by: Joakim Jäderberg Approved-by: Linus Flood
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import type { Meta, StoryObj } from '@storybook/nextjs-vite'
|
||||
import type { Meta, StoryObj } from "@storybook/nextjs-vite"
|
||||
|
||||
import { expect, fn } from 'storybook/test'
|
||||
import { expect, fn } from "storybook/test"
|
||||
|
||||
import ButtonLink from '.'
|
||||
import buttonMeta from '../Button/Button.stories'
|
||||
import ButtonLink from "."
|
||||
import buttonMeta from "../Button/Button.stories"
|
||||
|
||||
const meta: Meta<typeof ButtonLink> = {
|
||||
title: 'Core Components/ButtonLink',
|
||||
title: "Core Components/ButtonLink",
|
||||
component: ButtonLink,
|
||||
argTypes: {
|
||||
onClick: {
|
||||
table: {
|
||||
type: { summary: 'function' },
|
||||
defaultValue: { summary: 'undefined' },
|
||||
type: { summary: "function" },
|
||||
defaultValue: { summary: "undefined" },
|
||||
},
|
||||
description: 'Callback function to handle link click events.',
|
||||
description: "Callback function to handle link click events.",
|
||||
},
|
||||
variant: buttonMeta.argTypes?.variant,
|
||||
color: buttonMeta.argTypes?.color,
|
||||
@@ -25,16 +25,16 @@ const meta: Meta<typeof ButtonLink> = {
|
||||
fullWidth: buttonMeta.argTypes?.fullWidth,
|
||||
href: {
|
||||
table: {
|
||||
type: { summary: 'string' },
|
||||
defaultValue: { summary: 'undefined' },
|
||||
type: { summary: "string" },
|
||||
defaultValue: { summary: "undefined" },
|
||||
},
|
||||
description: 'The URL that the link points to.',
|
||||
description: "The URL that the link points to.",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const globalStoryPropsInverted = {
|
||||
backgrounds: { value: 'scandicPrimaryDark' },
|
||||
backgrounds: { value: "scandicPrimaryDark" },
|
||||
}
|
||||
export default meta
|
||||
|
||||
@@ -43,12 +43,12 @@ type Story = StoryObj<typeof ButtonLink>
|
||||
export const Default: Story = {
|
||||
args: {
|
||||
onClick: fn(),
|
||||
href: '#',
|
||||
children: 'Button link',
|
||||
href: "#",
|
||||
children: "Button link",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -56,12 +56,12 @@ export const Default: Story = {
|
||||
export const PrimaryLarge: Story = {
|
||||
args: {
|
||||
...Default.args,
|
||||
variant: 'Primary',
|
||||
size: 'lg',
|
||||
variant: "Primary",
|
||||
size: "lg",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -69,11 +69,11 @@ export const PrimaryLarge: Story = {
|
||||
export const PrimaryMedium: Story = {
|
||||
args: {
|
||||
...PrimaryLarge.args,
|
||||
size: 'md',
|
||||
size: "md",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -81,11 +81,11 @@ export const PrimaryMedium: Story = {
|
||||
export const PrimarySmall: Story = {
|
||||
args: {
|
||||
...PrimaryLarge.args,
|
||||
size: 'sm',
|
||||
size: "sm",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -94,12 +94,12 @@ export const PrimaryOnDarkBackground: Story = {
|
||||
globals: globalStoryPropsInverted,
|
||||
args: {
|
||||
...Default.args,
|
||||
variant: 'Primary',
|
||||
size: 'lg',
|
||||
variant: "Primary",
|
||||
size: "lg",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -108,14 +108,14 @@ export const PrimaryInvertedLarge: Story = {
|
||||
globals: globalStoryPropsInverted,
|
||||
args: {
|
||||
...Default.args,
|
||||
variant: 'Primary',
|
||||
color: 'Inverted',
|
||||
size: 'lg',
|
||||
variant: "Primary",
|
||||
color: "Inverted",
|
||||
size: "lg",
|
||||
},
|
||||
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -124,11 +124,11 @@ export const PrimaryInvertedMedium: Story = {
|
||||
globals: globalStoryPropsInverted,
|
||||
args: {
|
||||
...PrimaryInvertedLarge.args,
|
||||
size: 'md',
|
||||
size: "md",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -137,11 +137,11 @@ export const PrimaryInvertedSmall: Story = {
|
||||
globals: globalStoryPropsInverted,
|
||||
args: {
|
||||
...PrimaryInvertedLarge.args,
|
||||
size: 'sm',
|
||||
size: "sm",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -149,12 +149,12 @@ export const PrimaryInvertedSmall: Story = {
|
||||
export const SecondaryLarge: Story = {
|
||||
args: {
|
||||
...Default.args,
|
||||
variant: 'Secondary',
|
||||
size: 'lg',
|
||||
variant: "Secondary",
|
||||
size: "lg",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -162,11 +162,11 @@ export const SecondaryLarge: Story = {
|
||||
export const SecondaryMedium: Story = {
|
||||
args: {
|
||||
...SecondaryLarge.args,
|
||||
size: 'md',
|
||||
size: "md",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -174,11 +174,11 @@ export const SecondaryMedium: Story = {
|
||||
export const SecondarySmall: Story = {
|
||||
args: {
|
||||
...SecondaryLarge.args,
|
||||
size: 'sm',
|
||||
size: "sm",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -187,13 +187,13 @@ export const SecondaryInvertedLarge: Story = {
|
||||
globals: globalStoryPropsInverted,
|
||||
args: {
|
||||
...Default.args,
|
||||
variant: 'Secondary',
|
||||
color: 'Inverted',
|
||||
size: 'lg',
|
||||
variant: "Secondary",
|
||||
color: "Inverted",
|
||||
size: "lg",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -202,11 +202,11 @@ export const SecondaryInvertedMedium: Story = {
|
||||
globals: globalStoryPropsInverted,
|
||||
args: {
|
||||
...SecondaryInvertedLarge.args,
|
||||
size: 'md',
|
||||
size: "md",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -215,11 +215,11 @@ export const SecondaryInvertedSmall: Story = {
|
||||
globals: globalStoryPropsInverted,
|
||||
args: {
|
||||
...SecondaryInvertedLarge.args,
|
||||
size: 'sm',
|
||||
size: "sm",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -227,12 +227,12 @@ export const SecondaryInvertedSmall: Story = {
|
||||
export const TertiaryLarge: Story = {
|
||||
args: {
|
||||
...Default.args,
|
||||
variant: 'Tertiary',
|
||||
size: 'lg',
|
||||
variant: "Tertiary",
|
||||
size: "lg",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -240,11 +240,11 @@ export const TertiaryLarge: Story = {
|
||||
export const TertiaryMedium: Story = {
|
||||
args: {
|
||||
...TertiaryLarge.args,
|
||||
size: 'md',
|
||||
size: "md",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -252,11 +252,11 @@ export const TertiaryMedium: Story = {
|
||||
export const TertiarySmall: Story = {
|
||||
args: {
|
||||
...TertiaryLarge.args,
|
||||
size: 'sm',
|
||||
size: "sm",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -264,12 +264,12 @@ export const TertiarySmall: Story = {
|
||||
export const TextLarge: Story = {
|
||||
args: {
|
||||
...Default.args,
|
||||
variant: 'Text',
|
||||
size: 'lg',
|
||||
variant: "Text",
|
||||
size: "lg",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -277,11 +277,11 @@ export const TextLarge: Story = {
|
||||
export const TextMedium: Story = {
|
||||
args: {
|
||||
...TextLarge.args,
|
||||
size: 'md',
|
||||
size: "md",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -289,11 +289,11 @@ export const TextMedium: Story = {
|
||||
export const TextSmall: Story = {
|
||||
args: {
|
||||
...TextLarge.args,
|
||||
size: 'sm',
|
||||
size: "sm",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -301,12 +301,12 @@ export const TextSmall: Story = {
|
||||
export const TextNoWrapping: Story = {
|
||||
args: {
|
||||
...TextLarge.args,
|
||||
children: 'Text button with wrapping false',
|
||||
children: "Text button with wrapping false",
|
||||
wrapping: false,
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -315,13 +315,13 @@ export const TextInvertedLarge: Story = {
|
||||
globals: globalStoryPropsInverted,
|
||||
args: {
|
||||
...Default.args,
|
||||
variant: 'Text',
|
||||
color: 'Inverted',
|
||||
size: 'lg',
|
||||
variant: "Text",
|
||||
color: "Inverted",
|
||||
size: "lg",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -330,11 +330,11 @@ export const TextInvertedMedium: Story = {
|
||||
globals: globalStoryPropsInverted,
|
||||
args: {
|
||||
...TextInvertedLarge.args,
|
||||
size: 'md',
|
||||
size: "md",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -343,11 +343,11 @@ export const TextInvertedSmall: Story = {
|
||||
globals: globalStoryPropsInverted,
|
||||
args: {
|
||||
...TextInvertedLarge.args,
|
||||
size: 'sm',
|
||||
size: "sm",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -355,13 +355,13 @@ export const TextInvertedSmall: Story = {
|
||||
export const TextWithIcon: Story = {
|
||||
args: {
|
||||
...Default.args,
|
||||
variant: 'Text',
|
||||
children: 'Text with icon',
|
||||
trailingIconName: 'chevron_right',
|
||||
variant: "Text",
|
||||
children: "Text with icon",
|
||||
trailingIconName: "chevron_right",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
@@ -370,11 +370,11 @@ export const TextWithIconInverted: Story = {
|
||||
globals: globalStoryPropsInverted,
|
||||
args: {
|
||||
...TextWithIcon.args,
|
||||
color: 'Inverted',
|
||||
color: "Inverted",
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const link = canvasElement.querySelector('a')
|
||||
if (!link) throw new Error('Link not found')
|
||||
const link = canvasElement.querySelector("a")
|
||||
if (!link) throw new Error("Link not found")
|
||||
expect(link).toBeInTheDocument()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
'use client'
|
||||
"use client"
|
||||
|
||||
import { type ComponentProps } from 'react'
|
||||
import { type ComponentProps } from "react"
|
||||
|
||||
import { variants } from './variants'
|
||||
import { variants } from "./variants"
|
||||
|
||||
import type { VariantProps } from 'class-variance-authority'
|
||||
import Link from 'next/link'
|
||||
import { useIntl } from 'react-intl'
|
||||
import { ButtonIconName } from '../Button/types'
|
||||
import { MaterialIcon } from '../Icons/MaterialIcon'
|
||||
import { Typography } from '../Typography'
|
||||
import type { VariantProps } from "class-variance-authority"
|
||||
import Link from "next/link"
|
||||
import { useIntl } from "react-intl"
|
||||
import { ButtonIconName } from "../Button/types"
|
||||
import { MaterialIcon } from "../Icons/MaterialIcon"
|
||||
import { Typography } from "../Typography"
|
||||
|
||||
export interface ButtonLinkProps
|
||||
extends
|
||||
Omit<ComponentProps<typeof Link>, 'color'>,
|
||||
Omit<ComponentProps<typeof Link>, "color">,
|
||||
VariantProps<typeof variants> {
|
||||
leadingIconName?: ButtonIconName | null
|
||||
trailingIconName?: ButtonIconName | null
|
||||
@@ -44,30 +44,30 @@ export default function ButtonLink({
|
||||
|
||||
const intl = useIntl()
|
||||
const newTabText = intl.formatMessage({
|
||||
id: 'common.linkOpenInNewTab',
|
||||
defaultMessage: 'Opens in a new tab/window',
|
||||
id: "common.linkOpenInNewTab",
|
||||
defaultMessage: "Opens in a new tab/window",
|
||||
})
|
||||
|
||||
return (
|
||||
<Typography
|
||||
variant={
|
||||
size === 'sm'
|
||||
? 'Body/Supporting text (caption)/smBold'
|
||||
: 'Body/Paragraph/mdBold'
|
||||
size === "sm"
|
||||
? "Body/Supporting text (caption)/smBold"
|
||||
: "Body/Paragraph/mdBold"
|
||||
}
|
||||
>
|
||||
<Link
|
||||
className={classNames}
|
||||
href={href}
|
||||
target={target}
|
||||
title={target === '_blank' ? newTabText : ''}
|
||||
title={target === "_blank" ? newTabText : ""}
|
||||
{...props}
|
||||
>
|
||||
{leadingIconName ? (
|
||||
<MaterialIcon
|
||||
icon={leadingIconName}
|
||||
color="CurrentColor"
|
||||
size={size === 'sm' ? 20 : 24}
|
||||
size={size === "sm" ? 20 : 24}
|
||||
/>
|
||||
) : null}
|
||||
{children}
|
||||
@@ -75,7 +75,7 @@ export default function ButtonLink({
|
||||
<MaterialIcon
|
||||
icon={trailingIconName}
|
||||
color="CurrentColor"
|
||||
size={size === 'sm' ? 20 : 24}
|
||||
size={size === "sm" ? 20 : 24}
|
||||
/>
|
||||
) : null}
|
||||
</Link>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { cva } from 'class-variance-authority'
|
||||
import { cva } from "class-variance-authority"
|
||||
|
||||
import { withButton } from '../Button'
|
||||
import buttonStyles from '../Button/button.module.css'
|
||||
import { withButton } from "../Button"
|
||||
import buttonStyles from "../Button/button.module.css"
|
||||
|
||||
export const variants = cva([buttonStyles.button], withButton({}))
|
||||
|
||||
Reference in New Issue
Block a user