From c30713e98649882d8dfe2c5d423be56b15993900 Mon Sep 17 00:00:00 2001 From: Nina Andal Aarvik Date: Mon, 30 Oct 2023 12:43:57 +0100 Subject: [PATCH] feat(facelift): create StudioUI tooltip with delay and replace (#5016) * feat(facelift): create StudioUI tooltip with delay and replace * fix(core/desk): use StudioUi Tooltip * fix(core/desk): use Studio UI tooltip * fix(core/desk): use StudioUI tooltip and remove paddings * fix(core): use StudioUI tooltip for TooltipOfDisabled - ref prop error * fix(src): fix studioUI tooltip to take strings and replace current tooltips with this logic * fix(vision): change tooltip import path * fix(src): fix up content in StudioUI tooltips, remove comment * fix(core): add two arguments to forwardRef render function * fix(test-studio): add custom badge to author schema type * Update packages/sanity/src/ui/tooltip/Tooltip.tsx Co-authored-by: Robin Pyon * refactor: slightly DRY tooltip component --------- Co-authored-by: Robin Pyon Co-authored-by: Robin Pyon --- dev/test-studio/components/formComponents.tsx | 7 ++++ dev/test-studio/sanity.config.ts | 3 +- .../vision/src/components/VisionGui.tsx | 24 +++-------- .../InsufficientPermissionsMessage.tsx | 2 +- .../src/core/components/StatusButton.tsx | 23 ++--------- .../src/core/components/TooltipOfDisabled.tsx | 14 +++---- .../components/collapseMenu/CollapseMenu.tsx | 14 ++----- .../collapseMenu/CollapseMenuButton.tsx | 3 +- .../previews/general/MediaPreview.styled.ts | 2 +- .../previews/general/MediaPreview.tsx | 3 +- .../core/components/userAvatar/UserAvatar.tsx | 13 ++---- .../field/diff/components/DiffTooltip.tsx | 5 ++- .../formField/FormFieldValidationStatus.tsx | 5 ++- .../CrossDatasetReferencePreview.tsx | 15 ++++--- .../customSchema/blockActions.tsx | 13 ++---- .../inputs/PortableText/object/Annotation.tsx | 4 +- .../PortableText/object/BlockObject.tsx | 5 ++- .../PortableText/object/InlineObject.tsx | 4 +- .../inputs/PortableText/text/TextBlock.tsx | 5 ++- .../inputs/PortableText/toolbar/Toolbar.tsx | 5 ++- .../inputs/ReferenceInput/CreateButton.tsx | 15 ++----- .../ReferenceInput/PreviewReferenceValue.tsx | 15 ++++--- .../ReferenceInput/ReferencePreview.tsx | 3 +- .../ArrayOfObjectsFunctions.tsx | 22 ++-------- .../ArrayOfPrimitivesFunctions.tsx | 12 ++---- .../core/form/studio/assetSource/AssetRow.tsx | 9 ++--- .../core/presence/DocumentPreviewPresence.tsx | 5 ++- .../src/core/presence/PresenceTooltip.tsx | 5 ++- .../studio/components/navbar/StudioNavbar.tsx | 2 - .../navbar/new-document/NewDocumentButton.tsx | 5 +-- .../new-document/NewDocumentListOption.tsx | 5 ++- .../navbar/resources/ResourcesButton.tsx | 9 ++--- .../filters/addFilter/items/FilterTooltip.tsx | 5 ++- .../addFilter/items/MenuItemFilter.tsx | 22 +--------- .../inputs/date/ParsedDateTextInput.tsx | 3 +- .../searchResults/item/DebugOverlay.tsx | 37 +++++++++-------- .../components/navbar/userMenu/UserMenu.tsx | 14 +------ .../navbar/workspace/WorkspaceMenuButton.tsx | 8 +--- .../src/desk/components/DraftStatus.tsx | 11 +---- .../desk/components/NotPublishedStatus.tsx | 3 +- .../src/desk/components/PublishedStatus.tsx | 11 +---- .../ConfirmDeleteDialogBody.styles.tsx | 14 ++----- .../InsufficientPermissionsMessageTooltip.tsx | 13 ++---- .../header/DocumentPanelHeader.tsx | 14 ++----- .../document/statusBar/ActionMenuButton.tsx | 12 ++---- .../statusBar/DocumentStatusBarActions.tsx | 7 ++-- .../statusBar/sparkline/DocumentBadges.tsx | 11 ++--- .../statusBar/sparkline/PublishStatus.tsx | 5 ++- .../ReviewChangesButton.tsx | 5 ++- packages/sanity/src/ui/tooltip/Tooltip.tsx | 40 +++++++++++-------- 50 files changed, 184 insertions(+), 327 deletions(-) diff --git a/dev/test-studio/components/formComponents.tsx b/dev/test-studio/components/formComponents.tsx index 00a78fce7e5..0b970318189 100644 --- a/dev/test-studio/components/formComponents.tsx +++ b/dev/test-studio/components/formComponents.tsx @@ -78,6 +78,13 @@ export function Preview(props: PreviewProps) { ) } +export function CustomBadge() { + return { + label: 'Hello world', + title: 'Hello I am a custom document badge', + } +} + export const formComponentsPlugin = definePlugin({ name: 'form-components-plugin', form: { diff --git a/dev/test-studio/sanity.config.ts b/dev/test-studio/sanity.config.ts index 2cc25ef766f..5671d7c51b4 100644 --- a/dev/test-studio/sanity.config.ts +++ b/dev/test-studio/sanity.config.ts @@ -26,6 +26,7 @@ import { import { Annotation, Block, + CustomBadge, Field, formComponentsPlugin, InlineBlock, @@ -74,10 +75,10 @@ const sharedSettings = definePlugin({ return prev }, newDocumentOptions, - unstable_comments: { enabled: true, }, + badges: (prev, context) => (context.schemaType === 'author' ? [CustomBadge, ...prev] : prev), }, plugins: [ deskTool({ diff --git a/packages/@sanity/vision/src/components/VisionGui.tsx b/packages/@sanity/vision/src/components/VisionGui.tsx index 7f82df3a6b6..7ac12827eff 100644 --- a/packages/@sanity/vision/src/components/VisionGui.tsx +++ b/packages/@sanity/vision/src/components/VisionGui.tsx @@ -13,12 +13,12 @@ import { Select, Text, TextInput, - Tooltip, Grid, Button, ToastContextValue, Inline, } from '@sanity/ui' +import {Tooltip} from '../../../../sanity/src/ui' import {VisionCodeMirror} from '../codemirror/VisionCodeMirror' import {getLocalStorage, LocalStorageish} from '../util/localStorage' import {parseApiQueryString, ParsedApiQueryString} from '../util/parseApiQueryString' @@ -754,13 +754,7 @@ export class VisionGui extends React.PureComponent - - Copy to clipboard - - } - > +