From bbcf937b531a9b0dc8d71429ea30e8d2bddc7da6 Mon Sep 17 00:00:00 2001 From: Ilya Artamonov Date: Tue, 28 Nov 2023 15:47:04 +0300 Subject: [PATCH] feat: Added table component (#28) * feat: Added table component * test: Fixed tests, updated snapshots * fix: Fixed types build * fix: Added disabled state to BuiInput --- src/components/BuiButton/BuiButton.vue | 23 ++- .../test/default-disabled.output.html | 2 +- .../BuiButton/test/default.output.html | 2 +- .../test/secondary-disabled.output.html | 2 +- .../BuiButton/test/secondary.output.html | 2 +- .../BuiButton/test/text-disabled.output.html | 2 +- .../BuiButton/test/text.output.html | 2 +- src/components/BuiButton/types.ts | 2 +- src/components/BuiInput/BuiInput.spec.ts | 6 +- src/components/BuiInput/BuiInput.vue | 7 +- src/components/BuiRadio/BuiRadio.vue | 4 - src/components/BuiTable/BuiTable.story.vue | 159 ++++++++++++++++++ src/components/BuiTable/BuiTable.vue | 7 + src/components/BuiTable/BuiTableBody.vue | 7 + src/components/BuiTable/BuiTableCell.vue | 7 + src/components/BuiTable/BuiTableFooter.vue | 7 + src/components/BuiTable/BuiTableHead.vue | 9 + src/components/BuiTable/BuiTableHeadCell.vue | 7 + src/components/BuiTable/BuiTableRow.vue | 7 + src/index.ts | 7 + tailwind.config.ts | 3 +- 21 files changed, 253 insertions(+), 21 deletions(-) create mode 100644 src/components/BuiTable/BuiTable.story.vue create mode 100644 src/components/BuiTable/BuiTable.vue create mode 100644 src/components/BuiTable/BuiTableBody.vue create mode 100644 src/components/BuiTable/BuiTableCell.vue create mode 100644 src/components/BuiTable/BuiTableFooter.vue create mode 100644 src/components/BuiTable/BuiTableHead.vue create mode 100644 src/components/BuiTable/BuiTableHeadCell.vue create mode 100644 src/components/BuiTable/BuiTableRow.vue diff --git a/src/components/BuiButton/BuiButton.vue b/src/components/BuiButton/BuiButton.vue index 1ea2573..b37c7e1 100644 --- a/src/components/BuiButton/BuiButton.vue +++ b/src/components/BuiButton/BuiButton.vue @@ -7,14 +7,16 @@ interface IBuiButtonProps { disabled?: boolean color?: ButtonColor size?: ButtonSize + classes?: string } const props = withDefaults(defineProps(), { disabled: false, color: 'primary', - size: 'md' + size: 'md', + classes: '' }) -const baseClasses = 'font-medium rounded text-sm focus:outline-none' +const baseClasses = 'font-medium rounded text-sm focus:outline-none flex' // Style Classes @@ -45,6 +47,12 @@ const outlineButtonClasses = { disabled: 'text-primary-250 border-primary-250 bg-primary-100 dark:bg-transparent hover:bg-primary-100 cursor-not-allowed dark:border-primary-590 dark:text-primary-590 dark:hover:text-primary-590' } +const iconButtonClasses = { + base: 'bg-primary-150 dark:bg-primary-650', + hover: 'hover:bg-primary-150 dark:hover:bg-primary-650', + focus: 'dark:focus:ring-primary-300 focus:bg-primary-175', + disabled: 'text-primary-250 hover:bg-white cursor-not-allowed' +} const colorClasses: Record = { primary: twJoin( primaryButtonClasses.base, @@ -69,6 +77,12 @@ const colorClasses: Record = { outlineButtonClasses.hover, outlineButtonClasses.focus, props.disabled && outlineButtonClasses.disabled + ), + icon: twJoin( + iconButtonClasses.base, + iconButtonClasses.focus, + iconButtonClasses.hover, + props.disabled && iconButtonClasses.disabled ) } const sizeClasses: Record = { @@ -78,12 +92,13 @@ const sizeClasses: Record = { } const buttonClasses = computed(() => { - return twMerge(baseClasses, colorClasses[props.color], sizeClasses[props.size]) + return twMerge(baseClasses, colorClasses[props.color], sizeClasses[props.size], props.classes) }) +const emit = defineEmits(['click'])