Skip to content

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

Migrate home cards from Emotion to Mantine (#80335)

Andersoned16a0bc3709
diff --git a/frontend/src/metabase/home/components/HomeCaption/HomeCaption.styled.tsx b/frontend/src/metabase/home/components/HomeCaption/HomeCaption.styled.tsx
deleted file mode 100644
index 4ec9bd13658..00000000000
--- a/frontend/src/metabase/home/components/HomeCaption/HomeCaption.styled.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-// eslint-disable-next-line no-restricted-imports
-import styled from "@emotion/styled";
-
-import { breakpointMinExtraLarge } from "metabase/styled-components/theme";
-import { color } from "metabase/ui/utils/colors";
-
-interface CaptionProps {
- primary?: boolean;
-}
-
-export const CaptionRoot = styled.div<CaptionProps>`
- display: flex;
- align-items: center;
- color: ${(props) =>
- props.primary ? color("text-primary") : color("text-secondary")};
- font-weight: bold;
- margin-bottom: 1.5rem;
-
- ${breakpointMinExtraLarge} {
- margin-bottom: 2rem;
- }
-`;
diff --git a/frontend/src/metabase/home/components/HomeCaption/HomeCaption.tsx b/frontend/src/metabase/home/components/HomeCaption/HomeCaption.tsx
index d86ede76144..0611f204ba1 100644
--- a/frontend/src/metabase/home/components/HomeCaption/HomeCaption.tsx
+++ b/frontend/src/metabase/home/components/HomeCaption/HomeCaption.tsx
@@ -1,6 +1,6 @@
import type { ReactNode } from "react";
-import { CaptionRoot } from "./HomeCaption.styled";
+import { Flex } from "metabase/ui";
interface HomeCaptionProps {
primary?: boolean;
@@ -11,5 +11,14 @@ export const HomeCaption = ({
primary,
children,
}: HomeCaptionProps): JSX.Element => {
- return <CaptionRoot primary={primary}>{children}</CaptionRoot>;
+ return (
+ <Flex
+ align="center"
+ c={primary ? "text-primary" : "text-secondary"}
+ fw="bold"
+ mb={{ base: "lg", xl: "xl" }}
+ >
+ {children}
+ </Flex>
+ );
};
diff --git a/frontend/src/metabase/home/components/HomeCard/HomeCard.module.css b/frontend/src/metabase/home/components/HomeCard/HomeCard.module.css
new file mode 100644
index 00000000000..95138565955
--- /dev/null
+++ b/frontend/src/metabase/home/components/HomeCard/HomeCard.module.css
@@ -0,0 +1,8 @@
+.root {
+ box-shadow: 0 7px 20px var(--mb-color-shadow-default);
+
+ &:hover {
+ box-shadow: 0 10px 22px
+ color-mix(in srgb, var(--mb-color-shadow-default) 50%, transparent);
+ }
+}
diff --git a/frontend/src/metabase/home/components/HomeCard/HomeCard.styled.tsx b/frontend/src/metabase/home/components/HomeCard/HomeCard.styled.tsx
deleted file mode 100644
index ea1d00afb3e..00000000000
--- a/frontend/src/metabase/home/components/HomeCard/HomeCard.styled.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-// eslint-disable-next-line no-restricted-imports
-import styled from "@emotion/styled";
-
-import { Link } from "metabase/common/components/Link";
-import {
- breakpointMinLarge,
- breakpointMinSmall,
-} from "metabase/styled-components/theme";
-import { alpha } from "metabase/ui/colors";
-
-export const CardRoot = styled(Link)`
- display: flex;
- align-items: center;
- padding: 1rem;
- border: 1px solid var(--mb-color-border-neutral);
- border-radius: 0.5rem;
- background-color: var(--mb-color-background_page-primary);
- box-shadow: 0 7px 20px var(--mb-color-shadow-default);
- max-width: 100%;
-
- ${breakpointMinSmall} {
- max-width: 50%;
- }
-
- ${breakpointMinLarge} {
- padding: 1.5rem;
- }
-
- &:hover {
- box-shadow: 0 10px 22px ${() => alpha("shadow-default", 0.09)};
- }
-`;
diff --git a/frontend/src/metabase/home/components/HomeCard/HomeCard.tsx b/frontend/src/metabase/home/components/HomeCard/HomeCard.tsx
index 530da2eff18..e93555a45b5 100644
--- a/frontend/src/metabase/home/components/HomeCard/HomeCard.tsx
+++ b/frontend/src/metabase/home/components/HomeCard/HomeCard.tsx
@@ -1,6 +1,10 @@
+import cx from "classnames";
import type { ReactNode } from "react";
-import { CardRoot } from "./HomeCard.styled";
+import { Link } from "metabase/common/components/Link";
+import { Card, Flex } from "metabase/ui";
+
+import S from "./HomeCard.module.css";
interface HomeCardProps {
className?: string;
@@ -17,8 +21,18 @@ export const HomeCard = ({
onClick,
}: HomeCardProps): JSX.Element => {
return (
- <CardRoot className={className} to={url} onClick={onClick}>
- {children}
- </CardRoot>
+ <Card
+ component={Link}
+ className={cx(S.root, className)}
+ to={url}
+ onClick={onClick}
+ bg="background_page-primary"
+ maw={{ base: "100%", sm: "50%" }}
+ p={{ base: "md", lg: "lg" }}
+ radius="md"
+ withBorder
+ >
+ <Flex align="center">{children}</Flex>
+ </Card>
);
};
diff --git a/frontend/src/metabase/home/components/HomeModelCard/HomeModelCard.styled.tsx b/frontend/src/metabase/home/components/HomeModelCard/HomeModelCard.styled.tsx
deleted file mode 100644
index 042d85279fa..00000000000
--- a/frontend/src/metabase/home/components/HomeModelCard/HomeModelCard.styled.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-// eslint-disable-next-line no-restricted-imports
-import styled from "@emotion/styled";
-
-import { Ellipsified } from "metabase/ui";
-
-export const CardTitle = styled(Ellipsified)`
- color: var(--mb-color-text-primary);
- font-size: 1rem;
- font-weight: bold;
- margin-left: 1rem;
- max-width: 100%;
-`;
diff --git a/frontend/src/metabase/home/components/HomeModelCard/HomeModelCard.tsx b/frontend/src/metabase/home/components/HomeModelCard/HomeModelCard.tsx
index 1f4e6ca8b0c..d7b1711b9db 100644
--- a/frontend/src/metabase/home/components/HomeModelCard/HomeModelCard.tsx
+++ b/frontend/src/metabase/home/components/HomeModelCard/HomeModelCard.tsx
@@ -1,10 +1,9 @@
import { EntityIcon } from "metabase/common/components/EntityIcon";
import type { IconData } from "metabase/common/utils/icon";
+import { Box, Ellipsified } from "metabase/ui";
import { HomeCard } from "../HomeCard";
-import { CardTitle } from "./HomeModelCard.styled";
-
interface HomeModelCardProps {
title: string;
icon: IconData;
@@ -18,12 +17,12 @@ export const HomeModelCard = ({
}: HomeModelCardProps): JSX.Element => {
return (
<HomeCard url={url}>
- <EntityIcon
- {...icon}
- color="core-brand"
- style={{ display: "block", flex: "0 0 auto" }}
- />
- <CardTitle>{title}</CardTitle>
+ <Box display="flex" flex="0 0 auto">
+ <EntityIcon {...icon} color="core-brand" />
+ </Box>
+ <Ellipsified c="text-primary" fz="md" fw="bold" ml="md" maw="100%">
+ {title}
+ </Ellipsified>
</HomeCard>
);
};
diff --git a/frontend/src/metabase/home/components/HomeXrayCard/HomeXrayCard.styled.tsx b/frontend/src/metabase/home/components/HomeXrayCard/HomeXrayCard.styled.tsx
deleted file mode 100644
index cf4ffd9e9de..00000000000
--- a/frontend/src/metabase/home/components/HomeXrayCard/HomeXrayCard.styled.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-// eslint-disable-next-line no-restricted-imports
-import styled from "@emotion/styled";
-
-import { Ellipsified, Icon } from "metabase/ui";
-import { color } from "metabase/ui/utils/colors";
-
-export const CardIcon = styled(Icon)`
- display: block;
- flex: 0 0 auto;
- color: ${() => color("accent4")};
- width: 1.25rem;
- height: 1.25rem;
-`;
-
-export const CardTitle = styled(Ellipsified)`
- font-size: 1rem;
- font-weight: bold;
- margin-left: 0.5rem;
- padding-right: 0.2rem;
-`;
-
-export const CardTitlePrimary = styled.span`
- color: var(--mb-color-text-primary);
-`;
-
-export const CardTitleSecondary = styled.span`
- color: var(--mb-color-text-secondary);
-`;
diff --git a/frontend/src/metabase/home/components/HomeXrayCard/HomeXrayCard.tsx b/frontend/src/metabase/home/components/HomeXrayCard/HomeXrayCard.tsx
index 994fce4515e..b20335dd3b6 100644
--- a/frontend/src/metabase/home/components/HomeXrayCard/HomeXrayCard.tsx
+++ b/frontend/src/metabase/home/components/HomeXrayCard/HomeXrayCard.tsx
@@ -1,11 +1,7 @@
+import { Ellipsified, Icon, Text } from "metabase/ui";
+
import { HomeCard } from "../HomeCard";
-import {
- CardIcon,
- CardTitle,
- CardTitlePrimary,
- CardTitleSecondary,
-} from "./HomeXrayCard.styled";
import { trackHomeXRayClicked } from "./analytics";
interface HomeXrayCardProps {
@@ -21,11 +17,21 @@ export const HomeXrayCard = ({
}: HomeXrayCardProps): JSX.Element => {
return (
<HomeCard url={url} onClick={trackHomeXRayClicked}>
- <CardIcon name="bolt_filled" />
- <CardTitle>
- <CardTitleSecondary>{message}</CardTitleSecondary>{" "}
- <CardTitlePrimary>{title}</CardTitlePrimary>
- </CardTitle>
+ <Icon
+ name="bolt_filled"
+ c="accent4"
+ display="block"
+ flex="0 0 auto"
+ size={20}
+ />
+ <Ellipsified fz="md" fw="bold" ml="sm" pr="xs">
+ <Text component="span" c="text-secondary">
+ {message}
+ </Text>{" "}
+ <Text component="span" c="text-primary">
+ {title}
+ </Text>
+ </Ellipsified>
</HomeCard>
);
};
diff --git a/frontend/src/metabase/home/components/HomeXraySection/HomeXraySection.styled.tsx b/frontend/src/metabase/home/components/HomeXraySection/HomeXraySection.styled.tsx
deleted file mode 100644
index c183ef763a1..00000000000
--- a/frontend/src/metabase/home/components/HomeXraySection/HomeXraySection.styled.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-// eslint-disable-next-line no-restricted-imports
-import styled from "@emotion/styled";
-
-import { Link } from "metabase/common/components/Link";
-import { Icon } from "metabase/ui";
-
-export const SectionBody = styled.div`
- display: flex;
- gap: 1.5rem;
- flex-wrap: wrap;
-`;
-
-export const DatabaseLink = styled(Link)`
- display: flex;
- align-items: center;
- margin-left: 0.5rem;
-`;
-
-export const DatabaseLinkIcon = styled(Icon)`
- color: var(--mb-color-input-focus);
- width: 1rem;
- height: 1rem;
- margin-right: 0.25rem;
-`;
-
-export const DatabaseLinkText = styled.span`
- color: var(--mb-color-core-brand);
- font-weight: bold;
-`;
-
-export const SchemaTriggerIcon = styled(Icon)`
- color: var(--mb-color-core-brand);
- width: 0.625rem;
- height: 0.625rem;
- margin-left: 0.25rem;
-`;
-
-export const SchemaTriggerText = styled.span`
- color: var(--mb-color-core-brand);
- font-weight: bold;
-`;
diff --git a/frontend/src/metabase/home/components/HomeXraySection/HomeXraySection.tsx b/frontend/src/metabase/home/components/HomeXraySection/HomeXraySection.tsx
index f478f785a08..aee353cd6db 100644
--- a/frontend/src/metabase/home/components/HomeXraySection/HomeXraySection.tsx
+++ b/frontend/src/metabase/home/components/HomeXraySection/HomeXraySection.tsx
@@ -7,12 +7,17 @@ import {
useListDatabaseXraysQuery,
useListDatabasesQuery,
} from "metabase/api";
+import { Link } from "metabase/common/components/Link";
import { LoadingAndErrorWrapper } from "metabase/common/components/LoadingAndErrorWrapper";
import { useSelector } from "metabase/redux";
import { getApplicationName } from "metabase/selectors/whitelabel";
import {
+ Box,
Combobox,
DefaultSelectItem,
+ Flex,
+ Icon,
+ Text,
UnstyledButton,
useCombobox,
} from "metabase/ui";
@@ -25,15 +30,6 @@ import { HomeCaption } from "../HomeCaption";
import { HomeHelpCard } from "../HomeHelpCard";
import { HomeXrayCard } from "../HomeXrayCard";
-import {
- DatabaseLink,
- DatabaseLinkIcon,
- DatabaseLinkText,
- SchemaTriggerIcon,
- SchemaTriggerText,
- SectionBody,
-} from "./HomeXraySection.styled";
-
export const HomeXraySection = () => {
const {
data: databasesData,
@@ -78,7 +74,7 @@ const HomeXrayView = ({ database, candidates = [] }: HomeXrayViewProps) => {
const hasTables = (candidate?.tables.length ?? 0) > 0;
return (
- <div>
+ <Box>
{isSample ? (
<HomeCaption primary>
{t`Try out these sample x-rays to see what ${applicationName} can do.`}
@@ -100,7 +96,7 @@ const HomeXrayView = ({ database, candidates = [] }: HomeXrayViewProps) => {
<DatabaseInfo database={database} />
</HomeCaption>
) : null}
- <SectionBody>
+ <Flex gap="lg" wrap="wrap">
{candidate?.tables.map((table, index) => (
<HomeXrayCard
key={table.url}
@@ -110,8 +106,8 @@ const HomeXrayView = ({ database, candidates = [] }: HomeXrayViewProps) => {
/>
))}
<HomeHelpCard />
- </SectionBody>
- </div>
+ </Flex>
+ </Box>
);
};
@@ -143,17 +139,23 @@ const SchemaSelect = ({ schema, schemas, onChange }: SchemaSelectProps) => {
}}
>
<Combobox.Target>
- <UnstyledButton
+ <Flex
+ component={UnstyledButton}
+ align="center"
display="inline-flex"
mx="sm"
- style={{ alignItems: "center", outline: "none" }}
onClick={() => combobox.toggleDropdown()}
>
- <SchemaTriggerText data-testid="xray-schema-name">
+ <Text
+ component="span"
+ c="core-brand"
+ fw="bold"
+ data-testid="xray-schema-name"
+ >
{schema}
- </SchemaTriggerText>
- <SchemaTriggerIcon name="chevrondown" />
- </UnstyledButton>
+ </Text>
+ <Icon name="chevrondown" c="core-brand" size={10} ml="xs" />
+ </Flex>
</Combobox.Target>
<Combobox.Dropdown>
<Combobox.Options>
@@ -182,10 +184,22 @@ interface DatabaseInfoProps {
const DatabaseInfo = ({ database }: DatabaseInfoProps) => {
return (
- <DatabaseLink to={Urls.browseDatabase(database)}>
- <DatabaseLinkIcon name="database" />
- <DatabaseLinkText>{database.name}</DatabaseLinkText>
- </DatabaseLink>
+ <Flex
+ component={Link}
+ to={Urls.browseDatabase(database)}
+ align="center"
+ ml="sm"
+ >
+ <Icon
+ name="database"
+ c="input-focus"
+ size="var(--mantine-spacing-md)"
+ mr="xs"
+ />
+ <Text component="span" c="core-brand" fw="bold">
+ {database.name}
+ </Text>
+ </Flex>
);
};