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
Replace deprecated Card with Mantine Card (#75020)
Oleh K59f0e1214a13
diff --git a/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfo.styled.tsx b/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfo.styled.tsxindex 312984cbc08..49a3f67b113 100644--- a/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfo.styled.tsx+++ b/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfo.styled.tsx@@ -1,14 +1,9 @@import { css } from "@emotion/react";import styled from "@emotion/styled";-import { Card } from "metabase/common/components/Card";import { ExternalLink } from "metabase/common/components/ExternalLink";import { Link } from "metabase/common/components/Link";-export const BillingInfoCard = styled(Card)`- margin-top: 1rem;-`;-export const BillingInfoRowContainer = styled.div<{ extraPadding?: boolean }>`display: flex;justify-content: space-between;diff --git a/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfoTable.tsx b/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfoTable.tsxindex 414f0d7a3c2..e7d55b88eaa 100644--- a/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfoTable.tsx+++ b/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfoTable.tsx@@ -4,14 +4,13 @@ import { t } from "ttag";import ErrorBoundary from "metabase/ErrorBoundary";import { SettingHeader } from "metabase/admin/settings/components/SettingHeader";import { useSetting } from "metabase/common/hooks";-import { Icon, Text } from "metabase/ui";+import { Card, Icon, Text } from "metabase/ui";import type { BillingInfo, BillingInfoLineItem } from "metabase-types/api";import { StillNeedHelp } from "../StillNeedHelp";import {BillingExternalLink,- BillingInfoCard,BillingInfoRowContainer,BillingInternalLink,} from "./BillingInfo.styled";@@ -121,7 +120,7 @@ export const BillingInfoTable = ({return (<><SettingHeader id="billing" title={t`Billing`} />- <BillingInfoCard flat>+ <Card mt="md" p={0} radius="md" shadow="none" withBorder>{billingInfo.content?.map((lineItem, index, arr) => (<BillingInfoRowkey={lineItem.name}@@ -129,7 +128,7 @@ export const BillingInfoTable = ({extraPadding={arr.length === index + 1}/>))}- </BillingInfoCard>+ </Card>{airgap_enabled && <StillNeedHelp />}</>);diff --git a/frontend/src/metabase/account/login-history/components/LoginHistory/LoginHistory.tsx b/frontend/src/metabase/account/login-history/components/LoginHistory/LoginHistory.tsxindex 82cd859b1e9..14ca7aa3fed 100644--- a/frontend/src/metabase/account/login-history/components/LoginHistory/LoginHistory.tsx+++ b/frontend/src/metabase/account/login-history/components/LoginHistory/LoginHistory.tsx@@ -1,14 +1,12 @@-import cx from "classnames";import dayjs from "dayjs";import { t } from "ttag";import _ from "underscore";import NoResults from "assets/img/no_results.svg";-import { Card } from "metabase/common/components/Card";import { EmptyState } from "metabase/common/components/EmptyState";import { Label } from "metabase/common/components/type/Label";import CS from "metabase/css/core/index.css";-import { Box, Flex, Text } from "metabase/ui";+import { Box, Card, Flex, Text } from "metabase/ui";import type { UserLoginHistoryItem } from "metabase-types/api";interface FormattedLoginItem extends UserLoginHistoryItem {@@ -17,10 +15,7 @@ interface FormattedLoginItem extends UserLoginHistoryItem {}const LoginHistoryItem = ({ item }: { item: FormattedLoginItem }) => (- <Card- className={cx(CS.my2, CS.py1)}- style={{ paddingLeft: 20, paddingRight: 20 }}- >+ <Card px="md" py="sm" my="md" radius="md" withBorder><Flex align="flex-start"><div><Label>diff --git a/frontend/src/metabase/collections/components/PinnedItemCard/PinnedItemCard.styled.tsx b/frontend/src/metabase/collections/components/PinnedItemCard/PinnedItemCard.styled.tsxindex bb887773c63..ed5b58aba0a 100644--- a/frontend/src/metabase/collections/components/PinnedItemCard/PinnedItemCard.styled.tsx+++ b/frontend/src/metabase/collections/components/PinnedItemCard/PinnedItemCard.styled.tsx@@ -4,12 +4,9 @@ import { css } from "@emotion/react";import styled from "@emotion/styled";import { RawMaybeLink } from "metabase/common/components/Badge/Badge.styled";-import { Card } from "metabase/common/components/Card";import { MarkdownPreview } from "metabase/common/components/MarkdownPreview";import { Box, type BoxProps } from "metabase/ui";-export const ItemCard = styled(Card)``;-export const ItemLink = styled(RawMaybeLink)<{ to?: string }>`display: block;height: min-content;@@ -43,10 +40,11 @@ export const Title = styled.div`export const Description = styled(MarkdownPreview)`color: var(--mb-color-text-secondary);+ margin-top: 0.25rem;`;export const Body = styled.div`- padding: 1rem 1.5rem;+ padding: 1rem 1.5rem 1.25rem;display: flex;flex-direction: column;cursor: pointer;diff --git a/frontend/src/metabase/collections/components/PinnedItemCard/PinnedItemCard.tsx b/frontend/src/metabase/collections/components/PinnedItemCard/PinnedItemCard.tsxindex b60702182af..2e46ec6dcbc 100644--- a/frontend/src/metabase/collections/components/PinnedItemCard/PinnedItemCard.tsx+++ b/frontend/src/metabase/collections/components/PinnedItemCard/PinnedItemCard.tsx@@ -11,7 +11,7 @@ import { EntityIcon } from "metabase/common/components/EntityIcon";import { EventSandbox } from "metabase/common/components/EventSandbox";import { useGetIcon } from "metabase/hooks/use-icon";import { PLUGIN_MODERATION } from "metabase/plugins";-import { Flex, Skeleton, Tooltip } from "metabase/ui";+import { Card, Flex, Skeleton, Tooltip } from "metabase/ui";import { modelToUrl } from "metabase/urls";import type Database from "metabase-lib/v1/metadata/Database";import type {@@ -27,7 +27,6 @@ import {Body,Description,Header,- ItemCard,ItemLink,Title,} from "./PinnedItemCard.styled";@@ -125,7 +124,7 @@ function PinnedItemCard({to={item ? (modelToUrl(item) ?? "/") : undefined}onClick={onClick}>- <ItemCard flat>+ <Card p={0} radius="md" shadow="none" withBorder><Body><Header><EntityIcon {...iconData} size="1.5rem" color="brand" />@@ -182,7 +181,7 @@ function PinnedItemCard({</>)}</Body>- </ItemCard>+ </Card></ItemLink>);}diff --git a/frontend/src/metabase/common/components/BulkActionBar/BulkActionBar.styled.tsx b/frontend/src/metabase/common/components/BulkActionBar/BulkActionBar.styled.tsxindex 15563fd7049..c4c551edfe8 100644--- a/frontend/src/metabase/common/components/BulkActionBar/BulkActionBar.styled.tsx+++ b/frontend/src/metabase/common/components/BulkActionBar/BulkActionBar.styled.tsx@@ -1,8 +1,8 @@// eslint-disable-next-line no-restricted-importsimport styled from "@emotion/styled";-import { Card } from "metabase/common/components/Card";import { NAV_SIDEBAR_WIDTH } from "metabase/nav/constants";+import { Card } from "metabase/ui";export const BulkActionsToast = styled.div<{ isNavbarOpen: boolean }>`position: fixed;@@ -16,10 +16,12 @@ export const BulkActionsToast = styled.div<{ isNavbarOpen: boolean }>``;export const ToastCard = styled(Card)`+ background-color: var(--mb-color-background-primary-inverse);color: var(--mb-color-text-primary-inverse);padding: 0.75rem var(--mantine-spacing-md);display: flex;+ flex-direction: row;align-items: center;justify-content: space-between;gap: 2.5rem;-`;+` as unknown as typeof Card;diff --git a/frontend/src/metabase/common/components/BulkActionBar/BulkActionBar.tsx b/frontend/src/metabase/common/components/BulkActionBar/BulkActionBar.tsxindex 0a097846454..536cfe71e85 100644--- a/frontend/src/metabase/common/components/BulkActionBar/BulkActionBar.tsx+++ b/frontend/src/metabase/common/components/BulkActionBar/BulkActionBar.tsx@@ -4,7 +4,7 @@ import type { HTMLAttributes } from "react";import Animation from "metabase/css/core/animation.module.css";import { useSelector } from "metabase/redux";import { getIsNavbarOpen } from "metabase/selectors/app";-import { Box, type BoxProps, Flex, Portal, Text } from "metabase/ui";+import { type BoxProps, Flex, Portal, Text } from "metabase/ui";import { BulkActionsToast, ToastCard } from "./BulkActionBar.styled";@@ -48,12 +48,12 @@ export const BulkActionBarPortal = ({isNavbarOpen={isNavbarOpen}className={cx(className, Animation.popToast)}>- <Box component={ToastCard} dark data-testid="toast-card" {...props}>+ <ToastCard data-testid="toast-card" {...props}>{message && <Text color="text-primary-inverse">{message}</Text>}<Flex gap="sm" align="center">{children}</Flex>- </Box>+ </ToastCard></BulkActionsToast></Portal>);diff --git a/frontend/src/metabase/common/components/Card/Card.tsx b/frontend/src/metabase/common/components/Card/Card.tsxdeleted file mode 100644index 45cea4edd4c..00000000000--- a/frontend/src/metabase/common/components/Card/Card.tsx+++ /dev/null@@ -1,42 +0,0 @@-// eslint-disable-next-line no-restricted-imports-import { css } from "@emotion/react";-// eslint-disable-next-line no-restricted-imports-import styled from "@emotion/styled";--type CardProps = {- className?: string;- dark?: boolean;- hoverable?: boolean;- flat?: boolean;- compact?: boolean;-};--export const Card = styled.div<CardProps>`- background-color: ${(props) =>- props.dark- ? "var(--mb-color-background-primary-inverse)"- : "var(--mb-color-background-primary)"};- border: 1px solid- ${(props) => (props.dark ? "transparent" : "var(--mb-color-border)")};- ${(props) => props.dark && `color: white`};- border-radius: var(--mantine-radius-md);- box-shadow: 0 7px 20px var(--mb-color-shadow);- line-height: 24px;- ${({ hoverable }) =>- hoverable &&- css`- &:hover {- box-shadow: 0 10px 22px var(--mb-color-shadow);- }- `};- ${(props) =>- props.flat &&- css`- box-shadow: none;- `};- ${(props) =>- props.compact &&- css`- box-shadow: 0 1px 2px var(--mb-color-shadow);- `};-`;diff --git a/frontend/src/metabase/common/components/Card/index.tsx b/frontend/src/metabase/common/components/Card/index.tsxdeleted file mode 100644index fbaf43c22ad..00000000000--- a/frontend/src/metabase/common/components/Card/index.tsx+++ /dev/null@@ -1 +0,0 @@-export { Card } from "./Card";diff --git a/frontend/src/metabase/common/components/ListItem/ListItem.tsx b/frontend/src/metabase/common/components/ListItem/ListItem.tsxindex 4161589f808..18ba6de5aba 100644--- a/frontend/src/metabase/common/components/ListItem/ListItem.tsx+++ b/frontend/src/metabase/common/components/ListItem/ListItem.tsx@@ -1,10 +1,9 @@import cx from "classnames";import { memo } from "react";-import { Card } from "metabase/common/components/Card";import S from "metabase/common/components/List/List.module.css";import CS from "metabase/css/core/index.css";-import { Ellipsified, Icon } from "metabase/ui";+import { Box, Card, Ellipsified, Icon } from "metabase/ui";import type { IconName } from "metabase-types/api";import { ListItemLink, Root } from "./ListItem.styled";@@ -32,23 +31,26 @@ const ListItemInner = ({}: ListItemProps) => {const card = (<Card- hoverable- className={cx(CS.mb2, CS.p3, CS.bgWhite, CS.rounded, CS.bordered)}+ p="lg"+ mb="md"+ w="680px"+ radius="md"+ withBorder+ c="inherit"data-testid="data-reference-list-item"- style={{ width: "680px" }}><div className={cx(S.item)}><div className={S.itemIcons}>{icon && <Icon className={S.chartIcon} name={icon} size={16} />}</div><div className={cx(S.itemBody, CS.flexColumn)}>- <div className={S.itemTitle}>+ <Box className={S.itemTitle} lh="1.5"><Ellipsified tooltip={name}>{name}</Ellipsified>- </div>+ </Box>{(description || placeholder) && (- <div className={cx(S.itemSubtitle)}>+ <Box className={cx(S.itemSubtitle)} mt="sm">{description || placeholder}- </div>+ </Box>)}</div></div>diff --git a/frontend/src/metabase/common/components/UndoListing.styled.tsx b/frontend/src/metabase/common/components/UndoListing.styled.tsxindex caf90802074..b4af65a6b78 100644--- a/frontend/src/metabase/common/components/UndoListing.styled.tsx+++ b/frontend/src/metabase/common/components/UndoListing.styled.tsx@@ -1,50 +1,21 @@// eslint-disable-next-line no-restricted-imports-import { css } from "@emotion/react";-// eslint-disable-next-line no-restricted-importsimport styled from "@emotion/styled";-import { Card } from "metabase/common/components/Card";import { Link } from "metabase/common/components/Link";import type { BoxProps } from "metabase/ui";import { Box, Icon } from "metabase/ui";import { alpha } from "metabase/ui/colors";-const LIST_H_MARGINS = "var(--mantine-spacing-md)";-export const UndoList = styled.ul`position: fixed;left: 0;bottom: 0;- margin: ${LIST_H_MARGINS};+ margin: var(--mantine-spacing-md);display: flex;flex-direction: column;align-items: flex-start;`;-export const ToastCard = styled(Card)<{- translateY?: number;- color?: string;- noBorder?: boolean;-}>`- padding: 10px var(--mantine-spacing-md);- margin-top: var(--mantine-spacing-sm);- max-width: calc(100vw - 2 * ${LIST_H_MARGINS});- background-color: ${(props) =>- props.dark- ? "var(--mb-color-background-primary-inverse)"- : "var(--mb-color-background-primary)"};- color: ${(props) =>- props.dark- ? "var(--mb-color-text-secondary-inverse)"- : "var(--mb-color-text-primary)"};- ${({ noBorder }) =>- noBorder &&- css`- border: none;- overflow-x: hidden;- `};-`;-export const CardContent = styled.div`display: flex;align-items: center;diff --git a/frontend/src/metabase/common/components/UndoListing.tsx b/frontend/src/metabase/common/components/UndoListing.tsxindex 6b39c889394..8a982186962 100644--- a/frontend/src/metabase/common/components/UndoListing.tsx+++ b/frontend/src/metabase/common/components/UndoListing.tsx@@ -23,7 +23,7 @@ import {performUndo,resumeUndo,} from "metabase/redux/undo";-import { Ellipsified, Portal, Progress } from "metabase/ui";+import { Card, Ellipsified, Portal, Progress } from "metabase/ui";import { capitalize, inflect } from "metabase/utils/formatting";import CS from "./UndoListing.module.css";@@ -34,7 +34,6 @@ import {ControlsCardContent,DefaultText,DismissIcon,- ToastCard,UndoButton,UndoList,} from "./UndoListing.styled";@@ -89,18 +88,30 @@ function UndoToast({}};+ const dark = undo.dark ?? true;+ const noBorder = undo.showProgress;+return (- <ToastCard+ <Cardref={undo.ref}- dark={undo.dark ?? true}data-testid="toast-undo"color={undo.toastColor}role="status"- noBorder={undo.showProgress}className={CS.toast}onMouseEnter={handleMouseEnter}onMouseLeave={handleMouseLeave}- style={{ ...style, ...undo.style }}+ bg={dark ? "background-primary-inverse" : "background-primary"}+ c={dark ? "text-secondary-inverse" : "text-primary"}+ withBorder={!noBorder}+ radius="md"+ p="md"+ mt="sm"+ maw="calc(100vw - 2 * var(--mantine-spacing-md))"+ style={{+ overflowX: noBorder ? "hidden" : undefined,+ ...style,+ ...undo.style,+ }}>{undo.showProgress && (<Progress@@ -162,7 +173,7 @@ function UndoToast({)}</ControlsCardContent></CardContent>- </ToastCard>+ </Card>);}diff --git a/frontend/src/metabase/dashboard/components/DashboardSubscriptionsSidebar/PulsesListSidebar.styled.tsx b/frontend/src/metabase/dashboard/components/DashboardSubscriptionsSidebar/PulsesListSidebar.styled.tsxindex 890e0d17316..609c95d0a01 100644--- a/frontend/src/metabase/dashboard/components/DashboardSubscriptionsSidebar/PulsesListSidebar.styled.tsx+++ b/frontend/src/metabase/dashboard/components/DashboardSubscriptionsSidebar/PulsesListSidebar.styled.tsx@@ -2,14 +2,17 @@import { css } from "@emotion/react";// eslint-disable-next-line no-restricted-importsimport styled from "@emotion/styled";+import type { ComponentPropsWithoutRef, ComponentType } from "react";-import { Card } from "metabase/common/components/Card";+import type { CardProps } from "metabase/ui";+import { Card } from "metabase/ui";-interface PulesCardProps {- canEdit: boolean;-}+type PulseCardProps = CardProps &+ ComponentPropsWithoutRef<"div"> & {+ canEdit: boolean;+ };-export const PulseCard = styled(Card)<PulesCardProps>`+export const PulseCard = styled(Card)<{ canEdit: boolean }>`margin-bottom: 2rem;${({ canEdit }) =>@@ -21,7 +24,7 @@ export const PulseCard = styled(Card)<PulesCardProps>`background-color: var(--mb-color-brand);}`}-`;+` as unknown as ComponentType<PulseCardProps>;export const SidebarActions = styled.div`display: flex;diff --git a/frontend/src/metabase/dashboard/components/DashboardSubscriptionsSidebar/PulsesListSidebar.tsx b/frontend/src/metabase/dashboard/components/DashboardSubscriptionsSidebar/PulsesListSidebar.tsxindex a9383b3bab0..fbd626018db 100644--- a/frontend/src/metabase/dashboard/components/DashboardSubscriptionsSidebar/PulsesListSidebar.tsx+++ b/frontend/src/metabase/dashboard/components/DashboardSubscriptionsSidebar/PulsesListSidebar.tsx@@ -103,8 +103,11 @@ function _PulsesListSidebar({<PulseCardaria-label="Pulse Card"key={pulse.id}- flatcanEdit={canEdit}+ p={0}+ radius="md"+ shadow="none"+ withBorderonClick={() =>canEdit &&editPulse(pulse, pulse.channels[0].channel_type as ChannelType)diff --git a/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/SuggestionsSidebar.tsx b/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/SuggestionsSidebar.tsxindex cbb70dfa952..77802e765a0 100644--- a/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/SuggestionsSidebar.tsx+++ b/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/SuggestionsSidebar.tsx@@ -3,10 +3,9 @@ import type { PropsWithChildren } from "react";import { t } from "ttag";import _ from "underscore";-import { Card } from "metabase/common/components/Card";import { Link } from "metabase/common/components/Link";import CS from "metabase/css/core/index.css";-import { Box, Flex, Icon, Title, Tooltip } from "metabase/ui";+import { Box, Card, Flex, Icon, Title, Tooltip } from "metabase/ui";import { color } from "metabase/ui/utils/colors";import type { IconName, RelatedDashboardXRays } from "metabase-types/api";@@ -67,7 +66,7 @@ const SuggestionsList = ({className={cx(CS.hoverParent, CS.hoverVisibility, S.ItemLink)}onClick={() => trackSuggestedXRayClicked(suggestionKey)}>- <Card className={CS.p2} hoverable>+ <Card p="md" radius="md" withBorder c="inherit"><Flex align="center"><Iconname={RELATED_CONTENT[suggestionKey].icon}