-
Notifications
You must be signed in to change notification settings - Fork 75
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
UX improvements to the Cloud Image ComponentBlock #554
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
packages/keystatic/src/component-blocks/cloud-image-preview.tsx
Outdated
Show resolved
Hide resolved
packages/keystatic/src/component-blocks/cloud-image-preview.tsx
Outdated
Show resolved
Hide resolved
packages/keystatic/src/component-blocks/cloud-image-preview.tsx
Outdated
Show resolved
Hide resolved
packages/keystatic/src/component-blocks/cloud-image-preview.tsx
Outdated
Show resolved
Hide resolved
packages/keystatic/src/component-blocks/cloud-image-preview.tsx
Outdated
Show resolved
Hide resolved
packages/keystatic/src/component-blocks/cloud-image-preview.tsx
Outdated
Show resolved
Hide resolved
Update After a design session today, I've updated this with new and simpler/nicer UX. Now when you insert a Cloud Image component into a document, you get this placeholder: (@jossmac this isn't an ideal design, but I could get the DialogTrigger to work with anything other than a (also @emmatown may come up with a way to open this dialog from the start, before the placeholder is inserted, but that's basically a progressive enhancement since we'll still need to handle empty Markdoc tags) When you click it, you get this dialog: Pasting a valid Image URL reveals the rest of the form and auto-fills the width and height: And finally you get the image preview, you can use the edit button on the right to change the alt/width/height (or replace the image) and the delete button to remove it from the document: This is probably pretty close to ready from a UX perspective, we can tweak the workflow a bit more when we figure out how to really dial it in, but it's working pretty well for now. One thing it doesn't handle yet is if you have an invalid image URL in the document already (e.g if an image is deleted, or if you commit an invalid src directly into the codebase) but I think it's OK to handle that later. |
packages/keystatic/src/component-blocks/cloud-image-preview.tsx
Outdated
Show resolved
Hide resolved
return ( | ||
<NotEditable> | ||
<Flex gap="regular"> | ||
<Box flex="1"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is unnecessary, you should be able to move the flex prop to the Button
e.g.
<Flex>
<DialogTrigger>
<Button flex />
</DialogTrigger>
</Flex>
</Box> | ||
<Box> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do these do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boxes (block) around the Text (inline) components so they get spaced out correctly by the VStack
packages/keystatic/src/component-blocks/cloud-image-preview.tsx
Outdated
Show resolved
Hide resolved
This is by design, to stop people doing dodgy stuff. |
This improves the workflow and UX for the
cloudImage
component block, but needs some design love before it's ready to merge.When you first insert the component block, it now prompts you to focus the field and paste image data (can be a URL, JSON, or Markdown, it just has to have a valid image src in it)
Once you paste an image in, it will validate the image and detect the width and height, then switch to the current UI:
Depending on browser capabilities, sometimes we can trigger a paste event on click, otherwise there's an invisible text field that receives focus as a fallback. Might need some tweaking as we try different browsers... I've tested it on iOS, but need someone to check that the UX flow is good on Android as well. Firefox and Safari on MacOS are good.