-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test(core): components API * refactor(core): add `useMiddlewareComponents` JSDoc * feat(core): introduce `document.components.layout` * feat(desk): use document layout from Components API * feat(comments): use `document.components.layout` and rename components * test(core): fix e2e tests * fix(core): prefix document layout component with `unstable` * fix(comments): remove redundant provider * refactor(comments): simplify comments enabled check
- Loading branch information
1 parent
0c6a32e
commit adaae0e
Showing
45 changed files
with
841 additions
and
463 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {Flex} from '@sanity/ui' | ||
import {DocumentLayoutProps} from 'sanity' | ||
|
||
export function DocumentLayout(props: DocumentLayoutProps & {testId: string}) { | ||
const {testId} = props | ||
|
||
if (props.documentType !== 'formComponentsApi') { | ||
return props.renderDefault(props) | ||
} | ||
|
||
return ( | ||
<Flex data-testid={testId} direction="column" flex={1} height="fill" overflow="hidden"> | ||
{props.renderDefault(props)} | ||
</Flex> | ||
) | ||
} |
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,8 @@ | ||
import {Stack} from '@sanity/ui' | ||
import {FieldProps} from 'sanity' | ||
|
||
export function FormField(props: FieldProps & {testId: string}) { | ||
const {testId} = props | ||
|
||
return <Stack data-testid={testId}>{props.renderDefault(props)}</Stack> | ||
} |
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,10 @@ | ||
import {Stack} from '@sanity/ui' | ||
import {InputProps} from 'sanity' | ||
|
||
export function FormInput(props: InputProps & {testId: string}) { | ||
const {testId} = props | ||
|
||
if (props.id === 'root') return props.renderDefault(props) | ||
|
||
return <Stack data-testid={testId}>{props.renderDefault(props)}</Stack> | ||
} |
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,12 @@ | ||
import {Flex} from '@sanity/ui' | ||
import {LayoutProps} from 'sanity' | ||
|
||
export function StudioLayout(props: LayoutProps & {testId: string}) { | ||
const {testId} = props | ||
|
||
return ( | ||
<Flex data-testid={testId} direction="column" height="fill" overflow="hidden"> | ||
{props.renderDefault(props)} | ||
</Flex> | ||
) | ||
} |
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,9 @@ | ||
import {Box} from '@sanity/ui' | ||
import React from 'react' | ||
import {LogoProps} from 'sanity' | ||
|
||
export function StudioLogo(props: LogoProps & {testId: string}) { | ||
const {testId} = props | ||
|
||
return <Box data-testid={testId}>{props.renderDefault(props)}</Box> | ||
} |
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,8 @@ | ||
import {Stack} from '@sanity/ui' | ||
import {NavbarProps} from 'sanity' | ||
|
||
export function StudioNavbar(props: NavbarProps & {testId: string}) { | ||
const {testId} = props | ||
|
||
return <Stack data-testid={testId}>{props.renderDefault(props)}</Stack> | ||
} |
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,8 @@ | ||
import {Stack} from '@sanity/ui' | ||
import {ToolMenuProps} from 'sanity' | ||
|
||
export function StudioToolMenu(props: ToolMenuProps & {testId: string}) { | ||
const {testId} = props | ||
|
||
return <Stack data-testid={testId}>{props.renderDefault(props)}</Stack> | ||
} |
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 {definePlugin} from 'sanity' | ||
import {StudioLayout} from './StudioLayout' | ||
import {StudioNavbar} from './StudioNavbar' | ||
import {StudioLogo} from './StudioLogo' | ||
import {StudioToolMenu} from './StudioToolMenu' | ||
import {FormInput} from './FormInput' | ||
import {FormField} from './FormField' | ||
import {DocumentLayout} from './DocumentLayout' | ||
|
||
const childComponents = definePlugin({ | ||
name: 'child-components', | ||
|
||
document: { | ||
components: { | ||
unstable_layout: (props) => ( | ||
<DocumentLayout {...props} testId="child-parent-config-document-layout" /> | ||
), | ||
}, | ||
}, | ||
|
||
form: { | ||
components: { | ||
input: (props) => <FormInput {...props} testId="child-parent-config-form-input" />, | ||
field: (props) => <FormField {...props} testId="child-parent-config-form-field" />, | ||
}, | ||
}, | ||
|
||
studio: { | ||
components: { | ||
layout: (props) => <StudioLayout {...props} testId="child-parent-config-studio-layout" />, | ||
logo: (props) => <StudioLogo {...props} testId="child-parent-config-studio-logo" />, | ||
navbar: (props) => <StudioNavbar {...props} testId="child-parent-config-studio-navbar" />, | ||
toolMenu: (props) => ( | ||
<StudioToolMenu {...props} testId="child-parent-config-studio-tool-menu" /> | ||
), | ||
}, | ||
}, | ||
}) | ||
|
||
export const customComponents = definePlugin({ | ||
name: 'custom-components', | ||
|
||
document: { | ||
components: { | ||
unstable_layout: (props) => ( | ||
<DocumentLayout {...props} testId="parent-config-document-layout" /> | ||
), | ||
}, | ||
}, | ||
|
||
form: { | ||
components: { | ||
input: (props) => <FormInput {...props} testId="parent-config-form-input" />, | ||
field: (props) => <FormField {...props} testId="parent-config-form-field" />, | ||
}, | ||
}, | ||
|
||
studio: { | ||
components: { | ||
layout: (props) => <StudioLayout {...props} testId="parent-config-studio-layout" />, | ||
logo: (props) => <StudioLogo {...props} testId="parent-config-studio-logo" />, | ||
navbar: (props) => <StudioNavbar {...props} testId="parent-config-studio-navbar" />, | ||
toolMenu: (props) => <StudioToolMenu {...props} testId="parent-config-studio-tool-menu" />, | ||
}, | ||
}, | ||
|
||
plugins: [childComponents()], | ||
}) |
This file was deleted.
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
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 @@ | ||
export * from './types' |
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,16 @@ | ||
import {ComponentType} from 'react' | ||
import {PreviewProps} from '../../components' | ||
import {InputProps, FieldProps, ItemProps, BlockProps, BlockAnnotationProps} from '../../form' | ||
|
||
/** | ||
* @hidden | ||
* @beta */ | ||
export interface FormComponents { | ||
annotation?: ComponentType<BlockAnnotationProps> | ||
block?: ComponentType<BlockProps> | ||
field?: ComponentType<FieldProps> | ||
inlineBlock?: ComponentType<BlockProps> | ||
input?: ComponentType<InputProps> | ||
item?: ComponentType<ItemProps> | ||
preview?: ComponentType<PreviewProps> | ||
} |
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
Oops, something went wrong.
adaae0e
There was a problem hiding this comment.
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:
performance-studio – ./
performance-studio-git-next.sanity.build
performance-studio.sanity.build
adaae0e
There was a problem hiding this comment.
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.sanity.build
test-studio-git-next.sanity.build