Skip to content

Commit

Permalink
fix(desk): add studio ui tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
ninaandal committed Oct 19, 2023
1 parent 980a86c commit 81faebe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions packages/sanity/src/desk/components/DraftStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import {TextWithTone, useTimeAgo} from 'sanity'
export function DraftStatus(props: {document?: PreviewValue | Partial<SanityDocument> | null}) {
const {document} = props
const updatedAt = document && '_updatedAt' in document && document._updatedAt

// Label with abbreviations and suffix
const lastEditedTime = useTimeAgo(updatedAt || '', {minimal: true, agoSuffix: true})
const lastEditedTimeAgo = `${lastEditedTime} ago`

return (
<Tooltip
text={document ? `Edited ${updatedAt ? lastEditedTimeAgo : ''}` : 'No unpublished edits'}
>
<Tooltip text={document ? `Edited ${updatedAt ? lastEditedTime : ''}` : 'No unpublished edits'}>
<TextWithTone tone="caution" dimmed={!document} muted={!document} size={1}>
<EditIcon />
</TextWithTone>
Expand Down
4 changes: 2 additions & 2 deletions packages/sanity/src/desk/components/PublishedStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export function PublishedStatus(props: {document?: PreviewValue | Partial<Sanity
const updatedAt = document && '_updatedAt' in document && document._updatedAt
const statusLabel = document ? 'Published' : 'Not published'

// Label with abbreviations
const lastPublishedTime = useTimeAgo(updatedAt || '', {minimal: true})
// Label with abbreviations and suffix
const lastPublishedTime = useTimeAgo(updatedAt || '', {minimal: true, agoSuffix: true})

return (
<Tooltip text={document ? `Published ${updatedAt ? lastPublishedTime : ''}` : 'Not published'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function PublishStatus(props: PublishStatusProps) {
text={`${
liveEdit
? `Last updated ${lastUpdated ? lastUpdatedTimeAgo : lastPublishedTimeAgo}`
: `Last published ${lastPublishedTime}`
: `Last published ${lastPublishedTimeAgo}`
}`}
placement="top-start"
>
Expand Down

0 comments on commit 81faebe

Please sign in to comment.