From c5b034385ff5258d53da141b4765708239091e41 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Mon, 24 Apr 2023 18:53:07 +0530 Subject: [PATCH] chore: added custom toggle switch everywhere (#949) --- .../core/calendar-view/calendar.tsx | 23 ++++----------- .../components/core/issues-view-filter.tsx | 23 ++++----------- .../integration/github/import-data.tsx | 22 ++------------- apps/app/components/issues/form.tsx | 26 ++++++----------- apps/app/components/ui/toggle-switch.tsx | 23 +++++++++++---- .../[projectId]/settings/features.tsx | 28 ++++--------------- 6 files changed, 45 insertions(+), 100 deletions(-) diff --git a/apps/app/components/core/calendar-view/calendar.tsx b/apps/app/components/core/calendar-view/calendar.tsx index 19a09710a..dd814ed09 100644 --- a/apps/app/components/core/calendar-view/calendar.tsx +++ b/apps/app/components/core/calendar-view/calendar.tsx @@ -26,7 +26,7 @@ import { import { Popover, Transition } from "@headlessui/react"; import { DragDropContext, Draggable, DropResult } from "react-beautiful-dnd"; import StrictModeDroppable from "components/dnd/StrictModeDroppable"; -import { CustomMenu, Spinner } from "components/ui"; +import { CustomMenu, Spinner, ToggleSwitch } from "components/ui"; // icon import { CheckIcon, @@ -390,23 +390,10 @@ export const CalendarView: React.FC = ({ addIssueToDate }) => {

Show weekends

- + setShowWeekEnds(!showWeekEnds)} + />
diff --git a/apps/app/components/core/issues-view-filter.tsx b/apps/app/components/core/issues-view-filter.tsx index 49bf5cf6b..9a9f9494f 100644 --- a/apps/app/components/core/issues-view-filter.tsx +++ b/apps/app/components/core/issues-view-filter.tsx @@ -10,7 +10,7 @@ import { Popover, Transition } from "@headlessui/react"; // components import { SelectFilters } from "components/views"; // ui -import { CustomMenu } from "components/ui"; +import { CustomMenu, ToggleSwitch } from "components/ui"; // icons import { ChevronDownIcon, @@ -213,23 +213,10 @@ export const IssuesFilterView: React.FC = () => { <>

Show empty states

- + setShowEmptyGroups(!showEmptyGroups)} + />
+ onChange(!value)} /> )} />
diff --git a/apps/app/components/issues/form.tsx b/apps/app/components/issues/form.tsx index ca085f103..8d1db9e54 100644 --- a/apps/app/components/issues/form.tsx +++ b/apps/app/components/issues/form.tsx @@ -26,7 +26,14 @@ import { CreateStateModal } from "components/states"; import { CreateUpdateCycleModal } from "components/cycles"; import { CreateLabelModal } from "components/labels"; // ui -import { CustomMenu, Input, Loader, PrimaryButton, SecondaryButton } from "components/ui"; +import { + CustomMenu, + Input, + Loader, + PrimaryButton, + SecondaryButton, + ToggleSwitch, +} from "components/ui"; // icons import { SparklesIcon, XMarkIcon } from "@heroicons/react/24/outline"; // helpers @@ -449,22 +456,7 @@ export const IssueForm: FC = ({ onClick={() => setCreateMore((prevData) => !prevData)} > Create more - + {}} size="md" />
Discard diff --git a/apps/app/components/ui/toggle-switch.tsx b/apps/app/components/ui/toggle-switch.tsx index 8c221dad2..fe4e2c96d 100644 --- a/apps/app/components/ui/toggle-switch.tsx +++ b/apps/app/components/ui/toggle-switch.tsx @@ -4,27 +4,38 @@ type Props = { value: boolean; onChange: (value: boolean) => void; label?: string; + size?: "sm" | "md" | "lg"; disabled?: boolean; className?: string; }; export const ToggleSwitch: React.FC = (props) => { - const { value, onChange, label, disabled, className } = props; + const { value, onChange, label, size = "sm", disabled, className } = props; return ( {label} diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/features.tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/features.tsx index 150d28b4a..3b5a09e6c 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/features.tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/features.tsx @@ -12,7 +12,7 @@ import { ProjectAuthorizationWrapper } from "layouts/auth-layout"; // hooks import useToast from "hooks/use-toast"; // ui -import { SecondaryButton } from "components/ui"; +import { SecondaryButton, ToggleSwitch } from "components/ui"; import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; // icons import { ContrastIcon, PeopleGroupIcon, ViewListIcon } from "components/icons"; @@ -149,16 +149,9 @@ const FeaturesSettings: NextPage = () => {

{feature.description}

- + size="lg" + /> ))}