Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Migrate the static embed modal and embed frame off Emotion (#83916)

Andrei Chernykh67fa4b925c75
diff --git a/frontend/src/metabase/embedding/components/EmbedFooter.styled.tsx b/frontend/src/metabase/embedding/components/EmbedFooter.styled.tsx
deleted file mode 100644
index 917ee8e8aed..00000000000
--- a/frontend/src/metabase/embedding/components/EmbedFooter.styled.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-// eslint-disable-next-line eslint-js/no-restricted-imports
-import { css } from "@emotion/react";
-// eslint-disable-next-line eslint-js/no-restricted-imports
-import styled from "@emotion/styled";
-
-import {
- breakpointMinLarge,
- breakpointMinSmall,
-} from "metabase/styled-components/theme";
-
-export const ActionButtonsContainer = styled.div`
- color: var(--mb-color-text-secondary);
- margin-left: auto;
-`;
-
-export type FooterVariant = "default" | "large";
-
-const footerVariantStyles = {
- default: css`
- border-top: 1px solid var(--mb-color-border-neutral);
- `,
- large: css`
- justify-content: center;
- align-items: center;
- margin-bottom: 2rem;
-
- ${ActionButtonsContainer} {
- display: none;
- }
- `,
-};
-
-export const Footer = styled.footer<{ variant: FooterVariant }>`
- display: flex;
- flex-shrink: 0;
- align-items: center;
- ${(props) => footerVariantStyles[props.variant]}
- height: calc(50 / 16 * 1rem);
- padding: 0 1em;
-
- ${breakpointMinSmall} {
- height: calc(65 / 16 * 1rem);
- padding: 0 1.5rem;
- }
-
- ${breakpointMinLarge} {
- height: calc(80 / 16 * 1rem);
- padding: 0 2rem;
- }
-`;
diff --git a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/CodeSample.styled.tsx b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/CodeSample.styled.tsx
deleted file mode 100644
index c1ca8ebd06f..00000000000
--- a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/CodeSample.styled.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-// eslint-disable-next-line eslint-js/no-restricted-imports
-import styled from "@emotion/styled";
-
-export const CopyButtonContainer = styled.div`
- position: absolute;
- top: 0;
- right: 0;
- cursor: pointer;
- z-index: 2;
-
- &:hover {
- color: var(--mb-color-core-brand);
- }
-`;
diff --git a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/CodeSample.tsx b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/CodeSample.tsx
index c2085d3eb19..a88e05275a3 100644
--- a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/CodeSample.tsx
+++ b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/CodeSample.tsx
@@ -7,8 +7,8 @@ import { CopyButton } from "metabase/common/components/CopyButton";
import CS from "metabase/css/core/index.css";
import { EmbedServerSnippetLanguageSelect } from "metabase/embedding/components/EmbedServerSnippetLanguageSelect/EmbedServerSnippetLanguageSelect";
import type { CodeSampleOption } from "metabase/embedding/types";
+import { Box } from "metabase/ui";
-import { CopyButtonContainer } from "./CodeSample.styled";
import { getHighlightedRanges } from "./utils";
interface CodeSampleProps {
@@ -74,9 +74,14 @@ export const CodeSample = ({
value={source}
/>
{source && (
- <CopyButtonContainer>
+ <Box
+ className={cx(CS.z2, CS.cursorPointer, CS.textBrandHover)}
+ pos="absolute"
+ top={0}
+ right={0}
+ >
<CopyButton className={CS.p1} value={source} onCopy={onCopy} />
- </CopyButtonContainer>
+ </Box>
)}
</div>
</div>
diff --git a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/DisplayOptionSection.tsx b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/DisplayOptionSection.tsx
new file mode 100644
index 00000000000..5209a0e7817
--- /dev/null
+++ b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/DisplayOptionSection.tsx
@@ -0,0 +1,20 @@
+import type { ReactNode } from "react";
+
+import { Text } from "metabase/ui";
+
+interface DisplayOptionSectionProps {
+ title: string;
+ children: ReactNode;
+}
+
+export const DisplayOptionSection = ({
+ title,
+ children,
+}: DisplayOptionSectionProps) => (
+ <div>
+ <Text fw="bold" mb="xxs" lh="1rem">
+ {title}
+ </Text>
+ {children}
+ </div>
+);
diff --git a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/DownloadSettings.tsx b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/DownloadSettings.tsx
index 1fc157c84b1..8edaabf65e7 100644
--- a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/DownloadSettings.tsx
+++ b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/DownloadSettings.tsx
@@ -3,7 +3,7 @@ import { t } from "ttag";
import type { EmbeddingDisplayOptions } from "metabase/embedding/types";
import { Stack, Switch } from "metabase/ui";
-import { DisplayOptionSection } from "./StaticEmbedSetupPane.styled";
+import { DisplayOptionSection } from "./DisplayOptionSection";
interface DownloadSettingsProps {
displayOptions: EmbeddingDisplayOptions;
diff --git a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/LookAndFeelSettings.tsx b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/LookAndFeelSettings.tsx
index c2be07913e6..03c5ac0d0fd 100644
--- a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/LookAndFeelSettings.tsx
+++ b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/LookAndFeelSettings.tsx
@@ -16,36 +16,34 @@ import { getSetting } from "metabase/settings";
import {
Divider,
SegmentedControl,
+ type SegmentedControlItem,
Select,
Stack,
Switch,
Text,
} from "metabase/ui";
+import { DisplayOptionSection } from "./DisplayOptionSection";
import {
DashboardDownloadSettings,
QuestionDownloadSettings,
} from "./DownloadSettings";
-import { DisplayOptionSection } from "./StaticEmbedSetupPane.styled";
import { StaticEmbedSetupPaneSettingsContentSection } from "./StaticEmbedSetupPaneSettingsContentSection";
-const THEME_OPTIONS = [
+const THEME_OPTIONS: readonly SegmentedControlItem<DisplayTheme>[] = [
{
get label() {
return t`Light`;
},
- // Unjustified type cast. FIXME
- value: "light" as DisplayTheme,
+ value: "light",
},
{
get label() {
return t`Dark`;
},
- // Unjustified type cast. FIXME
- value: "night" as DisplayTheme,
+ value: "night",
},
-] as const;
-type ThemeOptions = (typeof THEME_OPTIONS)[number]["value"];
+];
interface AppearanceSettingsProps {
resourceType: EmbedResourceType;
@@ -130,9 +128,9 @@ export const LookAndFeelSettings = ({
<DisplayOptionSection title={t`Theme`}>
<SegmentedControl
value={displayOptions.theme ?? undefined}
- data={[...THEME_OPTIONS]}
+ data={THEME_OPTIONS}
fullWidth
- onChange={(value: ThemeOptions) => {
+ onChange={(value) => {
onChangeDisplayOptions({
...displayOptions,
theme: value,
diff --git a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/OverviewSettings.tsx b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/OverviewSettings.tsx
index 895be85f9ce..8c84ade7c45 100644
--- a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/OverviewSettings.tsx
+++ b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/OverviewSettings.tsx
@@ -15,7 +15,7 @@ import type {
import { Stack, Text } from "metabase/ui";
import { ClientEmbedCodePane } from "./ClientEmbedCodePane";
-import { SettingsTabLayout } from "./StaticEmbedSetupPane.styled";
+import { SettingsTabLayout } from "./SettingsTabLayout";
import { StaticEmbedSetupPaneSettingsContentSection } from "./StaticEmbedSetupPaneSettingsContentSection";
export interface OverviewSettingsProps {
@@ -66,20 +66,18 @@ export const OverviewSettings = ({
<StaticEmbedSetupPaneSettingsContentSection
title={t`Setting up a static embed`}
>
- <Text>{t`To embed this ${resourceType} in your application you’ll just need to publish it, and paste these code snippets in the proper places in your app.`}</Text>
- <br />
- {resourceType === "dashboard" && (
- <>
+ <Stack gap="lg">
+ <Text>{t`To embed this ${resourceType} in your application you’ll just need to publish it, and paste these code snippets in the proper places in your app.`}</Text>
+ {resourceType === "dashboard" && (
<Text>{t`You can also hide or lock any of the dashboard’s parameters.`}</Text>
- <br />
- </>
- )}
- <Text>{jt`Check out the ${(
- <ExternalLink
- key="doc"
- href={docsUrl}
- >{t`documentation`}</ExternalLink>
- )} for more.`}</Text>
+ )}
+ <Text>{jt`Check out the ${(
+ <ExternalLink
+ key="doc"
+ href={docsUrl}
+ >{t`documentation`}</ExternalLink>
+ )} for more.`}</Text>
+ </Stack>
</StaticEmbedSetupPaneSettingsContentSection>
}
previewSlot={
diff --git a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/SettingsTabLayout.module.css b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/SettingsTabLayout.module.css
new file mode 100644
index 00000000000..b96c9d8f46c
--- /dev/null
+++ b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/SettingsTabLayout.module.css
@@ -0,0 +1,3 @@
+.borderRight {
+ border-right: 1px solid var(--mb-color-border-neutral);
+}
diff --git a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/SettingsTabLayout.tsx b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/SettingsTabLayout.tsx
new file mode 100644
index 00000000000..ee742cc3a29
--- /dev/null
+++ b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/SettingsTabLayout.tsx
@@ -0,0 +1,46 @@
+import cx from "classnames";
+import type { ReactNode } from "react";
+
+import CS from "metabase/css/core/index.css";
+import { Box, Flex, Stack } from "metabase/ui";
+
+import S from "./SettingsTabLayout.module.css";
+
+interface SettingsTabLayoutProps {
+ settingsSlot: ReactNode;
+ previewSlot: ReactNode;
+}
+
+export const SettingsTabLayout = ({
+ settingsSlot,
+ previewSlot,
+}: SettingsTabLayoutProps): JSX.Element => {
+ return (
+ <Flex>
+ <Box
+ className={cx(S.borderRight, CS.overflowYAuto)}
+ flex="0 0 auto"
+ w="21.6rem"
+ h="45.125rem"
+ p="xxl"
+ bg="background_page-primary"
+ >
+ {settingsSlot}
+ </Box>
+ <Stack
+ w="100%"
+ miw="50rem"
+ pos="relative"
+ align="flex-start"
+ gap="lg"
+ pt="lg"
+ pr="xl"
+ pb="xxl"
+ pl="lg"
+ bg="background_page-secondary"
+ >
+ {previewSlot}
+ </Stack>
+ </Flex>
+ );
+};
diff --git a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/StaticEmbedSetupPane.styled.tsx b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/StaticEmbedSetupPane.styled.tsx
deleted file mode 100644
index 31090d91709..00000000000
--- a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/StaticEmbedSetupPane.styled.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-// eslint-disable-next-line eslint-js/no-restricted-imports
-import styled from "@emotion/styled";
-import type { ReactNode } from "react";
-
-import { Text } from "metabase/ui";
-
-const ContentWrapper = styled.div`
- width: 100%;
- display: flex;
- align-items: stretch;
- min-height: 648px;
-`;
-
-const SettingsAsideBlock = styled.div`
- flex-shrink: 0;
- width: 21.6rem;
- padding: 2rem;
- border-right: 1px solid var(--mb-color-border-neutral);
- background-color: var(--mb-color-background_page-primary);
- height: 45.125rem;
- overflow-y: auto;
-`;
-
-const PreviewAreaBlock = styled.div`
- width: 100%;
- min-width: 50rem;
- position: relative;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: stretch;
- gap: 1rem;
- padding: 1rem 1.5rem 2rem 1rem;
- background-color: var(--mb-color-background_page-secondary);
-`;
-
-export const SettingsTabLayout = ({
- settingsSlot,
- previewSlot,
-}: {
- settingsSlot: ReactNode;
- previewSlot: ReactNode;
-}): JSX.Element => {
- return (
- <ContentWrapper>
- <SettingsAsideBlock>{settingsSlot}</SettingsAsideBlock>
- <PreviewAreaBlock>{previewSlot}</PreviewAreaBlock>
- </ContentWrapper>
- );
-};
-
-export const DisplayOptionSection = ({
- title,
- titleId,
- children,
-}: {
- title: string;
- titleId?: string;
- children: ReactNode;
-}) => (
- <div>
- <Text fw="bold" mb="0.25rem" lh="1rem" id={titleId}>
- {title}
- </Text>
- {children}
- </div>
-);
diff --git a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/StaticEmbedSetupPane.tsx b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/StaticEmbedSetupPane.tsx
index 805587ed889..4b1a3096021 100644
--- a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/StaticEmbedSetupPane.tsx
+++ b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/StaticEmbedSetupPane.tsx
@@ -31,7 +31,7 @@ import { ParametersSettings } from "./ParametersSettings";
import { PreviewModeSelector } from "./PreviewModeSelector";
import { type PreviewBackgroundType, PreviewPane } from "./PreviewPane";
import { ServerEmbedCodePane } from "./ServerEmbedCodePane";
-import { SettingsTabLayout } from "./StaticEmbedSetupPane.styled";
+import { SettingsTabLayout } from "./SettingsTabLayout";
import { getDefaultDisplayOptions } from "./config";
import { getDefaultEmbeddingParams } from "./lib/get-default-embedding-params";
import { getHasParamsChanged } from "./lib/get-has-params-changed";
diff --git a/frontend/src/metabase/embedding/components/EmbeddingFooter/EmbeddingFooter.module.css b/frontend/src/metabase/embedding/components/EmbeddingFooter/EmbeddingFooter.module.css
index e8c591ce39b..bfe497bc7c1 100644
--- a/frontend/src/metabase/embedding/components/EmbeddingFooter/EmbeddingFooter.module.css
+++ b/frontend/src/metabase/embedding/components/EmbeddingFooter/EmbeddingFooter.module.css
@@ -1,5 +1,22 @@
+/* Same padding and breakpoints as FullWidthContainer, so the footer lines up with the content */
.EmbeddingFooter {
+ height: 3.125rem;
+ padding: 0 1em;
color: var(--mb-color-text-primary);
background-color: transparent;
transition: var(--transition-theme-change);
+
+ @media screen and (min-width: 40em) {
+ height: 4.0625rem;
+ padding: 0 1.5rem;
+ }
+
+ @media screen and (min-width: 80em) {
+ height: 5rem;
+ padding: 0 2rem;
+ }
+}
+
+.borderTop {
+ border-top: 1px solid var(--mb-color-border-neutral);
}
diff --git a/frontend/src/metabase/embedding/components/EmbeddingFooter/EmbeddingFooter.tsx b/frontend/src/metabase/embedding/components/EmbeddingFooter/EmbeddingFooter.tsx
index eca895b8b9f..e43491a8c5f 100644
--- a/frontend/src/metabase/embedding/components/EmbeddingFooter/EmbeddingFooter.tsx
+++ b/frontend/src/metabase/embedding/components/EmbeddingFooter/EmbeddingFooter.tsx
@@ -1,13 +1,13 @@
+import cx from "classnames";
import type { PropsWithChildren } from "react";
-import {
- Footer,
- type FooterVariant,
-} from "metabase/embedding/components/EmbedFooter.styled";
import { LogoBadge } from "metabase/embedding/components/LogoBadge";
+import { Flex } from "metabase/ui";
import EmbeddingFooterS from "./EmbeddingFooter.module.css";
+export type FooterVariant = "default" | "large";
+
type Props = {
hasEmbedBranding: boolean;
variant: FooterVariant;
@@ -21,14 +21,20 @@ export const EmbeddingFooter = ({
isDarkMode,
}: PropsWithChildren<Props>) => {
return (
- <Footer
+ <Flex
+ component="footer"
data-testid="embedding-footer"
- className={EmbeddingFooterS.EmbeddingFooter}
- variant={variant}
+ className={cx(EmbeddingFooterS.EmbeddingFooter, {
+ [EmbeddingFooterS.borderTop]: variant === "default",
+ })}
+ flex="0 0 auto"
+ align="center"
+ justify={variant === "large" ? "center" : undefined}
+ mb={variant === "large" ? "xxl" : undefined}
>
{hasEmbedBranding && <LogoBadge dark={!!isDarkMode} />}
{children}
- </Footer>
+ </Flex>
);
};
diff --git a/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.module.css b/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.module.css
index 13699c88371..1fd8e00c2a3 100644
--- a/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.module.css
+++ b/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.module.css
@@ -84,3 +84,37 @@ body:where(:global(.mb-wrapper)) {
has `z-index: 3`. */
z-index: 4;
}
+
+.overflowAuto {
+ overflow: auto;
+
+ /* Prevents https://github.com/metabase/metabase/issues/40660 when printing an embedded dashboard */
+ @media print {
+ &.printOverflowVisible {
+ overflow: visible;
+ }
+ }
+}
+
+.border {
+ border: 1px solid var(--mb-color-border-neutral);
+ border-radius: 0.5rem;
+ box-shadow: 0 2px 2px var(--mb-color-shadow-default);
+}
+
+.borderBottom {
+ border-bottom: 2px solid var(--mb-color-border-neutral);
+}
+
+/* Full-bleed tab row on small screens, with higher specificity than FullWidthContainer's padding */
+div.dashboardTabs {
+ @media screen and (max-width: 40em) {
+ padding-left: 0;
+ padding-right: 0;
+ }
+}
+
+/* Leaves room for the floating PDF button next to a scrolling tab row */
+.narrowTabs [role="tablist"]:global(.scrollable) {
+ width: calc(100% - 3.75rem);
+}
diff --git a/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.styled.tsx b/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.styled.tsx
deleted file mode 100644
index 6f58dd3b624..00000000000
--- a/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.styled.tsx
+++ /dev/null
@@ -1,119 +0,0 @@
-import isPropValid from "@emotion/is-prop-valid";
-// eslint-disable-next-line eslint-js/no-restricted-imports
-import { css } from "@emotion/react";
-// eslint-disable-next-line eslint-js/no-restricted-imports
-import styled from "@emotion/styled";
-
-import { FixedWidthContainer } from "metabase/dashboard/components/Dashboard/DashboardComponents";
-import { FullWidthContainer } from "metabase/styled-components/layout/FullWidthContainer";
-import {
- breakpointMaxSmall,
- breakpointMinLarge,
- breakpointMinSmall,
-} from "metabase/styled-components/theme";
-
-export const Root = styled.div<{
- hasScroll: boolean;
- hasVisibleOverflowWhenPriting?: boolean;
- isBordered?: boolean;
-}>`
- display: flex;
- flex-direction: column;
- overflow: auto;
-
- ${(props) =>
- props.hasScroll &&
- css`
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- `}
-
- ${(props) =>
- props.isBordered &&
- css`
- border: 1px solid var(--mb-color-border-neutral);
- border-radius: 8px;
- box-shadow: 0 2px 2px var(--mb-color-shadow-default);
- `}
-
- ${(props) =>
- // Prevents https://github.com/metabase/metabase/issues/40660
- // when printing an embedded dashboard
- props.hasVisibleOverflowWhenPriting &&
- css`
- @media print {
- overflow: visible;
- }
- `}
-`;
-
-export const ContentContainer = styled.div`
- display: flex;
- flex-direction: column;
- flex: 1 0 auto;
- position: relative;
-`;
-
-export const Header = styled.header`
- display: flex;
- flex-direction: column;
-`;
-
-export const TitleAndDescriptionContainer = styled(FullWidthContainer, {
- shouldForwardProp: (prop) => prop !== "hasTitle",
-})<{ hasTitle?: boolean }>`
- margin-top: 0.5rem;
-
- ${({ hasTitle }) =>
- hasTitle &&
- css`
- ${breakpointMinSmall} {
- margin-top: 1rem;
- }
-
- ${breakpointMinLarge} {
- margin-top: 1.5rem;
- }
- `}
-`;
-
-export const DashboardTabsContainer = styled(FullWidthContainer, {
- shouldForwardProp: isPropValid,
-})<{
- narrow?: boolean;
-}>`
- ${breakpointMaxSmall} {
- padding-left: 0;
- padding-right: 0;
- }
-
- ${({ narrow }) =>
- narrow &&
- `
- [role="tablist"].scrollable {
- width: calc(100% - 60px);
- }
- `}
-`;
-
-export const Separator = styled.div`
- border-bottom: 2px solid var(--mb-color-border-neutral);
-`;
-
-export const Body = styled.main`
- display: flex;
- flex-direction: column;
- flex: 1 0 auto;
- width: 100%;
- position: relative;
-`;
-
-export const TitleAndButtonsContainer = styled(FixedWidthContainer)`
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
-`;
diff --git a/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.tsx b/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.tsx
index 5c1ec45c6e4..c3b574cdf34 100644
--- a/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.tsx
+++ b/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.tsx
@@ -13,10 +13,9 @@ import { FilterApplyToast } from "metabase/dashboard/components/FilterApplyToast
import { useIsParameterPanelSticky } from "metabase/dashboard/hooks/use-is-parameter-panel-sticky";
import { isEmbeddingSdk } from "metabase/embedding-sdk/config";
import {
- ActionButtonsContainer,
+ EmbeddingFooter,
type FooterVariant,
-} from "metabase/embedding/components/EmbedFooter.styled";
-import { EmbeddingFooter } from "metabase/embedding/components/EmbeddingFooter/EmbeddingFooter";
+} from "metabase/embedding/components/EmbeddingFooter/EmbeddingFooter";
import EmbedThemeS from "metabase/embedding/theme.module.css";
import { ParametersList } from "metabase/parameters/components/ParametersList";
import { SyncedParametersList } from "metabase/parameters/components/SyncedParametersList";
@@ -25,7 +24,7 @@ import { getVisibleParameters } from "metabase/parameters/utils/ui";
import { useSelector } from "metabase/redux";
import { getSetting } from "metabase/settings";
import { FullWidthContainer } from "metabase/styled-components/layout/FullWidthContainer";
-import { Box } from "metabase/ui";
+import { Box, Stack } from "metabase/ui";
import { getDashboardType } from "metabase/utils/dashboard";
import { initializeIframeResizer, isSmallScreen } from "metabase/utils/dom";
import {
@@ -45,16 +44,6 @@ import type {
import type { DashboardUrlHashOptions } from "../../../dashboard/types";
import EmbedFrameS from "./EmbedFrame.module.css";
-import {
- Body,
- ContentContainer,
- DashboardTabsContainer,
- Header,
- Root,
- Separator,
- TitleAndButtonsContainer,
- TitleAndDescriptionContainer,
-} from "./EmbedFrame.styled";
import { useGlobalTheme } from "./useGlobalTheme";
export type EmbedFrameBaseProps = Partial<{
@@ -181,19 +170,27 @@ export const EmbedFrame = ({
const hasDashboardTabs = dashboard?.tabs && dashboard.tabs.length > 1;
return (
- <Root
- hasScroll={hasFrameScroll}
- isBordered={bordered}
- hasVisibleOverflowWhenPriting={isPublicDashboard}
- className={cx(className, EmbedThemeS.EmbedFrame, {
- [EmbedThemeS.NoBackground]: !background,
- })}
+ <Stack
+ className={cx(
+ className,
+ EmbedFrameS.overflowAuto,
+ EmbedThemeS.EmbedFrame,
+ {
+ [EmbedThemeS.NoBackground]: !background,
+ [EmbedFrameS.border]: bordered,
+ [EmbedFrameS.printOverflowVisible]: isPublicDashboard,
+ },
+ )}
+ gap={0}
+ pos={hasFrameScroll ? "absolute" : undefined}
+ inset={hasFrameScroll ? 0 : undefined}
data-testid="embed-frame"
data-embed-theme={theme}
>
- <ContentContainer
+ <Stack
id={DASHBOARD_PDF_EXPORT_ROOT_ID}
- className={cx(contentClassName, {
+ // flex stays a class, so a contentClassName can still override it
+ className={cx(contentClassName, CS.flexFull, {
[EmbedThemeS.ContentContainer]: true,
[EmbedThemeS.WithThemeBackground]: true,
@@ -201,18 +198,25 @@ export const EmbedFrame = ({
[CS.hoverParent]: question,
[CS.hoverVisibility]: question,
})}
+ gap={0}
+ pos="relative"
>
{hasHeader && (
- <Header
+ <Stack
+ component="header"
className={cx(
EmbedThemeS.EmbedFrameHeader,
SAVING_DOM_IMAGE_DISPLAY_NONE_CLASS,
)}
+ gap={0}
data-testid="embed-frame-header"
>
{(finalName || pdfDownloadsEnabled) && (
- <TitleAndDescriptionContainer hasTitle={!!finalName}>
- <TitleAndButtonsContainer
+ <FullWidthContainer
+ mt={finalName ? { base: "sm", sm: "lg", lg: "xl" } : "sm"}
+ >
+ <FixedWidthContainer
+ className={cx(CS.flex, CS.alignCenter)}
data-testid="fixed-width-dashboard-header"
isFixedWidth={dashboard?.width === "fixed"}
>
@@ -235,22 +239,30 @@ export const EmbedFrame = ({
/>
)}
{headerButtons}
- </TitleAndButtonsContainer>
- </TitleAndDescriptionContainer>
+ </FixedWidthContainer>
+ </FullWidthContainer>
)}
{dashboardTabs && (
- <DashboardTabsContainer narrow={!titled && pdfDownloadsEnabled}>
+ <FullWidthContainer
+ className={cx(EmbedFrameS.dashboardTabs, {
+ [EmbedFrameS.narrowTabs]: !titled && pdfDownloadsEnabled,
+ })}
+ >
<FixedWidthContainer
data-testid="fixed-width-dashboard-tabs"
isFixedWidth={dashboard?.width === "fixed"}
>
{dashboardTabs}
</FixedWidthContainer>
- </DashboardTabsContainer>
+ </FullWidthContainer>
)}
- {finalName && <Separator className={EmbedThemeS.Separator} />}
- </Header>
+ {finalName && (
+ <div
+ className={cx(EmbedThemeS.Separator, EmbedFrameS.borderBottom)}
+ />
+ )}
+ </Stack>
)}
{/* show floating header buttons if there is no title */}
@@ -289,8 +301,10 @@ export const EmbedFrame = ({
</FixedWidthContainer>
</FullWidthContainer>
)}
- <Body>{children}</Body>
- </ContentContainer>
+ <Stack component="main" gap={0} flex="1 0 auto" pos="relative">
+ {children}
+ </Stack>
+ </Stack>
{dashboard && <FilterApplyToast position="fixed" />}
{isFooterEnabled && (
@@ -299,12 +313,14 @@ export const EmbedFrame = ({
isDarkMode={theme === "night"}
hasEmbedBranding={hasEmbedBranding}
>
- {actionButtons && (
- <ActionButtonsContainer>{actionButtons}</ActionButtonsContainer>
+ {actionButtons && footerVariant === "default" && (
+ <Box c="text-secondary" ml="auto">
+ {actionButtons}
+ </Box>
)}
</EmbeddingFooter>
)}
- </Root>
+ </Stack>
);
};