-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add PTE in Presentation race condition reproduction (#5961)
- Loading branch information
Showing
8 changed files
with
116 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import {PortableText, type PortableTextComponents} from '@portabletext/react' | ||
import {type PortableTextBlock} from 'sanity' | ||
|
||
import {imageBuilder, useQuery} from './loader' | ||
|
||
const components: PortableTextComponents = { | ||
types: { | ||
image: ({value}) => { | ||
if (!value?.asset?._ref) { | ||
return null | ||
} | ||
return ( | ||
<img | ||
alt={value.alt || ''} | ||
src={imageBuilder.image(value).width(150).height(150).fit('crop').url()} | ||
/> | ||
) | ||
}, | ||
}, | ||
} | ||
|
||
export function SimpleBlockPortableText(): JSX.Element { | ||
const {data, loading, error} = useQuery< | ||
{ | ||
_id: string | ||
title: string | null | ||
body: PortableTextBlock[] | ||
notes: {_key: string; title?: string; minutes?: number; notes?: PortableTextBlock[]}[] | ||
}[] | ||
>(/* groq */ `*[_type == "simpleBlock"]{_id,title,body,notes}`) | ||
|
||
if (error) { | ||
throw error | ||
} | ||
|
||
if (loading) { | ||
return <p>Loading...</p> | ||
} | ||
|
||
return ( | ||
<> | ||
{data?.map((item) => { | ||
return ( | ||
<article | ||
key={item._id} | ||
style={{ | ||
margin: '10px 20px', | ||
background: 'ghostwhite', | ||
borderRadius: '8px', | ||
border: '1px solid lightgray', | ||
padding: '10px 20px', | ||
}} | ||
> | ||
<h1>{item.title || 'Untitled'}</h1> | ||
<PortableText components={components} value={item.body} /> | ||
{item.notes?.map((note) => ( | ||
<div key={note._key}> | ||
<h2>{note.title}</h2> | ||
<p>{note.minutes} minutes</p> | ||
<PortableText components={components} value={note.notes || []} /> | ||
</div> | ||
))} | ||
</article> | ||
) | ||
})} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {createClient} from '@sanity/client' | ||
import imageUrlBuilder from '@sanity/image-url' | ||
import {createQueryStore} from '@sanity/react-loader' | ||
|
||
const client = createClient({ | ||
projectId: 'ppsg7ml5', | ||
dataset: 'playground', | ||
useCdn: true, | ||
apiVersion: '2023-02-06', | ||
stega: { | ||
enabled: true, | ||
studioUrl: '/presentation', | ||
// logger: console, | ||
filter: (props) => { | ||
return props.filterDefault(props) | ||
}, | ||
}, | ||
}) | ||
|
||
export const {useQuery, useLiveMode} = createQueryStore({client}) | ||
export const imageBuilder: ReturnType<typeof imageUrlBuilder> = imageUrlBuilder(client) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters