diff --git a/components/ui/table.tsx b/components/ui/table.tsx new file mode 100644 index 0000000..3f55e27 --- /dev/null +++ b/components/ui/table.tsx @@ -0,0 +1,114 @@ +import * as React from "react" + +import { cn } from "@/lib/utils" + +const Table = React.forwardRef< + HTMLTableElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+ + +)) +Table.displayName = "Table" + +const TableHeader = React.forwardRef< + HTMLTableSectionElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( + +)) +TableHeader.displayName = "TableHeader" + +const TableBody = React.forwardRef< + HTMLTableSectionElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( + +)) +TableBody.displayName = "TableBody" + +const TableFooter = React.forwardRef< + HTMLTableSectionElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( + +)) +TableFooter.displayName = "TableFooter" + +const TableRow = React.forwardRef< + HTMLTableRowElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( + +)) +TableRow.displayName = "TableRow" + +const TableHead = React.forwardRef< + HTMLTableCellElement, + React.ThHTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +TableHead.displayName = "TableHead" + +const TableCell = React.forwardRef< + HTMLTableCellElement, + React.TdHTMLAttributes +>(({ className, ...props }, ref) => ( + +)) +TableCell.displayName = "TableCell" + +const TableCaption = React.forwardRef< + HTMLTableCaptionElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +TableCaption.displayName = "TableCaption" + +export { + Table, + TableHeader, + TableBody, + TableFooter, + TableHead, + TableRow, + TableCell, + TableCaption, +} \ No newline at end of file diff --git a/wp-blocks/AcfFieldTypeSettings.js b/wp-blocks/AcfFieldTypeSettings.js deleted file mode 100644 index 11e5056..0000000 --- a/wp-blocks/AcfFieldTypeSettings.js +++ /dev/null @@ -1,22 +0,0 @@ -import { gql } from '@apollo/client' - -const AcfFieldTypeSettings = (props) => { - // @todo: this component should render a table of settings for the field type, similar to what's seen on pages like: https://www.advancedcustomfields.com/resources/email/#settings - return
{JSON.stringify(props, null, 2)}
-} - -export default AcfFieldTypeSettings - -AcfFieldTypeSettings.displayName = `AcfFieldTypeSettings` -AcfFieldTypeSettings.config = { - name: `AcfFieldTypeSettings`, -} -AcfFieldTypeSettings.fragments = { - key: `AcfFieldTypeSettings`, - // @todo: the fragment should be updated to fetch the fields for the field type, and return a list of the selected settings for the Field Type. - entry: gql` - fragment AcfFieldTypeSettings on AcfFieldTypeSettings { - test: renderedHtml - } - `, -} diff --git a/wp-blocks/AcfFieldTypeSettingsBlock.js b/wp-blocks/AcfFieldTypeSettingsBlock.js new file mode 100644 index 0000000..25a845d --- /dev/null +++ b/wp-blocks/AcfFieldTypeSettingsBlock.js @@ -0,0 +1,61 @@ +import { gql } from '@apollo/client'; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table" + +export function AcfFieldTypeSettingsBlock(props) { + const { fieldTypeSettings } = props?.fieldTypeSettingsBlockFields; + + return ( + + + + Name + Description + {/* Impact on WPGraphQL */} + + + + {fieldTypeSettings?.nodes?.map((item, index) => ( + + {item.name} + {item.description} + {/* {item.impactOnWpgraphql} */} + + ))} + +
+ ); +} + +AcfFieldTypeSettingsBlock.displayName = `AcfFieldTypeSettingsBlock`; +AcfFieldTypeSettingsBlock.config = { + name: `AcfFieldTypeSettingsBlock`, +}; +AcfFieldTypeSettingsBlock.fragments = { + key: `AcfFieldTypeSettingsBlockFragment`, + entry: gql` + fragment AcfFieldTypeSettingsBlockFragment on AcfFieldTypeSettingsBlock { + fieldTypeSettingsBlockFields { + fieldTypeSettings(first: 100) { + nodes { + __typename + id + ...on ACFFieldTypeSetting { + name + description + fieldTypeSettingsMeta { + impactOnWpgraphql + } + } + } + } + } + } + `, +}; \ No newline at end of file diff --git a/wp-blocks/CoreHeading.js b/wp-blocks/CoreHeading.js index 1061116..7498556 100644 --- a/wp-blocks/CoreHeading.js +++ b/wp-blocks/CoreHeading.js @@ -2,7 +2,7 @@ import { CoreBlocks } from '@faustwp/blocks' import slugify from '@sindresorhus/slugify' const { CoreHeading: FaustCoreHeading } = CoreBlocks -function CoreHeading(props) { +function Component(props) { const { attributes } = props const customAttributes = { @@ -19,8 +19,8 @@ function CoreHeading(props) { ) } -CoreHeading.displayName = { ...FaustCoreHeading.displayName } -CoreHeading.config = { ...FaustCoreHeading.config } -CoreHeading.fragments = { ...FaustCoreHeading.fragments } +Component.displayName = { ...FaustCoreHeading.displayName } +Component.config = { ...FaustCoreHeading.config } +Component.fragments = { ...FaustCoreHeading.fragments } -export default CoreHeading +export default Component diff --git a/wp-blocks/index.js b/wp-blocks/index.js index 8fb5e90..6595f95 100644 --- a/wp-blocks/index.js +++ b/wp-blocks/index.js @@ -1,12 +1,12 @@ import { CoreBlocks } from '@faustwp/blocks' -import AcfFieldTypeSettings from './AcfFieldTypeSettings' +import { AcfFieldTypeSettingsBlock } from './AcfFieldTypeSettingsBlock' import CustomHeading from './CoreHeading' const blocks = { ...CoreBlocks, CoreHeading: CustomHeading, - AcfFieldTypeSettings: AcfFieldTypeSettings, + AcfFieldTypeSettingsBlock, } export default blocks diff --git a/wp-templates/single-field_type.js b/wp-templates/single-field_type.js index 3fa66b6..102f386 100644 --- a/wp-templates/single-field_type.js +++ b/wp-templates/single-field_type.js @@ -6,16 +6,7 @@ import { Separator } from '@radix-ui/react-separator' import { Layout } from '@/components/Layout' import { Badge } from '@/components/ui/badge' import blocks from '@/wp-blocks' - - -// const nodeContent =` -//
-//

Description

-//

Field Settings

-//

Query in GraphQL

-//
{JSON.stringify(node, null, 2)
-//
-// `; +import { AcfFieldTypeSettingsBlock } from '@/wp-blocks/AcfFieldTypeSettingsBlock'; export const SingleFieldType = ({ data }) => { const { node } = data @@ -75,30 +66,7 @@ export const SingleFieldType = ({ data }) => { })} )} - {/* { - node.editorBlocks && node.editorBlocks.map( ( block, i ) => { - switch( block.__typename ) { - case 'CoreHeading': - let Tag = `h${block.attributes.level}`; - return ( - - {block.attributes.content} - - ); - break; - case 'AcfTestBlock': - return
{JSON.stringify(block, null, 2)}
- default: - return ; - break; - } - }) - } */} - {/*

Raw Blocks List

-
{JSON.stringify( blockList, null, 2)}
-

Raw editorBlocks

-
{JSON.stringify(node.editorBlocks, null, 2)}
*/} ) } @@ -141,6 +109,7 @@ query SingleAcfFieldType($uri: String!) { ...${blocks.CoreSeparator.fragments.key} ...${blocks.CoreList.fragments.key} ...${blocks.CoreHeading.fragments.key} + ...AcfFieldTypeSettingsBlockFragment } } ...aCFFieldTypeCategoriesFragment @@ -148,6 +117,8 @@ query SingleAcfFieldType($uri: String!) { } ${Layout.fragment} ${aCFFieldTypeCategoriesFragment} +${AcfFieldTypeSettingsBlock.fragments.entry} + ${blocks.CoreParagraph.fragments.entry} ${blocks.CoreColumns.fragments.entry} ${blocks.CoreColumn.fragments.entry}