From 1caa6d146a363ca728b310dc0f22061917451efc Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Thu, 6 Jan 2022 17:33:34 +0100 Subject: [PATCH] chore(Badge): add preset system --- docs/pages/migration.vue | 4 +- src/presets/tailwindui.ts | 19 ++++++- src/runtime/components/elements/Badge.vue | 63 +++++++++-------------- 3 files changed, 44 insertions(+), 42 deletions(-) diff --git a/docs/pages/migration.vue b/docs/pages/migration.vue index ca61f2f4..33684feb 100644 --- a/docs/pages/migration.vue +++ b/docs/pages/migration.vue @@ -78,7 +78,9 @@ const components = [ { label: 'Badge', to: '/components/Badge', - nuxt3: true + nuxt3: true, + capi: true, + preset: true }, { label: 'Button', diff --git a/src/presets/tailwindui.ts b/src/presets/tailwindui.ts index facfe17b..ed58f607 100644 --- a/src/presets/tailwindui.ts +++ b/src/presets/tailwindui.ts @@ -95,6 +95,22 @@ const button = { } } +const badge = { + base: 'inline-flex items-center font-medium', + size: { + sm: 'text-xs px-2 py-0.5', + md: 'text-sm px-2.5 py-0.5', + lg: 'text-sm px-3 py-0.5', + xl: 'text-sm px-4 py-1' + }, + variant: { + ...colors.reduce((acc: any, color) => { + acc[color] = `bg-${color}-100 dark:bg-${color}-700 text-${color}-800 dark:text-${color}-100` + return acc + }, {}) + } +} + const formGroup = { wrapper: '', label: 'block text-sm font-medium u-text-gray-700', @@ -256,14 +272,15 @@ const verticalNavigation = { } export default { + card, button, + badge, formGroup, input, textarea, select, checkbox, radio, - card, container, toggle, verticalNavigation diff --git a/src/runtime/components/elements/Badge.vue b/src/runtime/components/elements/Badge.vue index 016c52b7..3f965a74 100644 --- a/src/runtime/components/elements/Badge.vue +++ b/src/runtime/components/elements/Badge.vue @@ -1,27 +1,34 @@