From 15812aba6391d26979cb4f8085468285b585a0d0 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Wed, 18 Jan 2023 20:08:42 +0530 Subject: [PATCH 1/2] fix:add icon sizes, table checkbox padding not align for sm size, tab remove default value --- .../src/components/button/Button.stories.tsx | 38 +++++++++++++++- .../src/components/button/Button.tsx | 43 +++++++++++-------- .../src/components/table/Table.stories.tsx | 13 ++++++ .../src/components/table/Table.tsx | 20 +++++---- .../src/components/tabs/Tabs.tsx | 4 +- 5 files changed, 87 insertions(+), 31 deletions(-) diff --git a/deepfence_frontend/packages/ui-components/src/components/button/Button.stories.tsx b/deepfence_frontend/packages/ui-components/src/components/button/Button.stories.tsx index aa2a8cbc43..49edfabe73 100644 --- a/deepfence_frontend/packages/ui-components/src/components/button/Button.stories.tsx +++ b/deepfence_frontend/packages/ui-components/src/components/button/Button.stories.tsx @@ -18,6 +18,40 @@ Default.args = { children: 'Button text md', }; +export const XsSize = Template.bind({}); +XsSize.args = { + children: 'Button text md', + endIcon: , + size: 'xs', +}; + +export const SMSize = Template.bind({}); +SMSize.args = { + children: 'Button text md', + endIcon: , + size: 'sm', +}; + +export const MDSize = Template.bind({}); +MDSize.args = { + children: 'Button text md', + endIcon: , +}; + +export const LGSize = Template.bind({}); +LGSize.args = { + children: 'Button text md', + endIcon: , + size: 'lg', +}; + +export const XLSize = Template.bind({}); +XLSize.args = { + children: 'Button text md', + endIcon: , + size: 'xl', +}; + export const NormalButton = Template.bind({}); NormalButton.args = { children: 'Normal text md', @@ -112,8 +146,8 @@ PrimaryWithBothIcon.args = { endIcon: , }; -export const DefaultWithIcon = Template.bind({}); -DefaultWithIcon.args = { +export const XSWithIcon = Template.bind({}); +XSWithIcon.args = { children: 'Button text', size: 'xs', startIcon: , diff --git a/deepfence_frontend/packages/ui-components/src/components/button/Button.tsx b/deepfence_frontend/packages/ui-components/src/components/button/Button.tsx index 191ef0e716..9f932099ae 100644 --- a/deepfence_frontend/packages/ui-components/src/components/button/Button.tsx +++ b/deepfence_frontend/packages/ui-components/src/components/button/Button.tsx @@ -1,5 +1,6 @@ import { cva, VariantProps } from 'cva'; import React, { ComponentProps, useId } from 'react'; +import { IconContext } from 'react-icons'; import { twMerge } from 'tailwind-merge'; import { ObjectWithNonNullableValues } from '@/types/utils'; @@ -156,11 +157,11 @@ interface ButtonProps const iconCva = cva('', { variants: { size: { - xs: '', - sm: '', - md: '', - lg: '', - xl: '', + xs: 'w-3 h-3', + sm: 'w-3.5 h-3.5', + md: 'w-4.5 h-4.5', + lg: 'w-5.5 h-5.5', + xl: 'w-5.5 h-5.5', }, withStartIcon: { true: '', @@ -229,31 +230,35 @@ interface IconProps extends VariantProps { const StartIcon = ({ id, startIcon, endIcon, size }: IconProps) => { return ( - {startIcon} - + ); }; const EndIcon = ({ id, size, startIcon, endIcon }: IconProps) => { return ( - {endIcon} - + ); }; diff --git a/deepfence_frontend/packages/ui-components/src/components/table/Table.stories.tsx b/deepfence_frontend/packages/ui-components/src/components/table/Table.stories.tsx index 5c4737fd76..7ab2d27c32 100644 --- a/deepfence_frontend/packages/ui-components/src/components/table/Table.stories.tsx +++ b/deepfence_frontend/packages/ui-components/src/components/table/Table.stories.tsx @@ -24,6 +24,11 @@ type Fruit = { const Template: ComponentStory> = (args) => { const columnHelper = createColumnHelper(); + const checkboxRow = getRowSelectionColumn(columnHelper, { + size: 100, + minSize: 100, + maxSize: 100, + }); const columns = useMemo( () => [ columnHelper.accessor('id', { @@ -42,6 +47,9 @@ const Template: ComponentStory> = (args) => { ], [], ); + if (args.enableRowSelection) { + columns.unshift(checkboxRow); + } return ( { + return false; + }, }; export const StripedTable = Template.bind({}); diff --git a/deepfence_frontend/packages/ui-components/src/components/table/Table.tsx b/deepfence_frontend/packages/ui-components/src/components/table/Table.tsx index 9bfaa4f97b..5f2d382587 100644 --- a/deepfence_frontend/packages/ui-components/src/components/table/Table.tsx +++ b/deepfence_frontend/packages/ui-components/src/components/table/Table.tsx @@ -251,8 +251,8 @@ function Th({ onClick={header.column.getToggleSortingHandler()} >
@@ -360,12 +360,16 @@ function Td({
diff --git a/deepfence_frontend/packages/ui-components/src/components/tabs/Tabs.tsx b/deepfence_frontend/packages/ui-components/src/components/tabs/Tabs.tsx index 4bff2b4ce6..eb9ec8c5aa 100644 --- a/deepfence_frontend/packages/ui-components/src/components/tabs/Tabs.tsx +++ b/deepfence_frontend/packages/ui-components/src/components/tabs/Tabs.tsx @@ -30,9 +30,9 @@ const classes = { }; const Tabs = (props: TabProps) => { - const { tabs, value, defaultValue, size = 'sm', children, ...rest } = props; + const { tabs, value, size = 'sm', children, ...rest } = props; return ( - + Date: Wed, 18 Jan 2023 20:27:44 +0530 Subject: [PATCH 2/2] fix test failed --- .../src/components/button/Button.tsx | 50 ++++++++++--------- .../table/__snapshots__/table.test.tsx.snap | 38 +++++++------- 2 files changed, 45 insertions(+), 43 deletions(-) diff --git a/deepfence_frontend/packages/ui-components/src/components/button/Button.tsx b/deepfence_frontend/packages/ui-components/src/components/button/Button.tsx index 9f932099ae..a426969aa0 100644 --- a/deepfence_frontend/packages/ui-components/src/components/button/Button.tsx +++ b/deepfence_frontend/packages/ui-components/src/components/button/Button.tsx @@ -230,35 +230,37 @@ interface IconProps extends VariantProps { const StartIcon = ({ id, startIcon, endIcon, size }: IconProps) => { return ( - - {startIcon} - + + + {startIcon} + + ); }; const EndIcon = ({ id, size, startIcon, endIcon }: IconProps) => { return ( - - {endIcon} - + + + {endIcon} + + ); }; diff --git a/deepfence_frontend/packages/ui-components/src/components/table/__snapshots__/table.test.tsx.snap b/deepfence_frontend/packages/ui-components/src/components/table/__snapshots__/table.test.tsx.snap index 78eb358250..7ee39a76a6 100644 --- a/deepfence_frontend/packages/ui-components/src/components/table/__snapshots__/table.test.tsx.snap +++ b/deepfence_frontend/packages/ui-components/src/components/table/__snapshots__/table.test.tsx.snap @@ -1,35 +1,35 @@ // Vitest Snapshot v1 -exports[`Component Table > should render a basic table > cells with border 0 1`] = `""`; +exports[`Component Table > should render a basic table > cells with border 0 1`] = `""`; -exports[`Component Table > should render a basic table > cells with border 1 1`] = `""`; +exports[`Component Table > should render a basic table > cells with border 1 1`] = `""`; -exports[`Component Table > should render a basic table > cells with border 2 1`] = `""`; +exports[`Component Table > should render a basic table > cells with border 2 1`] = `""`; -exports[`Component Table > should render a basic table > cells without border 3 1`] = `""`; +exports[`Component Table > should render a basic table > cells without border 3 1`] = `""`; -exports[`Component Table > should render a basic table > cells without border 4 1`] = `""`; +exports[`Component Table > should render a basic table > cells without border 4 1`] = `""`; -exports[`Component Table > should render a basic table > cells without border 5 1`] = `""`; +exports[`Component Table > should render a basic table > cells without border 5 1`] = `""`; exports[`Component Table > should render a basic table > row with hover state on normal table 1`] = `
{flexRender(cell.column.columnDef.cell, cell.getContext())} 00Fruit 0Fruit 0Description for 0Description for 011Fruit 1Fruit 1Description for 1Description for 1
1 Fruit 1 Description for 1 @@ -39,7 +39,7 @@ exports[`Component Table > should render a basic table > row with hover state on exports[`Component Table > should render a striped table > cells should not have border 1`] = ` Fruit 0 @@ -51,19 +51,19 @@ exports[`Component Table > should render a striped table > even rows should have class="bg-gray-50 dark:bg-gray-700 hover:!bg-gray-100 dark:hover:!bg-gray-600 transition-colors" > 1 Fruit 1 Description for 1 @@ -76,19 +76,19 @@ exports[`Component Table > should render a striped table > odd rows should have class="hover:!bg-gray-100 dark:hover:!bg-gray-600 transition-colors" > 0 Fruit 0 Description for 0 @@ -101,19 +101,19 @@ exports[`Component Table > should render a striped table > row with hover state class="bg-gray-50 dark:bg-gray-700 hover:!bg-gray-100 dark:hover:!bg-gray-600 transition-colors" > 1 Fruit 1 Description for 1