Skip to content

Commit

Permalink
feat: add IconPicker to app-page-builder and app-headless-cms
Browse files Browse the repository at this point in the history
  • Loading branch information
leopuleo committed Feb 2, 2025
1 parent 3823221 commit 1b4b8be
Show file tree
Hide file tree
Showing 30 changed files with 57 additions and 560 deletions.
2 changes: 1 addition & 1 deletion packages/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@storybook/theming": "7.6.20",
"@svgr/webpack": "^6.1.1",
"@types/react": "18.2.79",
"@types/react-virtualized": "^9",
"@types/react-virtualized": "^9.22.0",
"@webiny/cli": "0.0.0",
"@webiny/project-utils": "0.0.0",
"chalk": "^4.1.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/admin-ui/src/IconPicker/IconPicker.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { useState } from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { IconPicker } from "~/IconPicker";
import { IconDto, IconPicker } from "~/IconPicker";
import { IconName, library } from "@fortawesome/fontawesome-svg-core";
import { IconPrefix } from "@fortawesome/fontawesome-common-types";
import { fas } from "@fortawesome/free-solid-svg-icons";
import { IconDto } from "~/IconPicker/primitives/domains";

const meta: Meta<typeof IconPicker> = {
title: "Components/Form/IconPicker",
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/src/IconPicker/IconPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ const DecoratableIconPicker = ({
};
const IconPicker = makeDecoratable("IconPicker", DecoratableIconPicker);

export { IconPicker };
export { IconPicker, type IconPickerProps };
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Icon {
if (typeof value === "string" && value.includes("/")) {
const values = value.split("/");
return new Icon({
prefix: values[1],
prefix: values[0],
name: values[1]
});
} else {
Expand Down
1 change: 1 addition & 0 deletions packages/admin-ui/src/IconPicker/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./IconPicker";
export { IconDto } from "./domains";
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useState } from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { IconPickerPrimitive } from "./IconPickerPrimitive";
import { IconDto } from "~/IconPicker";
import { IconName, library } from "@fortawesome/fontawesome-svg-core";
import { IconPrefix } from "@fortawesome/fontawesome-common-types";
import { fas } from "@fortawesome/free-solid-svg-icons";
import { IconDto } from "~/IconPicker/primitives/domains";

const meta: Meta<typeof IconPickerPrimitive> = {
title: "Components/Form Primitives/IconPicker",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { inputVariants } from "~/Input";
import { Popover } from "~/Popover";
import { cn, cva, type VariantProps } from "~/utils";
import { IconPickerGrid, IconPickerInput, IconPickerTrigger } from "./components";
import { IconDto } from "./domains";
import { IconDto } from "../domains";
import { useIconPicker } from "./useIconPicker";

const iconPickerVariants = cva("wby-cursor-pointer wby-text-neutral-strong", {
variants: {
size: {
md: "wby-w-[64px]",
lg: "wby-w-[68px]",
lg: "wby-w-[64px]",
xl: "wby-w-[76px]"
},
disabled: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useCallback } from "react";
import { Grid, GridCellProps } from "react-virtualized";
import { Text } from "~/Text";
import { cn } from "~/utils";
import { IconFormattedFontAwesome, IconFormatter } from "../domains";
import { IconFormattedFontAwesome, IconFormatter } from "../../domains";
import { IconPickerIcon } from "./IconPickerIcon";

const COLUMN_COUNT = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Icon as IconComponent } from "~/Icon";
import { inputVariants } from "~/Input";
import type { VariantProps } from "~/utils";
import { IconPickerIcon } from "./IconPickerIcon";
import { Icon, IconFormatter } from "../domains";
import { Icon, IconFormatter } from "../../domains";

interface IconPickerTriggerProps {
value?: string;
Expand All @@ -17,13 +17,11 @@ const IconPickerTrigger = ({ value, size }: IconPickerTriggerProps) => {
return IconFormatter.formatFontAwesome(icon);
}, [value]);

const iconSize = useMemo(() => (size === "lg" || size === "xl" ? "lg" : "md"), [size]);

return (
<div className={"wby-flex wby-items-center wby-gap-xs"}>
<div>
<IconComponent
size={iconSize}
size={size === "xl" ? "lg" : "md"}
icon={<IconPickerIcon prefix={icon.prefix} name={icon.name} />}
label={`Selected icon`}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeAutoObservable } from "mobx";
import { Icon, IconDto, IconFormattedFontAwesome, IconFormatter, ListCache } from "../domains";
import { Icon, IconDto, IconFormattedFontAwesome, IconFormatter, ListCache } from "../../domains";

interface IconPickerParams {
icons: IconDto[];
Expand Down
1 change: 1 addition & 0 deletions packages/app-headless-cms-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"devDependencies": {
"@emotion/babel-plugin": "^11.11.0",
"@webiny/admin-ui": "0.0.0",
"@webiny/cli": "0.0.0",
"@webiny/project-utils": "0.0.0",
"babel-plugin-module-resolver": "^5.0.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/app-headless-cms-common/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { CmsModel, CmsModelField } from "./model";
import { CmsIdentity } from "~/types/shared";
import type { SourceType } from "dnd-core";
import { IconDto } from "@webiny/admin-ui";

export type DragObjectWithType = {
type: SourceType;
Expand Down Expand Up @@ -472,7 +473,7 @@ export interface CmsIcon {

export interface CmsIconsPlugin extends Plugin {
type: "cms-icons";
getIcons(): CmsIcon[];
getIcons(): IconDto[];
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/app-headless-cms-common/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.build.json",
"include": ["src"],
"references": [
{ "path": "../admin-ui/tsconfig.build.json" },
{ "path": "../app-security/tsconfig.build.json" },
{ "path": "../form/tsconfig.build.json" },
{ "path": "../plugins/tsconfig.build.json" },
Expand Down
3 changes: 3 additions & 0 deletions packages/app-headless-cms-common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.json",
"include": ["src", "__tests__"],
"references": [
{ "path": "../admin-ui" },
{ "path": "../app-security" },
{ "path": "../form" },
{ "path": "../plugins" },
Expand All @@ -14,6 +15,8 @@
"paths": {
"~/*": ["./src/*"],
"~tests/*": ["./__tests__/*"],
"@webiny/admin-ui/*": ["../admin-ui/src/*"],
"@webiny/admin-ui": ["../admin-ui/src"],
"@webiny/app-security/*": ["../app-security/src/*"],
"@webiny/app-security": ["../app-security/src"],
"@webiny/form/*": ["../form/src/*"],
Expand Down
2 changes: 1 addition & 1 deletion packages/app-headless-cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@material-design-icons/svg": "^0.14.13",
"@svgr/webpack": "^6.1.1",
"@types/react": "18.2.79",
"@webiny/admin-ui": "0.0.0",
"@webiny/app": "0.0.0",
"@webiny/app-aco": "0.0.0",
"@webiny/app-admin": "0.0.0",
Expand Down Expand Up @@ -74,7 +75,6 @@
"react-dom": "18.2.0",
"react-helmet": "^6.1.0",
"react-hotkeyz": "^1.0.4",
"react-virtualized": "^9.22.5",
"use-deep-compare-effect": "^1.8.1"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 1b4b8be

Please sign in to comment.