Skip to content

Commit

Permalink
✨ feat(icons): synchronize icons to single package
Browse files Browse the repository at this point in the history
  • Loading branch information
thrownullexception committed Jul 2, 2024
1 parent 2726e33 commit ea864c8
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 107 deletions.
15 changes: 0 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-popover": "^1.1.0",
"@radix-ui/react-scroll-area": "^1.0.5",
Expand Down
1 change: 1 addition & 0 deletions src/components/app/alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export function Alert({ type, message, renderJsx, action }: IProps) {
type="button"
onClick={renderMode.off}
variant="ghost"
className="p-0"
aria-label="Close"
>
<X size={16} />
Expand Down
17 changes: 0 additions & 17 deletions src/components/app/form/input/Stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { FormInput } from "./text";
import { FormNumberInput } from "./number";
import { FormRichTextArea } from "./rich-text";
import { FormTextArea } from "./textarea";
import { FormMultiSelect } from "../../../../frontend/design-system/components/Form/Select";
import { FormCodeEditor } from "../../../../frontend/design-system/components/Form/CodeEditor";
import { FormSwitch } from "./switch";
import { FormFileInput } from "../../../../frontend/design-system/components/Form/File";
Expand Down Expand Up @@ -210,22 +209,6 @@ function DemoForm() {
)}
</Field>

<Field name="foo7" validateFields={[]}>
{(formProps) => (
<FormMultiSelect
selectData={[
{ label: fakeMessageDescriptor("Foo"), value: "foo" },
{ label: fakeMessageDescriptor("Bar"), value: "bar" },
{ label: fakeMessageDescriptor("Baz"), value: "baz" },
{ label: fakeMessageDescriptor("Noop"), value: "noop" },
{ label: fakeMessageDescriptor("Dupe"), value: "dupe" },
]}
values={formProps.input.value || ["foo", "bar"]}
onChange={formProps.input.onChange}
/>
)}
</Field>

