From f6ac7575fd8b51f622c93faa9161563f0400e646 Mon Sep 17 00:00:00 2001 From: Nishchit14 Date: Thu, 17 Aug 2023 18:42:39 +0530 Subject: [PATCH] ui: updated usage of checkbox in all related components --- .../status-bar/items/FcAgentSelector.tsx | 2 +- .../src/components/checkbox/Checkbox.scss | 19 ---- .../src/components/checkbox/Checkbox.tsx | 93 +----------------- .../src/components/checkbox/Checkbox2.tsx | 95 +++++++++++-------- .../src/components/checkbox/CheckboxGroup.tsx | 6 +- .../src/components/form/Form.stories.tsx | 20 ++-- .../table/basic-table/BasicTable.tsx | 6 +- .../table/multipart-table/MultipartTable.tsx | 5 +- .../src/components/table/primitive/table.sass | 3 - platform/firecamp-ui/src/scss/base.scss | 5 +- platform/firecamp-ui/src/scss/tailwind.scss | 5 +- .../src/stories/DesignClasses.stories.mdx | 1 - platform/firecamp-ui/src/ui-kit.ts | 4 +- .../src/components/request/tabs/ConfigTab.tsx | 4 +- .../connection-panel/connection/ConfigTab.tsx | 2 +- .../connection/PlaygroundTab.tsx | 2 +- .../connection/playground/EmitterBody.tsx | 6 +- .../src/components/common/config/Config.tsx | 2 +- .../connection-panel/connection/ConfigTab.tsx | 2 +- 19 files changed, 91 insertions(+), 191 deletions(-) diff --git a/platform/firecamp-platform/src/components/status-bar/items/FcAgentSelector.tsx b/platform/firecamp-platform/src/components/status-bar/items/FcAgentSelector.tsx index ccdd6921..47492a06 100644 --- a/platform/firecamp-platform/src/components/status-bar/items/FcAgentSelector.tsx +++ b/platform/firecamp-platform/src/components/status-bar/items/FcAgentSelector.tsx @@ -123,7 +123,7 @@ const AgentItem: FC = ({ className={cx(className, 'text-base text-app-foreground flex items-start')} >
- +
diff --git a/platform/firecamp-ui/src/components/checkbox/Checkbox2.tsx b/platform/firecamp-ui/src/components/checkbox/Checkbox2.tsx index 7ce2387f..c818aaf6 100644 --- a/platform/firecamp-ui/src/components/checkbox/Checkbox2.tsx +++ b/platform/firecamp-ui/src/components/checkbox/Checkbox2.tsx @@ -23,47 +23,60 @@ export interface ICheckbox extends CheckboxProps { showLabel?: boolean; } -const useStyles = createStyles((theme, { primary }: Partial) => ({ - disabled: { - opacity: '50% !important', - '&:checked': { - borderColor: primary - ? theme.colors[theme.primaryColor][theme.colorScheme === 'dark' ? 8 : 6] - : 'initial', - }, - borderColor: 'initial', - }, - input: { - borderRadius: '0px', - borderColor: - theme.colorScheme === 'dark' - ? theme.colors.gray[4] - : theme.colors.dark[5], - backgroundColor: 'transparent !important', - }, - icon: { - ...(primary - ? { - color: `${ - theme.colors[theme.primaryColor][ +const useStyles = createStyles( + (theme, { primary, labelPosition }: Partial) => ({ + disabled: { + opacity: '50% !important', + '&:checked': { + borderColor: primary + ? theme.colors[theme.primaryColor][ theme.colorScheme === 'dark' ? 8 : 6 ] - } !important`, - } - : { - color: `${ - theme.colorScheme === 'dark' - ? theme.colors.gray[4] - : theme.colors.dark[5] - } !important`, - }), - }, - label: { - color: `${ - theme.colorScheme === 'dark' ? theme.colors.gray[4] : theme.colors.dark[5] - } !important`, - }, -})); + : 'initial', + }, + borderColor: 'initial !important', + }, + input: { + borderRadius: '0px', + borderColor: + theme.colorScheme === 'dark' + ? theme.colors.gray[4] + : theme.colors.dark[5], + backgroundColor: 'transparent !important', + }, + icon: { + ...(primary + ? { + color: `${ + theme.colors[theme.primaryColor][ + theme.colorScheme === 'dark' ? 8 : 6 + ] + } !important`, + } + : { + color: `${ + theme.colorScheme === 'dark' + ? theme.colors.gray[4] + : theme.colors.dark[5] + } !important`, + }), + }, + label: { + ...(labelPosition === 'left' + ? { + paddingRight: '0.5rem', + } + : { + paddingLeft: '0.5rem', + }), + color: `${ + theme.colorScheme === 'dark' + ? theme.colors.gray[4] + : theme.colors.dark[5] + } !important`, + }, + }) +); const Checkbox: FC = ({ color, @@ -74,9 +87,10 @@ const Checkbox: FC = ({ disabled = false, onToggleCheck = (l, v) => {}, showLabel = true, + labelPosition, ...props }) => { - const { classes, cx, theme } = useStyles({ primary: primary }); + const { classes, cx, theme } = useStyles({ primary, labelPosition }); const customColor = primary ? 'primaryColor' : theme.colorScheme === 'dark' @@ -91,6 +105,7 @@ const Checkbox: FC = ({ label={showLabel ? label : ''} disabled={disabled} checked={checked} + labelPosition={labelPosition} classNames={{ ...classNames, input: cx(classes.input, classNames.input, { diff --git a/platform/firecamp-ui/src/components/checkbox/CheckboxGroup.tsx b/platform/firecamp-ui/src/components/checkbox/CheckboxGroup.tsx index d335f010..2bdadaf1 100644 --- a/platform/firecamp-ui/src/components/checkbox/CheckboxGroup.tsx +++ b/platform/firecamp-ui/src/components/checkbox/CheckboxGroup.tsx @@ -1,4 +1,4 @@ -import Checkbox from './Checkbox'; +import {Checkbox} from '@firecamp/ui'; const CheckboxGroup = ({ onToggleCheck = (v: {[k: string]: any}) => {}, @@ -15,14 +15,14 @@ const CheckboxGroup = ({ return ( onToggleCheck({ [checkbox.id]: !checkbox.isChecked }) } - className="mr-2" + classNames={{root:"mr-2"}} /> ); })} diff --git a/platform/firecamp-ui/src/components/form/Form.stories.tsx b/platform/firecamp-ui/src/components/form/Form.stories.tsx index 828f7fd5..e6a82903 100644 --- a/platform/firecamp-ui/src/components/form/Form.stories.tsx +++ b/platform/firecamp-ui/src/components/form/Form.stories.tsx @@ -103,16 +103,16 @@ export function FormWithCheckBox() { label={'Namespace'} {...getInputProps('namespace')} /> - - +
+ + +
diff --git a/platform/firecamp-ui/src/components/table/multipart-table/MultipartTable.tsx b/platform/firecamp-ui/src/components/table/multipart-table/MultipartTable.tsx index f967fad2..712233fd 100644 --- a/platform/firecamp-ui/src/components/table/multipart-table/MultipartTable.tsx +++ b/platform/firecamp-ui/src/components/table/multipart-table/MultipartTable.tsx @@ -4,9 +4,8 @@ import { File, GripVertical, Plus, Trash2 } from 'lucide-react'; import { _array } from '@firecamp/utils'; import { VscTextSize } from '@react-icons/all-files/vsc/VscTextSize'; import { EEditorLanguage } from '@firecamp/types'; -import { Input, Button } from '@firecamp/ui'; +import { Button, Checkbox, Input } from '@firecamp/ui'; -import Checkbox from '../../checkbox/Checkbox'; import SingleLineEditor from '../../editors/monaco-v2/SingleLineEditor'; import Table from '../primitive/Table'; import { @@ -68,7 +67,7 @@ const MultipartTable = ({ { onChange(column.key, !val); }} diff --git a/platform/firecamp-ui/src/components/table/primitive/table.sass b/platform/firecamp-ui/src/components/table/primitive/table.sass index 23fe79f6..aa0c57bb 100644 --- a/platform/firecamp-ui/src/components/table/primitive/table.sass +++ b/platform/firecamp-ui/src/components/table/primitive/table.sass @@ -4,9 +4,6 @@ width: calc(100% - 24px) margin: 12px -.primary-table td:first-child svg - width: 100% - .primary-table th position: relative diff --git a/platform/firecamp-ui/src/scss/base.scss b/platform/firecamp-ui/src/scss/base.scss index 6efe5101..8a3e05f3 100644 --- a/platform/firecamp-ui/src/scss/base.scss +++ b/platform/firecamp-ui/src/scss/base.scss @@ -222,9 +222,6 @@ body { .theme-dark .drag-icon { filter: invert(1); } -.icon { - font-family: 'icomoon' !important; -} a, a:hover { @@ -427,7 +424,7 @@ tr:focus-visible { white-space: nowrap !important; } -.fc-form input, +.fc-form input:not([type="checkbox"]), .fc-form select { border-radius: 0px !important; resize: none; diff --git a/platform/firecamp-ui/src/scss/tailwind.scss b/platform/firecamp-ui/src/scss/tailwind.scss index 75c23b1b..9231b40b 100644 --- a/platform/firecamp-ui/src/scss/tailwind.scss +++ b/platform/firecamp-ui/src/scss/tailwind.scss @@ -2191,9 +2191,6 @@ body { .theme-dark .drag-icon { filter: invert(1); } -.icon { - font-family: 'icomoon' !important; -} a, a:hover { @@ -2402,7 +2399,7 @@ tr:focus-visible { white-space: nowrap !important; } -.fc-form input, +.fc-form input:not([type="checkbox"]), .fc-form select { border-radius: 0px !important; resize: none; diff --git a/platform/firecamp-ui/src/stories/DesignClasses.stories.mdx b/platform/firecamp-ui/src/stories/DesignClasses.stories.mdx index e990a2ee..e664d958 100644 --- a/platform/firecamp-ui/src/stories/DesignClasses.stories.mdx +++ b/platform/firecamp-ui/src/stories/DesignClasses.stories.mdx @@ -11,7 +11,6 @@ import { Meta, ColorPalette, ColorItem } from '@storybook/addon-docs'; | ------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | | .theme-light.primary-green,.theme-dark.primary-green | to update the app primary color | | .theme-dark .drag-icon | to invert the icon color in dark theme | -| .icon | to add font family `icomoon` | | a,a:hover | to inherit the text color | | button:disabled,button[disabled] | to update opacity for all disabled button using pseudo class selector | | hr | to update the app border color in horizontal line | diff --git a/platform/firecamp-ui/src/ui-kit.ts b/platform/firecamp-ui/src/ui-kit.ts index 42335fd3..732d48d2 100644 --- a/platform/firecamp-ui/src/ui-kit.ts +++ b/platform/firecamp-ui/src/ui-kit.ts @@ -1,8 +1,8 @@ export { default as Button } from './components/buttons/Button'; export { default as CopyButton } from './components/buttons/CopyButton'; -export { default as Checkbox } from './components/checkbox/Checkbox'; -export { default as Checkbox2 } from './components/checkbox/Checkbox2'; +export { default as Checkbox } from './components/checkbox/Checkbox2'; +export type { ICheckbox } from './components/checkbox/Checkbox2'; export { default as CheckboxGroup } from './components/checkbox/CheckboxGroup'; export { default as Dropdown } from './components/dropdown/Dropdown'; diff --git a/playgrounds/firecamp-rest/src/components/request/tabs/ConfigTab.tsx b/playgrounds/firecamp-rest/src/components/request/tabs/ConfigTab.tsx index 82f33264..23f2fb61 100644 --- a/playgrounds/firecamp-rest/src/components/request/tabs/ConfigTab.tsx +++ b/playgrounds/firecamp-rest/src/components/request/tabs/ConfigTab.tsx @@ -73,13 +73,13 @@ const ConfigTab = () => { _onToggleCheckBox(RejectUnauthorized)} /> { return ( _onChange(name, !connection[name])} diff --git a/playgrounds/firecamp-socket-io/src/components/connection-panel/connection/PlaygroundTab.tsx b/playgrounds/firecamp-socket-io/src/components/connection-panel/connection/PlaygroundTab.tsx index f8f867e0..c3dd3672 100644 --- a/playgrounds/firecamp-socket-io/src/components/connection-panel/connection/PlaygroundTab.tsx +++ b/playgrounds/firecamp-socket-io/src/components/connection-panel/connection/PlaygroundTab.tsx @@ -74,7 +74,7 @@ const EmitterPlayground = () => { changePlgEmitterAck(val)} /> diff --git a/playgrounds/firecamp-socket-io/src/components/connection-panel/connection/playground/EmitterBody.tsx b/playgrounds/firecamp-socket-io/src/components/connection-panel/connection/playground/EmitterBody.tsx index 7ea51c69..3b136baf 100644 --- a/playgrounds/firecamp-socket-io/src/components/connection-panel/connection/playground/EmitterBody.tsx +++ b/playgrounds/firecamp-socket-io/src/components/connection-panel/connection/playground/EmitterBody.tsx @@ -148,16 +148,16 @@ const EmitterBody = ({ // ); case EArgumentBodyType.Boolean: return ( -
+
{ changeArgValue(true); }} /> { changeArgValue(false); diff --git a/playgrounds/firecamp-websocket/src/components/common/config/Config.tsx b/playgrounds/firecamp-websocket/src/components/common/config/Config.tsx index fc363c5e..592e57f5 100644 --- a/playgrounds/firecamp-websocket/src/components/common/config/Config.tsx +++ b/playgrounds/firecamp-websocket/src/components/common/config/Config.tsx @@ -212,7 +212,7 @@ const Config = ({ config = {} }) => { _onChange(name, !config[name])} /> diff --git a/playgrounds/firecamp-websocket/src/components/connection-panel/connection/ConfigTab.tsx b/playgrounds/firecamp-websocket/src/components/connection-panel/connection/ConfigTab.tsx index 6ebfe959..388c6b17 100644 --- a/playgrounds/firecamp-websocket/src/components/connection-panel/connection/ConfigTab.tsx +++ b/playgrounds/firecamp-websocket/src/components/connection-panel/connection/ConfigTab.tsx @@ -95,7 +95,7 @@ const Config = ({ config = {}, onUpdate }) => { return ( _onChange(name, !config[name])}