-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(structure): document panel UI updates #8622
Open
pedrobonamin
wants to merge
14
commits into
next
Choose a base branch
from
sapp-2072
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cf145c1
feat(structure): adds document panel sub header
pedrobonamin 88d69f5
chore(structure): update document Banners, add padding and rounded co…
pedrobonamin 232b26b
feat(structure): update document pane footer layout
pedrobonamin 6ffb6fb
fix(structure): update usage of Create banner and footer to match new…
pedrobonamin 28d9df7
fix(structure): keep document pane dialogs within the document box
pedrobonamin 939c5c3
fix(core): update changes tabs vertical alignment
pedrobonamin ec39f6b
fix(structure): update draftLiveEditBanner alignment
pedrobonamin e308f8e
fix(create): update banners buttons size
pedrobonamin 3f2eff3
fix(structure): update mobile view for document panel
pedrobonamin 794cb4b
fix(structure): add scroller to document perspective list
pedrobonamin 38b58e2
feat(structure): add document header tabs menu item
pedrobonamin 88cf420
fix(structure): remove document panel comments
pedrobonamin 74730a3
fix(structure): document actions position is flex end
pedrobonamin e355083
chore(structure): split document layout footer
pedrobonamin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
75 changes: 75 additions & 0 deletions
75
packages/sanity/src/structure/panes/document/document-layout/DocumentLayoutFooter.tsx
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,75 @@ | ||
import {DialogProvider, type DialogProviderProps, PortalProvider} from '@sanity/ui' | ||
import {type Dispatch, type ReactNode, type SetStateAction, useMemo} from 'react' | ||
import {getSanityCreateLinkMetadata, useSanityCreateConfig, useZIndex} from 'sanity' | ||
|
||
import {TooltipDelayGroupProvider} from '../../../../ui-components/tooltipDelayGroupProvider/TooltipDelayGroupProvider' | ||
import {PaneFooter, usePane} from '../../../components' | ||
import {DOCUMENT_PANEL_PORTAL_ELEMENT} from '../../../constants' | ||
import {DocumentStatusBar} from '../statusBar' | ||
import {useDocumentPane} from '../useDocumentPane' | ||
|
||
const DIALOG_PROVIDER_POSITION: DialogProviderProps['position'] = [ | ||
// We use the `position: fixed` for dialogs on narrower screens (first two media breakpoints). | ||
'fixed', | ||
'fixed', | ||
// And we use the `position: absolute` strategy (within panes) on wide screens. | ||
'absolute', | ||
] | ||
|
||
export function DocumentLayoutFooter({ | ||
documentPanelPortalElement, | ||
setFooterElement, | ||
setActionsBoxElement, | ||
}: { | ||
documentPanelPortalElement: HTMLElement | null | ||
setFooterElement: Dispatch<SetStateAction<HTMLDivElement | null>> | ||
setActionsBoxElement: Dispatch<SetStateAction<HTMLDivElement | null>> | ||
}) { | ||
const zOffsets = useZIndex() | ||
|
||
const {value, isInitialValueLoading, ready, documentId, schemaType} = useDocumentPane() | ||
const portalElements = useMemo( | ||
() => ({[DOCUMENT_PANEL_PORTAL_ELEMENT]: documentPanelPortalElement}), | ||
[documentPanelPortalElement], | ||
) | ||
|
||
const createLinkMetadata = getSanityCreateLinkMetadata(value) | ||
const {startInCreateBanner: StartInCreateBanner} = useSanityCreateConfig().components ?? {} | ||
return ( | ||
// These providers are added because we want the dialogs in `DocumentStatusBar` to be scoped to the document pane | ||
// The portal element comes from `DocumentPanel`. | ||
<PortalProvider __unstable_elements={portalElements}> | ||
<DialogProvider position={DIALOG_PROVIDER_POSITION} zOffset={zOffsets.portal}> | ||
<PaneFooter ref={setFooterElement} padding={1}> | ||
{StartInCreateBanner && ( | ||
<ShowWhenPaneOpen> | ||
<StartInCreateBanner | ||
document={value} | ||
documentId={documentId} | ||
documentType={schemaType} | ||
documentReady={ready} | ||
isInitialValueLoading={!!isInitialValueLoading} | ||
panelPortalElementId={DOCUMENT_PANEL_PORTAL_ELEMENT} | ||
/> | ||
</ShowWhenPaneOpen> | ||
)} | ||
<TooltipDelayGroupProvider> | ||
<DocumentStatusBar | ||
actionsBoxRef={setActionsBoxElement} | ||
createLinkMetadata={createLinkMetadata} | ||
/> | ||
</TooltipDelayGroupProvider> | ||
</PaneFooter> | ||
</DialogProvider> | ||
</PortalProvider> | ||
) | ||
} | ||
|
||
/** | ||
* Prevents whatever is inside of it from rendering when the pane is collapsed. | ||
* Needed locally as DocumentLayout does lives outside PaneContext, but is provided _somewhere_ within it. | ||
*/ | ||
function ShowWhenPaneOpen(props: {children: ReactNode}) { | ||
const {collapsed} = usePane() | ||
return collapsed ? null : props.children | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nice!