feat: comment updates

This commit is contained in:
Simon Emanuelsson
2025-05-03 21:56:56 +02:00
committed by Michael Zetterberg
parent 29abc3cba6
commit 91933f47cf
6 changed files with 86 additions and 68 deletions

View File

@@ -2,6 +2,7 @@
import { zodResolver } from "@hookform/resolvers/zod" import { zodResolver } from "@hookform/resolvers/zod"
import { usePathname, useRouter, useSearchParams } from "next/navigation" import { usePathname, useRouter, useSearchParams } from "next/navigation"
import { cx } from "class-variance-authority"
import { useCallback, useEffect, useState } from "react" import { useCallback, useEffect, useState } from "react"
import { Label } from "react-aria-components" import { Label } from "react-aria-components"
import { FormProvider, useForm } from "react-hook-form" import { FormProvider, useForm } from "react-hook-form"
@@ -480,7 +481,9 @@ export default function PaymentClient({
return ( return (
<section <section
className={`${styles.paymentSection} ${allRoomsComplete && !isSubmitting ? "" : styles.disabled}`} className={cx(styles.paymentSection, {
[styles.disabled]: !allRoomsComplete || isSubmitting,
})}
> >
<header> <header>
<Title level="h2" as="h4"> <Title level="h2" as="h4">

View File

@@ -24,24 +24,20 @@ export function Button({
className, className,
}) })
let loadingType: LoadingProps['type'] = 'White'
if (variant === 'Secondary') {
if (color === 'Inverted') {
loadingType = 'White'
} else {
loadingType = 'Dark'
}
} else {
if (color === 'Inverted') {
loadingType = 'Dark'
} else {
loadingType = 'White'
}
}
return ( return (
<ButtonRAC {...props} className={classNames}> <ButtonRAC {...props} className={classNames}>
{({ isPending }) => { {({ isPending, isHovered }) => {
let loadingType: LoadingProps['type'] = 'White'
if (variant === 'Secondary') {
if (isHovered || color !== 'Inverted') {
loadingType = 'Dark'
}
} else {
if (color === 'Inverted') {
loadingType = 'Dark'
}
}
return ( return (
<> <>
{children} {children}

View File

@@ -8,9 +8,14 @@
justify-content: center; justify-content: center;
gap: var(--Space-x05); gap: var(--Space-x05);
&:disabled { &:disabled,
&[data-disabled] {
cursor: unset; cursor: unset;
} }
&[data-pending] {
cursor: progress;
}
} }
.size-large { .size-large {

View File

@@ -3,13 +3,15 @@ import 'react-material-symbols/rounded'
import type { Meta, StoryObj } from '@storybook/react' import type { Meta, StoryObj } from '@storybook/react'
import { Loading } from './Loading' import { Loading } from './Loading'
import { config } from './variants'
const meta: Meta<typeof Loading> = { const meta: Meta<typeof Loading> = {
title: 'Components/Loading', title: 'Components/Loading',
component: Loading, component: Loading,
argTypes: { argTypes: {
type: { type: {
control: 'text', control: 'select',
options: Object.keys(config.variants.type),
}, },
size: { size: {
control: 'number', control: 'number',

View File

@@ -1,35 +1,40 @@
import styles from './loading.module.css'
import { VariantProps } from 'class-variance-authority' import { VariantProps } from 'class-variance-authority'
import { variants } from './variants' import { variants } from './variants'
import { ProgressBar } from 'react-aria-components' import { ProgressBar } from 'react-aria-components'
export interface LoadingProps extends VariantProps<typeof variants> { export interface LoadingProps extends VariantProps<typeof variants> {
ariaLabel?: string
size?: number size?: number
} }
export function Loading({ type, size = 20 }: LoadingProps) { export function Loading({
ariaLabel = 'Loading',
size = 20,
type,
}: LoadingProps) {
const classNames = variants({ const classNames = variants({
type, type,
}) })
return ( return (
<ProgressBar isIndeterminate className={classNames}> <ProgressBar aria-label={ariaLabel} isIndeterminate className={classNames}>
<svg <svg
className={classNames}
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
width={size}
height={size}
viewBox="0 0 20 21"
fill="none" fill="none"
height={size}
viewBox="0 0 20 20"
width={size}
> >
<circle className={styles.dot} cx="10" cy="2.64147" r="1.73913" /> <circle cx="50%" cy="8.6955%" r="8.6955%" />
<circle className={styles.dot} cx="16.087" cy="5.25018" r="1.73913" /> <circle cx="80.435%" cy="21.73915%" r="8.6955%" />
<circle className={styles.dot} cx="18.2609" cy="10.9023" r="1.73913" /> <circle cx="91.3045%" cy="50%" r="8.6955%" />
<circle className={styles.dot} cx="16.087" cy="16.5545" r="1.73913" /> <circle cx="80.435%" cy="78.261%" r="8.6955%" />
<circle className={styles.dot} cx="10" cy="19.1632" r="1.73913" /> <circle cx="50%" cy="91.3045%" r="8.6955%" />
<circle className={styles.dot} cx="3.91304" cy="16.5545" r="1.73913" /> <circle cx="19.5652%" cy="78.261%" r="8.6955%" />
<circle className={styles.dot} cx="1.73913" cy="10.9023" r="1.73913" /> <circle cx="8.6955%" cy="50%" r="8.6955%" />
<circle className={styles.dot} cx="3.91304" cy="5.25018" r="1.73913" /> <circle cx="19.5652%" cy="21.73915%" r="8.6955%" />
</svg> </svg>
</ProgressBar> </ProgressBar>
) )

View File

@@ -1,50 +1,57 @@
.loading { .loading {
display: flex; display: flex;
align-items: center; align-items: center;
}
.dot { & circle {
animation: pulse 0.8s linear infinite; animation: pulse 0.8s linear infinite;
transform-origin: center;
}
.dark .dot { &:nth-child(1) {
fill: var(--Icon-Interactive-Default); animation-delay: -0.7s;
} }
.white .dot { &:nth-child(2) {
fill: var(--Icon-Inverted); animation-delay: -0.6s;
} }
.dot:nth-child(1) { &:nth-child(3) {
animation-delay: -0.7s; animation-delay: -0.5s;
} }
.dot:nth-child(2) {
animation-delay: -0.6s; &:nth-child(4) {
} animation-delay: -0.4s;
.dot:nth-child(3) { }
animation-delay: -0.5s;
} &:nth-child(5) {
.dot:nth-child(4) { animation-delay: -0.3s;
animation-delay: -0.4s; }
}
.dot:nth-child(5) { &:nth-child(6) {
animation-delay: -0.3s; animation-delay: -0.2s;
} }
.dot:nth-child(6) {
animation-delay: -0.2s; &:nth-child(7) {
} animation-delay: -0.1s;
.dot:nth-child(7) { }
animation-delay: -0.1s;
} &:nth-child(8) {
.dot:nth-child(8) { animation-delay: 0s;
animation-delay: 0s; }
}
&.dark circle {
fill: var(--Icon-Interactive-Default);
}
&.white circle {
fill: var(--Icon-Inverted);
}
} }
@keyframes pulse { @keyframes pulse {
0% { 0% {
opacity: 1; opacity: 1;
} }
100% { 100% {
opacity: 0; opacity: 0;
} }