-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sanity): update restore button (#7448)
* feat(sanity): update restore button * chore(sanity): update translations * feat(sanity): add left side information on footer (revision status line)
- Loading branch information
1 parent
3d16064
commit a4c1200
Showing
5 changed files
with
98 additions
and
33 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
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
56 changes: 56 additions & 0 deletions
56
packages/sanity/src/structure/panes/document/statusBar/RevisionStatusLine.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,56 @@ | ||
import {RestoreIcon} from '@sanity/icons' | ||
import {Box, Flex, Text} from '@sanity/ui' | ||
import {format} from 'date-fns' | ||
import {createElement} from 'react' | ||
import {Translate, useTranslation} from 'sanity' | ||
import {styled} from 'styled-components' | ||
|
||
import {useDocumentPane} from '../useDocumentPane' | ||
|
||
export const StatusText = styled(Text)` | ||
color: var(--card-muted-fg-color); | ||
em { | ||
color: var(--card-fg-color); | ||
font-weight: 500; | ||
font-style: normal; | ||
} | ||
` | ||
|
||
export function RevisionStatusLine(): JSX.Element { | ||
const {displayed} = useDocumentPane() | ||
const {t} = useTranslation() | ||
|
||
const message = { | ||
name: 'revision', | ||
icon: RestoreIcon, | ||
text: ( | ||
<Translate | ||
t={t} | ||
i18nKey="document-status.revision-from" | ||
values={{ | ||
date: format( | ||
new Date(displayed?._updatedAt || displayed?._createdAt || 0), | ||
`MMM d, yyyy '@' pp`, | ||
), | ||
}} | ||
/> | ||
), | ||
tone: 'caution', | ||
} | ||
|
||
return ( | ||
<> | ||
<Flex flex={1} gap={3} padding={2}> | ||
<Box flex="none"> | ||
<Text size={1}>{createElement(message.icon)}</Text> | ||
</Box> | ||
<Box flex={1}> | ||
<StatusText size={1} textOverflow="ellipsis"> | ||
{message.text} | ||
</StatusText> | ||
</Box> | ||
</Flex> | ||
</> | ||
) | ||
} |