-
Notifications
You must be signed in to change notification settings - Fork 1
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
Design improvements for Shoppy (Part 1) #80
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
const icons = { | ||
filter: | ||
"M1 4.5c0-.69.56-1.25 1.25-1.25h11.5a1.25 1.25 0 1 1 0 2.5H2.25C1.56 5.75 1 5.19 1 4.5zM4 9a1 1 0 0 1 1-1h6a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1zm2 4.25a1 1 0 0 1 1-1h2a1 1 0 1 1 0 2H7a1 1 0 0 1-1-1z", | ||
sum: "M2.295 2.745A.75.75 0 0 1 3 2.25h9a.75.75 0 1 1 0 1.5H5.072l3.486 2.906c.84.7.84 1.989 0 2.688L5.072 12.25h6.763a.75.75 0 0 1 0 1.5H3a.75.75 0 0 1-.48-1.326l5.078-4.232a.25.25 0 0 0 0-.384L2.52 3.576a.75.75 0 0 1-.225-.831z", | ||
notebook: | ||
"M3.5 3a.5.5 0 0 1 .5.5V5a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5V3.5A.5.5 0 0 1 2 3h1.5zM11.5 3.5A.5.5 0 0 0 11 3H6a.5.5 0 0 0-.5.5V5a.5.5 0 0 0 .5.5h5a.5.5 0 0 0 .5-.5V3.5zM14.5 7.25a.5.5 0 0 0-.5-.5H6a.5.5 0 0 0-.5.5v1.5a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-1.5zM4 7.25a.5.5 0 0 0-.5-.5H2a.5.5 0 0 0-.5.5v1.5a.5.5 0 0 0 .5.5h1.5a.5.5 0 0 0 .5-.5v-1.5zM3.5 10.5a.5.5 0 0 1 .5.5v1.5a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5V11a.5.5 0 0 1 .5-.5h1.5zM10 11a.5.5 0 0 0-.5-.5H6a.5.5 0 0 0-.5.5v1.5a.5.5 0 0 0 .5.5h3.5a.5.5 0 0 0 .5-.5V11z", | ||
} as const satisfies Record<string, string> |
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.
The icons used in Maz's design are Metabase icons, so we add the icon paths here.
@@ -7,7 +7,7 @@ | |||
"@mantine/core": "^7.8.0", | |||
"@mantine/form": "^7.8.0", | |||
"@mantine/hooks": "^7.8.0", | |||
"@metabase/embedding-sdk-react": "^0.1.37", | |||
"@metabase/embedding-sdk-react": "^1.51.2", |
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.
Targets the 51-stable
version.
type QuestionView = "viz" | "filter" | "summary" | "editor" | ||
|
||
interface Props { | ||
isSaveEnabled?: boolean |
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.
Currently the save question button is only enabled in the "New Question from Template" flow.
withCloseButton={false} | ||
> | ||
<Box bg="background"> | ||
<InteractiveQuestion.SaveQuestionForm onClose={closeSaveModal} /> |
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.
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.
Is there a way to automatically close the modal once the question is saved? mine showed success
then changed to save
again after a while, but the modal remains which is not expected.
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.
@WiNloSt This smells like a bug on the SDK - the InteractiveQuestion.SaveQuestionForm
component only exposes a single onClose
prop, so if the modal does not close after success we need to fix it. Let me re-test it.
...props | ||
}: CustomIconProps) => ( | ||
<svg | ||
viewBox="0 0 16 16" |
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.
So far our icons here only uses the 16x16
viewBox.
(view: QuestionView, nextView: QuestionView) => | ||
view !== "viz" && view === nextView ? "viz" : nextView, |
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.
This allows us to click on the same view's button again and go back to the visualization view.
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.
inlining this logic makes it a little hard to understand. What this does is essentially changing the view to viz
if we're clicking the same button as the current view. Otherwise, change to whatever the nextViz is.
I'd like to see this being structured with some if blocks, that might make this more readable.
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.
@WiNloSt Good idea! I initially has this explicitly written with if-blocks, but later collapsed to this. I'll revert this then, as the former version is indeed more readable.
} | ||
|
||
export const InteractiveQuestionView = (props: Props) => { | ||
const { isSaveEnabled = false } = props |
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.
We only enable the "Save" button in the "new question from template" page for now.
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.
why do you destructure props on some components but not all? I can understand in case you need to access the whole props
for spreading for example. But I don't see the reason to do that here. I found using props
needs a bit more work to figure out where the all the props are used.
</Flex> | ||
|
||
{view === "viz" && ( | ||
<Box h="500px"> |
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.
We use a fixed height for now, as the SDK does not provide a sensible default height in QuestionVisualization
yet. We can remove this from Shoppy once the SDK implements a sane default height in QuestionVisualization
.
@@ -13,3 +14,5 @@ export const siteAtom = atomWithStorage<SiteKey>( | |||
getOnInit: true, | |||
}, | |||
) | |||
|
|||
export const siteIsReloadingAtom = atom(false) |
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.
We need to fully reload the page in some cases - do a full page search on useReloadOnSiteChange
to see where that applies. This helps us to show the full-page loading indicator while the page is being reloaded by window.location.reload()
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.
Tested and all looks good 👍
} | ||
|
||
export const InteractiveQuestionView = (props: Props) => { | ||
const { isSaveEnabled = false } = props |
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.
why do you destructure props on some components but not all? I can understand in case you need to access the whole props
for spreading for example. But I don't see the reason to do that here. I found using props
needs a bit more work to figure out where the all the props are used.
rowGap="sm" | ||
> | ||
<Group gap="xs"> | ||
<InteractiveQuestion.BackButton /> |
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.
How do you get this button to render? I don't couldn't figure out how.
(view: QuestionView, nextView: QuestionView) => | ||
view !== "viz" && view === nextView ? "viz" : nextView, |
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.
inlining this logic makes it a little hard to understand. What this does is essentially changing the view to viz
if we're clicking the same button as the current view. Otherwise, change to whatever the nextViz is.
I'd like to see this being structured with some if blocks, that might make this more readable.
withCloseButton={false} | ||
> | ||
<Box bg="background"> | ||
<InteractiveQuestion.SaveQuestionForm onClose={closeSaveModal} /> |
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.
Is there a way to automatically close the modal once the question is saved? mine showed success
then changed to save
again after a while, but the modal remains which is not expected.
Closes #79
This PR makes design improvements to Shoppy. Refer to the product docs for the full list of changes to Shoppy - this PR acts on a subset of them, as other changes will require changes to the SDK itself. I have commented in the product doc on which change requires further improvements.
PS. the diffs is a bit misleading, the
yarn.lock
changes make it looks big but it's actually not a lot of diffs.Loom
Private Loom
Checklist
InteractiveQuestion
components