Skip to content

Commit

Permalink
chore(test-studio): add an example of initial value on type reference…
Browse files Browse the repository at this point in the history
…d by name
  • Loading branch information
bjoerge committed Apr 28, 2021
1 parent 1bd6332 commit b0e9aa2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
22 changes: 21 additions & 1 deletion examples/test-studio/schemas/initialValuesTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,38 @@ import {PlayIcon} from '@sanity/icons'

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

export const superlatives = {
name: 'superlatives',
type: 'object',
fields: [
{name: 'english', type: 'string', title: 'English'},
{name: 'norwegian', type: 'string', title: 'Norwegian'},
{name: 'swedish', type: 'string', title: 'Swedish', initialValue: 'Jättebra'},
],
}

export const initialValuesTest = {
name: 'initialValuesTest',
type: 'document',
title: 'Initial values test',
icon: PlayIcon,
initialValue: {superlatives: {norwegian: 'Kjempebra'}},
fields: [
{
name: 'title',
type: 'string',
title: 'String (initially set to "initial title")',
initialValue: 'initial title',
},
{name: 'recursive', type: 'initialValuesTest'},
{
name: 'superlatives',
title: 'Superlatives',
type: 'superlatives',
initialValue: {
// see definition of the superlatives type for initial values defined for other fields
english: 'Awesome',
},
},
{
name: 'asyncString',
type: 'string',
Expand Down Expand Up @@ -196,6 +215,7 @@ export const initialValuesTest = {
{_type: 'simpleObject', title: 'initial 2', primitiveValues: {title: 'inner title'}},
],
},
{name: 'recursive', type: 'initialValuesTest'},
],
}

Expand Down
3 changes: 2 additions & 1 deletion examples/test-studio/schemas/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import review from './review'
import gallery from './gallery'
import presence, {objectWithNestedArray} from './presence'
import {customBlock, hoistedPt, hoistedPtDocument} from './hoistedPt'
import {initialValuesTest} from './initialValuesTest'
import {initialValuesTest, superlatives} from './initialValuesTest'

export default createSchema({
name: 'test-examples',
Expand All @@ -73,6 +73,7 @@ export default createSchema({
presence,
species,
initialValuesTest,
superlatives,
spotifyEmbed,
focus,
strings,
Expand Down

2 comments on commit b0e9aa2

@vercel
Copy link

@vercel vercel bot commented on b0e9aa2 Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

test-studio – ./

test-studio-git-next.sanity.build
test-studio.sanity.build

@vercel
Copy link

@vercel vercel bot commented on b0e9aa2 Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

perf-studio – ./

perf-studio-git-next.sanity.build
perf-studio.sanity.build

Please sign in to comment.