chore: update button stylings
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ThemeColor, getThemeColorHexByName, getThemeColorRgbByName } from '../../../../shared/util/themeColors';
|
|
||||||
import type IconComponent from '~icons/material-symbols';
|
import type IconComponent from '~icons/material-symbols';
|
||||||
|
import { ThemeColor, getThemeColorHexByName, getThemeColorRgbByName } from '../../../../shared/util/themeColors';
|
||||||
import Text from '../Text/Text';
|
import Text from '../Text/Text';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -40,21 +40,17 @@ export function Button({
|
|||||||
style={
|
style={
|
||||||
{
|
{
|
||||||
...style,
|
...style,
|
||||||
'--color': colorHex,
|
color: colorHex,
|
||||||
'--bg-color-8': `rgba(${colorRgb} / 0.08)`,
|
backgroundColor: `rgb(${colorRgb} / var(--un-bg-opacity)`,
|
||||||
'--shadow-color-15': `rgba(${colorRgb} / 0.15)`,
|
|
||||||
'--shadow-color-30': `rgba(${colorRgb} / 0.3)`,
|
|
||||||
} as React.CSSProperties
|
} as React.CSSProperties
|
||||||
}
|
}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'btn',
|
'btn',
|
||||||
{
|
{
|
||||||
'disabled:(cursor-not-allowed opacity-50)': disabled,
|
'text-white! bg-opacity-100 hover:enabled:shadow-md active:enabled:shadow-sm shadow-black/20':
|
||||||
'color-white bg-[var(--color)] border-[var(--color)] hover:enabled:btn-shadow':
|
|
||||||
variant === 'filled',
|
variant === 'filled',
|
||||||
'color-[var(--color)] bg-white border-current hover:enabled:btn-shade border border-solid':
|
'bg-opacity-0 border-current hover:enabled:bg-opacity-8 border': variant === 'outline',
|
||||||
variant === 'outline',
|
'bg-opacity-0 border-none hover:enabled:bg-opacity-8': variant === 'single', // settings is the only "single"
|
||||||
'color-[var(--color)] bg-white border-white hover:enabled:btn-shade': variant === 'single', // settings is the only "single"
|
|
||||||
'px-2 py-1.25': isIconOnly && variant !== 'outline',
|
'px-2 py-1.25': isIconOnly && variant !== 'outline',
|
||||||
'px-1.75 py-1.25': isIconOnly && variant === 'outline',
|
'px-1.75 py-1.25': isIconOnly && variant === 'outline',
|
||||||
'px-3.75': variant === 'outline' && !isIconOnly,
|
'px-3.75': variant === 'outline' && !isIconOnly,
|
||||||
@@ -65,7 +61,7 @@ export function Button({
|
|||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onClick={disabled ? undefined : onClick}
|
onClick={disabled ? undefined : onClick}
|
||||||
>
|
>
|
||||||
{icon && <Icon className='size-6' />}
|
{icon && <Icon className='h-6 w-6' />}
|
||||||
{!isIconOnly && (
|
{!isIconOnly && (
|
||||||
<Text variant='h4' className='translate-y-0.08'>
|
<Text variant='h4' className='translate-y-0.08'>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -7,18 +7,9 @@ import { colors } from './src/shared/util/themeColors';
|
|||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
rules: [
|
rules: [
|
||||||
['btn-transition', { transition: 'color 180ms, border-color 150ms, background-color 150ms, transform 50ms' }],
|
|
||||||
[
|
[
|
||||||
'btn-shadow',
|
'btn-transition',
|
||||||
{
|
{ transition: 'color 180ms, border-color 150ms, background-color 150ms, box-shadow 100ms, transform 50ms' },
|
||||||
'box-shadow': '0px 1px 3px 1px var(--shadow-color-15), 0px 1px 2px 0px var(--shadow-color-30);',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'btn-shade',
|
|
||||||
{
|
|
||||||
'background-color': 'var(--bg-color-8)',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'ring-offset-0',
|
'ring-offset-0',
|
||||||
@@ -29,7 +20,7 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
shortcuts: {
|
shortcuts: {
|
||||||
focusable: 'outline-none ring-blue-500/50 dark:ring-blue-400/60 ring-0 focus-visible:ring-4',
|
focusable: 'outline-none ring-blue-500/50 dark:ring-blue-400/60 ring-0 focus-visible:ring-4',
|
||||||
btn: 'h-10 w-auto flex cursor-pointer justify-center items-center gap-2 rounded-1 px-4 py-0 text-4.5 btn-transition',
|
btn: 'h-10 w-auto flex cursor-pointer justify-center items-center gap-2 rounded-1 px-4 py-0 text-4.5 btn-transition btn-transition disabled:(cursor-not-allowed opacity-50) active:enabled:scale-96 focusable',
|
||||||
},
|
},
|
||||||
theme: {
|
theme: {
|
||||||
easing: {
|
easing: {
|
||||||
|
|||||||
Reference in New Issue
Block a user