<Field name="file" validateFields={[]} validate={required}>
{(formProps) => (
<FormFileInput
Expand Down
4 changes: 3 additions & 1 deletion src/components/app/off-canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export function OffCanvas({ show, onClose, title, children, size }: IProps) {
<SheetTitle>{_(title)}</SheetTitle>
</SheetHeader>
<Separator className="mt-2" />
<ScrollArea className="flex-grow px-4 my-2">{children}</ScrollArea>
<ScrollArea className="flex-grow">
<div className="px-4 my-2">{children}</div>
</ScrollArea>
</SheetContent>
</Sheet>
</NextPortal>
Expand Down
4 changes: 1 addition & 3 deletions src/components/app/table/Head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface IProps {
table: Table<Record<string, unknown>>;
}

export function _TableHead({ table }: IProps) {
export function TableHead({ table }: IProps) {
return (
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
Expand Down Expand Up @@ -74,5 +74,3 @@ export function _TableHead({ table }: IProps) {
</TableHeader>
);
}

export const TableHead = React.memo(_TableHead);
5 changes: 2 additions & 3 deletions src/components/app/table/_Pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import ReactPaginate from "react-paginate";
import { Trans, msg } from "@lingui/macro";
import { ChevronLeft, ChevronRight } from "react-feather";
import { ChevronLeft, ChevronRight, MoreHorizontal } from "react-feather";
import { fakeMessageDescriptor } from "translations/fake";
import { DotsHorizontalIcon } from "@radix-ui/react-icons";
import { TABLE_PAGE_SIZES } from "./constants";
import { Select } from "@/components/ui/select";
import { buttonVariants } from "@/components/ui/button";
Expand Down Expand Up @@ -57,7 +56,7 @@ export function TablePagination({
<ReactPaginate
previousLabel={<ChevronLeft className="h-4 w-4" />}
nextLabel={<ChevronRight className="h-4 w-4" />}
breakLabel={<DotsHorizontalIcon className="h-4 w-4" />}
breakLabel={<MoreHorizontal className="h-4 w-4" />}
pageCount={totalPageCount}
renderOnZeroPageCount={() => null}
marginPagesDisplayed={2}
Expand Down
61 changes: 42 additions & 19 deletions src/components/app/toast/toaster.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { useLingui } from "@lingui/react";
import React from "react";
import {
AlertCircle,
CheckCircle,
Icon as IconType,
XCircle,
} from "react-feather";
import {
Toast,
ToastAction,
Expand All @@ -12,39 +19,55 @@ import { useToast } from "./use-toast";
import { spectrumVariants } from "@/components/ui/spectrum";
import { cn } from "@/lib/utils";

const ToastConfigMap: Record<
"green" | "red" | "yellow",
{
Icon: IconType;
}
> = {
green: { Icon: CheckCircle },
red: { Icon: XCircle },
yellow: { Icon: AlertCircle },
};

export function Toaster() {
const { toasts } = useToast();
const { _ } = useLingui();

return (
<ToastProvider>
{toasts.map(({ id, title, variant, description, action, ...props }) => {
{toasts.map(({ id, title, description, variant, action, ...props }) => {
const { Icon } = ToastConfigMap[variant];
return (
<Toast
key={id}
{...props}
variant={variant}
duration={variant === "red" || action ? 10000 : 5000}
>
<div className="grid gap-1">
{title && <ToastTitle>{_(title)}</ToastTitle>}
{description && (
<ToastDescription>{_(description)}</ToastDescription>
)}
</div>
{action && (
<ToastAction
onClick={action.action}
altText={_(action.label)}
className={cn(
spectrumVariants({
spectrum: variant || "green",
})
<div className="flex items-center">
<Icon className="mr-3 w-5 h-5 shrink-0" />
<div className="flex flex-col gap-2">
{title && <ToastTitle>{_(title)}</ToastTitle>}
{description && (
<ToastDescription>{_(description)}</ToastDescription>
)}
>
{_(action.label)}
</ToastAction>
)}
{action && (
<ToastAction
onClick={action.action}
altText={_(action.label)}
className={cn(
"self-start",
spectrumVariants({
spectrum: variant,
})
)}
>
{_(action.label)}
</ToastAction>
)}
</div>
</div>
<ToastClose />
</Toast>
);
Expand Down
10 changes: 8 additions & 2 deletions src/components/app/toast/use-toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import type { ToastProps } from "@/components/ui/toast";
const TOAST_LIMIT = 1;
const TOAST_REMOVE_DELAY = 1000000;

type ToasterToast = Pick<ToastProps, "open" | "onOpenChange" | "variant"> & {
type ToasterToast = Pick<ToastProps, "open" | "onOpenChange"> & {
id: string;
title?: MessageDescriptor;
description?: MessageDescriptor;
variant: ToastProps["variant"];
action?: { label: MessageDescriptor; action: () => void };
};

Expand Down Expand Up @@ -129,7 +130,12 @@ const listeners: Array<(state: State) => void> = [];

let memoryState: State = { toasts: [] };

type Toast = Omit<ToasterToast, "id">;
type Toast = {
description: MessageDescriptor;
variant: ToastProps["variant"];
title?: MessageDescriptor;
action?: { label: MessageDescriptor; action: () => void };
};

function dispatch(action: Action) {
memoryState = reducer(memoryState, action);
Expand Down
7 changes: 3 additions & 4 deletions src/components/ui/breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable react/prop-types */
import * as React from "react";
import { ChevronRightIcon, DotsHorizontalIcon } from "@radix-ui/react-icons";
import { Slot } from "@radix-ui/react-slot";

import { ChevronRight, MoreHorizontal } from "react-feather";
import { cn } from "@/lib/utils";

const Breadcrumb = React.forwardRef<
Expand Down Expand Up @@ -85,7 +84,7 @@ function BreadcrumbSeparator({
className={cn("[&>svg]:size-3.5", className)}
{...props}
>
{children ?? <ChevronRightIcon />}
{children ?? <ChevronRight />}
</li>
);
}
Expand All @@ -102,7 +101,7 @@ function BreadcrumbEllipsis({
className={cn("flex h-9 w-9 items-center justify-center", className)}
{...props}
>
<DotsHorizontalIcon className="h-4 w-4" />
<MoreHorizontal className="h-4 w-4" />
<span className="sr-only">More</span>
</span>
);
Expand Down
7 changes: 3 additions & 4 deletions src/components/ui/calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-disable react/no-unstable-nested-components */
/* eslint-disable react/prop-types */
import * as React from "react";
import { ChevronLeftIcon, ChevronRightIcon } from "@radix-ui/react-icons";
import { DayPicker } from "react-day-picker";

import { ChevronLeft, ChevronRight } from "react-feather";
import { cn } from "@/lib/utils";
import { buttonVariants } from "@/components/ui/button";

Expand Down Expand Up @@ -54,8 +53,8 @@ function Calendar({ className, classNames, ...props }: CalendarProps) {
...classNames,
}}
components={{
IconLeft: () => <ChevronLeftIcon className="h-4 w-4" />,
IconRight: () => <ChevronRightIcon className="h-4 w-4" />,
IconLeft: () => <ChevronLeft className="h-4 w-4" />,
IconRight: () => <ChevronRight className="h-4 w-4" />,
}}
{...props}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/command.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable react/prop-types */
import * as React from "react";
import { type DialogProps } from "@radix-ui/react-dialog";
import { MagnifyingGlassIcon } from "@radix-ui/react-icons";
import { Command as CommandPrimitive } from "cmdk";

import { Search } from "react-feather";
import { cn } from "@/lib/utils";
import { Dialog, DialogContent } from "@/components/ui/dialog";

Expand Down Expand Up @@ -41,7 +41,7 @@ const CommandInput = React.forwardRef<
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
>(({ className, ...props }, ref) => (
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
<MagnifyingGlassIcon className="mr-2 h-4 w-4 shrink-0 opacity-50" />
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
<CommandPrimitive.Input
ref={ref}
className={cn(
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/prop-types */
import * as React from "react";
import * as DialogPrimitive from "@radix-ui/react-dialog";
import { Cross2Icon } from "@radix-ui/react-icons";
import { X } from "react-feather";

import { cn } from "@/lib/utils";

Expand Down Expand Up @@ -44,7 +44,7 @@ const DialogContent = React.forwardRef<
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-base transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-primary data-[state=open]:text-muted">
<Cross2Icon className="h-4 w-4" />
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/dropdown-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable react/prop-types */
import * as React from "react";
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
import { ChevronRightIcon } from "@radix-ui/react-icons";

import { ChevronRight } from "react-feather";
import { cn } from "@/lib/utils";

const DropdownMenu = DropdownMenuPrimitive.Root;
Expand Down Expand Up @@ -33,7 +33,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
{...props}
>
{children}
<ChevronRightIcon className="ml-auto h-4 w-4" />
<ChevronRight className="ml-auto h-4 w-4" />
</DropdownMenuPrimitive.SubTrigger>
));
DropdownMenuSubTrigger.displayName =
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/scroll-area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ const ScrollArea = React.forwardRef<
));
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;

export { ScrollArea, ScrollBar };
export { ScrollArea };
Loading

0 comments on commit ea864c8

Please sign in to comment.