The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Restyle Sidesheet to Figma and add the offset variant (GDGT-2480) (#82747)
Stas Gavrylovcbc6c3a858e0
diff --git a/.loki/reference/chrome_laptop_Components_Sidesheet_Default.png b/.loki/reference/chrome_laptop_Components_Sidesheet_Default.pngnew file mode 100644index 00000000000..9171326601bBinary files /dev/null and b/.loki/reference/chrome_laptop_Components_Sidesheet_Default.png differdiff --git a/.loki/reference/chrome_laptop_Components_Sidesheet_Offset.png b/.loki/reference/chrome_laptop_Components_Sidesheet_Offset.pngnew file mode 100644index 00000000000..1e9e7db68cdBinary files /dev/null and b/.loki/reference/chrome_laptop_Components_Sidesheet_Offset.png differdiff --git a/frontend/src/metabase/common/components/Sidesheet/Sidesheet.mdx b/frontend/src/metabase/common/components/Sidesheet/Sidesheet.mdxindex 715ae7bfd39..67ce8339bdd 100644--- a/frontend/src/metabase/common/components/Sidesheet/Sidesheet.mdx+++ b/frontend/src/metabase/common/components/Sidesheet/Sidesheet.mdx@@ -1,48 +1,41 @@-import { Canvas, Story, Meta } from "@storybook/blocks";-import { Box, Flex } from "metabase/ui";+import { Meta } from "@storybook/blocks";import * as SidesheetStories from "./Sidesheet.stories";-import { Sidesheet } from "./Sidesheet";-import { SidesheetCard } from "./SidesheetCard";-import { SidesheetCardSection } from "./SidesheetCardSection";-import { SidesheetButton, SidesheetButtonWithChevron } from "./SidesheetButton";--import { TestTabbedSidesheet, TestPagedSidesheet } from "./Sidesheet.samples";-<Meta of={SidesheetStories} /># Sidesheet-## When to use a Sidesheet--## Docs--## Caveats--## Usage guidelines--## Examples--// TODO: figure out how to get CSS modules working with storybook 🔥+A Sidesheet keeps details and settings close to the item you're viewing. It+opens from the right side of the screen, so you can stay in context as you work.-<Canvas of={SidesheetStories.Default} />+Explore the individual stories in the sidebar to see each layout and theme.-### With cards+## Show details and settings in context-<Canvas of={SidesheetStories.WithCards} />+Use a Sidesheet for information about the current item, such as its description,+history, and relationships. It also works for settings you can change while+viewing the item.-### With sectioned cards+## Choose a width for the content-<Canvas of={SidesheetStories.WithSectionedCards} />+The default size is `sm` (30rem / 480px). Use `md` for wider content, such as+info panels with tabs. Other available sizes are `xs`, `lg`, `xl`, and `auto`.-### With pages+## Use the inset layout for a floating panel-<Canvas of={SidesheetStories.WithSubPages} />+Set `offset` to add 16px of space above, below, and to the right of the+Sidesheet, with rounded corners. The inset uses the `lg` spacing token.-### With tabs+## Organize content with cards, pages, and tabs-<Canvas of={SidesheetStories.WithTabs} />+- Use `SidesheetCard` to group related information and `SidesheetCardSection` to+ divide a card into sections. Card borders separate them from the Sidesheet+ surface.+- Use `SidesheetSubPage` for a second level of settings with back navigation.+- Use `SidesheetTabPanelContainer` with `removeBodyPadding` to scroll tab+ content while keeping the tabs visible.-### Sidesheet Buttons+## Keep Escape focused on the topmost dialog-<Canvas of={SidesheetStories.SidesheetButtons} />+Set `closeOnEscape={false}` on the Sidesheet while a dialog is open above it. One+press of Escape then closes the topmost dialog.diff --git a/frontend/src/metabase/common/components/Sidesheet/Sidesheet.samples.tsx b/frontend/src/metabase/common/components/Sidesheet/Sidesheet.samples.tsxindex 259c02d989a..0bd97fe9629 100644--- a/frontend/src/metabase/common/components/Sidesheet/Sidesheet.samples.tsx+++ b/frontend/src/metabase/common/components/Sidesheet/Sidesheet.samples.tsx@@ -2,7 +2,11 @@import { useState } from "react";import { useMount } from "react-use";-import { Sidesheet, SidesheetCard } from "metabase/common/components/Sidesheet";+import {+ SIDESHEET_HORIZONTAL_PADDING,+ Sidesheet,+ SidesheetCard,+} from "metabase/common/components/Sidesheet";import { SidesheetCardSection } from "metabase/common/components/Sidesheet/SidesheetCardSection";import SideSheetStyles from "metabase/common/components/Sidesheet/sidesheet.module.css";import { Flex, Icon, Stack, Switch, Tabs } from "metabase/ui";@@ -22,7 +26,7 @@ export const TestTabbedSidesheet = () => {removeBodyPadding><Tabs defaultValue="two" className={SideSheetStyles.FlexScrollContainer}>- <Tabs.List mx="xl">+ <Tabs.List mx={SIDESHEET_HORIZONTAL_PADDING}><Tabs.Tab value="one">One</Tabs.Tab><Tabs.Tab value="two">Two</Tabs.Tab><Tabs.Tab value="three">Three</Tabs.Tab>diff --git a/frontend/src/metabase/common/components/Sidesheet/Sidesheet.stories.tsx b/frontend/src/metabase/common/components/Sidesheet/Sidesheet.stories.tsxindex 84dc31f1b3c..57fec416e5b 100644--- a/frontend/src/metabase/common/components/Sidesheet/Sidesheet.stories.tsx+++ b/frontend/src/metabase/common/components/Sidesheet/Sidesheet.stories.tsx@@ -9,7 +9,6 @@ import { SidesheetCard } from "./SidesheetCard";import { SidesheetCardSection } from "./SidesheetCardSection";const args = {- size: "md",title: "My Awesome Sidesheet",onClose: () => {},isOpen: true,@@ -26,10 +25,20 @@ const argTypes = {isOpen: {control: { type: "boolean" },},+ offset: {+ control: { type: "boolean" },+ },};type SidesheetProps = ComponentProps<typeof Sidesheet>;+// Wait for the portaled panel, then capture the full viewport and overlay.+const sidesheetLokiParameters = {+ loki: {+ chromeSelector: 'body:has([data-testid="sidesheet"]:not([data-hidden]))',+ },+};+const DefaultTemplate = (args: SidesheetProps) => (<Sidesheet {...args}>Call me Ishmael ...</Sidesheet>);@@ -91,6 +100,15 @@ export default {export const Default = {render: DefaultTemplate,+ parameters: sidesheetLokiParameters,+};++export const Offset = {+ render: DefaultTemplate,+ args: {+ offset: true,+ },+ parameters: sidesheetLokiParameters,};export const WithCards = {diff --git a/frontend/src/metabase/common/components/Sidesheet/Sidesheet.tsx b/frontend/src/metabase/common/components/Sidesheet/Sidesheet.tsxindex 8ef96c74852..89ff073e8c3 100644--- a/frontend/src/metabase/common/components/Sidesheet/Sidesheet.tsx+++ b/frontend/src/metabase/common/components/Sidesheet/Sidesheet.tsx@@ -11,6 +11,8 @@ import Styles from "./sidesheet.module.css";export type SidesheetSize = "xs" | "sm" | "md" | "lg" | "xl" | "auto";+export const SIDESHEET_HORIZONTAL_PADDING = "xl";+interface SidesheetProps {title?: React.ReactNode;isOpen: boolean;@@ -22,6 +24,7 @@ interface SidesheetProps {withOverlay?: boolean;overlayProps?: ModalOverlayProps;closeOnEscape?: boolean;+ offset?: boolean;}const sizes: Record<SidesheetSize, string> = {@@ -43,6 +46,7 @@ export function Sidesheet({withOverlay = true,overlayProps,closeOnEscape = true,+ offset,}: SidesheetProps) {const titleId = useMemo(() => uniqueId("sidesheet-title"), []);return (@@ -51,6 +55,7 @@ export function Sidesheet({opened={isOpen}onClose={onClose}closeOnEscape={closeOnEscape}+ shadow="xs_outline"h="100dvh">{withOverlay && (@@ -60,20 +65,36 @@ export function Sidesheet({transitionProps={{ duration: 0 }}px={0}w={sizes[size]}- bg="background_page-secondary"+ pos="fixed"+ bd={0}+ display="flex"+ flex={1}+ bg="background_surface-primary"data-testid="sidesheet"+ data-offset={offset || undefined}classNames={{content: cx(Styles.SidesheetContent, Animation.slideLeft),}}aria-labelledby={titleId}>- <Modal.Header bg="background_page-secondary" px="xxl">+ <Modal.Header+ bg="background_surface-primary"+ px={SIDESHEET_HORIZONTAL_PADDING}+ pt="xl"+ pb="lg"+ >{title && (- <Modal.Title py="lg" pr="sm" id={titleId}>+ <Modal.Title pr="sm" id={titleId} fz="h4" lh="h4">{title}</Modal.Title>)}- <Modal.CloseButton aria-label={t`Close`} />+ <Modal.CloseButton+ aria-label={t`Close`}+ w="2rem"+ h="2rem"+ bdrs="xs"+ className={Styles.SidesheetCloseButton}+ /></Modal.Header><Modal.Bodyp={0}@@ -86,8 +107,8 @@ export function Sidesheet({><Stackgap="xl"- px={removeBodyPadding ? 0 : "xxl"}- pb={removeBodyPadding ? 0 : "xxl"}+ px={removeBodyPadding ? 0 : SIDESHEET_HORIZONTAL_PADDING}+ pb={removeBodyPadding ? 0 : "xl"}mt={title ? 0 : "lg"}h="100%"className={Styles.OverflowAuto}diff --git a/frontend/src/metabase/common/components/Sidesheet/SidesheetTabPanelContainer.tsx b/frontend/src/metabase/common/components/Sidesheet/SidesheetTabPanelContainer.tsxindex 79869d7981a..23346f5a96b 100644--- a/frontend/src/metabase/common/components/Sidesheet/SidesheetTabPanelContainer.tsx+++ b/frontend/src/metabase/common/components/Sidesheet/SidesheetTabPanelContainer.tsx@@ -2,6 +2,7 @@ import type React from "react";import { Box, type MantineStyleProps } from "metabase/ui";+import { SIDESHEET_HORIZONTAL_PADDING } from "./Sidesheet";import Styles from "./sidesheet.module.css";/** pass the removeBodyPadding prop to the Sidesheet component and wrap@@ -10,7 +11,12 @@ import Styles from "./sidesheet.module.css";export const SidesheetTabPanelContainer = (props: MantineStyleProps & { children: React.ReactNode },) => (- <Box className={Styles.OverflowAuto} px="xxl" py="xl" {...props}>+ <Box+ className={Styles.OverflowAuto}+ px={SIDESHEET_HORIZONTAL_PADDING}+ py="xl"+ {...props}+ ><div>{props.children}</div></Box>);diff --git a/frontend/src/metabase/common/components/Sidesheet/sidesheet.module.css b/frontend/src/metabase/common/components/Sidesheet/sidesheet.module.cssindex e28abf5015b..16ed14844ec 100644--- a/frontend/src/metabase/common/components/Sidesheet/sidesheet.module.css+++ b/frontend/src/metabase/common/components/Sidesheet/sidesheet.module.css@@ -1,13 +1,39 @@.SidesheetContent {+ inset-block: 0;+ inset-inline-end: 0;+ flex-direction: column;++ /* Mantine's content height rules must lose regardless of stylesheet order. */&:not([data-css-specificity-hack="🤷♀️"]) {- position: fixed;height: 100dvh;max-height: 100dvh;- inset-inline-end: 0;border-radius: 0;- display: flex;- flex: 1;- flex-direction: column;++ &[data-offset] {+ height: calc(+ 100dvh - var(--mantine-spacing-lg) - var(--mantine-spacing-lg)+ );+ max-height: calc(+ 100dvh - var(--mantine-spacing-lg) - var(--mantine-spacing-lg)+ );+ inset-block: var(--mantine-spacing-lg);+ inset-inline-end: var(--mantine-spacing-lg);+ border-radius: var(--mantine-radius-lg);+ }+ }+}++.SidesheetCloseButton {+ /* Modal.module.css uses !important for the close color and icon size. */+ color: var(--mb-color-text-primary) !important;++ &:hover {+ color: var(--mb-color-text-primary) !important;+ }++ svg {+ width: rem(16px) !important;+ height: rem(16px) !important;}}diff --git a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardInfoSidebar.tsx b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardInfoSidebar.tsxindex 5768a6a75e3..6a5fdb1373e 100644--- a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardInfoSidebar.tsx+++ b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardInfoSidebar.tsx@@ -10,6 +10,7 @@ import ErrorBoundary from "metabase/common/components/ErrorBoundary";import { RevisionHistoryTimeline } from "metabase/common/components/RevisionHistoryTimeline";import { getTimelineEvents } from "metabase/common/components/RevisionHistoryTimeline/utils";import {+ SIDESHEET_HORIZONTAL_PADDING,Sidesheet,SidesheetCard,SidesheetTabPanelContainer,@@ -142,7 +143,7 @@ export function DashboardInfoSidebarInner({defaultValue={Tab.Overview}className={SidesheetS.FlexScrollContainer}>- <Tabs.List mx="xxl">+ <Tabs.List mx={SIDESHEET_HORIZONTAL_PADDING}><Tabs.Tab value={Tab.Overview}>{t`Overview`}</Tabs.Tab>{!isIADashboard && (<Tabs.Tab value={Tab.History}>{t`History`}</Tabs.Tab>diff --git a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/QuestionInfoSidebar.tsx b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/QuestionInfoSidebar.tsxindex ddfabf80c1f..95b94388000 100644--- a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/QuestionInfoSidebar.tsx+++ b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/QuestionInfoSidebar.tsx@@ -7,6 +7,7 @@ import { isInstanceAnalyticsCollection } from "metabase/common/collections/utilsimport { EntityIdCard } from "metabase/common/components/EntityIdCard";import { Link } from "metabase/common/components/Link";import {+ SIDESHEET_HORIZONTAL_PADDING,Sidesheet,SidesheetCard,SidesheetCardTitle,@@ -79,7 +80,7 @@ export const QuestionInfoSidebar = ({defaultValue="overview"className={SidesheetStyles.FlexScrollContainer}>- <Tabs.List mx="xxl">+ <Tabs.List mx={SIDESHEET_HORIZONTAL_PADDING}><Tabs.Tab value="overview">{t`Overview`}</Tabs.Tab>{!isIAQuestion && <Tabs.Tab value="history">{t`History`}</Tabs.Tab>}<Tabs.Tab value="relationships">{t`Relationships`}</Tabs.Tab>diff --git a/loki.config.js b/loki.config.jsindex e3d924b7481..8da1e3987d7 100644--- a/loki.config.js+++ b/loki.config.js@@ -11,6 +11,7 @@ module.exports = {"^Components/Overlays/Menu Hover state","^Components/Overlays/Popover (Opened|Overview)","^Components/Overlays/Modal Opened",+ "^Components/Sidesheet (Default|Offset)$","^Components/Overlays/HoverCard Opened","^Components/Utils/Paper Shadow matrix","^Components/Data display/Card Shadow matrix",