From d0911aeb1c3d81cde91ea025bcf4de8b4ca9a9fb Mon Sep 17 00:00:00 2001 From: ecklf Date: Thu, 19 Jan 2023 22:29:10 +0100 Subject: [PATCH 1/2] style(demo): fix centering --- demo/components/context-menu.tsx | 7 +++---- demo/pages/index.tsx | 10 ++-------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/demo/components/context-menu.tsx b/demo/components/context-menu.tsx index 5ba37a2..d7f52d9 100644 --- a/demo/components/context-menu.tsx +++ b/demo/components/context-menu.tsx @@ -15,6 +15,7 @@ import { } from "@radix-ui/react-icons"; import cx from "classnames"; import React, { ReactNode, useState } from "react"; +import Button from "./shared/button"; interface RadixMenuItem { label: string; @@ -77,10 +78,8 @@ const ContextMenu = (props: Props) => { return (
- - - Right Click - + + diff --git a/demo/pages/index.tsx b/demo/pages/index.tsx index 15cf24e..7e09042 100644 --- a/demo/pages/index.tsx +++ b/demo/pages/index.tsx @@ -30,11 +30,6 @@ import ToggleGroup from "../components/toggle-group"; import Toolbar from "../components/toolbar"; import Tooltip from "../components/tooltip"; import { CommandMenu } from "../components/shared/command-menu"; -import { - QuestionMarkCircledIcon, - QuestionMarkIcon, - SunIcon, -} from "@radix-ui/react-icons"; import cx from "classnames"; import { QuestionMarkCircleIcon } from "@heroicons/react/24/outline"; @@ -125,7 +120,6 @@ const RADIX_COMPONENTS: RadixComponent[] = [ { label: "Hover Card", link: `${REPO_URL}/components/hover-card.tsx`, - center: true, component: , }, { @@ -199,7 +193,6 @@ const RADIX_COMPONENTS: RadixComponent[] = [ { label: "Toast", link: `${REPO_URL}/components/toast.tsx`, - center: true, component: (
@@ -403,8 +396,9 @@ const Demo = () => { />
- {RADIX_COMPONENTS.map(({ label, link, component }, i) => ( + {RADIX_COMPONENTS.map(({ label, link, component, center }, i) => ( Date: Thu, 19 Jan 2023 23:17:26 +0100 Subject: [PATCH 2/2] refactor(demo): run code transformer --- demo/components/accordion.tsx | 14 +++--- demo/components/alert-dialog.tsx | 14 +++--- demo/components/aspect-ratio.tsx | 10 ++-- demo/components/avatar.tsx | 18 ++++--- demo/components/checkbox.tsx | 10 ++-- demo/components/collapsible.tsx | 12 ++--- demo/components/context-menu.tsx | 24 +++++----- demo/components/dialog.tsx | 18 +++---- demo/components/dropdown-menu.tsx | 24 +++++----- demo/components/hover-card.tsx | 14 +++--- demo/components/menubar.tsx | 18 +++---- demo/components/navigation-menu.tsx | 28 +++++------ demo/components/popover.tsx | 14 +++--- demo/components/progress.tsx | 6 +-- demo/components/radio-group.tsx | 10 ++-- demo/components/select.tsx | 10 ++-- demo/components/shared/button.tsx | 4 +- demo/components/shared/command-menu.tsx | 12 ++--- demo/components/shared/demo-card.tsx | 10 ++-- demo/components/shared/theme-switcher.tsx | 14 +++--- demo/components/slider.tsx | 10 ++-- demo/components/switch.tsx | 12 ++--- demo/components/tabs.tsx | 16 +++---- demo/components/toast.tsx | 10 ++-- demo/components/toggle-group.tsx | 10 ++-- demo/components/toggle.tsx | 6 +-- demo/components/toolbar.tsx | 14 +++--- demo/components/tooltip.tsx | 10 ++-- demo/package.json | 4 +- demo/pages/index.tsx | 58 +++++++++++------------ demo/pnpm-lock.yaml | 13 ++--- 31 files changed, 226 insertions(+), 221 deletions(-) diff --git a/demo/components/accordion.tsx b/demo/components/accordion.tsx index 28efbf6..ea3ac84 100644 --- a/demo/components/accordion.tsx +++ b/demo/components/accordion.tsx @@ -1,6 +1,6 @@ import * as AccordionPrimitive from "@radix-ui/react-accordion"; import { ChevronDownIcon } from "@radix-ui/react-icons"; -import cx from "classnames"; +import { clsx } from "clsx"; import React from "react"; interface AccordionItem { @@ -25,14 +25,14 @@ const items: AccordionItem[] = [ }, ]; -interface Props {} +interface AccordionProps {} -const Accordion = (props: Props) => { +const Accordion = (props: AccordionProps) => { return ( {items.map(({ header, content }, i) => ( { > { {header} { ); }; -export default Accordion; +export { Accordion }; diff --git a/demo/components/alert-dialog.tsx b/demo/components/alert-dialog.tsx index 48f8fa6..c6d4943 100644 --- a/demo/components/alert-dialog.tsx +++ b/demo/components/alert-dialog.tsx @@ -1,12 +1,12 @@ import { Transition } from "@headlessui/react"; import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"; -import cx from "classnames"; +import { clsx } from "clsx"; import React, { Fragment, useState } from "react"; import Button from "./shared/button"; -interface Props {} +interface AlertDialogProps {} -const AlertDialog = (props: Props) => { +const AlertDialog = (props: AlertDialogProps) => { let [isOpen, setIsOpen] = useState(false); return ( @@ -41,7 +41,7 @@ const AlertDialog = (props: Props) => { > {
{ Cancel { ); }; -export default AlertDialog; +export { AlertDialog }; diff --git a/demo/components/aspect-ratio.tsx b/demo/components/aspect-ratio.tsx index c6ef380..4c6673a 100644 --- a/demo/components/aspect-ratio.tsx +++ b/demo/components/aspect-ratio.tsx @@ -1,10 +1,10 @@ import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio"; -import cx from "classnames"; +import { clsx } from "clsx"; import React, { Fragment } from "react"; -interface Props {} +interface AspectRatioProps {} -const AspectRatio = (props: Props) => { +const AspectRatio = (props: AspectRatioProps) => { return ( {
{ ); }; -export default AspectRatio; +export { AspectRatio }; diff --git a/demo/components/avatar.tsx b/demo/components/avatar.tsx index 292efcb..e679068 100644 --- a/demo/components/avatar.tsx +++ b/demo/components/avatar.tsx @@ -1,5 +1,5 @@ import * as AvatarPrimitive from "@radix-ui/react-avatar"; -import cx from "classnames"; +import { clsx } from "clsx"; import React, { Fragment } from "react"; import { getRandomInitials } from "../utils/random"; @@ -8,7 +8,7 @@ enum Variant { Rounded, } -type Props = { +type AvatarProps = { variant: Variant; renderInvalidUrls?: boolean; isOnline?: boolean; @@ -21,7 +21,11 @@ let users = [ "https://images.unsplash.com/photo-1546456073-ea246a7bd25f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80", ]; -const Avatar = ({ variant, isOnline, renderInvalidUrls = false }: Props) => { +const Avatar = ({ + variant, + isOnline, + renderInvalidUrls = false, +}: AvatarProps) => { const urls = renderInvalidUrls ? Array.from({ length: users.length }, () => "") : users; @@ -36,7 +40,7 @@ const Avatar = ({ variant, isOnline, renderInvalidUrls = false }: Props) => { { /> {isOnline && (
{
)} { }; Avatar.variant = Variant; -export default Avatar; +export { Avatar }; diff --git a/demo/components/checkbox.tsx b/demo/components/checkbox.tsx index fcd5ffe..19e93b3 100644 --- a/demo/components/checkbox.tsx +++ b/demo/components/checkbox.tsx @@ -1,18 +1,18 @@ import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; import { CheckIcon } from "@radix-ui/react-icons"; import * as LabelPrimitive from "@radix-ui/react-label"; -import cx from "classnames"; +import { clsx } from "clsx"; import React from "react"; -interface Props {} +interface CheckboxProps {} -const Checkbox = (props: Props) => { +const Checkbox = (props: CheckboxProps) => { return (
{ ); }; -export default Checkbox; +export { Checkbox }; diff --git a/demo/components/collapsible.tsx b/demo/components/collapsible.tsx index 8e64e11..1613ec4 100644 --- a/demo/components/collapsible.tsx +++ b/demo/components/collapsible.tsx @@ -1,17 +1,17 @@ import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"; import { PlayIcon, Share2Icon, TriangleRightIcon } from "@radix-ui/react-icons"; -import cx from "classnames"; +import { clsx } from "clsx"; import React from "react"; -interface Props {} +interface CollapsibleProps {} -const Collapsible = (props: Props) => { +const Collapsible = (props: CollapsibleProps) => { const [isOpen, setIsOpen] = React.useState(true); return ( { (title, i) => (
{ ); }; -export default Collapsible; +export { Collapsible }; diff --git a/demo/components/context-menu.tsx b/demo/components/context-menu.tsx index d7f52d9..c9ec9b4 100644 --- a/demo/components/context-menu.tsx +++ b/demo/components/context-menu.tsx @@ -13,7 +13,7 @@ import { PersonIcon, TransparencyGridIcon, } from "@radix-ui/react-icons"; -import cx from "classnames"; +import { clsx } from "clsx"; import React, { ReactNode, useState } from "react"; import Button from "./shared/button"; @@ -69,9 +69,9 @@ const users: User[] = [ }, ]; -interface Props {} +interface ContextMenuProps {} -const ContextMenu = (props: Props) => { +const ContextMenu = (props: ContextMenuProps) => { const [showGrid, setShowGrid] = useState(false); const [showUi, setShowUi] = useState(false); @@ -84,7 +84,7 @@ const ContextMenu = (props: Props) => { { {generalMenuItems.map(({ label, icon, shortcut }, i) => ( { setShowGrid(state); } }} - className={cx( + className={clsx( "flex w-full cursor-default select-none items-center rounded-md px-2 py-2 text-xs outline-none", "text-gray-400 focus:bg-gray-50 dark:text-gray-500 dark:focus:bg-gray-900" )} @@ -140,7 +140,7 @@ const ContextMenu = (props: Props) => { setShowUi(state); } }} - className={cx( + className={clsx( "flex w-full cursor-default select-none items-center rounded-md px-2 py-2 text-xs outline-none", "text-gray-400 focus:bg-gray-50 dark:text-gray-500 dark:focus:bg-gray-900" )} @@ -167,7 +167,7 @@ const ContextMenu = (props: Props) => { {regionToolMenuItems.map(({ label, icon, shortcut }, i) => ( { { { {users.map(({ name, url }, i) => ( { ); }; -export default ContextMenu; +export { ContextMenu }; diff --git a/demo/components/dialog.tsx b/demo/components/dialog.tsx index 25ed2fd..f224457 100644 --- a/demo/components/dialog.tsx +++ b/demo/components/dialog.tsx @@ -1,13 +1,13 @@ import { Transition } from "@headlessui/react"; import * as DialogPrimitive from "@radix-ui/react-dialog"; import { Cross1Icon } from "@radix-ui/react-icons"; -import cx from "classnames"; +import { clsx } from "clsx"; import React, { Fragment, useState } from "react"; import Button from "./shared/button"; -interface Props {} +interface DialogProps {} -const Dialog = (props: Props) => { +const Dialog = (props: DialogProps) => { let [isOpen, setIsOpen] = useState(false); return ( @@ -42,7 +42,7 @@ const Dialog = (props: Props) => { > { type="text" placeholder="Tim" autoComplete="given-name" - className={cx( + className={clsx( "mt-1 block w-full rounded-md", "text-sm text-gray-700 placeholder:text-gray-500 dark:text-gray-400 dark:placeholder:text-gray-600", "border border-gray-400 focus-visible:border-transparent dark:border-gray-700 dark:bg-gray-800", @@ -91,7 +91,7 @@ const Dialog = (props: Props) => { type="text" placeholder="Cook" autoComplete="family-name" - className={cx( + className={clsx( "mt-1 block w-full rounded-md", "text-sm text-gray-700 placeholder:text-gray-500 dark:text-gray-400 dark:placeholder:text-gray-600", "border border-gray-400 focus-visible:border-transparent dark:border-gray-700 dark:bg-gray-800", @@ -103,7 +103,7 @@ const Dialog = (props: Props) => {
{
{ ); }; -export default Dialog; +export { Dialog }; diff --git a/demo/components/dropdown-menu.tsx b/demo/components/dropdown-menu.tsx index b1c37d5..d1dddaf 100644 --- a/demo/components/dropdown-menu.tsx +++ b/demo/components/dropdown-menu.tsx @@ -13,7 +13,7 @@ import { PersonIcon, TransparencyGridIcon, } from "@radix-ui/react-icons"; -import cx from "classnames"; +import { clsx } from "clsx"; import React, { ReactNode, useState } from "react"; import Button from "./shared/button"; @@ -69,9 +69,9 @@ const users: User[] = [ }, ]; -interface Props {} +interface DropdownMenuProps {} -const DropdownMenu = (props: Props) => { +const DropdownMenu = (props: DropdownMenuProps) => { const [showGrid, setShowGrid] = useState(false); const [showUi, setShowUi] = useState(false); @@ -86,7 +86,7 @@ const DropdownMenu = (props: Props) => { { {generalMenuItems.map(({ label, icon, shortcut }, i) => ( { setShowGrid(state); } }} - className={cx( + className={clsx( "flex w-full cursor-default select-none items-center rounded-md px-2 py-2 text-xs outline-none", "text-gray-400 focus:bg-gray-50 dark:text-gray-500 dark:focus:bg-gray-900" )} @@ -142,7 +142,7 @@ const DropdownMenu = (props: Props) => { setShowUi(state); } }} - className={cx( + className={clsx( "flex w-full cursor-default select-none items-center rounded-md px-2 py-2 text-xs outline-none", "text-gray-400 focus:bg-gray-50 dark:text-gray-500 dark:focus:bg-gray-900" )} @@ -169,7 +169,7 @@ const DropdownMenu = (props: Props) => { {regionToolMenuItems.map(({ label, icon, shortcut }, i) => ( { { { {users.map(({ name, url }, i) => ( { ); }; -export default DropdownMenu; +export { DropdownMenu }; diff --git a/demo/components/hover-card.tsx b/demo/components/hover-card.tsx index 445fb93..3e06980 100644 --- a/demo/components/hover-card.tsx +++ b/demo/components/hover-card.tsx @@ -1,5 +1,5 @@ import * as HoverCardPrimitive from "@radix-ui/react-hover-card"; -import cx from "classnames"; +import { clsx } from "clsx"; import React from "react"; const TailwindLogo = () => ( @@ -16,14 +16,14 @@ const TailwindLogo = () => ( ); -interface Props {} +interface HoverCardProps {} -const HoverCard = (props: Props) => { +const HoverCard = (props: HoverCardProps) => { return (
@@ -33,7 +33,7 @@ const HoverCard = (props: Props) => { {
@@ -67,4 +67,4 @@ const HoverCard = (props: Props) => { ); }; -export default HoverCard; +export { HoverCard }; diff --git a/demo/components/menubar.tsx b/demo/components/menubar.tsx index 0440cd6..8243814 100644 --- a/demo/components/menubar.tsx +++ b/demo/components/menubar.tsx @@ -4,7 +4,7 @@ import { ChevronRightIcon, DotFilledIcon, } from "@radix-ui/react-icons"; -import cx from "classnames"; +import { clsx } from "clsx"; import React from "react"; type MenubarSeparatorProps = Omit< @@ -28,7 +28,7 @@ type MenubarTriggerProps = Omit< const MenubarTrigger = ({ children, ...rest }: MenubarTriggerProps) => ( ( ( ( ( ( ); -type Props = {}; +type MenubarProps = {}; const RADIO_ITEMS = ["rauchg", "steventey", "0xca0a"]; const CHECK_ITEMS = ["Always Show Bookmarks Bar", "Always Show Full URLs"]; -const Menubar = (props: Props) => { +const Menubar = (props: MenubarProps) => { const [checkedSelection, setCheckedSelection] = React.useState([ CHECK_ITEMS[1], ]); @@ -309,4 +309,4 @@ const Menubar = (props: Props) => { ); }; -export default Menubar; +export { Menubar }; diff --git a/demo/components/navigation-menu.tsx b/demo/components/navigation-menu.tsx index 12b0e52..2d39b96 100644 --- a/demo/components/navigation-menu.tsx +++ b/demo/components/navigation-menu.tsx @@ -1,16 +1,16 @@ import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu"; -import cx from "classnames"; +import { clsx } from "clsx"; import React from "react"; -type Props = {}; +type NavigationMenuProps = {}; -const NavigationMenu = (props: Props) => { +const NavigationMenu = (props: NavigationMenuProps) => { return ( { { { {
{ { { {
{ }} > { ); }; -export default NavigationMenu; +export { NavigationMenu }; diff --git a/demo/components/popover.tsx b/demo/components/popover.tsx index 11d58c1..4dae92b 100644 --- a/demo/components/popover.tsx +++ b/demo/components/popover.tsx @@ -1,10 +1,10 @@ import { Cross1Icon } from "@radix-ui/react-icons"; import * as PopoverPrimitive from "@radix-ui/react-popover"; -import cx from "classnames"; +import { clsx } from "clsx"; import React from "react"; import Button from "./shared/button"; -interface Props {} +interface PopoverProps {} const items = [ { @@ -29,7 +29,7 @@ const items = [ }, ]; -const Popover = (props: Props) => { +const Popover = (props: PopoverProps) => { return (
@@ -39,7 +39,7 @@ const Popover = (props: Props) => { { type="text" defaultValue={defaultValue} autoComplete="given-name" - className={cx( + className={clsx( "block w-1/2 rounded-md", "text-xs text-gray-700 placeholder:text-gray-500 dark:text-gray-400 dark:placeholder:text-gray-600", "border border-gray-400 focus-visible:border-transparent dark:border-gray-700 dark:bg-gray-800", @@ -82,7 +82,7 @@ const Popover = (props: Props) => { { ); }; -export default Popover; +export { Popover }; diff --git a/demo/components/progress.tsx b/demo/components/progress.tsx index c1ac952..89a6c59 100644 --- a/demo/components/progress.tsx +++ b/demo/components/progress.tsx @@ -2,9 +2,9 @@ import * as ProgressPrimitive from "@radix-ui/react-progress"; import React, { useEffect } from "react"; import { getRandomArbitrary } from "../utils/math"; -interface Props {} +interface ProgressProps {} -const Progress = (props: Props) => { +const Progress = (props: ProgressProps) => { const [progress, setProgress] = React.useState(60); useEffect(() => { @@ -35,4 +35,4 @@ const Progress = (props: Props) => { ); }; -export default Progress; +export { Progress }; diff --git a/demo/components/radio-group.tsx b/demo/components/radio-group.tsx index 7692bba..5d0a7be 100644 --- a/demo/components/radio-group.tsx +++ b/demo/components/radio-group.tsx @@ -1,8 +1,8 @@ -import cx from "classnames"; +import { clsx } from "clsx"; import React from "react"; import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"; -interface Props {} +interface RadioGroupProps {} const starters = [ { id: "red", title: "Bulbasaur" }, @@ -10,7 +10,7 @@ const starters = [ { id: "blue", title: "Squirtle" }, ]; -const RadioGroup = (props: Props) => { +const RadioGroup = (props: RadioGroupProps) => { const [value, setValue] = React.useState(starters[0].title); return ( @@ -29,7 +29,7 @@ const RadioGroup = (props: Props) => { { ); }; -export default RadioGroup; +export { RadioGroup }; diff --git a/demo/components/select.tsx b/demo/components/select.tsx index 89b3eb2..32803d3 100644 --- a/demo/components/select.tsx +++ b/demo/components/select.tsx @@ -4,13 +4,13 @@ import { ChevronUpIcon, } from "@radix-ui/react-icons"; import * as SelectPrimitive from "@radix-ui/react-select"; -import cx from "classnames"; +import { clsx } from "clsx"; import React from "react"; import Button from "./shared/button"; -type Props = {}; +type SelectProps = {}; -const Select = (props: Props) => { +const Select = (props: SelectProps) => { return ( @@ -33,7 +33,7 @@ const Select = (props: Props) => { disabled={f === "Grapes"} key={`${f}-${i}`} value={f.toLowerCase()} - className={cx( + className={clsx( "relative flex items-center px-8 py-2 rounded-md text-sm text-gray-700 dark:text-gray-300 font-medium focus:bg-gray-100 dark:focus:bg-gray-900", "radix-disabled:opacity-50", "focus:outline-none select-none" @@ -56,4 +56,4 @@ const Select = (props: Props) => { ); }; -export default Select; +export { Select }; diff --git a/demo/components/shared/button.tsx b/demo/components/shared/button.tsx index 98d6214..b1e6a87 100644 --- a/demo/components/shared/button.tsx +++ b/demo/components/shared/button.tsx @@ -1,4 +1,4 @@ -import cx from "classnames"; +import { clsx } from "clsx"; import React from "react"; type Props = Omit, "className"> & {}; @@ -8,7 +8,7 @@ const Button = React.forwardRef(