Skip to content
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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

heypoom
Copy link
Contributor

@heypoom heypoom commented Nov 1, 2024

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

  • Sidebar navigation copy
  • Remove the divider from sidebar
  • Add "New custom exploration" and "New dashboard" buttons
  • Small copy tweaks
  • Implement the "add a filter" and "change the summary" buttons by using modular InteractiveQuestion components
  • Re-implement the “create question from template” flow with InteractiveQuestion instead of ModifyQuestion

Copy link

vercel bot commented Nov 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
customer-zero ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 4, 2024 0:00am

@heypoom heypoom marked this pull request as ready for review November 1, 2024 17:32
@heypoom heypoom changed the title UX improvements for Shoppy (Part 1) Visual improvements for Shoppy (Part 1) Nov 1, 2024
@heypoom heypoom changed the title Visual improvements for Shoppy (Part 1) Design improvements for Shoppy (Part 1) Nov 1, 2024
Comment on lines +3 to +9
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>
Copy link
Contributor Author

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",
Copy link
Contributor Author

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
Copy link
Contributor Author

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} />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The form only allows creating new questions, and not "save as" as far as I am aware.

CleanShot 2567-11-02 at 00 38 29@2x

Copy link
Member

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.

Copy link
Contributor Author

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"
Copy link
Contributor Author

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.

Comment on lines +20 to +21
(view: QuestionView, nextView: QuestionView) =>
view !== "viz" && view === nextView ? "viz" : nextView,
Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

@heypoom heypoom Nov 5, 2024

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
Copy link
Contributor Author

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.

Copy link
Member

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">
Copy link
Contributor Author

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)
Copy link
Contributor Author

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()

@heypoom heypoom requested a review from a team November 4, 2024 12:01
Copy link
Member

@WiNloSt WiNloSt left a 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
Copy link
Member

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 />
Copy link
Member

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.

Comment on lines +20 to +21
(view: QuestionView, nextView: QuestionView) =>
view !== "viz" && view === nextView ? "viz" : nextView,
Copy link
Member

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} />
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Low-hanging fruit design improvements for Shoppy
2 participants