Skip to content
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(core): add studioActiveToolLayout and navbar rightSectionNode prop #5749

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/sanity/src/core/config/studio/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {type ComponentType, type ReactElement} from 'react'
import {type ComponentType, type ReactElement, type ReactNode} from 'react'

import {type Tool} from '../types'

Expand All @@ -23,6 +23,10 @@ export interface LogoProps {
* @beta */
export interface NavbarProps {
renderDefault: (props: NavbarProps) => ReactElement
/**
* @internal
* @beta */
__internal_rightSectionNode?: ReactNode
}
Copy link
Member

Choose a reason for hiding this comment

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

We should probably think about how we could offer an API with more granularity, so we could use a render/renderDefault pattern for these things as well, but I understand why navbar.render + renderDefault didn't work for you here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it was an interesting discussion with the ex team, but we couldn't find any other solution given this navbar component adds multiple internal components and we would have need to recreate the same through the plugin.
Will be a nice discussion to bring to next studio meeting. Will propose it.

Thanks @bjoerge !


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {type RouterState, useRouterState} from 'sanity/router'
import styled from 'styled-components'

import {Button, TooltipDelayGroupProvider} from '../../../../ui-components'
import {type NavbarProps} from '../../../config/studio/types'
import {isDev} from '../../../environment'
import {useTranslation} from '../../../i18n'
import {useToolMenuComponent} from '../../studio-components-hooks'
Expand Down Expand Up @@ -58,7 +59,9 @@ const NavGrid = styled(Grid)`
/**
* @hidden
* @beta */
export function StudioNavbar() {
export function StudioNavbar(props: Omit<NavbarProps, 'renderDefault'>) {
// eslint-disable-next-line camelcase
const {__internal_rightSectionNode = null} = props
const {name, tools} = useWorkspace()
const routerState = useRouterState()
const mediaIndex = useMediaIndex()
Expand Down Expand Up @@ -233,7 +236,6 @@ export function StudioNavbar() {
</BoundaryElementProvider>
</SearchProvider>
</LayerProvider>

{shouldRender.tools && <FreeTrial type="topbar" />}
{shouldRender.configIssues && <ConfigIssuesButton />}
{shouldRender.resources && <ResourcesButton />}
Expand All @@ -245,6 +247,11 @@ export function StudioNavbar() {
ref={setSearchOpenButtonEl}
/>
)}

{
// eslint-disable-next-line camelcase
__internal_rightSectionNode
}
</Flex>
{shouldRender.tools && (
<Box flex="none" marginLeft={1}>
Expand Down
Loading