-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(form): check for invalid image value, provide reset option
- Loading branch information
Showing
3 changed files
with
92 additions
and
39 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
36 changes: 36 additions & 0 deletions
36
packages/sanity/src/form/inputs/files/ImageInput/InvalidImageWarning.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,36 @@ | ||
import {ResetIcon, WarningOutlineIcon} from '@sanity/icons' | ||
import {Card, Flex, Box, Text, Stack, Button} from '@sanity/ui' | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
|
||
type Props = { | ||
onClearValue?: () => void | ||
} | ||
|
||
const ButtonWrapper = styled(Button)` | ||
width: 100%; | ||
` | ||
|
||
export function InvalidImageWarning({onClearValue}: Props) { | ||
return ( | ||
<Card tone="caution" padding={4} border radius={2}> | ||
<Flex gap={4} marginBottom={4}> | ||
<Box> | ||
<Text size={1}> | ||
<WarningOutlineIcon /> | ||
</Text> | ||
</Box> | ||
<Stack space={3}> | ||
<Text size={1} weight="semibold"> | ||
Invalid image value | ||
</Text> | ||
<Text size={1}> | ||
The value of this field is not a valid image. Resetting this field will let you choose a | ||
new image. | ||
</Text> | ||
</Stack> | ||
</Flex> | ||
<ButtonWrapper icon={ResetIcon} text="Reset value" onClick={onClearValue} mode="ghost" /> | ||
</Card> | ||
) | ||
} |
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