diff --git a/ui/src/components/Button.tsx b/ui/src/components/Button.tsx index 7655415..9e4f191 100644 --- a/ui/src/components/Button.tsx +++ b/ui/src/components/Button.tsx @@ -1,5 +1,5 @@ import clsx from 'clsx' -import { JSXElement, Show } from 'solid-js' +import { JSX, JSXElement, Show } from 'solid-js' type DaisyUIButtonColor = | 'neutral' @@ -15,14 +15,9 @@ type DaisyUIButtonVariant = 'outline' | 'dash' | 'soft' | 'ghost' | 'link' type DaisyUIButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' -/** - * Renders a button component with an optional loading state. - * If the loading state is passed the button will be disabled and show - * a loader ball while loading. - */ -export function Button(props: { - label: string - icon?: string +type DaisyUIButtonShape = 'square' | 'circle' + +interface ButtonBaseProps { onClick?: (event?: MouseEvent) => void isLoading?: boolean disabled?: boolean @@ -30,68 +25,99 @@ export function Button(props: { color?: DaisyUIButtonColor size?: DaisyUIButtonSize variant?: DaisyUIButtonVariant + shape?: DaisyUIButtonShape + block?: boolean class?: string + style?: JSX.CSSProperties dataCy?: string -}): JSXElement { + ref?: (el: HTMLButtonElement) => void +} + +/** + * Renders a button component with an optional loading state. + * If the loading state is passed the button will be disabled and show + * a loader ball while loading. + */ +export function Button( + props: ButtonBaseProps & { + label: JSXElement + icon?: string + trailingIcon?: string + } +): JSXElement { + const isDisabled = () => props.disabled || props.isLoading + return ( ) } -export function IconButton(props: { - icon: string - onClick?: () => void - isLoading?: boolean - disabled?: boolean - color?: DaisyUIButtonColor - size?: DaisyUIButtonSize - variant?: DaisyUIButtonVariant - class?: string - dataCy?: string -}): JSXElement { +export function IconButton( + props: ButtonBaseProps & { + icon: string + } +): JSXElement { + const isDisabled = () => props.disabled || props.isLoading + return ( - + label={ + + {t('frozen_upgrade_button')} + + } + />

{t('upgrade_available_soon')} diff --git a/ui/src/components/LanguageSelector.tsx b/ui/src/components/LanguageSelector.tsx index ad671fd..0118c46 100644 --- a/ui/src/components/LanguageSelector.tsx +++ b/ui/src/components/LanguageSelector.tsx @@ -1,5 +1,6 @@ import { createEffect, JSXElement, For } from 'solid-js' +import { Button } from './Button' import { useLocale, locales } from '../context/LocaleProvider' export function LanguageSelector(): JSXElement { @@ -23,19 +24,20 @@ export function LanguageSelector(): JSXElement { {(language) => (

  • - + label={ +
    + + {language} +
    + } + />
  • )} diff --git a/ui/src/components/Modal.tsx b/ui/src/components/Modal.tsx index abba0c4..3d0710b 100644 --- a/ui/src/components/Modal.tsx +++ b/ui/src/components/Modal.tsx @@ -2,6 +2,8 @@ import clsx from 'clsx' import { createSignal, JSXElement } from 'solid-js' import { Portal } from 'solid-js/web' +import { Button } from './Button' + /** * Creates a modal state that can be used to open and close modals * the keys passed in are used as identifiers for identifying differnent modals. @@ -43,12 +45,14 @@ export function Modal(props: { class={clsx('modal z-1000', isOpen() ? 'modal-open' : 'modal-close')} > diff --git a/ui/src/components/ProfileMenu.tsx b/ui/src/components/ProfileMenu.tsx index 0c91952..7b9aca0 100644 --- a/ui/src/components/ProfileMenu.tsx +++ b/ui/src/components/ProfileMenu.tsx @@ -1,9 +1,9 @@ import { createSignal, JSXElement, Show } from 'solid-js' import { A, useNavigate } from '@solidjs/router' -import { clsx } from 'clsx' import { useUser } from '../context/UserProvider' import { useLocale } from '../context/LocaleProvider' +import { Button } from './Button' import { Toast } from './Toast' import { logout } from '../api' @@ -65,24 +65,17 @@ export function ProfileMenu(): JSXElement {
  • - + dataCy="logout" + label={t('logout')} + />
  • diff --git a/ui/src/components/TopBar.tsx b/ui/src/components/TopBar.tsx index 2675118..a45a8dc 100644 --- a/ui/src/components/TopBar.tsx +++ b/ui/src/components/TopBar.tsx @@ -5,6 +5,7 @@ import { clsx } from 'clsx' import { useUser } from '../context/UserProvider' import { useLocale } from '../context/LocaleProvider' +import { Button, IconButton } from '../components/Button' import { ThemeSwitcher } from '../components/ThemeSwitcher' import { LanguageSelector } from '../components/LanguageSelector' import { LoginModal } from '../components/LoginModal' @@ -22,12 +23,12 @@ export function TopBar(): JSXElement { <> @@ -82,12 +81,12 @@ export function TopBar(): JSXElement { My solid app - + />
    @@ -104,29 +103,31 @@ export function TopBar(): JSXElement { } >
    -