Skip to content

Commit

Permalink
Merge pull request #58 from wp-graphql/revert-47-faustjs-multiple-que…
Browse files Browse the repository at this point in the history
…ries

Revert "Implement Faust’s multiple queries"
  • Loading branch information
jasonbahl authored Jan 12, 2024
2 parents 60eccc2 + 6049523 commit 2335f65
Show file tree
Hide file tree
Showing 7 changed files with 1,199 additions and 1,321 deletions.
21 changes: 7 additions & 14 deletions components/FieldTypesList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,10 @@ export function FieldTypesList({ data }) {
{contentNodes.nodes.map((fieldType) => (
<div
key={fieldType.uri}
className="dark:bg-white/2.5 group relative flex flex-col rounded-2xl bg-zinc-50 transition-shadow hover:shadow-md hover:shadow-zinc-900/5 dark:bg-gray-800 dark:hover:bg-gray-900 dark:hover:shadow-black/5"
className="dark:bg-white/2.5 group relative flex rounded-2xl bg-zinc-50 transition-shadow hover:shadow-md hover:shadow-zinc-900/5 dark:bg-gray-800 dark:hover:bg-gray-900 dark:hover:shadow-black/5"
>
<Link
href={fieldType.uri}
tabIndex={0}
className="z-20 absolute inset-0 rounded-2xl focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-zinc-900/75"
aria-label={`${fieldType.title} field type`}
/>
<div className="ring-zinc-900/7.5 absolute inset-0 rounded-2xl ring-1 ring-inset group-hover:ring-zinc-900/10 dark:ring-white/10 dark:group-hover:ring-white/20" />
<div className="relative flex flex-col rounded-2xl px-4 pb-4 pt-16 h-full z-10">
<div className="relative rounded-2xl px-4 pb-4 pt-16">
{fieldType?.featuredImage?.node && (
<Image
src={fieldType?.featuredImage?.node.sourceUrl}
Expand All @@ -45,15 +39,14 @@ export function FieldTypesList({ data }) {
fieldType?.featuredImage?.node.altText ??
'screenshot of the field type'
}
layout="responsive"
className="flex-shrink-0"
/>
)}
<div className="mt-auto">
<h3 className="font-semibold text-center text-gray-900 dark:text-gray-100 pt-6 pb-4">
<h3 className="mt-6 font-semibold text-gray-900 dark:text-gray-100">
<Link href={fieldType.uri}>
<span className="absolute inset-0 rounded-2xl" />
{fieldType.title}
</h3>
</div>
</Link>
</h3>
</div>
</div>
))}
Expand Down
6 changes: 3 additions & 3 deletions components/LayoutArchive.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { SiteFooter } from '@/components/SiteFooter'
import { SiteHeader } from '@/components/SiteHeader'
import { SitewideNotice } from '@/components/SitewideNotice'

export const GET_LAYOUT_QUERY = gql`
query GetLayout {
LayoutArchive.fragment = gql`
fragment LayoutArchiveFragment on RootQuery {
...SitewideNoticeFragment
...PrimaryNavigationFragment
...DocsSidebarNavigationFragment
Expand All @@ -21,7 +21,7 @@ export const GET_LAYOUT_QUERY = gql`
${PrimaryNavigation.fragment}
${DocsSidebarNavigation.fragment}
${FooterNavigation.fragment}
`;
`

export function LayoutArchive({ data, children, title }) {
const primaryMenuItems = data?.primaryMenuItems ?? []
Expand Down
1 change: 0 additions & 1 deletion faust.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ export default setConfig({
templates,
experimentalPlugins: [],
usePersistedQueries: true,
experimentalToolbar: false,
possibleTypes,
})
2,397 changes: 1,148 additions & 1,249 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"@docsearch/css": "^3.5.2",
"@docsearch/react": "^3.5.2",
"@faustwp/blocks": "^2.0.0",
"@faustwp/cli": "^2.0.0",
"@faustwp/core": "^2.1.0",
"@faustwp/cli": "^1.1.4",
"@faustwp/core": "^1.1.2",
"@graphiql/react": "^0.20.2",
"@graphiql/toolkit": "^0.9.1",
"@headlessui/react": "^1.7.13",
Expand Down
85 changes: 35 additions & 50 deletions wp-templates/archive-field_type.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
import { gql } from '@apollo/client'
import Head from 'next/head'
import { useFaustQuery } from "@faustwp/core";

import { FieldTypesList } from '@/components/FieldTypesList'
import { LayoutArchive, GET_LAYOUT_QUERY } from '@/components/LayoutArchive'
import { LayoutArchive } from '@/components/LayoutArchive'

export const GET_POST_QUERY = gql`
query GetPost($uri: String!) {
export const ArchiveFieldType = (props) => {
const { data } = props

const { node } = data

if (!node) {
return null
}

let toc = []

return (
<>
<Head>
<title>{`${data?.node?.label} - WPGraphQL for ACF`}</title>
</Head>
<LayoutArchive
title={data?.node?.label ? data.node.label : 'WPGraphQL for ACF'}
data={data}
navigation={data?.navigation?.nodes}
toc={toc}
>
<FieldTypesList data={data} />
</LayoutArchive>
</>
)
}

ArchiveFieldType.query = gql`
query GetArchiveFieldType($uri: String!) {
node: nodeByUri(uri: $uri) {
__typename
uri
Expand Down Expand Up @@ -35,51 +62,9 @@ export const GET_POST_QUERY = gql`
}
}
}
...LayoutArchiveFragment
}
`;
${LayoutArchive.fragment}
`

export const ArchiveFieldType = (props) => {
const { node } = useFaustQuery(GET_POST_QUERY);
const {
docsSidebarMenuItems,
footerMenuItems,
primaryMenuItems,
sitewideNotice
} = useFaustQuery(GET_LAYOUT_QUERY);

// console.log({ node, docsSidebarMenuItems, footerMenuItems, primaryMenuItems, sitewideNotice });

if (!node) {
return null
}

return (
<>
<Head>
<title>{`${node?.label} - WPGraphQL for ACF`}</title>
</Head>
<LayoutArchive
title={node?.label ? node.label : 'WPGraphQL for ACF'}
data={{
node,
docsSidebarMenuItems,
footerMenuItems,
primaryMenuItems,
sitewideNotice
}}
>
<FieldTypesList data={{ node }} />
</LayoutArchive>
</>
)
}

ArchiveFieldType.queries = [
{
query: GET_LAYOUT_QUERY,
},
{
query: GET_POST_QUERY,
variables: ({ uri }) => ({ uri }),
}
];
ArchiveFieldType.variables = ({ uri }) => ({ uri })
6 changes: 4 additions & 2 deletions wp-templates/archive.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { gql } from '@apollo/client'
import Head from 'next/head'

import { LayoutArchive, GET_LAYOUT_QUERY } from '@/components/LayoutArchive'
import { LayoutArchive } from '@/components/LayoutArchive'

export const Archive = (props) => {
const { data } = props
Expand All @@ -22,7 +22,7 @@ export const Archive = (props) => {
)
}

const GET_ARCHIVE_QUERY = gql`
Archive.query = gql`
query GetArchive($uri: String!) {
node: nodeByUri(uri: $uri) {
__typename
Expand All @@ -41,7 +41,9 @@ const GET_ARCHIVE_QUERY = gql`
}
}
}
...LayoutArchiveFragment
}
${LayoutArchive.fragment}
`

Archive.variables = (seedNode) => {
Expand Down

0 comments on commit 2335f65

Please sign in to comment.