From c0545eaea1ed700277dab7507d136e9dca7494b6 Mon Sep 17 00:00:00 2001 From: ErwannRousseau Date: Sun, 24 Nov 2024 19:29:12 +0100 Subject: [PATCH] feat: refactor button component to use link component and remove unused variants --- templates/components/button.html.twig | 5 ----- templates/components/link.html.twig | 26 ++++++++++++++++++++++++++ templates/default/index.html.twig | 2 +- templates/products/index.html.twig | 2 +- 4 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 templates/components/link.html.twig diff --git a/templates/components/button.html.twig b/templates/components/button.html.twig index f1fb345..0392bb3 100644 --- a/templates/components/button.html.twig +++ b/templates/components/button.html.twig @@ -7,7 +7,6 @@ default: 'bg-primary text-primary-foreground hover:bg-primary/90', secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80', destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90', - link: 'text-primary underline-offset-4 hover:underline', }, size: { default: 'h-10 px-4 py-2', @@ -15,10 +14,6 @@ lg: 'h-12 rounded-md px-8', } }, - compoundVariants: [{ - variant: ['link'], - class: 'h-auto p-0', - }], defaultVariants: { variant: 'default', size: 'default', diff --git a/templates/components/link.html.twig b/templates/components/link.html.twig new file mode 100644 index 0000000..1b53212 --- /dev/null +++ b/templates/components/link.html.twig @@ -0,0 +1,26 @@ +{% props variant = 'default', size = 'default' %} + +{% set linkVariants = cva({ + base: 'inline-flex items-center justify-center gap-2 w-fit whitespace-nowrap transition-colors underline-offset-4 hover:underline', + variants: { + variant: { + default: 'text-primary', + secondary: 'text-secondary', + }, + size: { + default: 'text-base', + sm: 'text-sm', + lg: 'text-lg', + } + }, + defaultVariants: { + variant: 'default', + size: 'default', + } +}) %} + + + {% block content '' %} + diff --git a/templates/default/index.html.twig b/templates/default/index.html.twig index d84d353..f6dcbd4 100644 --- a/templates/default/index.html.twig +++ b/templates/default/index.html.twig @@ -10,7 +10,7 @@ Default Secondary Destructive - Show products + Show products {% endblock %} diff --git a/templates/products/index.html.twig b/templates/products/index.html.twig index 6663476..de2e318 100644 --- a/templates/products/index.html.twig +++ b/templates/products/index.html.twig @@ -1,7 +1,7 @@ {% extends 'base.html.twig' %} {% block body %} - Back home + Back home
Our products