Skip to content

Commit c4df56c

Browse files
author
mdatelle
committed
refactor: add brand variants to the regulr button
1 parent c4d4860 commit c4df56c

File tree

3 files changed

+65
-54
lines changed

3 files changed

+65
-54
lines changed

unraid-ui/src/components/brand/BrandButton.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
2-
import { computed } from 'vue';
3-
import { type BrandButtonVariants, brandButtonVariants } from './brand-button.variants';
42
import { cn } from '@/lib/utils';
3+
import { computed } from 'vue';
4+
import { brandButtonVariants, type BrandButtonVariants } from './brand-button.variants';
55
66
export interface BrandButtonProps {
77
variant?: BrandButtonVariants['variant'];
@@ -43,7 +43,10 @@ const classes = computed(() => {
4343
const iconSize = `w-${props.size}`;
4444
4545
return {
46-
button: cn(brandButtonVariants({ variant: props.variant, size: props.size, padding: props.padding }), props.class),
46+
button: cn(
47+
brandButtonVariants({ variant: props.variant, size: props.size, padding: props.padding }),
48+
props.class
49+
),
4750
icon: `${iconSize} fill-current flex-shrink-0`,
4851
};
4952
});
@@ -74,11 +77,7 @@ const needsBrandGradientBackground = computed(() => {
7477
class="absolute -top-[2px] -right-[2px] -bottom-[2px] -left-[2px] -z-10 bg-gradient-to-r from-unraid-red to-orange opacity-0 transition-all rounded-md group-hover:opacity-100 group-focus:opacity-100"
7578
/>
7679

77-
<component
78-
:is="icon"
79-
v-if="icon"
80-
:class="classes.icon"
81-
/>
80+
<component :is="icon" v-if="icon" :class="classes.icon" />
8281

8382
{{ text }}
8483
<slot />
@@ -88,7 +87,8 @@ const needsBrandGradientBackground = computed(() => {
8887
v-if="iconRight"
8988
:class="[
9089
classes.icon,
91-
iconRightHoverDisplay && 'opacity-0 group-hover:opacity-100 group-focus:opacity-100 transition-all',
90+
iconRightHoverDisplay &&
91+
'opacity-0 group-hover:opacity-100 group-focus:opacity-100 transition-all',
9292
]"
9393
/>
9494
</component>

unraid-ui/src/components/brand/brand-button.variants.ts

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,78 @@
1-
import { cva, type VariantProps } from "class-variance-authority";
1+
import { cva, type VariantProps } from 'class-variance-authority';
22

33
export const brandButtonVariants = cva(
4-
"group text-center font-semibold leading-none relative z-0 flex flex-row items-center justify-center border-2 border-solid shadow-none cursor-pointer rounded-md hover:shadow-md focus:shadow-md disabled:opacity-25 disabled:hover:opacity-25 disabled:focus:opacity-25 disabled:cursor-not-allowed",
4+
'group text-center font-semibold leading-none relative z-0 flex flex-row items-center justify-center border-2 border-solid shadow-none cursor-pointer rounded-md hover:shadow-md focus:shadow-md disabled:opacity-25 disabled:hover:opacity-25 disabled:focus:opacity-25 disabled:cursor-not-allowed',
55
{
66
variants: {
77
variant: {
8-
fill: "[&]:text-white bg-transparent border-transparent",
9-
black: "[&]:text-white bg-black border-black transition hover:text-black focus:text-black hover:bg-grey focus:bg-grey hover:border-grey focus:border-grey",
10-
gray: "text-black bg-grey transition hover:text-white focus:text-white hover:bg-grey-mid focus:bg-grey-mid hover:border-grey-mid focus:border-grey-mid",
11-
outline: "[&]:text-orange bg-transparent border-orange hover:text-white focus:text-white",
12-
"outline-primary": "text-primary [&]:text-primary uppercase tracking-widest bg-transparent border-primary rounded-sm hover:text-white focus:text-white",
13-
"outline-black": "text-black bg-transparent border-black hover:text-black focus:text-black hover:bg-grey focus:bg-grey hover:border-grey focus:border-grey",
14-
"outline-white": "text-white bg-transparent border-white hover:text-black focus:text-black hover:bg-white focus:bg-white",
15-
underline: "opacity-75 underline border-transparent transition hover:text-primary hover:bg-muted hover:border-muted focus:text-primary focus:bg-muted focus:border-muted hover:opacity-100 focus:opacity-100",
16-
"underline-hover-red": "opacity-75 underline border-transparent transition hover:text-white hover:bg-unraid-red hover:border-unraid-red focus:text-white focus:bg-unraid-red focus:border-unraid-red hover:opacity-100 focus:opacity-100",
17-
white: "text-black bg-white transition hover:bg-grey focus:bg-grey",
18-
none: "",
8+
fill: '[&]:text-white bg-transparent border-transparent',
9+
black:
10+
'[&]:text-white bg-black border-black transition hover:text-black focus:text-black hover:bg-grey focus:bg-grey hover:border-grey focus:border-grey',
11+
gray: 'text-black bg-grey transition hover:text-white focus:text-white hover:bg-grey-mid focus:bg-grey-mid hover:border-grey-mid focus:border-grey-mid',
12+
outline: '[&]:text-orange bg-transparent border-orange hover:text-white focus:text-white',
13+
'outline-primary':
14+
'text-primary [&]:text-primary uppercase tracking-widest bg-transparent border-primary rounded-sm hover:text-white focus:text-white',
15+
'outline-black':
16+
'text-black bg-transparent border-black hover:text-black focus:text-black hover:bg-grey focus:bg-grey hover:border-grey focus:border-grey',
17+
'outline-white':
18+
'text-white bg-transparent border-white hover:text-black focus:text-black hover:bg-white focus:bg-white',
19+
underline:
20+
'opacity-75 underline border-transparent transition hover:text-primary hover:bg-muted hover:border-muted focus:text-primary focus:bg-muted focus:border-muted hover:opacity-100 focus:opacity-100',
21+
'underline-hover-red':
22+
'opacity-75 underline border-transparent transition hover:text-white hover:bg-unraid-red hover:border-unraid-red focus:text-white focus:bg-unraid-red focus:border-unraid-red hover:opacity-100 focus:opacity-100',
23+
white: 'text-black bg-white transition hover:bg-grey focus:bg-grey',
24+
none: '',
1925
},
2026
size: {
21-
"12px": "text-12px gap-4px",
22-
"14px": "text-14px gap-8px",
23-
"16px": "text-16px gap-8px",
24-
"18px": "text-18px gap-8px",
25-
"20px": "text-20px gap-8px",
26-
"24px": "text-24px gap-8px",
27+
'12px': 'text-xs gap-1',
28+
'14px': 'text-sm gap-2',
29+
'16px': 'text-base gap-2',
30+
'18px': 'text-lg gap-2',
31+
'20px': 'text-xl gap-2',
32+
'24px': 'text-2xl gap-2',
2733
},
2834
padding: {
29-
default: "",
30-
none: "p-0",
31-
lean: "px-4 py-2",
35+
default: '',
36+
none: 'p-0',
37+
lean: 'px-4 py-2',
3238
},
3339
},
3440
compoundVariants: [
3541
{
36-
size: "12px",
37-
padding: "default",
38-
class: "p-8px",
42+
size: '12px',
43+
padding: 'default',
44+
class: 'p-8px',
3945
},
4046
{
41-
size: "14px",
42-
padding: "default",
43-
class: "p-8px",
47+
size: '14px',
48+
padding: 'default',
49+
class: 'p-8px',
4450
},
4551
{
46-
size: "16px",
47-
padding: "default",
48-
class: "p-12px",
52+
size: '16px',
53+
padding: 'default',
54+
class: 'p-12px',
4955
},
5056
{
51-
size: "18px",
52-
padding: "default",
53-
class: "p-12px",
57+
size: '18px',
58+
padding: 'default',
59+
class: 'p-12px',
5460
},
5561
{
56-
size: "20px",
57-
padding: "default",
58-
class: "p-16px",
62+
size: '20px',
63+
padding: 'default',
64+
class: 'p-16px',
5965
},
6066
{
61-
size: "24px",
62-
padding: "default",
63-
class: "p-16px",
67+
size: '24px',
68+
padding: 'default',
69+
class: 'p-16px',
6470
},
6571
],
6672
defaultVariants: {
67-
variant: "fill",
68-
size: "16px",
69-
padding: "default",
73+
variant: 'fill',
74+
size: '16px',
75+
padding: 'default',
7076
},
7177
}
7278
);

unraid-ui/src/components/common/button/button.variants.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
import { cva, VariantProps } from 'class-variance-authority';
1+
import { cva, type VariantProps } from 'class-variance-authority';
22

33
export const buttonVariants = cva(
44
'inline-flex items-center justify-center rounded-md text-base font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
55
{
66
variants: {
77
variant: {
88
primary: 'bg-primary text-primary-foreground hover:bg-primary/90',
9+
brand:
10+
'bg-gradient-to-r from-unraid-red to-orange text-white opacity-100 transition-all hover:opacity-60 focus:opacity-60',
911
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
10-
outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
12+
outline:
13+
'border border-input border-2 bg-transparent hover:bg-accent hover:text-accent-foreground',
14+
'outline-brand':
15+
'text-orange bg-transparent border-orange border-2 hover:text-white focus:text-white hover:bg-gradient-to-r hover:from-unraid-red hover:to-orange hover:text-white hover:bg-gradient-to-r hover:from-unraid-red hover:to-orange transition-[background,color,opacity] duration-300 ease-in-out rounded-md hover:opacity-100 focus:opacity-100',
1116
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
1217
ghost: 'hover:bg-accent hover:text-accent-foreground',
1318
link: 'text-primary underline-offset-4 hover:underline',

0 commit comments

Comments
 (0)