Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
fgatti675 committed Jan 23, 2024
1 parent 7f65991 commit 80f50e7
Show file tree
Hide file tree
Showing 8 changed files with 606 additions and 598 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react";
import { EntityCollection, getIconForView, SearchIcons, singular, toSnakeCase, } from "@firecms/core";
import { EntityCollection, getIconForView, SearchIconsView, singular, toSnakeCase, } from "@firecms/core";
import {
Autocomplete,
AutocompleteItem,
Expand Down Expand Up @@ -351,8 +351,8 @@ export function CollectionDetailsForm({
fullWidth
>
<div className={"p-4 overflow-auto min-h-[200px]"}>
<SearchIcons selectedIcon={values.icon}
onIconSelected={(icon: string) => {
<SearchIconsView selectedIcon={values.icon}
onIconSelected={(icon: string) => {
setIconDialogOpen(false);
setFieldValue("icon", icon);
}}/>
Expand Down
18 changes: 11 additions & 7 deletions packages/firecms_core/src/components/SearchIconsView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from "react";
import React from "react";

import { coolIconKeys, debounce, Icon, IconButton, iconKeys, SearchBar, Tooltip } from "@firecms/ui";
import { iconsSearch, icon_synonyms } from "../util";
import { icon_synonyms, iconsSearch } from "../util";

const UPDATE_SEARCH_INDEX_WAIT_MS = 220;

Expand All @@ -14,10 +15,13 @@ if (process.env.NODE_ENV !== "production") {

export interface SearchIconsProps {
selectedIcon?: string;
onIconSelected: (icon: string) => void;
onIconSelected?: (icon: string) => void;
}

export function SearchIcons({ selectedIcon = "", onIconSelected }: SearchIconsProps) {
export function SearchIconsView({
selectedIcon = "",
onIconSelected
}: SearchIconsProps) {
const [keys, setKeys] = React.useState<string[] | null>(null);
const [query, setQuery] = React.useState<string>("");

Expand All @@ -27,7 +31,7 @@ export function SearchIcons({ selectedIcon = "", onIconSelected }: SearchIconsPr
setKeys(null);
} else {
const searchResult = iconsSearch.search(value);
setKeys(searchResult.map((e:any) => e.key));
setKeys(searchResult.map((e: any) => e.key));
}
}, UPDATE_SEARCH_INDEX_WAIT_MS), []
);
Expand Down Expand Up @@ -57,10 +61,10 @@ export function SearchIcons({ selectedIcon = "", onIconSelected }: SearchIconsPr
<IconButton
shape={"square"}
toggled={selectedIcon === icon}
onClick={() => onIconSelected(icon)}
onClick={onIconSelected ? () => onIconSelected(icon) : undefined}
className="box-content m-1"
>
<Icon iconKey={icon} size={24} />
<Icon iconKey={icon} size={24}/>
</IconButton>
</Tooltip>
);
Expand Down
1,170 changes: 585 additions & 585 deletions packages/firecms_core/src/form/field_bindings/MarkdownFieldBinding.tsx

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/ui/src/components/common/SelectInputLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { cn } from "../../util";

export function SelectInputLabel({ children, error }: { children: React.ReactNode, error?: boolean }) {
Expand Down
5 changes: 3 additions & 2 deletions website/docs/icons/icons.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ id: icons
title: Icons
---

import { SearchIcons } from "@firecms/core";

<SearchIcons/>
import { DocsIconsView } from "../../src/DocsIconsView";

<DocsIconsView/>
1 change: 1 addition & 0 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
resolve: {
alias: {
"firecms": path.resolve(__dirname, "../packages/firecms/src"),
"@firecms/core": path.resolve(__dirname, "../packages/firecms_core/src"),
"@firecms/ui": path.resolve(__dirname, "../packages/ui/src"),
},
},
Expand Down
1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ module.exports = {
"recipes/documents_as_subcollections"
]
},
"icons/icons",
{
"type": "category",
"label": "Components",
Expand Down
2 changes: 1 addition & 1 deletion website/src/DocsIconsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import React from "react";

import { SearchIconsView } from "@firecms/core";

export default function DocsIconsView() {
export function DocsIconsView() {
return <SearchIconsView/>;
}

0 comments on commit 80f50e7

Please sign in to comment.