Skip to content

πŸ“ˆ Open source, privacy-first web analytics β€” a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Refactor Button API and use it instead of custom raw buttons in the app

Blue Mouseb6fe52274b2e
diff --git a/web/app/components/GithubAuth.tsx b/web/app/components/GithubAuth.tsx
index 16bb05372..8164f0ac7 100644
--- a/web/app/components/GithubAuth.tsx
+++ b/web/app/components/GithubAuth.tsx
@@ -18,10 +18,9 @@ const GithubAuth = ({ className, onClick, disabled }: GoogleAuthProps) => {
return (
<Button
+ variant='secondary'
className={cx(className, 'flex items-center justify-center')}
onClick={onClick}
- secondary
- regular
disabled={disabled}
>
<>
diff --git a/web/app/components/GoogleAuth.tsx b/web/app/components/GoogleAuth.tsx
index a0bad5ab4..22340bb61 100644
--- a/web/app/components/GoogleAuth.tsx
+++ b/web/app/components/GoogleAuth.tsx
@@ -15,10 +15,9 @@ const GoogleAuth = ({ onClick, className, disabled }: GoogleAuthProps) => {
return (
<Button
+ variant='secondary'
className={cx(className, 'flex items-center justify-center')}
onClick={onClick}
- secondary
- regular
disabled={disabled}
>
<>
diff --git a/web/app/components/NotificationChannels/EnableWebPushButton.tsx b/web/app/components/NotificationChannels/EnableWebPushButton.tsx
index 83ba5d4ca..24ab4dfa1 100644
--- a/web/app/components/NotificationChannels/EnableWebPushButton.tsx
+++ b/web/app/components/NotificationChannels/EnableWebPushButton.tsx
@@ -182,8 +182,8 @@ const EnableWebPushButton = ({
return (
<Button
- secondary
- small
+ variant='secondary'
+ size='xs'
onClick={onClick}
loading={loading}
className={className}
diff --git a/web/app/components/NotificationChannels/NotificationChannels.tsx b/web/app/components/NotificationChannels/NotificationChannels.tsx
index 7488c322f..b138aedc1 100644
--- a/web/app/components/NotificationChannels/NotificationChannels.tsx
+++ b/web/app/components/NotificationChannels/NotificationChannels.tsx
@@ -324,8 +324,7 @@ const NotificationChannels = ({
</Text>
</div>
<Button
- small
- primary
+ size='xs'
onClick={() => {
setForm(blankForm(allowedTypes[0]))
setCreating(true)
@@ -363,8 +362,6 @@ const NotificationChannels = ({
</Text>
<div className='mt-5 flex justify-center'>
<Button
- primary
- regular
onClick={() => {
setForm(blankForm(allowedTypes[0]))
setCreating(true)
@@ -421,8 +418,8 @@ const NotificationChannels = ({
<div className='flex shrink-0 flex-wrap items-center gap-1.5'>
{canVerify ? (
<Button
- small
- secondary
+ variant='secondary'
+ size='xs'
onClick={() => onVerify(channel)}
disabled={isMutating}
>
diff --git a/web/app/components/OIDCAuth.tsx b/web/app/components/OIDCAuth.tsx
index e2a19bd25..6e1e9ba52 100644
--- a/web/app/components/OIDCAuth.tsx
+++ b/web/app/components/OIDCAuth.tsx
@@ -15,10 +15,9 @@ const OIDCAuth = ({ onClick, className, disabled }: OIDCAuthProps) => {
return (
<Button
+ variant='secondary'
className={cx(className, 'flex items-center justify-center')}
onClick={onClick}
- secondary
- regular
disabled={disabled}
>
<KeyIcon className='mr-2 size-5' />
diff --git a/web/app/components/pricing/BillingPricing.tsx b/web/app/components/pricing/BillingPricing.tsx
index fd677c0ff..fa19da3fb 100644
--- a/web/app/components/pricing/BillingPricing.tsx
+++ b/web/app/components/pricing/BillingPricing.tsx
@@ -454,6 +454,7 @@ const BillingPricing = ({
</span>
</div>
<Button
+ size='xs'
onClick={() => {
const action = getActionLabel(tier)
@@ -466,8 +467,6 @@ const BillingPricing = ({
type='button'
loading={planCodeLoading === tier.planCode}
disabled={isDisabledForTier(tier)}
- small
- primary
>
{getActionLabel(tier)}
</Button>
diff --git a/web/app/modals/AnnotationModal.tsx b/web/app/modals/AnnotationModal.tsx
index 4262bd736..2a44da8bd 100644
--- a/web/app/modals/AnnotationModal.tsx
+++ b/web/app/modals/AnnotationModal.tsx
@@ -1,10 +1,10 @@
-import { InfoIcon } from '@phosphor-icons/react'
import { useState, useEffect, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { Annotation } from '~/lib/models/Project'
+import Alert from '~/ui/Alert'
+import Button from '~/ui/Button'
import Datepicker from '~/ui/Datepicker'
-import Spin from '~/ui/icons/Spin'
import Modal from '~/ui/Modal'
import Textarea from '~/ui/Textarea'
import { cn } from '~/utils/generic'
@@ -85,34 +85,36 @@ const AnnotationModal = ({
customButtons={
<div className='flex w-full flex-col-reverse gap-2 sm:flex-row sm:justify-between'>
{isEditMode && onDelete && allowedToManage ? (
- <button
- type='button'
+ <Button
+ variant='danger-outline'
+ size='lg'
onClick={_onDelete}
disabled={loading}
- className='inline-flex w-full justify-center rounded-md border border-red-300 bg-white px-4 py-2 text-base font-medium text-red-700 transition-colors hover:bg-red-50 sm:w-auto sm:text-sm dark:border-red-600 dark:bg-slate-900 dark:text-red-400 dark:hover:bg-red-900/20'
+ className='w-full justify-center sm:w-auto'
>
{t('common.delete')}
- </button>
+ </Button>
) : (
<div />
)}
<div className='flex flex-col-reverse gap-2 sm:flex-row'>
- <button
- type='button'
+ <Button
+ variant='secondary'
+ size='lg'
onClick={_onClose}
- className='inline-flex w-full justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-base font-medium text-gray-700 transition-colors hover:bg-gray-50 sm:w-auto sm:text-sm dark:border-slate-600 dark:bg-slate-900 dark:text-gray-50 dark:hover:bg-gray-700'
+ className='w-full justify-center sm:w-auto'
>
{t('common.cancel')}
- </button>
- <button
- type='button'
+ </Button>
+ <Button
+ size='lg'
onClick={_onSubmit}
- disabled={!date || !text.trim() || !allowedToManage || loading}
- className='inline-flex w-full items-center justify-center gap-2 rounded-md bg-indigo-600 px-4 py-2 text-base font-medium text-white transition-colors hover:bg-indigo-700 disabled:cursor-not-allowed disabled:opacity-70 sm:w-auto sm:text-sm'
+ disabled={!date || !text.trim() || !allowedToManage}
+ loading={loading}
+ className='w-full justify-center sm:w-auto'
>
- {loading ? <Spin alwaysLight /> : null}
{t('common.save')}
- </button>
+ </Button>
</div>
</div>
}
@@ -162,12 +164,7 @@ const AnnotationModal = ({
{text.length}/{MAX_ANNOTATION_LENGTH}
</p>
</div>
- <div className='flex items-start gap-2 rounded-md bg-blue-50 p-3 dark:bg-blue-900/20'>
- <InfoIcon className='mt-0.5 h-4 w-4 shrink-0 text-blue-600 dark:text-blue-400' />
- <p className='text-xs text-blue-700 dark:text-blue-300'>
- {t('modals.annotation.warning')}
- </p>
- </div>
+ <Alert variant='info'>{t('modals.annotation.warning')}</Alert>
</div>
}
title={
diff --git a/web/app/modals/NewFunnel.tsx b/web/app/modals/NewFunnel.tsx
index 1af0f277b..21f9ff43e 100644
--- a/web/app/modals/NewFunnel.tsx
+++ b/web/app/modals/NewFunnel.tsx
@@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next'
import { MIN_FUNNEL_STEPS, MAX_FUNNEL_STEPS } from '~/lib/constants'
import { Funnel } from '~/lib/models/Project'
import { useCurrentProject } from '~/providers/CurrentProjectProvider'
+import Button from '~/ui/Button'
import Input from '~/ui/Input'
import Modal from '~/ui/Modal'
import Select from '~/ui/Select'
@@ -163,9 +164,8 @@ const NewFunnel = ({
disabled={!allowedToManage}
/>
{steps.length > MIN_FUNNEL_STEPS && allowedToManage ? (
- <button
- type='button'
- className='rounded-md border border-transparent p-1.5 text-gray-800 transition-colors hover:border-gray-300 hover:bg-gray-50 hover:text-gray-900 dark:text-slate-400 hover:dark:border-slate-700/80 dark:hover:bg-slate-900 dark:hover:text-slate-300'
+ <Button
+ variant='icon'
onClick={() => {
const newSteps = [...steps]
newSteps.splice(index, 1)
@@ -174,7 +174,7 @@ const NewFunnel = ({
aria-label='Remove step'
>
<TrashIcon className='size-5' />
- </button>
+ </Button>
) : null}
</div>
))}
diff --git a/web/app/pages/Auth/CreateNewPassword/CreateNewPassword.tsx b/web/app/pages/Auth/CreateNewPassword/CreateNewPassword.tsx
index 9ae0c3132..664350b3c 100644
--- a/web/app/pages/Auth/CreateNewPassword/CreateNewPassword.tsx
+++ b/web/app/pages/Auth/CreateNewPassword/CreateNewPassword.tsx
@@ -51,11 +51,10 @@ const CreateNewPassword = () => {
disabled={isSubmitting}
/>
<Button
+ size='xl'
className='w-full justify-center'
type='submit'
loading={isSubmitting}
- primary
- giant
>
{t('auth.recovery.save')}
</Button>
diff --git a/web/app/pages/Auth/ForgotPassword/ForgotPassword.tsx b/web/app/pages/Auth/ForgotPassword/ForgotPassword.tsx
index c2555fb9f..bed809d4c 100644
--- a/web/app/pages/Auth/ForgotPassword/ForgotPassword.tsx
+++ b/web/app/pages/Auth/ForgotPassword/ForgotPassword.tsx
@@ -56,11 +56,10 @@ const ForgotPassword = () => {
disabled={isSubmitting}
/>
<Button
+ size='xl'
className='w-full justify-center'
type='submit'
loading={isSubmitting}
- primary
- giant
>
{t('auth.forgot.reset')}
</Button>
diff --git a/web/app/pages/Auth/Signin/Signin.tsx b/web/app/pages/Auth/Signin/Signin.tsx
index 3080dcad3..6f20f414b 100644
--- a/web/app/pages/Auth/Signin/Signin.tsx
+++ b/web/app/pages/Auth/Signin/Signin.tsx
@@ -374,19 +374,18 @@ const Signin = () => {
<div className='flex flex-col gap-3 pt-2'>
<Button
+ size='xl'
type='submit'
loading={isLinkingLoading}
- primary
- giant
className='w-full justify-center'
>
{t('auth.linkAccount.linkButton')}
</Button>
<Button
+ size='xl'
type='button'
onClick={handleCancelLinking}
disabled={isLinkingLoading}
- giant
className='w-full justify-center'
>
{t('auth.linkAccount.returnToSignIn')}
@@ -451,7 +450,7 @@ const Signin = () => {
/>
) : null}
</Text>
- <Button type='submit' loading={is2FALoading} primary large>
+ <Button size='lg' type='submit' loading={is2FALoading}>
{t('common.continue')}
</Button>
</div>
@@ -576,11 +575,10 @@ const Signin = () => {
</div>
<Button
+ size='xl'
className='mt-6 w-full justify-center'
type='submit'
loading={isFormSubmitting}
- primary
- giant
>
{t('auth.signin.button')}
</Button>
diff --git a/web/app/pages/Auth/Signup/InvitationSignup.tsx b/web/app/pages/Auth/Signup/InvitationSignup.tsx
index 4947b0c55..e37948975 100644
--- a/web/app/pages/Auth/Signup/InvitationSignup.tsx
+++ b/web/app/pages/Auth/Signup/InvitationSignup.tsx
@@ -223,11 +223,10 @@ const InvitationSignup = () => {
</div>
<Button
+ size='xl'
className='mt-6 flex w-full items-center justify-center gap-1'
type='submit'
loading={isFormSubmitting}
- primary
- giant
>
<span>
{t('auth.invitation.createAndJoin', { type: typeLabel })}
diff --git a/web/app/pages/Auth/Signup/Signup.tsx b/web/app/pages/Auth/Signup/Signup.tsx
index 50c1298d9..9e56ea2a0 100644
--- a/web/app/pages/Auth/Signup/Signup.tsx
+++ b/web/app/pages/Auth/Signup/Signup.tsx
@@ -401,11 +401,10 @@ const Signup = () => {
</div>
<Button
+ size='xl'
className='mt-6 flex w-full items-center justify-center gap-1'
type='submit'
loading={isFormSubmitting}
- primary
- giant
>
<span>{t('common.continue')}</span>
<ArrowRightIcon className='size-4 translate-y-px' />
diff --git a/web/app/pages/Captcha/CaptchaDemo.tsx b/web/app/pages/Captcha/CaptchaDemo.tsx
index 1db708b5b..9dba82cfe 100644
--- a/web/app/pages/Captcha/CaptchaDemo.tsx
+++ b/web/app/pages/Captcha/CaptchaDemo.tsx
@@ -242,12 +242,7 @@ const CaptchaDemo = () => {
})).find((opt) => opt.value === config.dummySecret)}
/>
</div>
- <Button
- type='button'
- primary
- regular
- onClick={handleValidateToken}
- >
+ <Button type='button' onClick={handleValidateToken}>
{t('captchaPage.demoPage.validateButton')}
</Button>
</div>
diff --git a/web/app/pages/Captcha/index.tsx b/web/app/pages/Captcha/index.tsx
index 4fb759ab9..214ee7f82 100644
--- a/web/app/pages/Captcha/index.tsx
+++ b/web/app/pages/Captcha/index.tsx
@@ -378,9 +378,8 @@ const Captcha = () => {
) : null}
<Button
+ size='xl'
type='submit'
- primary
- giant
className='w-full justify-center'
>
{t('captchaPage.demo.submit')}
diff --git a/web/app/pages/Dashboard/Dashboard.tsx b/web/app/pages/Dashboard/Dashboard.tsx
index cdd913bff..5e6103213 100644
--- a/web/app/pages/Dashboard/Dashboard.tsx
+++ b/web/app/pages/Dashboard/Dashboard.tsx
@@ -362,7 +362,7 @@ const Dashboard = () => {
<span>{t('titles.dashboard')}</span>
{isSearchActive ? (
<Button
- icon
+ variant='icon'
onClick={() => {
setSearch('')
setIsSearchActive(false)
@@ -373,7 +373,7 @@ const Dashboard = () => {
</Button>
) : (
<Button
- icon
+ variant='icon'
onClick={() => {
setIsSearchActive(true)
setTimeout(() => {
@@ -422,7 +422,7 @@ const Dashboard = () => {
<div className='hidden lg:block'>
{viewMode === DASHBOARD_VIEW.GRID ? (
<Button
- icon
+ variant='icon'
title={t('dashboard.listView')}
aria-label={t('dashboard.listView')}
onClick={() => handleViewModeChange(DASHBOARD_VIEW.LIST)}
@@ -432,7 +432,7 @@ const Dashboard = () => {
) : null}
{viewMode === DASHBOARD_VIEW.LIST ? (
<Button
- icon
+ variant='icon'
title={t('dashboard.gridView')}
aria-label={t('dashboard.gridView')}
onClick={() => handleViewModeChange(DASHBOARD_VIEW.GRID)}
@@ -441,7 +441,7 @@ const Dashboard = () => {
</Button>
) : null}
</div>
- <Button onClick={onNewProject} primary large>
+ <Button size='lg' onClick={onNewProject}>
<FolderPlusIcon className='mr-1 h-5 w-5' />
{t('dashboard.newProject')}
</Button>
diff --git a/web/app/pages/Dashboard/NoProjects.tsx b/web/app/pages/Dashboard/NoProjects.tsx
index 23b7bdfc2..6a833e5bb 100644
--- a/web/app/pages/Dashboard/NoProjects.tsx
+++ b/web/app/pages/Dashboard/NoProjects.tsx
@@ -1,6 +1,7 @@
import { FolderSimpleIcon, FolderPlusIcon } from '@phosphor-icons/react'
import { useTranslation } from 'react-i18next'
+import Button from '~/ui/Button'
import { Text } from '~/ui/Text'
interface NoProjectsProps {
@@ -40,14 +41,10 @@ export const NoProjects = ({ onClick, search }: NoProjectsProps) => {
{t('dashboard.createProject')}
</Text>
<div className='mt-6'>
- <button
- type='button'
- onClick={onClick}
- className='inline-flex items-center justify-center rounded-md border border-transparent bg-slate-900 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-slate-700 dark:border-gray-800 dark:bg-slate-900 dark:text-gray-50 dark:hover:bg-slate-800'
- >
- <FolderPlusIcon className='mr-2 h-5 w-5' />
+ <Button size='lg' onClick={onClick}>
+ <FolderPlusIcon className='mr-2 size-5' />
{t('dashboard.newProject')}
- </button>
+ </Button>
</div>
</div>
)
diff --git a/web/app/pages/Dashboard/PeriodSelector.tsx b/web/app/pages/Dashboard/PeriodSelector.tsx
index 83065c0bd..ec84345b5 100644
--- a/web/app/pages/Dashboard/PeriodSelector.tsx
+++ b/web/app/pages/Dashboard/PeriodSelector.tsx
@@ -10,6 +10,8 @@ import { CalendarDotsIcon, CaretDownIcon } from '@phosphor-icons/react'
import { Fragment, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
+import { buttonClasses } from '~/ui/Button'
+
interface PeriodSelectorProps {
activePeriod: string
setActivePeriod: (period: string) => void
@@ -66,12 +68,14 @@ export const PeriodSelector = ({
<Popover className='relative'>
{({ open }) => (
<>
- <PopoverButton className='inline-flex w-full rounded-md border border-transparent bg-gray-50 p-2 text-sm font-medium text-gray-700 outline-hidden transition-colors hover:border-gray-300 hover:bg-white dark:bg-slate-950 dark:text-gray-50 hover:dark:border-slate-700/80 dark:hover:bg-slate-900'>
- <CalendarDotsIcon className='mr-1 h-5 w-5' />
+ <PopoverButton
+ className={buttonClasses({ variant: 'icon', className: 'w-full' })}
+ >
+ <CalendarDotsIcon className='mr-1 size-5' />
<span>{period}</span>
<CaretDownIcon
className={cx(
- 'ml-2 h-5 w-5 transform-gpu text-gray-700 transition ease-in-out dark:text-gray-50',
+ 'ml-2 size-5 transform-gpu text-gray-700 transition ease-in-out dark:text-gray-50',
{
'rotate-180': open,
},
diff --git a/web/app/pages/Dashboard/SortSelector.tsx b/web/app/pages/Dashboard/SortSelector.tsx
index 17508afd4..71933356f 100644
--- a/web/app/pages/Dashboard/SortSelector.tsx
+++ b/web/app/pages/Dashboard/SortSelector.tsx
@@ -11,6 +11,7 @@ import { Fragment, useEffect, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { useAuth } from '~/providers/AuthProvider'
+import { buttonClasses } from '~/ui/Button'
interface SortSelectorProps {
activeSort: string
@@ -71,12 +72,14 @@ export const SortSelector = ({
<Popover className='relative'>
{({ open }) => (
<>
- <PopoverButton className='inline-flex w-full rounded-md border border-transparent bg-gray-50 p-2 text-sm font-medium text-gray-700 outline-hidden transition-colors hover:border-gray-300 hover:bg-white dark:bg-slate-950 dark:text-gray-50 hover:dark:border-slate-700/80 dark:hover:bg-slate-900'>
- <ArrowsDownUpIcon className='mr-1 h-5 w-5' />
+ <PopoverButton
+ className={buttonClasses({ variant: 'icon', className: 'w-full' })}
+ >
+ <ArrowsDownUpIcon className='mr-1 size-5' />
<span>{sortLabel}</span>
<CaretDownIcon
className={cx(
- 'ml-2 h-5 w-5 transform-gpu text-gray-700 transition ease-in-out dark:text-gray-50',
+ 'ml-2 size-5 transform-gpu text-gray-700 transition ease-in-out dark:text-gray-50',
{
'rotate-180': open,
},
diff --git a/web/app/pages/Onboarding/Onboarding.tsx b/web/app/pages/Onboarding/Onboarding.tsx
index e5affdac9..069f5d2bd 100644
--- a/web/app/pages/Onboarding/Onboarding.tsx
+++ b/web/app/pages/Onboarding/Onboarding.tsx
@@ -880,12 +880,12 @@ const Onboarding = () => {
{currentStepIndex > 0 &&
STEPS.indexOf(currentStep) <
STEPS.indexOf('setup_tracking') && (
- <Button onClick={goBack} secondary large>
+ <Button variant='secondary' size='lg' onClick={goBack}>
{t('common.back')}
</Button>
)}
{currentStep === 'language' && (
- <Button onClick={handleLanguageConfirm} primary large>
+ <Button size='lg' onClick={handleLanguageConfirm}>
{t('common.next')}
</Button>
)}
@@ -893,16 +893,15 @@ const Onboarding = () => {
currentStep === 'feature_traffic' ||
currentStep === 'feature_errors' ||
currentStep === 'feature_sessions') && (
- <Button onClick={goNext} primary large>
+ <Button size='lg' onClick={goNext}>
{t('common.next')}
</Button>
)}
{currentStep === 'create_project' && (
<Button
+ size='lg'
onClick={() => handleCreateProject()}
loading={isLoading}
- primary
- large
>
{t('common.continue')}
</Button>
@@ -910,18 +909,17 @@ const Onboarding = () => {
{currentStep === 'setup_tracking' && (
<>
<Button
+ variant='secondary'
+ size='lg'
onClick={() => handleCompleteOnboarding(true)}
- secondary
- large
>
{t('onboarding.installTracking.skipForNow')}
</Button>
<Button
+ size='lg'
onClick={() => {
handleCompleteOnboarding(false)
}}
- primary
- large
>
{t('common.continue')}
</Button>
diff --git a/web/app/pages/Organisations/Organisations.tsx b/web/app/pages/Organisations/Organisations.tsx
index 295d40bb1..a9baf9e1a 100644
--- a/web/app/pages/Organisations/Organisations.tsx
+++ b/web/app/pages/Organisations/Organisations.tsx
@@ -187,7 +187,7 @@ const Organisations = () => {
<span>{t('titles.organisations')}</span>
{isSearchActive ? (
<Button
- icon
+ variant='icon'
onClick={() => {
setSearch('')
setIsSearchActive(false)
@@ -198,7 +198,7 @@ const Organisations = () => {
</Button>
) : (
<Button
- icon
+ variant='icon'
onClick={() => {
setIsSearchActive(true)
setTimeout(() => {
@@ -233,7 +233,7 @@ const Organisations = () => {
</div>
) : null}
</div>
- <Button onClick={onNewOrganisation} primary large>
+ <Button size='lg' onClick={onNewOrganisation}>
<BuildingOfficeIcon className='mr-1 h-5 w-5' />
{t('organisations.new')}
</Button>
diff --git a/web/app/pages/Organisations/Settings/People.tsx b/web/app/pages/Organisations/Settings/People.tsx
index d0b2fc108..50fdda497 100644
--- a/web/app/pages/Organisations/Settings/People.tsx
+++ b/web/app/pages/Organisations/Settings/People.tsx
@@ -159,7 +159,12 @@ const UsersList = ({ members, onRemove, fetcher }: UsersListProps) => {
className='mr-3'
label={t('common.pending')}
/>
- <Button type='button' white small onClick={() => onRemove(member)}>
+ <Button
+ variant='white'
+ size='xs'
+ type='button'
+ onClick={() => onRemove(member)}
+ >
<TrashIcon className='h-4 w-4' />
</Button>
</div>
@@ -311,8 +316,6 @@ const People = ({ organisation }: PeopleProps) => {
</div>
<Button
className='h-8 pl-2'
- primary
- regular
type='button'
onClick={() => setShowModal(true)}
>
diff --git a/web/app/pages/Organisations/Settings/Projects.tsx b/web/app/pages/Organisations/Settings/Projects.tsx
index b0d380859..290c87e5e 100644
--- a/web/app/pages/Organisations/Settings/Projects.tsx
+++ b/web/app/pages/Organisations/Settings/Projects.tsx
@@ -180,7 +180,7 @@ const ProjectList = ({ projects, onRemove }: ProjectListProps) => {
/>
) : null}
- <Button onClick={() => onRemove(project)} danger small>
+ <Button variant='danger' size='xs' onClick={() => onRemove(project)}>
{t('common.remove')}
</Button>
</div>
@@ -286,8 +286,6 @@ export const Projects = ({ organisation }: ProjectsProps) => {
</h3>
<Button
className='h-8 pl-2'
- primary
- regular
type='button'
onClick={() => {
setShowAddProjectModal(true)
diff --git a/web/app/pages/Organisations/Settings/index.tsx b/web/app/pages/Organisations/Settings/index.tsx
index 4345a6ca8..d9a27a909 100644
--- a/web/app/pages/Organisations/Settings/index.tsx
+++ b/web/app/pages/Organisations/Settings/index.tsx
@@ -374,16 +374,15 @@ const OrganisationSettings = () => {
<div className='mt-8 flex flex-wrap justify-center gap-2 sm:justify-between'>
<div className='flex flex-wrap items-center gap-2'>
<Button
+ variant='secondary'
className='border-indigo-100 dark:border-slate-700/50 dark:bg-slate-900 dark:text-gray-50 dark:hover:bg-slate-800'
as={Link}
// @ts-expect-error
to={routes.organisations}
- secondary
- regular
>
{t('common.cancel')}
</Button>
- <Button type='submit' loading={isSaving} primary regular>
+ <Button type='submit' loading={isSaving}>
{t('common.save')}
</Button>
</div>
@@ -449,11 +448,10 @@ const OrganisationSettings = () => {
{t('organisations.modals.delete.message')}
</p>
<Button
+ variant='danger'
className='mt-4'
onClick={() => setShowDelete(true)}
disabled={isDeleting}
- danger
- regular
>
<TrashIcon className='mr-1 h-5 w-5' />
{t('organisations.delete')}
diff --git a/web/app/pages/Project/Settings/Alerts/AlertTemplateEditor.tsx b/web/app/pages/Project/Settings/Alerts/AlertTemplateEditor.tsx
index ce5791173..8e483f5d6 100644
--- a/web/app/pages/Project/Settings/Alerts/AlertTemplateEditor.tsx
+++ b/web/app/pages/Project/Settings/Alerts/AlertTemplateEditor.tsx
@@ -246,8 +246,8 @@ const AlertTemplateEditor = ({
</Text>
</div>
<Button
- secondary
- small
+ variant='secondary'
+ size='xs'
onClick={() => setShowPreview((v) => !v)}
className='self-start sm:self-auto'
>
diff --git a/web/app/pages/Project/Settings/Alerts/ProjectAlertsSettings.tsx b/web/app/pages/Project/Settings/Alerts/ProjectAlertsSettings.tsx
index 221652945..0693dd80d 100644
--- a/web/app/pages/Project/Settings/Alerts/ProjectAlertsSettings.tsx
+++ b/web/app/pages/Project/Settings/Alerts/ProjectAlertsSettings.tsx
@@ -770,7 +770,11 @@ const ProjectAlertsSettings = ({
{isSettings ? (
<div className='mt-5 flex items-center justify-between'>
- <Button onClick={() => setShowModal(true)} danger semiSmall>
+ <Button
+ variant='danger'
+ size='sm'
+ onClick={() => setShowModal(true)}
+ >
<>
<WarningOctagonIcon className='mr-1 h-5 w-5' />
{t('alert.delete')}
@@ -778,31 +782,25 @@ const ProjectAlertsSettings = ({
</Button>
<div className='flex items-center justify-between'>
<Button
+ variant='secondary'
className='mr-2 border-indigo-100 dark:border-slate-700/50 dark:bg-slate-900 dark:text-gray-50 dark:hover:bg-slate-800'
onClick={onClose}
- secondary
- regular
>
{t('common.cancel')}
</Button>
- <Button type='submit' primary regular>
- {t('common.save')}
- </Button>
+ <Button type='submit'>{t('common.save')}</Button>
</div>
</div>
) : (
<div className='mt-5 flex items-center justify-between'>
<Button
+ variant='secondary'
className='mr-2 border-indigo-100 dark:border-slate-700/50 dark:bg-slate-900 dark:text-gray-50 dark:hover:bg-slate-800'
onClick={onClose}
- secondary
- regular
>
{t('common.cancel')}
</Button>
- <Button type='submit' primary regular>
- {t('common.save')}
- </Button>
+ <Button type='submit'>{t('common.save')}</Button>
</div>
)}
</fetcher.Form>
diff --git a/web/app/pages/Project/Settings/Alerts/ProjectAlertsView.tsx b/web/app/pages/Project/Settings/Alerts/ProjectAlertsView.tsx
index 3f7ba873f..35190197f 100644
--- a/web/app/pages/Project/Settings/Alerts/ProjectAlertsView.tsx
+++ b/web/app/pages/Project/Settings/Alerts/ProjectAlertsView.tsx
@@ -507,7 +507,7 @@ const ProjectAlertsInner = ({
{t('dashboard.alertsDesc')}
</Text>
<div className='mt-6'>
- <Button onClick={handleNewAlert} primary large>
+ <Button size='lg' onClick={handleNewAlert}>
<PlusIcon className='mr-1.5 size-4' />
{t('alert.add')}
</Button>
@@ -526,7 +526,7 @@ const ProjectAlertsInner = ({
<Text as='p' size='sm' colour='muted'>
{t('alert.totalCount', { count: total })}
</Text>
- <Button onClick={handleNewAlert} primary regular>
+ <Button onClick={handleNewAlert}>
<PlusIcon className='mr-1.5 size-4' />
{t('alert.add')}
</Button>
diff --git a/web/app/pages/Project/Settings/Annotations.tsx b/web/app/pages/Project/Settings/Annotations.tsx
index a7aaa7fac..c41dab1da 100644
--- a/web/app/pages/Project/Settings/Annotations.tsx
+++ b/web/app/pages/Project/Settings/Annotations.tsx
@@ -178,7 +178,7 @@ const Annotations = ({ projectId, allowedToManage }: AnnotationsProps) => {
</Text>
</div>
{allowedToManage ? (
- <Button type='button' onClick={openCreateModal} primary small>
+ <Button size='xs' type='button' onClick={openCreateModal}>
<PlusIcon className='mr-1 size-4' />
{t('project.settings.annotations.add')}
</Button>
@@ -191,13 +191,7 @@ const Annotations = ({ projectId, allowedToManage }: AnnotationsProps) => {
{t('project.settings.annotations.empty')}
</p>
{allowedToManage ? (
- <Button
- type='button'
- onClick={openCreateModal}
- className='mt-4'
- primary
- regular
- >
+ <Button type='button' onClick={openCreateModal} className='mt-4'>
<PlusIcon className='mr-1 h-4 w-4' />
{t('project.settings.annotations.addFirst')}
</Button>
diff --git a/web/app/pages/Project/Settings/Emails/Emails.tsx b/web/app/pages/Project/Settings/Emails/Emails.tsx
index 58077b94f..3e77eea86 100644
--- a/web/app/pages/Project/Settings/Emails/Emails.tsx
+++ b/web/app/pages/Project/Settings/Emails/Emails.tsx
@@ -216,9 +216,9 @@ const EmailList = ({ data, onRemove, setEmails }: EmailListProps) => {
label={t('common.pending')}
/>
<Button
+ size='xs'
type='button'
className='rounded-md bg-white text-base font-medium text-indigo-700 hover:bg-indigo-50 dark:border-gray-600 dark:bg-slate-900 dark:text-gray-50 dark:hover:bg-slate-800'
- small
onClick={onRemove}
>
<TrashIcon className='h-4 w-4' />
@@ -450,7 +450,7 @@ const Emails = ({ projectId }: { projectId: string }) => {
{t('project.emails.description')}
</Text>
</div>
- <Button small primary type='button' onClick={() => setShowModal(true)}>
+ <Button size='xs' type='button' onClick={() => setShowModal(true)}>
<EnvelopeSimpleIcon className='mr-1 size-4' />
{t('project.emails.add')}
</Button>
diff --git a/web/app/pages/Project/Settings/People/People.tsx b/web/app/pages/Project/Settings/People/People.tsx
index 9bf784189..431df8879 100644
--- a/web/app/pages/Project/Settings/People/People.tsx
+++ b/web/app/pages/Project/Settings/People/People.tsx
@@ -175,7 +175,7 @@ const TableUserRow = ({
className='mr-3'
label={t('common.pending')}
/>
- <Button type='button' white small onClick={onRemove}>
+ <Button variant='white' size='xs' type='button' onClick={onRemove}>
<TrashIcon className='h-4 w-4' />
</Button>
</div>
@@ -330,7 +330,7 @@ const People = ({ project }: PeopleProps) => {
{t('project.settings.inviteCoworkers')}
</Text>
</div>
- <Button small primary type='button' onClick={() => setShowModal(true)}>
+ <Button size='xs' type='button' onClick={() => setShowModal(true)}>
<UserCirclePlusIcon className='mr-1 size-4' />
{t('project.settings.invite')}
</Button>
@@ -408,8 +408,7 @@ const People = ({ project }: PeopleProps) => {
onClose={closeModal}
customButtons={
<Button
- primary
- large
+ size='lg'
onClick={handleSubmit}
className='w-full justify-center sm:ml-3 sm:w-auto'
>
diff --git a/web/app/pages/Project/Settings/ProjectSettings.tsx b/web/app/pages/Project/Settings/ProjectSettings.tsx
index 32198df0c..dcebf8bc0 100644
--- a/web/app/pages/Project/Settings/ProjectSettings.tsx
+++ b/web/app/pages/Project/Settings/ProjectSettings.tsx
@@ -1046,7 +1046,7 @@ const ProjectSettings = () => {
) : null}
<div className='mt-4 flex flex-wrap justify-center gap-2 sm:justify-between'>
- <Button type='submit' loading={isSaving} primary regular>
+ <Button type='submit' loading={isSaving}>
{t('common.save')}
</Button>
</div>
@@ -1184,8 +1184,6 @@ const ProjectSettings = () => {
'gsc-connect'
: undefined
}
- primary
- regular
>
<GoogleGSVG className='size-4' />
{t('common.connect')}
@@ -1201,10 +1199,9 @@ const ProjectSettings = () => {
/>
<Button
+ variant='danger-outline'
type='button'
className='max-w-max'
- semiDanger
- regular
onClick={() => {
gscFetcher.submit(
{ intent: 'gsc-disconnect' },
@@ -1272,8 +1269,6 @@ const ProjectSettings = () => {
'gsc-set-property'
: undefined
}
- primary
- regular
>
{t('common.save')}
</Button>
@@ -1373,10 +1368,9 @@ const ProjectSettings = () => {
/>
<div className='mt-4 flex gap-2'>
<Button
+ variant='danger'
type='button'
onClick={() => setShowRegenerateSecret(true)}
- danger
- regular
>
{t('project.settings.captcha.regenerateKey')}
</Button>
@@ -1464,8 +1458,6 @@ const ProjectSettings = () => {
)
fetcher.submit(formData, { method: 'post' })
}}
- primary
- regular
>
{t('common.save')}
</Button>
@@ -1476,12 +1468,7 @@ const ProjectSettings = () => {
<p className='mb-4 text-sm text-gray-600 dark:text-gray-300'>
{t('project.settings.captcha.noKeyGenerated')}
</p>
- <Button
- type='button'
- onClick={onRegenerateCaptchaKey}
- primary
- regular
- >
+ <Button type='button' onClick={onRegenerateCaptchaKey}>
{t('project.settings.captcha.generateKey')}
</Button>
</>
diff --git a/web/app/pages/Project/Settings/components/DataImportTab.tsx b/web/app/pages/Project/Settings/components/DataImportTab.tsx
index 1f3118500..d79a1c97a 100644
--- a/web/app/pages/Project/Settings/components/DataImportTab.tsx
+++ b/web/app/pages/Project/Settings/components/DataImportTab.tsx
@@ -669,8 +669,8 @@ export default function DataImportTab({ projectId }: DataImportTabProps) {
)}
</Text>
<Button
- secondary
- large
+ variant='secondary'
+ size='lg'
onClick={handleGa4Connect}
loading={ga4Connecting}
className='flex w-full items-center justify-center gap-2'
diff --git a/web/app/pages/Project/Settings/components/ProxyDomainsTab.tsx b/web/app/pages/Project/Settings/components/ProxyDomainsTab.tsx
index a5ca5ccde..17fe0978c 100644
--- a/web/app/pages/Project/Settings/components/ProxyDomainsTab.tsx
+++ b/web/app/pages/Project/Settings/components/ProxyDomainsTab.tsx
@@ -588,9 +588,8 @@ export default function ProxyDomainsTab({ projectId }: ProxyDomainsTabProps) {
{t('project.settings.proxy.domainsTitle')}
</Text>
<Button
+ size='xs'
type='button'
- primary
- small
onClick={() => {
setHostnameInput('')
setHostnameError(null)
diff --git a/web/app/pages/Project/Settings/tabs/DangerZone.tsx b/web/app/pages/Project/Settings/tabs/DangerZone.tsx
index 80878f3fc..4c39151bb 100644
--- a/web/app/pages/Project/Settings/tabs/DangerZone.tsx
+++ b/web/app/pages/Project/Settings/tabs/DangerZone.tsx
@@ -41,7 +41,7 @@ const DangerZone = ({
hint={t('project.settings.enabledHint')}
/>
<div className='mt-4 flex'>
- <Button type='submit' loading={isSaving} primary regular>
+ <Button type='submit' loading={isSaving}>
{t('common.save')}
</Button>
</div>
@@ -60,10 +60,9 @@ const DangerZone = ({
</p>
</div>
<Button
+ variant='danger-outline'
type='button'
onClick={() => setShowTransfer(true)}
- semiDanger
- regular
className='shrink-0'
>
{t('project.settings.transfer')}
@@ -82,11 +81,10 @@ const DangerZone = ({
</p>
</div>
<Button
+ variant='danger-outline'
type='button'
onClick={() => !setResetting && setShowReset(true)}
loading={setResetting}
- semiDanger
- regular
className='shrink-0'
>
{t('project.settings.reset')}
@@ -105,11 +103,10 @@ const DangerZone = ({
</p>
</div>
<Button
+ variant='danger'
type='button'
onClick={() => !isDeleting && setShowDelete(true)}
loading={isDeleting}
- danger
- regular
className='shrink-0'
>
{t('project.settings.delete')}
diff --git a/web/app/pages/Project/Settings/tabs/Revenue.tsx b/web/app/pages/Project/Settings/tabs/Revenue.tsx
index 3f1241f3c..f3843ff0c 100644
--- a/web/app/pages/Project/Settings/tabs/Revenue.tsx
+++ b/web/app/pages/Project/Settings/tabs/Revenue.tsx
@@ -267,12 +267,11 @@ const Revenue = ({ projectId }: Props) => {
) : null}
<Button
+ variant='danger-outline'
type='button'
className='max-w-max'
onClick={handleDisconnect}
loading={isDisconnecting}
- semiDanger
- regular
>
{t('common.disconnect')}
</Button>
@@ -332,8 +331,6 @@ const Revenue = ({ projectId }: Props) => {
className='max-w-max'
onClick={handleConnect}
loading={isConnecting}
- primary
- regular
>
{t('common.connect')}
</Button>
@@ -371,8 +368,6 @@ const Revenue = ({ projectId }: Props) => {
className='max-w-max'
onClick={handleCurrencyChange}
loading={isSavingCurrency}
- primary
- regular
disabled={!isConnected}
>
{t('common.save')}
diff --git a/web/app/pages/Project/View/ViewProject.tsx b/web/app/pages/Project/View/ViewProject.tsx
index 30b58d29c..72cc6243e 100644
--- a/web/app/pages/Project/View/ViewProject.tsx
+++ b/web/app/pages/Project/View/ViewProject.tsx
@@ -1645,7 +1645,7 @@ const ViewProjectContent = () => {
/>
<div className='flex items-center gap-2'>
<Button
- icon
+ variant='icon'
onClick={() => setIsHotkeysHelpOpened(true)}
aria-label={t('modals.shortcuts.title')}
>
diff --git a/web/app/pages/Project/View/components/ChartTypeSwitcher.tsx b/web/app/pages/Project/View/components/ChartTypeSwitcher.tsx
index 16bd88a5b..d8b959f18 100644
--- a/web/app/pages/Project/View/components/ChartTypeSwitcher.tsx
+++ b/web/app/pages/Project/View/components/ChartTypeSwitcher.tsx
@@ -1,6 +1,7 @@
import { ChartBarIcon, ChartLineIcon } from '@phosphor-icons/react'
import { useTranslation } from 'react-i18next'
import { chartTypes } from '~/lib/constants'
+import Button from '~/ui/Button'
interface ChartTypeSwitcherProps {
type: (typeof chartTypes)[keyof typeof chartTypes]
@@ -13,27 +14,18 @@ export const ChartTypeSwitcher = ({
}: ChartTypeSwitcherProps) => {
const { t } = useTranslation('common')
- if (type === chartTypes.bar) {
- return (
- <button
- type='button'
- title={t('project.lineChart')}
- onClick={() => onSwitch(chartTypes.line)}
- className='rounded-md border border-transparent p-1.5 text-sm font-medium transition-colors ring-inset hover:border-gray-300 hover:bg-white focus:z-10 focus:ring-1 focus:ring-slate-900 focus:outline-hidden hover:dark:border-slate-700/80 hover:dark:bg-slate-950 dark:focus:ring-slate-300'
- >
- <ChartLineIcon className='h-5 w-5 text-gray-700 dark:text-gray-50' />
- </button>
- )
- }
+ const isBar = type === chartTypes.bar
+ const label = isBar ? t('project.lineChart') : t('project.barChart')
+ const Icon = isBar ? ChartLineIcon : ChartBarIcon
return (
- <button
- type='button'
- title={t('project.barChart')}
- onClick={() => onSwitch(chartTypes.bar)}
- className='rounded-md border border-transparent p-1.5 text-sm font-medium transition-colors ring-inset hover:border-gray-300 hover:bg-white focus:z-10 focus:ring-1 focus:ring-slate-900 focus:outline-hidden hover:dark:border-slate-700/80 hover:dark:bg-slate-950 dark:focus:ring-slate-300'
+ <Button
+ variant='icon'
+ title={label}
+ aria-label={label}
+ onClick={() => onSwitch(isBar ? chartTypes.line : chartTypes.bar)}
>
- <ChartBarIcon className='h-5 w-5 text-gray-700 dark:text-gray-50' />
- </button>
+ <Icon className='size-5 text-gray-700 dark:text-gray-50' />
+ </Button>
)
}
diff --git a/web/app/pages/Project/View/components/DashboardHeader.tsx b/web/app/pages/Project/View/components/DashboardHeader.tsx
index 4f87f5b41..d4af0ebf8 100644
--- a/web/app/pages/Project/View/components/DashboardHeader.tsx
+++ b/web/app/pages/Project/View/components/DashboardHeader.tsx
@@ -1,4 +1,3 @@
-import cx from 'clsx'
import dayjs from 'dayjs'
import _find from 'lodash/find'
import { MagnifyingGlassIcon, UsersIcon } from '@phosphor-icons/react'
@@ -12,6 +11,7 @@ import {
TBPeriodPairsProps,
} from '~/lib/constants'
import { useAuth } from '~/providers/AuthProvider'
+import Button from '~/ui/Button'
import DatePicker from '~/ui/Datepicker'
import Dropdown from '~/ui/Dropdown'
@@ -185,27 +185,15 @@ const DashboardHeader = ({
<RefreshStatsButton onRefresh={refreshStats} />
) : null}
{showSearchButton ? (
- <div className='border-gray-200 dark:border-slate-800'>
- <button
- type='button'
- title={t('project.search')}
- onClick={() => {
- if (dataLoading) {
- return
- }
-
- setShowFiltersSearch(true)
- }}
- className={cx(
- 'relative rounded-md border border-transparent p-2 text-sm font-medium transition-colors ring-inset hover:border-gray-300 hover:bg-white focus:z-10 focus:ring-1 focus:ring-slate-900 focus:outline-hidden hover:dark:border-slate-700/80 dark:hover:bg-slate-900 dark:focus:ring-slate-300',
- {
- 'cursor-not-allowed opacity-50': authLoading || dataLoading,
- },
- )}
- >
- <MagnifyingGlassIcon className='h-5 w-5 text-gray-700 dark:text-gray-50' />
- </button>
- </div>
+ <Button
+ variant='icon'
+ title={t('project.search')}
+ aria-label={t('project.search')}
+ disabled={authLoading || dataLoading}
+ onClick={() => setShowFiltersSearch(true)}
+ >
+ <MagnifyingGlassIcon className='size-5 text-gray-700 dark:text-gray-50' />
+ </Button>
) : null}
{rightContent}
{showPeriodSelector ? (
diff --git a/web/app/pages/Project/View/components/PasswordRequiredModal.tsx b/web/app/pages/Project/View/components/PasswordRequiredModal.tsx
index 5d8e84a96..47aecacfc 100644
--- a/web/app/pages/Project/View/components/PasswordRequiredModal.tsx
+++ b/web/app/pages/Project/View/components/PasswordRequiredModal.tsx
@@ -103,16 +103,15 @@ const PasswordRequiredModal = ({
<div className='flex flex-col-reverse gap-2 sm:flex-row sm:justify-end'>
<Button
+ variant='secondary'
className='border-indigo-100 dark:border-slate-700/50 dark:bg-slate-900 dark:text-gray-50 dark:hover:bg-slate-800'
as={Link}
// @ts-expect-error
to={routes.main}
- secondary
- regular
>
{t('common.cancel')}
</Button>
- <Button type='submit' loading={isLoading} primary regular>
+ <Button type='submit' loading={isLoading}>
{t('common.continue')}
</Button>
</div>
diff --git a/web/app/pages/Project/View/components/RefreshStatsButton.tsx b/web/app/pages/Project/View/components/RefreshStatsButton.tsx
index d17c79cdc..87073a937 100644
--- a/web/app/pages/Project/View/components/RefreshStatsButton.tsx
+++ b/web/app/pages/Project/View/components/RefreshStatsButton.tsx
@@ -3,6 +3,8 @@ import { useState, useEffect, useRef } from 'react'
import { useTranslation } from 'react-i18next'
import { useAuth } from '~/providers/AuthProvider'
+import Button from '~/ui/Button'
+import Tooltip from '~/ui/Tooltip'
import { cn } from '~/utils/generic'
import { useViewProjectContext } from '../ViewProject'
@@ -85,48 +87,48 @@ export const RefreshStatsButton = ({ onRefresh }: RefreshStatsButtonProps) => {
)
const showSpinner = isRefreshing || dataLoading
+ const tooltipText = showSpinner
+ ? t('project.refreshing')
+ : t('project.refreshingIn', { seconds: remainingSeconds })
+
return (
- <button
- type='button'
- title={t('project.refreshStats')}
- onClick={handleManualRefresh}
- className={cn(
- 'group relative rounded-md border border-transparent p-2 transition-all ring-inset hover:border-gray-300 hover:bg-white focus:z-10 focus:ring-1 focus:ring-slate-900 focus:outline-hidden hover:dark:border-slate-700/80 dark:hover:bg-slate-900 dark:focus:ring-slate-300',
- {
- 'cursor-not-allowed opacity-50': authLoading,
- },
- )}
- >
- <div className='relative h-5 w-5'>
- <ArrowClockwiseIcon
- className={cn(
- 'absolute inset-0 h-5 w-5 text-gray-400/80 dark:text-slate-600',
- {
- 'animate-spin': showSpinner,
- },
- )}
- />
- {!showSpinner ? (
- <div
- className='absolute inset-0'
- style={{
- maskImage: `conic-gradient(from 100deg, black ${progress}%, transparent ${progress}%)`,
- WebkitMaskImage: `conic-gradient(from 100deg, black ${progress}%, transparent ${progress}%)`,
- }}
- >
- <ArrowClockwiseIcon className='h-5 w-5 text-gray-700 dark:text-gray-50' />
- </div>
- ) : null}
- {showSpinner ? (
- <ArrowClockwiseIcon className='absolute inset-0 h-5 w-5 animate-spin text-gray-700 dark:text-gray-50' />
- ) : null}
- </div>
- <div className='pointer-events-none absolute bottom-full left-1/2 z-30 mb-2 -translate-x-1/2 rounded bg-gray-900 px-2 py-1 text-xs whitespace-nowrap text-white opacity-0 transition-opacity group-hover:opacity-100 dark:bg-slate-700'>
- {showSpinner
- ? t('project.refreshing')
- : t('project.refreshingIn', { seconds: remainingSeconds })}
- <div className='absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-gray-900 dark:border-t-slate-700' />
- </div>
- </button>
+ <Tooltip
+ text={tooltipText}
+ ariaLabel={t('project.refreshStats')}
+ asChild
+ tooltipNode={
+ <Button
+ variant='icon'
+ onClick={handleManualRefresh}
+ aria-label={t('project.refreshStats')}
+ disabled={authLoading}
+ >
+ <span className='relative size-5'>
+ <ArrowClockwiseIcon
+ className={cn(
+ 'absolute inset-0 size-5 text-gray-400/80 dark:text-slate-600',
+ {
+ 'animate-spin': showSpinner,
+ },
+ )}
+ />
+ {!showSpinner ? (
+ <span
+ className='absolute inset-0'
+ style={{
+ maskImage: `conic-gradient(from 100deg, black ${progress}%, transparent ${progress}%)`,
+ WebkitMaskImage: `conic-gradient(from 100deg, black ${progress}%, transparent ${progress}%)`,
+ }}
+ >
+ <ArrowClockwiseIcon className='size-5 text-gray-700 dark:text-gray-50' />
+ </span>
+ ) : null}
+ {showSpinner ? (
+ <ArrowClockwiseIcon className='absolute inset-0 size-5 animate-spin text-gray-700 dark:text-gray-50' />
+ ) : null}
+ </span>
+ </Button>
+ }
+ />
)
}
diff --git a/web/app/pages/Project/tabs/AskAI/AskAIView.tsx b/web/app/pages/Project/tabs/AskAI/AskAIView.tsx
index b1cde156d..f29264fb0 100644
--- a/web/app/pages/Project/tabs/AskAI/AskAIView.tsx
+++ b/web/app/pages/Project/tabs/AskAI/AskAIView.tsx
@@ -1302,10 +1302,15 @@ const TagEditor = ({
</Text>
) : null}
<div className='flex items-center justify-end gap-2'>
- <Button onClick={onCancel} secondary small className='py-1'>
+ <Button
+ variant='secondary'
+ size='xs'
+ onClick={onCancel}
+ className='py-1'
+ >
{t('common.cancel')}
</Button>
- <Button onClick={commit} primary small className='py-1'>
+ <Button size='xs' onClick={commit} className='py-1'>
{t('project.askAi.saveTags')}
</Button>
</div>
@@ -1665,8 +1670,8 @@ const ChatHistoryPanel = ({
{chats.length < total ? (
<Button
- secondary
- small
+ variant='secondary'
+ size='xs'
onClick={onLoadMore}
disabled={isFetchingMore}
loading={isFetchingMore}
diff --git a/web/app/pages/Project/tabs/Errors/ErrorDetails.tsx b/web/app/pages/Project/tabs/Errors/ErrorDetails.tsx
index ecc15c5a3..23f52f0ce 100644
--- a/web/app/pages/Project/tabs/Errors/ErrorDetails.tsx
+++ b/web/app/pages/Project/tabs/Errors/ErrorDetails.tsx
@@ -590,12 +590,12 @@ export const ErrorDetails = ({
</div>
{canLoadMoreSessions ? (
<Button
+ variant='secondary'
+ size='sm'
onClick={() => loadSessions()}
disabled={!!sessionsLoading}
loading={!!sessionsLoading}
className='mx-2 mb-1 justify-center'
- secondary
- semiSmall
>
{t('project.loadMore')}
</Button>
diff --git a/web/app/pages/Project/tabs/Experiments/ExperimentResults.tsx b/web/app/pages/Project/tabs/Experiments/ExperimentResults.tsx
index 9fb88bc63..2fbdbef64 100644
--- a/web/app/pages/Project/tabs/Experiments/ExperimentResults.tsx
+++ b/web/app/pages/Project/tabs/Experiments/ExperimentResults.tsx
@@ -879,13 +879,13 @@ const ExperimentResults = ({
}
tooltipNode={
<Button
+ variant='ghost'
+ size='xs'
type='button'
onClick={() => setIsSettingsOpen(true)}
disabled={
results.status === 'running' || results.status === 'completed'
}
- ghost
- small
>
<PencilIcon className='mr-1 size-4' />
{t('common.edit')}
diff --git a/web/app/pages/Project/tabs/Experiments/ExperimentSettingsModal.tsx b/web/app/pages/Project/tabs/Experiments/ExperimentSettingsModal.tsx
index 8f795608f..f878073ce 100644
--- a/web/app/pages/Project/tabs/Experiments/ExperimentSettingsModal.tsx
+++ b/web/app/pages/Project/tabs/Experiments/ExperimentSettingsModal.tsx
@@ -547,10 +547,10 @@ const ExperimentSettingsModal = ({
/>
</div>
<Button
+ variant='secondary'
+ size='sm'
type='button'
onClick={distributeEvenly}
- semiSmall
- secondary
>
{t('experiments.distributeEvenly')}
</Button>
@@ -655,11 +655,11 @@ const ExperimentSettingsModal = ({
{variants.length > 2 ? (
<Button
+ variant='secondary'
+ size='sm'
type='button'
className='p-1.5'
onClick={() => handleRemoveVariant(index)}
- semiSmall
- secondary
>
<TrashIcon className='size-4' />
</Button>
@@ -670,10 +670,10 @@ const ExperimentSettingsModal = ({
<div className='mt-2 flex items-center justify-between'>
<Button
+ variant='secondary'
+ size='sm'
type='button'
onClick={handleAddVariant}
- semiSmall
- secondary
className='gap-1.5'
>
<PlusIcon className='size-4' />
@@ -813,9 +813,11 @@ const ExperimentSettingsModal = ({
type='button'
onClick={() => setFeatureFlagMode('create')}
className='flex-1 justify-center'
- regular
- primary={featureFlagMode === 'create'}
- secondary={featureFlagMode !== 'create'}
+ variant={
+ featureFlagMode === 'create'
+ ? 'primary'
+ : 'secondary'
+ }
>
Create new
</Button>
@@ -823,9 +825,11 @@ const ExperimentSettingsModal = ({
type='button'
onClick={() => setFeatureFlagMode('link')}
className='flex-1 justify-center'
- regular
- primary={featureFlagMode === 'link'}
- secondary={featureFlagMode !== 'link'}
+ variant={
+ featureFlagMode === 'link'
+ ? 'primary'
+ : 'secondary'
+ }
>
Link existing
</Button>
@@ -886,9 +890,11 @@ const ExperimentSettingsModal = ({
setExposureTrigger('feature_flag')
}
className='flex-1 justify-center'
- regular
- primary={exposureTrigger === 'feature_flag'}
- secondary={exposureTrigger !== 'feature_flag'}
+ variant={
+ exposureTrigger === 'feature_flag'
+ ? 'primary'
+ : 'secondary'
+ }
>
Default
</Button>
@@ -898,9 +904,11 @@ const ExperimentSettingsModal = ({
setExposureTrigger('custom_event')
}
className='flex-1 justify-center'
- regular
- primary={exposureTrigger === 'custom_event'}
- secondary={exposureTrigger !== 'custom_event'}
+ variant={
+ exposureTrigger === 'custom_event'
+ ? 'primary'
+ : 'secondary'
+ }
>
Custom event
</Button>
@@ -958,10 +966,10 @@ const ExperimentSettingsModal = ({
setMultipleVariantHandling('exclude')
}
className='flex-1 justify-center'
- regular
- primary={multipleVariantHandling === 'exclude'}
- secondary={
- multipleVariantHandling !== 'exclude'
+ variant={
+ multipleVariantHandling === 'exclude'
+ ? 'primary'
+ : 'secondary'
}
>
Exclude
@@ -972,12 +980,10 @@ const ExperimentSettingsModal = ({
setMultipleVariantHandling('first_exposure')
}
className='flex-1 justify-center'
- regular
- primary={
+ variant={
multipleVariantHandling === 'first_exposure'
- }
- secondary={
- multipleVariantHandling !== 'first_exposure'
+ ? 'primary'
+ : 'secondary'
}
>
First only
@@ -991,10 +997,10 @@ const ExperimentSettingsModal = ({
</div>
<div className='flex justify-end gap-3 border-t border-gray-200 px-6 py-4 dark:border-slate-700'>
- <Button type='button' onClick={onClose} secondary regular>
+ <Button variant='secondary' type='button' onClick={onClose}>
{t('common.cancel')}
</Button>
- <Button type='submit' primary regular loading={isSaving}>
+ <Button type='submit' loading={isSaving}>
{isEditing ? t('common.save') : t('experiments.create')}
</Button>
</div>
diff --git a/web/app/pages/Project/tabs/Experiments/ExperimentsView.tsx b/web/app/pages/Project/tabs/Experiments/ExperimentsView.tsx
index 7a6c7ccbf..137711f6f 100644
--- a/web/app/pages/Project/tabs/Experiments/ExperimentsView.tsx
+++ b/web/app/pages/Project/tabs/Experiments/ExperimentsView.tsx
@@ -461,7 +461,6 @@ const ExperimentsView = ({
const { timeBucket } = useViewProjectContext()
const { t } = useTranslation()
const [searchParams, setSearchParams] = useSearchParams()
- const isEmbedded = searchParams.get('embedded') === 'true'
const listFetcher = useFetcher<ProjectViewActionData>()
const actionFetcher = useFetcher<ProjectViewActionData>()
@@ -816,26 +815,24 @@ const ExperimentsView = ({
<div>
{isLoading && !_isEmpty(experiments) ? <LoadingBar /> : null}
{_isEmpty(experiments) && !filterQuery ? (
- <div
- className={cx('flex flex-col bg-gray-50 dark:bg-slate-950', {
- 'min-h-including-header': !isEmbedded,
- 'min-h-screen': isEmbedded,
- })}
- >
- <div className='mt-5 rounded-lg bg-slate-700 p-5 dark:bg-slate-900'>
- <div className='flex items-center text-gray-50'>
- <FlaskIcon className='mr-2 h-8 w-8' />
- <p className='text-3xl font-bold'>{t('experiments.title')}</p>
- </div>
- <p className='mt-2 text-sm whitespace-pre-wrap text-gray-100'>
- {t('experiments.description')}
- </p>
- <Button
- onClick={handleNewExperiment}
- className='mt-6 block max-w-max rounded-md border border-transparent bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:bg-indigo-50 md:px-4'
- secondary
- large
- >
+ <div className='mx-auto w-full max-w-2xl py-16 text-center'>
+ <div className='mx-auto mb-6 flex size-14 items-center justify-center rounded-xl bg-gray-100 dark:bg-slate-900'>
+ <FlaskIcon className='size-7 text-gray-700 dark:text-gray-200' />
+ </div>
+ <Text as='h3' size='xl' weight='medium' className='tracking-tight'>
+ {t('experiments.title')}
+ </Text>
+ <Text
+ as='p'
+ size='sm'
+ colour='secondary'
+ className='mx-auto mt-2 max-w-md whitespace-pre-wrap'
+ >
+ {t('experiments.description')}
+ </Text>
+ <div className='mt-6'>
+ <Button size='lg' onClick={handleNewExperiment}>
+ <PlusIcon className='mr-1.5 size-4' />
{t('experiments.create')}
</Button>
</div>
@@ -853,7 +850,7 @@ const ExperimentsView = ({
className='w-full rounded-lg border-0 bg-white py-2 pr-4 pl-9 text-sm text-gray-900 placeholder-gray-500 ring-1 ring-gray-300 ring-inset focus:ring-slate-900 focus:outline-none sm:w-64 dark:bg-slate-950 dark:text-gray-50 dark:placeholder-gray-400 dark:ring-slate-700/80 dark:focus:ring-slate-300'
/>
</div>
- <Button onClick={handleNewExperiment} primary regular>
+ <Button onClick={handleNewExperiment}>
<PlusIcon className='mr-1.5 size-4' />
{t('experiments.create')}
</Button>
diff --git a/web/app/pages/Project/tabs/FeatureFlags/FeatureFlagSettingsModal.tsx b/web/app/pages/Project/tabs/FeatureFlags/FeatureFlagSettingsModal.tsx
index 997b6740b..214e4e08b 100644
--- a/web/app/pages/Project/tabs/FeatureFlags/FeatureFlagSettingsModal.tsx
+++ b/web/app/pages/Project/tabs/FeatureFlags/FeatureFlagSettingsModal.tsx
@@ -797,10 +797,10 @@ const flags = await swetrix.getFeatureFlags(undefined, true)`
</div>
<div className='flex justify-end gap-3 border-t border-gray-200 px-6 py-4 dark:border-slate-700'>
- <Button type='button' onClick={onClose} secondary regular>
+ <Button variant='secondary' type='button' onClick={onClose}>
{t('common.cancel')}
</Button>
- <Button type='submit' primary regular loading={isSaving}>
+ <Button type='submit' loading={isSaving}>
{isNew ? t('featureFlags.create') : t('featureFlags.save')}
</Button>
</div>
diff --git a/web/app/pages/Project/tabs/FeatureFlags/FeatureFlagsView.tsx b/web/app/pages/Project/tabs/FeatureFlags/FeatureFlagsView.tsx
index 687c5a800..d43944ef4 100644
--- a/web/app/pages/Project/tabs/FeatureFlags/FeatureFlagsView.tsx
+++ b/web/app/pages/Project/tabs/FeatureFlags/FeatureFlagsView.tsx
@@ -31,7 +31,6 @@ import { useTranslation } from 'react-i18next'
import { Link } from '~/ui/Link'
import {
useLocation,
- useSearchParams,
useFetcher,
useLoaderData,
useRevalidator,
@@ -544,9 +543,6 @@ const FeatureFlagsViewInner = ({
const { featureFlagsRefreshTrigger } = useRefreshTriggers()
const { timeFormat } = useViewProjectContext()
const { t } = useTranslation()
- const [searchParams] = useSearchParams()
- const isEmbedded = searchParams.get('embedded') === 'true'
-
const listFetcher = useFetcher<ProjectViewActionData>()
const actionFetcher = useFetcher<ProjectViewActionData>()
@@ -969,26 +965,24 @@ const FeatureFlagsViewInner = ({
<div>
{isLoading && !_isEmpty(flags) ? <LoadingBar /> : null}
{_isEmpty(flags) && !filterQuery ? (
- <div
- className={cx('flex flex-col bg-gray-50 dark:bg-slate-950', {
- 'min-h-including-header': !isEmbedded,
- 'min-h-screen': isEmbedded,
- })}
- >
- <div className='mt-5 rounded-lg bg-slate-700 p-5 dark:bg-slate-900'>
- <div className='flex items-center text-gray-50'>
- <ToggleRightIcon className='mr-2 h-8 w-8' />
- <p className='text-3xl font-bold'>{t('featureFlags.title')}</p>
- </div>
- <p className='mt-2 text-sm whitespace-pre-wrap text-gray-100'>
- {t('featureFlags.description')}
- </p>
- <Button
- onClick={handleNewFlag}
- className='mt-6 block max-w-max rounded-md border border-transparent bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:bg-indigo-50 md:px-4'
- secondary
- large
- >
+ <div className='mx-auto w-full max-w-2xl py-16 text-center'>
+ <div className='mx-auto mb-6 flex size-14 items-center justify-center rounded-xl bg-gray-100 dark:bg-slate-900'>
+ <ToggleRightIcon className='size-7 text-gray-700 dark:text-gray-200' />
+ </div>
+ <Text as='h3' size='xl' weight='medium' className='tracking-tight'>
+ {t('featureFlags.title')}
+ </Text>
+ <Text
+ as='p'
+ size='sm'
+ colour='secondary'
+ className='mx-auto mt-2 max-w-md whitespace-pre-wrap'
+ >
+ {t('featureFlags.description')}
+ </Text>
+ <div className='mt-6'>
+ <Button size='lg' onClick={handleNewFlag}>
+ <PlusIcon className='mr-1.5 size-4' />
{t('featureFlags.add')}
</Button>
</div>
@@ -1007,7 +1001,7 @@ const FeatureFlagsViewInner = ({
className='w-full rounded-lg border-0 bg-white py-2 pr-4 pl-9 text-sm text-gray-900 placeholder-gray-500 ring-1 ring-gray-300 ring-inset focus:ring-slate-900 focus:outline-none sm:w-64 dark:bg-slate-950 dark:text-gray-50 dark:placeholder-gray-400 dark:ring-slate-700/80 dark:focus:ring-slate-300'
/>
</div>
- <Button onClick={handleNewFlag} primary regular>
+ <Button onClick={handleNewFlag}>
<PlusIcon className='mr-1.5 size-4' />
{t('featureFlags.addFlag')}
</Button>
diff --git a/web/app/pages/Project/tabs/Funnels/FunnelsView.tsx b/web/app/pages/Project/tabs/Funnels/FunnelsView.tsx
index 3d7d8968a..2bcd1bd8b 100644
--- a/web/app/pages/Project/tabs/Funnels/FunnelsView.tsx
+++ b/web/app/pages/Project/tabs/Funnels/FunnelsView.tsx
@@ -3,7 +3,7 @@ import _filter from 'lodash/filter'
import _find from 'lodash/find'
import _includes from 'lodash/includes'
import _isEmpty from 'lodash/isEmpty'
-import { FunnelIcon } from '@phosphor-icons/react'
+import { FunnelIcon, PlusIcon } from '@phosphor-icons/react'
import {
useState,
useEffect,
@@ -43,6 +43,7 @@ import type {
ProjectLoaderData,
ProjectViewActionData,
} from '~/routes/projects.$id'
+import Button from '~/ui/Button'
import Loader from '~/ui/Loader'
import LoadingBar from '~/ui/LoadingBar'
import { Text } from '~/ui/Text'
@@ -471,33 +472,32 @@ const FunnelsViewInner = ({ deferredData }: FunnelsViewInnerProps) => {
// Render empty state
return (
<>
- <div
- className={cx('flex flex-col bg-gray-50 dark:bg-slate-950', {
- 'min-h-including-header': !isEmbedded,
- 'min-h-screen': isEmbedded,
- })}
- >
- <div className='mt-5 rounded-xl bg-slate-700 p-5 dark:bg-slate-900'>
- <div className='flex items-center text-gray-50'>
- <FunnelIcon className='mr-2 h-8 w-8' />
- <p className='text-3xl font-bold'>{t('dashboard.funnels')}</p>
- </div>
- <p className='mt-2 text-sm whitespace-pre-wrap text-gray-100'>
- {t('dashboard.funnelsDesc')}
- </p>
+ <div className='mx-auto w-full max-w-2xl py-16 text-center'>
+ <div className='mx-auto mb-6 flex size-14 items-center justify-center rounded-xl bg-gray-100 dark:bg-slate-900'>
+ <FunnelIcon className='size-7 text-gray-700 dark:text-gray-200' />
+ </div>
+ <Text as='h3' size='xl' weight='medium' className='tracking-tight'>
+ {t('dashboard.funnels')}
+ </Text>
+ <Text
+ as='p'
+ size='sm'
+ colour='secondary'
+ className='mx-auto mt-2 max-w-md whitespace-pre-wrap'
+ >
+ {t('dashboard.funnelsDesc')}
+ </Text>
+ <div className='mt-6'>
{isAuthenticated ? (
- <button
- type='button'
- onClick={() => setIsNewFunnelOpened(true)}
- className='mt-6 block max-w-max rounded-md border border-transparent bg-white px-3 py-2 text-sm font-medium text-slate-900 hover:bg-indigo-50 md:px-4'
- >
+ <Button size='lg' onClick={() => setIsNewFunnelOpened(true)}>
+ <PlusIcon className='mr-1.5 size-4' />
{t('dashboard.newFunnel')}
- </button>
+ </Button>
) : (
<Link
to={routes.signup}
- className='mt-6 block max-w-max rounded-md border border-transparent bg-white px-3 py-2 text-sm font-medium text-slate-900 hover:bg-indigo-50 md:px-4'
aria-label={t('titles.signup')}
+ className='inline-flex items-center justify-center rounded-md border border-transparent bg-slate-900 px-4 py-2 text-sm font-medium text-white shadow-xs transition-colors hover:bg-slate-700 dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-white'
>
{t('header.startForFree')}
</Link>
diff --git a/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx b/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx
index d2a4a4745..da7b6a2b4 100644
--- a/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx
+++ b/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx
@@ -342,10 +342,10 @@ const GoalSettingsModal = ({
</div>
<div className='flex justify-end gap-3 border-t border-gray-200 px-6 py-4 dark:border-slate-700'>
- <Button type='button' onClick={onClose} secondary regular>
+ <Button variant='secondary' type='button' onClick={onClose}>
{t('common.cancel')}
</Button>
- <Button type='submit' primary regular loading={isSaving}>
+ <Button type='submit' loading={isSaving}>
{isNew ? t('goals.create') : t('goals.save')}
</Button>
</div>
diff --git a/web/app/pages/Project/tabs/Goals/GoalsView.tsx b/web/app/pages/Project/tabs/Goals/GoalsView.tsx
index 4cfe2047a..99deb3e9e 100644
--- a/web/app/pages/Project/tabs/Goals/GoalsView.tsx
+++ b/web/app/pages/Project/tabs/Goals/GoalsView.tsx
@@ -27,12 +27,7 @@ import {
use,
} from 'react'
import { useTranslation } from 'react-i18next'
-import {
- useSearchParams,
- useFetcher,
- useLoaderData,
- useRevalidator,
-} from 'react-router'
+import { useFetcher, useLoaderData, useRevalidator } from 'react-router'
import { toast } from 'sonner'
import type {
@@ -544,8 +539,6 @@ const GoalsViewInner = ({
const revalidator = useRevalidator()
const { goalsRefreshTrigger } = useRefreshTriggers()
const { timeBucket, timeFormat } = useViewProjectContext()
- const [searchParams] = useSearchParams()
- const isEmbedded = searchParams.get('embedded') === 'true'
const { t } = useTranslation()
const fetcher = useFetcher<ProjectViewActionData>()
@@ -857,26 +850,24 @@ const GoalsViewInner = ({
<div>
{isLoading && !_isEmpty(goals) ? <LoadingBar /> : null}
{_isEmpty(goals) && !filterQuery ? (
- <div
- className={cx('flex flex-col bg-gray-50 dark:bg-slate-950', {
- 'min-h-including-header': !isEmbedded,
- 'min-h-screen': isEmbedded,
- })}
- >
- <div className='mt-5 rounded-lg bg-slate-700 p-5 dark:bg-slate-900'>
- <div className='flex items-center text-gray-50'>
- <TargetIcon className='mr-2 h-8 w-8' />
- <p className='text-3xl font-bold'>{t('goals.title')}</p>
- </div>
- <p className='mt-2 text-sm whitespace-pre-wrap text-gray-100'>
- {t('goals.description')}
- </p>
- <Button
- onClick={handleNewGoal}
- className='mt-6 block max-w-max rounded-md border border-transparent bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:bg-indigo-50 md:px-4'
- secondary
- large
- >
+ <div className='mx-auto w-full max-w-2xl py-16 text-center'>
+ <div className='mx-auto mb-6 flex size-14 items-center justify-center rounded-xl bg-gray-100 dark:bg-slate-900'>
+ <TargetIcon className='size-7 text-gray-700 dark:text-gray-200' />
+ </div>
+ <Text as='h3' size='xl' weight='medium' className='tracking-tight'>
+ {t('goals.title')}
+ </Text>
+ <Text
+ as='p'
+ size='sm'
+ colour='secondary'
+ className='mx-auto mt-2 max-w-md whitespace-pre-wrap'
+ >
+ {t('goals.description')}
+ </Text>
+ <div className='mt-6'>
+ <Button size='lg' onClick={handleNewGoal}>
+ <PlusIcon className='mr-1.5 size-4' />
{t('goals.add')}
</Button>
</div>
@@ -895,7 +886,7 @@ const GoalsViewInner = ({
className='w-full rounded-lg border-0 bg-white py-2 pr-4 pl-9 text-sm text-gray-900 placeholder-gray-500 ring-1 ring-gray-300 ring-inset focus:ring-slate-900 focus:outline-none sm:w-64 dark:bg-slate-950 dark:text-gray-50 dark:placeholder-gray-400 dark:ring-slate-700/80 dark:focus:ring-slate-300'
/>
</div>
- <Button onClick={handleNewGoal} primary regular>
+ <Button onClick={handleNewGoal}>
<PlusIcon className='mr-1.5 size-4' />
{t('goals.addGoal')}
</Button>
diff --git a/web/app/pages/Project/tabs/Profiles/ProfileDetails.tsx b/web/app/pages/Project/tabs/Profiles/ProfileDetails.tsx
index 3110372ae..4a8ee45db 100644
--- a/web/app/pages/Project/tabs/Profiles/ProfileDetails.tsx
+++ b/web/app/pages/Project/tabs/Profiles/ProfileDetails.tsx
@@ -578,8 +578,6 @@ export const ProfileDetails = ({
disabled={!!sessionsLoading}
loading={!!sessionsLoading}
className='mt-4 w-full'
- primary
- regular
>
{t('project.loadMore')}
</Button>
diff --git a/web/app/pages/Subscribe/Subscribe.tsx b/web/app/pages/Subscribe/Subscribe.tsx
index 1d7ddcc78..60a727866 100644
--- a/web/app/pages/Subscribe/Subscribe.tsx
+++ b/web/app/pages/Subscribe/Subscribe.tsx
@@ -382,19 +382,18 @@ const Subscribe = () => {
)}
<div className='mt-3'>
- <button
- type='button'
+ <Button
+ variant='ghost'
+ size='xs'
onClick={() => setShowAllPlans((v) => !v)}
- className='rounded-full bg-gray-100 px-3.5 py-1.5 transition-colors hover:bg-gray-200 dark:bg-slate-900 dark:hover:bg-slate-800'
+ className='rounded-full'
>
- <Text as='p' size='xs' weight='semibold'>
- {showAllPlans
- ? t('common.showLess')
- : t('common.showMore', {
- count: STANDARD_PLANS.length - INITIAL_VISIBLE_PLANS,
- })}
- </Text>
- </button>
+ {showAllPlans
+ ? t('common.showLess')
+ : t('common.showMore', {
+ count: STANDARD_PLANS.length - INITIAL_VISIBLE_PLANS,
+ })}
+ </Button>
</div>
</div>
@@ -440,10 +439,9 @@ const Subscribe = () => {
</div>
) : (
<Button
+ size='xl'
className='w-full justify-center'
onClick={handleStartCheckout}
- primary
- giant
loading={generatePayLinkFetcher.state !== 'idle'}
disabled={generatePayLinkFetcher.state !== 'idle'}
>
diff --git a/web/app/pages/UserSettings/UserSettings.tsx b/web/app/pages/UserSettings/UserSettings.tsx
index 7466c5b4a..ec124d315 100644
--- a/web/app/pages/UserSettings/UserSettings.tsx
+++ b/web/app/pages/UserSettings/UserSettings.tsx
@@ -802,7 +802,7 @@ const UserSettings = () => {
onChange={handleInput}
error={emailBeenSubmitted ? errors.email : null}
/>
- <Button onClick={handleEmailSubmit} primary large>
+ <Button size='lg' onClick={handleEmailSubmit}>
{t('profileSettings.update')}
</Button>
</div>
@@ -829,10 +829,10 @@ const UserSettings = () => {
/>
</div>
<Button
+ variant='danger'
+ size='lg'
className='mt-4'
onClick={() => setShowAPIDeleteModal(true)}
- danger
- large
>
{t('profileSettings.deleteApiKeyBtn')}
</Button>
@@ -847,7 +847,7 @@ const UserSettings = () => {
>
{t('profileSettings.noApiKey')}
</Text>
- <Button onClick={onApiKeyGenerate} primary large>
+ <Button size='lg' onClick={onApiKeyGenerate}>
{t('profileSettings.addApiKeyBtn')}
</Button>
</>
@@ -1034,9 +1034,9 @@ const UserSettings = () => {
isLast
>
<Button
+ variant='danger-outline'
+ size='sm'
onClick={() => setShowModal(true)}
- semiSmall
- semiDanger
>
<>
<WarningOctagonIcon className='mr-1 h-5 w-5' />
@@ -1082,10 +1082,9 @@ const UserSettings = () => {
error={passwordBeenSubmitted ? errors.repeat : null}
/>
<Button
+ size='lg'
onClick={handlePasswordSubmit}
disabled={!form.password || !form.repeat}
- primary
- large
>
{t('profileSettings.updatePassword')}
</Button>
@@ -1110,11 +1109,11 @@ const UserSettings = () => {
{t('profileSettings.logoutAllWarning')}
</Alert>
<Button
+ variant='danger-outline'
+ size='lg'
onClick={() => {
logout(true)
}}
- semiDanger
- large
>
{t('profileSettings.logoutAll')}
</Button>
@@ -1139,10 +1138,9 @@ const UserSettings = () => {
<div className='max-w-md'>
<TimezonePicker value={timezone} onChange={setTimezone} />
<Button
+ size='lg'
className='mt-4'
onClick={handleTimezoneSave}
- primary
- large
>
{t('common.save')}
</Button>
@@ -1182,10 +1180,9 @@ const UserSettings = () => {
}
/>
<Button
+ size='lg'
className='mt-4'
onClick={setAsyncTimeFormat}
- primary
- large
>
{t('common.save')}
</Button>
@@ -1515,20 +1512,19 @@ const UserSettings = () => {
<div className='mt-4 flex flex-wrap gap-3'>
{subUpdateURL && !cancellationEffectiveDate ? (
<Button
+ size='lg'
onClick={onUpdatePaymentDetails}
type='button'
- primary
- large
>
{t('billing.update')}
</Button>
) : null}
{subCancelURL && !cancellationEffectiveDate ? (
<Button
+ variant='danger-outline'
+ size='lg'
onClick={() => setIsCancelSubModalOpened(true)}
type='button'
- semiDanger
- large
>
{t('billing.cancelSub')}
</Button>
@@ -1583,10 +1579,9 @@ const UserSettings = () => {
}
/>
<Button
+ size='lg'
className='mt-4'
onClick={handleReportSave}
- primary
- large
>
{t('common.save')}
</Button>
diff --git a/web/app/pages/UserSettings/components/Organisations.tsx b/web/app/pages/UserSettings/components/Organisations.tsx
index eb97ae1ee..96d61d134 100644
--- a/web/app/pages/UserSettings/components/Organisations.tsx
+++ b/web/app/pages/UserSettings/components/Organisations.tsx
@@ -93,20 +93,23 @@ const Organisations = ({ membership }: OrganisationsProps) => {
</td>
<td className='px-4 py-3 text-right text-sm whitespace-nowrap'>
{role === 'owner' ? null : confirmed ? (
- <Button onClick={() => setShowDeleteModal(true)} danger small>
+ <Button
+ variant='danger'
+ size='xs'
+ onClick={() => setShowDeleteModal(true)}
+ >
{t('common.quit')}
</Button>
) : (
<>
<Button
+ size='xs'
className='mr-2'
onClick={() => setShowDeleteModal(true)}
- primary
- small
>
{t('common.reject')}
</Button>
- <Button onClick={onAccept} loading={isLoading} primary small>
+ <Button size='xs' onClick={onAccept} loading={isLoading}>
{t('common.accept')}
</Button>
</>
diff --git a/web/app/pages/UserSettings/components/ProjectList.tsx b/web/app/pages/UserSettings/components/ProjectList.tsx
index 2ff31b2c6..062708861 100644
--- a/web/app/pages/UserSettings/components/ProjectList.tsx
+++ b/web/app/pages/UserSettings/components/ProjectList.tsx
@@ -91,9 +91,9 @@ const ProjectList = ({ item }: ProjectListProps) => {
<td className='px-4 py-3 text-right text-sm whitespace-nowrap'>
{confirmed ? (
<Button
+ variant='danger'
+ size='xs'
onClick={() => setShowDeleteModal(true)}
- danger
- small
loading={isPending}
>
{t('common.quit')}
@@ -101,15 +101,14 @@ const ProjectList = ({ item }: ProjectListProps) => {
) : (
<>
<Button
+ size='xs'
className='mr-2'
onClick={() => setShowDeleteModal(true)}
- primary
- small
loading={isPending}
>
{t('common.reject')}
</Button>
- <Button onClick={onAccept} primary small loading={isPending}>
+ <Button size='xs' onClick={onAccept} loading={isPending}>
{t('common.accept')}
</Button>
</>
diff --git a/web/app/pages/UserSettings/components/Socialisations.tsx b/web/app/pages/UserSettings/components/Socialisations.tsx
index 6d801b936..54705f176 100644
--- a/web/app/pages/UserSettings/components/Socialisations.tsx
+++ b/web/app/pages/UserSettings/components/Socialisations.tsx
@@ -235,13 +235,13 @@ const Socialisations = () => {
<div className='flex items-center justify-end gap-2'>
{connected && !unlinkable ? (
<Button
+ variant='danger'
+ size='xs'
onClick={() =>
toast.error(
t('profileSettings.cantUnlinkSocialisation'),
)
}
- small
- danger
>
{t('common.unlink')}
</Button>
@@ -249,10 +249,10 @@ const Socialisations = () => {
{connected && unlinkable ? (
<Button
+ variant='danger'
+ size='xs'
onClick={() => onUnlinkSSO(key)}
loading={isUnlinking}
- small
- danger
>
{t('common.unlink')}
</Button>
@@ -260,10 +260,9 @@ const Socialisations = () => {
{!connected ? (
<Button
+ size='xs'
onClick={() => linkSSO(key)}
loading={isLoading}
- small
- primary
>
{t('common.link')}
</Button>
diff --git a/web/app/pages/UserSettings/components/TwoFA.tsx b/web/app/pages/UserSettings/components/TwoFA.tsx
index 42bcfa79e..7eba9a9ce 100644
--- a/web/app/pages/UserSettings/components/TwoFA.tsx
+++ b/web/app/pages/UserSettings/components/TwoFA.tsx
@@ -127,7 +127,7 @@ const TwoFA = () => {
{t('profileSettings.2faRecoveryNote')}
</p>
<Input className='mt-4' value={twoFARecovery} disabled />
- <Button className='mt-4' onClick={recoverySaved} primary large>
+ <Button size='lg' className='mt-4' onClick={recoverySaved}>
{t('profileSettings.2faRecoverySaved')}
</Button>
</div>
@@ -153,11 +153,11 @@ const TwoFA = () => {
disabled={isLoading}
/>
<Button
+ variant='danger'
+ size='lg'
className={twoFACodeError ? 'mb-5' : ''}
onClick={_disable2FA}
loading={isLoading}
- danger
- large
>
{t('common.disable')}
</Button>
@@ -175,10 +175,10 @@ const TwoFA = () => {
{t('profileSettings.2faEnabled')}
</p>
<Button
+ variant='danger'
+ size='lg'
className='mt-4'
onClick={() => setTwoFADisabling(true)}
- danger
- large
>
{t('profileSettings.2faDisableBtn')}
</Button>
@@ -216,11 +216,10 @@ const TwoFA = () => {
disabled={isLoading}
/>
<Button
+ size='lg'
className={twoFACodeError ? 'mb-5' : ''}
onClick={_enable2FA}
loading={isLoading}
- primary
- large
>
{t('common.enable')}
</Button>
@@ -238,7 +237,7 @@ const TwoFA = () => {
>
{t('profileSettings.2faSecurityRecommendation')}
</Alert>
- <Button onClick={_generate2FA} loading={isLoading} primary large>
+ <Button size='lg' onClick={_generate2FA} loading={isLoading}>
<LockIcon className='mr-2 size-4' weight='duotone' />
{t('profileSettings.2faEnableBtn')}
</Button>
diff --git a/web/app/routes/tools.conversion-rate-calculator.tsx b/web/app/routes/tools.conversion-rate-calculator.tsx
index e09127f49..2e404b176 100644
--- a/web/app/routes/tools.conversion-rate-calculator.tsx
+++ b/web/app/routes/tools.conversion-rate-calculator.tsx
@@ -299,7 +299,7 @@ export default function ConversionRateCalculator() {
</div>
<div className='mt-6'>
- <Button onClick={reset} secondary regular>
+ <Button variant='secondary' onClick={reset}>
Reset
</Button>
</div>
@@ -416,7 +416,7 @@ export default function ConversionRateCalculator() {
</div>
<div className='mt-6'>
- <Button onClick={reset} secondary regular>
+ <Button variant='secondary' onClick={reset}>
Reset
</Button>
</div>
@@ -506,7 +506,7 @@ export default function ConversionRateCalculator() {
</div>
<div className='mt-6'>
- <Button onClick={reset} secondary regular>
+ <Button variant='secondary' onClick={reset}>
Reset
</Button>
</div>
diff --git a/web/app/routes/tools.ctr-calculator.tsx b/web/app/routes/tools.ctr-calculator.tsx
index 1c93ca53f..ecfd27c4a 100644
--- a/web/app/routes/tools.ctr-calculator.tsx
+++ b/web/app/routes/tools.ctr-calculator.tsx
@@ -204,9 +204,7 @@ export default function CTRCalculator() {
</div>
<div className='mt-6'>
- <Button onClick={reset} regular>
- Reset
- </Button>
+ <Button onClick={reset}>Reset</Button>
</div>
</div>
diff --git a/web/app/routes/tools.ip-lookup.tsx b/web/app/routes/tools.ip-lookup.tsx
index 5c4149763..76108f8ce 100644
--- a/web/app/routes/tools.ip-lookup.tsx
+++ b/web/app/routes/tools.ip-lookup.tsx
@@ -474,8 +474,6 @@ export default function IpLookup() {
/>
<Button
type='submit'
- primary
- regular
disabled={isLoading}
className='sm:mt-px'
loading={isLoading}
diff --git a/web/app/routes/tools.percentage-calculator.tsx b/web/app/routes/tools.percentage-calculator.tsx
index 323bcfe66..afc10a0fd 100644
--- a/web/app/routes/tools.percentage-calculator.tsx
+++ b/web/app/routes/tools.percentage-calculator.tsx
@@ -258,7 +258,7 @@ export default function PercentageCalculator() {
</div>
<div className='mt-6'>
- <Button onClick={reset} secondary regular>
+ <Button variant='secondary' onClick={reset}>
Reset
</Button>
</div>
@@ -327,7 +327,7 @@ export default function PercentageCalculator() {
</div>
<div className='mt-6'>
- <Button onClick={reset} secondary regular>
+ <Button variant='secondary' onClick={reset}>
Reset
</Button>
</div>
@@ -397,7 +397,7 @@ export default function PercentageCalculator() {
</div>
<div className='mt-6'>
- <Button onClick={reset} secondary regular>
+ <Button variant='secondary' onClick={reset}>
Reset
</Button>
</div>
diff --git a/web/app/routes/tools.qr-code-generator.tsx b/web/app/routes/tools.qr-code-generator.tsx
index 645141ecc..2dd63394a 100644
--- a/web/app/routes/tools.qr-code-generator.tsx
+++ b/web/app/routes/tools.qr-code-generator.tsx
@@ -197,8 +197,6 @@ export default function QRCodeGenerator() {
<Button
onClick={downloadSVG}
- primary
- regular
disabled={!value}
className='w-full max-w-xs'
>
diff --git a/web/app/routes/tools.robots-txt-generator.tsx b/web/app/routes/tools.robots-txt-generator.tsx
index 64e45abc0..320a5d74a 100644
--- a/web/app/routes/tools.robots-txt-generator.tsx
+++ b/web/app/routes/tools.robots-txt-generator.tsx
@@ -374,9 +374,8 @@ export default function RobotsTxtGenerator() {
</div>
))}
<Button
+ variant='secondary'
type='button'
- regular
- secondary
onClick={() => addRule(groupIndex)}
className='mt-2 w-full text-sm text-gray-900 dark:border-slate-700 dark:bg-slate-800 dark:text-gray-100 dark:hover:bg-slate-700'
>
@@ -389,8 +388,6 @@ export default function RobotsTxtGenerator() {
<Button
type='button'
- regular
- primary
onClick={addAgentGroup}
className='w-full'
>
@@ -409,7 +406,7 @@ export default function RobotsTxtGenerator() {
</div>
<div className='flex items-center gap-2'>
<Button
- secondary
+ variant='secondary'
onClick={handleCopy}
className='h-auto! border-slate-700! bg-slate-800! px-3! py-1.5! text-gray-300! hover:bg-slate-700! hover:text-white!'
>
@@ -421,7 +418,7 @@ export default function RobotsTxtGenerator() {
{copied ? 'Copied' : 'Copy'}
</Button>
<Button
- secondary
+ variant='secondary'
onClick={handleDownload}
className='h-auto! border-slate-700! bg-slate-800! px-3! py-1.5! text-gray-300! hover:bg-slate-700! hover:text-white!'
>
diff --git a/web/app/routes/tools.schema-markup-generator.tsx b/web/app/routes/tools.schema-markup-generator.tsx
index b989d02c9..d6f8779e4 100644
--- a/web/app/routes/tools.schema-markup-generator.tsx
+++ b/web/app/routes/tools.schema-markup-generator.tsx
@@ -435,8 +435,8 @@ export default function SchemaMarkupGenerator() {
</div>
))}
<Button
+ variant='secondary'
type='button'
- secondary
onClick={() =>
setFaqData((p) => [
...p,
@@ -462,7 +462,7 @@ export default function SchemaMarkupGenerator() {
</h3>
</div>
<Button
- secondary
+ variant='secondary'
onClick={handleCopy}
className='h-auto! border-slate-700! bg-slate-800! px-3! py-1.5! text-gray-300! hover:bg-slate-700! hover:text-white!'
>
diff --git a/web/app/routes/tools.sitemap-validator.tsx b/web/app/routes/tools.sitemap-validator.tsx
index 173673e9c..a7eb808af 100644
--- a/web/app/routes/tools.sitemap-validator.tsx
+++ b/web/app/routes/tools.sitemap-validator.tsx
@@ -675,8 +675,6 @@ export default function SitemapValidator() {
/>
<Button
type='submit'
- primary
- regular
disabled={isLoading}
className='mt-px'
loading={isLoading}
diff --git a/web/app/routes/tools.utm-generator.tsx b/web/app/routes/tools.utm-generator.tsx
index 7c9989891..523da7c4a 100644
--- a/web/app/routes/tools.utm-generator.tsx
+++ b/web/app/routes/tools.utm-generator.tsx
@@ -378,12 +378,7 @@ export default function UTMGenerator() {
className='w-full font-mono text-sm tracking-tight'
disabled={!generatedURL}
/>
- <Button
- onClick={copyToClipboard}
- disabled={!generatedURL}
- primary
- regular
- >
+ <Button onClick={copyToClipboard} disabled={!generatedURL}>
<CopyIcon className='mr-1 h-4 w-4' />
{copied ? 'Copied!' : 'Copy'}
</Button>
diff --git a/web/app/ui/Button.tsx b/web/app/ui/Button.tsx
index 282342372..01f83c5fc 100644
--- a/web/app/ui/Button.tsx
+++ b/web/app/ui/Button.tsx
@@ -5,95 +5,136 @@ import { cn } from '~/utils/generic'
import Spin from './icons/Spin'
-interface ButtonProps extends React.ComponentPropsWithoutRef<
- typeof HeadlessButton
+/**
+ * Visual style of the button.
+ *
+ * - `primary` β€” Filled slate. Default. Use for the main action.
+ * - `secondary` β€” Bordered light grey card. Use for inline secondary actions.
+ * - `white` β€” White surface card with a subtle shadow. Use on grey backgrounds.
+ * - `ghost` β€” No surface. Use for tertiary actions where chrome would be noise.
+ * - `danger` β€” Filled red. Use for destructive actions (delete, etc.).
+ * - `danger-outline` β€” Outlined red. Use for destructive actions in a quieter context.
+ * - `icon` β€” Square, square-padded, quiet. Reveals a card on hover. Pair with an
+ * icon child sized `size-5` (or `size-4` for compact toolbars).
+ * Always set `aria-label` for accessibility.
+ */
+type ButtonVariant =
+ | 'primary'
+ | 'secondary'
+ | 'white'
+ | 'ghost'
+ | 'danger'
+ | 'danger-outline'
+ | 'icon'
+
+/**
+ * Padding + text scale.
+ *
+ * - `xs` β€” `px-2.5 py-1.5 text-xs` (smallest)
+ * - `sm` β€” `px-2.5 py-1.5 text-sm`
+ * - `md` β€” `px-3 py-2 text-sm` (default)
+ * - `lg` β€” `px-4 py-2 text-sm`
+ * - `xl` β€” `px-6 py-3 text-base` (largest)
+ *
+ * Ignored when `variant='icon'` (icon buttons use square padding + `text-sm`).
+ */
+type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
+
+interface ButtonProps extends Omit<
+ React.ComponentPropsWithoutRef<typeof HeadlessButton>,
+ 'children'
> {
- text?: string
- children?: React.ReactNode
- primary?: boolean
- secondary?: boolean
- danger?: boolean
- white?: boolean
- small?: boolean
- regular?: boolean
- large?: boolean
- giant?: boolean
+ variant?: ButtonVariant
+ size?: ButtonSize
loading?: boolean
- semiSmall?: boolean
- semiDanger?: boolean
- focus?: boolean
- noBorder?: boolean
- title?: string
- ghost?: boolean
/**
- * Square icon-only button. Quiet by default, reveals a border + lifts to white
- * on hover. Pair with an icon child sized `size-5` (or `size-4` for compact toolbars).
+ * Whether to render a focus ring on keyboard focus. Defaults to `true`.
+ * Set to `false` for compact toolbar buttons embedded in a list where the ring would be visual noise.
*/
- icon?: boolean
+ focus?: boolean
+ /** Native HTML `title` (tooltip on hover). Prefer the `Tooltip` primitive for richer content. */
+ title?: string
+ children?: React.ReactNode
+}
+
+/**
+ * Class strings for each button variant. Exported so that 3rd-party render-as components
+ * like `<PopoverButton as={...}>` can match the look without nesting two buttons.
+ */
+const BUTTON_VARIANT_CLASSES: Record<ButtonVariant, string> = {
+ primary:
+ 'border-transparent bg-slate-900 text-gray-50 shadow-xs hover:bg-slate-700 dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-white',
+ secondary:
+ 'border-gray-300 bg-gray-50 text-slate-900 hover:bg-slate-200/70 dark:border-slate-700/80 dark:bg-slate-950 dark:text-slate-100 dark:hover:bg-slate-900',
+ white:
+ 'border-transparent bg-white text-gray-700 shadow-xs hover:bg-gray-50 dark:bg-slate-900 dark:text-gray-100 dark:ring-1 dark:ring-slate-700 dark:hover:bg-slate-800',
+ ghost:
+ 'border-transparent bg-transparent text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-900 dark:hover:text-gray-100',
+ danger:
+ 'border-transparent bg-red-500 text-gray-50 shadow-xs hover:bg-red-600 dark:bg-red-600 dark:hover:bg-red-500',
+ 'danger-outline':
+ 'border-red-500 text-red-600 hover:bg-red-50 dark:border-red-400/70 dark:text-red-400 dark:hover:bg-red-500/15',
+ icon: 'border-transparent bg-gray-50 p-2 text-sm text-gray-700 hover:border-gray-300 hover:bg-white dark:bg-slate-950 dark:text-gray-200 dark:hover:border-slate-700/80 dark:hover:bg-slate-900',
+}
+
+const BUTTON_SIZE_CLASSES: Record<ButtonSize, string> = {
+ xs: 'px-2.5 py-1.5 text-xs',
+ sm: 'px-2.5 py-1.5 text-sm',
+ md: 'px-3 py-2 text-sm',
+ lg: 'px-4 py-2 text-sm',
+ xl: 'px-6 py-3 text-base',
+}
+
+interface ButtonClassesOptions {
+ variant?: ButtonVariant
+ size?: ButtonSize
+ focus?: boolean
+ className?: string
+}
+
+/**
+ * Returns the merged class string for a Button. Use this when you need the same
+ * styling on a non-Button element (e.g., `<PopoverButton as='div' className={buttonClasses({variant: 'icon'})}>`).
+ */
+export const buttonClasses = ({
+ variant = 'primary',
+ size = 'md',
+ focus = true,
+ className,
+}: ButtonClassesOptions = {}) => {
+ const isIcon = variant === 'icon'
+ return cn(
+ 'relative inline-flex items-center rounded-md border leading-4 font-medium select-none',
+ 'transition-[background-color,color,box-shadow,transform] duration-150 ease-out',
+ 'active:scale-[0.985] active:duration-75',
+ focus &&
+ 'focus-visible:ring-2 focus-visible:ring-slate-900 focus-visible:ring-offset-2 focus-visible:outline-hidden dark:focus-visible:ring-slate-300 dark:focus-visible:ring-offset-slate-950',
+ 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 disabled:active:scale-100',
+ BUTTON_VARIANT_CLASSES[variant],
+ !isIcon && BUTTON_SIZE_CLASSES[size],
+ className,
+ )
}
const Button = ({
- text,
- children,
- primary,
- secondary,
- danger,
- white,
- small,
- regular,
- large,
- giant,
+ variant = 'primary',
+ size = 'md',
type = 'button',
className,
loading,
- semiSmall,
- semiDanger,
- noBorder,
- focus = true,
disabled,
- ghost,
- icon,
+ focus = true,
+ children,
...props
}: ButtonProps) => (
<HeadlessButton
{...props}
disabled={disabled || loading}
type={type}
- className={cn(
- 'relative inline-flex items-center rounded-md border leading-4 font-medium select-none',
- 'transition-[background-color,color,box-shadow,transform] duration-150 ease-out',
- 'active:scale-[0.985] active:duration-75',
- 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 disabled:active:scale-100',
- {
- 'border-transparent bg-slate-900 text-gray-50 shadow-xs hover:bg-slate-700 dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-white':
- primary,
- 'border-gray-300 bg-gray-50 text-slate-900 hover:bg-slate-200/70 dark:border-slate-700/80 dark:bg-slate-950 dark:text-slate-100 dark:hover:bg-slate-900':
- secondary,
- 'border-transparent bg-white text-gray-700 shadow-xs hover:bg-gray-50 dark:bg-slate-900 dark:text-gray-100 dark:ring-1 dark:ring-slate-700 dark:hover:bg-slate-800':
- white,
- 'border-transparent bg-red-500 text-gray-50 shadow-xs hover:bg-red-600 dark:bg-red-600 dark:hover:bg-red-500':
- danger,
- 'border-red-500 text-red-600 hover:bg-red-50 dark:border-red-400/70 dark:text-red-400 dark:hover:bg-red-500/15':
- semiDanger,
- 'border-transparent bg-transparent text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-900 dark:hover:text-gray-100':
- ghost,
- 'border-transparent bg-gray-50 p-2 text-gray-700 hover:border-gray-300 hover:bg-white dark:bg-slate-950 dark:text-gray-200 dark:hover:border-slate-700/80 dark:hover:bg-slate-900':
- icon,
- 'border-none text-gray-700 focus:border-none focus:ring-0 focus:ring-offset-0 dark:text-gray-200':
- noBorder,
- 'px-2.5 py-1.5 text-xs': small && !icon,
- 'px-2.5 py-1.5 text-sm': semiSmall && !icon,
- 'px-4 py-2 text-sm': large && !icon,
- 'px-6 py-3 text-base': giant && !icon,
- 'px-3 py-2 text-sm': regular && !icon,
- 'focus-visible:ring-2 focus-visible:ring-slate-900 focus-visible:ring-offset-2 focus-visible:outline-hidden dark:focus-visible:ring-slate-300 dark:focus-visible:ring-offset-slate-950':
- focus,
- },
- className,
- )}
+ className={buttonClasses({ variant, size, focus, className })}
>
{loading ? <Spin inherit /> : null}
- {text || children}
+ {children}
</HeadlessButton>
)
diff --git a/web/app/ui/Modal.tsx b/web/app/ui/Modal.tsx
index 82a09e325..b83e06f76 100644
--- a/web/app/ui/Modal.tsx
+++ b/web/app/ui/Modal.tsx
@@ -166,13 +166,13 @@ const Modal = ({
<div className='mt-5 flex flex-col-reverse gap-2 sm:mt-4 sm:flex-row sm:justify-end'>
{closeText ? (
<Button
+ variant='secondary'
+ size='lg'
onClick={(e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault()
e.stopPropagation()
onClose?.()
}}
- secondary
- large
className='w-full justify-center sm:w-auto'
>
{closeText}
@@ -180,12 +180,11 @@ const Modal = ({
) : null}
{submitText ? (
<Button
+ size='lg'
onClick={onSubmit}
disabled={submitDisabled}
loading={isLoading}
- primary={submitType === 'regular'}
- danger={submitType === 'danger'}
- large
+ variant={submitType === 'danger' ? 'danger' : 'primary'}
className='w-full justify-center sm:w-auto'
>
{submitText}