Skip to content

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

Migrate Object Detail from Emotion to Mantine and CSS modules (#74985)

Andrei Chernykhcf6eb54cf381
diff --git a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailBody.module.css b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailBody.module.css
new file mode 100644
index 00000000000..a5220127d57
--- /dev/null
+++ b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailBody.module.css
@@ -0,0 +1,4 @@
+.body {
+ font-size: 1.15em;
+ overflow-y: auto;
+}
diff --git a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailBody.styled.tsx b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailBody.styled.tsx
deleted file mode 100644
index 2d22e9666aa..00000000000
--- a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailBody.styled.tsx
+++ /dev/null
@@ -1,8 +0,0 @@
-// eslint-disable-next-line no-restricted-imports
-import styled from "@emotion/styled";
-
-export const ObjectDetailBodyWrapper = styled.div`
- font-size: 1.15em;
- flex: 1;
- overflow-y: auto;
-`;
diff --git a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailBody.tsx b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailBody.tsx
index 5ca85268d1d..9315bca19b9 100644
--- a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailBody.tsx
+++ b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailBody.tsx
@@ -1,10 +1,11 @@
+import { Box } from "metabase/ui";
import type {
DatasetColumn,
RowValue,
VisualizationSettings,
} from "metabase-types/api";
-import { ObjectDetailBodyWrapper } from "./ObjectDetailBody.styled";
+import S from "./ObjectDetailBody.module.css";
import { DetailsTable } from "./ObjectDetailsTable";
import type { OnVisualizationClickType } from "./types";
@@ -26,7 +27,7 @@ export function ObjectDetailBody({
isDashboard,
}: ObjectDetailBodyProps): JSX.Element {
return (
- <ObjectDetailBodyWrapper>
+ <Box flex={1} className={S.body}>
<DetailsTable
columns={columns}
zoomedRow={zoomedRow}
@@ -35,6 +36,6 @@ export function ObjectDetailBody({
visualizationIsClickable={visualizationIsClickable}
isDashboard={isDashboard}
/>
- </ObjectDetailBodyWrapper>
+ </Box>
);
}
diff --git a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailHeader.module.css b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailHeader.module.css
new file mode 100644
index 00000000000..2231c80f9ca
--- /dev/null
+++ b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailHeader.module.css
@@ -0,0 +1,10 @@
+.headerWrapper {
+ flex-shrink: 0;
+ display: flex;
+ position: relative;
+ border-bottom: 1px solid var(--mb-color-border);
+}
+
+.closeButton {
+ border-left: 1px solid var(--mb-color-border);
+}
diff --git a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailHeader.styled.tsx b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailHeader.styled.tsx
deleted file mode 100644
index 72f32fe19a0..00000000000
--- a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailHeader.styled.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-// eslint-disable-next-line no-restricted-imports
-import styled from "@emotion/styled";
-
-export const ObjectDetailHeaderWrapper = styled.div`
- flex-shrink: 0;
- display: flex;
- position: relative;
- border-bottom: 1px solid var(--mb-color-border);
-`;
-
-export const ObjectIdLabel = styled.span`
- color: var(--mb-color-text-secondary);
- margin-left: 0.5rem;
-`;
-
-export const CloseButton = styled.div`
- display: flex;
- margin-left: 1rem;
- padding-left: 1rem;
- border-left: 1px solid var(--mb-color-border);
-`;
diff --git a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailHeader.tsx b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailHeader.tsx
index 754b4197d62..e21aedfd772 100644
--- a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailHeader.tsx
+++ b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailHeader.tsx
@@ -1,13 +1,11 @@
+import cx from "classnames";
+
import { Button } from "metabase/common/components/Button";
import { EntityMenu } from "metabase/common/components/EntityMenu";
import CS from "metabase/css/core/index.css";
-import { Flex } from "metabase/ui/components";
+import { Box, Flex, Text } from "metabase/ui";
-import {
- CloseButton,
- ObjectDetailHeaderWrapper,
- ObjectIdLabel,
-} from "./ObjectDetailHeader.styled";
+import S from "./ObjectDetailHeader.module.css";
import type { ObjectId } from "./types";
export interface ObjectDetailHeaderProps {
@@ -40,11 +38,16 @@ export function ObjectDetailHeader({
closeObjectDetail,
}: ObjectDetailHeaderProps): JSX.Element {
return (
- <ObjectDetailHeaderWrapper className={CS.Grid}>
+ <Box className={cx(CS.Grid, S.headerWrapper)}>
<div className={CS.GridCell}>
<h2 className={CS.p3}>
{objectName}
- {objectId !== null && <ObjectIdLabel> {objectId}</ObjectIdLabel>}
+ {objectId !== null && (
+ <Text component="span" c="text-secondary" ml="sm">
+ {" "}
+ {objectId}
+ </Text>
+ )}
</h2>
</div>
@@ -81,7 +84,7 @@ export function ObjectDetailHeader({
/>
)}
- <CloseButton>
+ <Flex ml="md" pl="md" className={S.closeButton}>
<Button
data-testid="object-detail-close-button"
onlyIcon
@@ -89,9 +92,9 @@ export function ObjectDetailHeader({
onClick={closeObjectDetail}
icon="close"
/>
- </CloseButton>
+ </Flex>
</Flex>
)}
- </ObjectDetailHeaderWrapper>
+ </Box>
);
}
diff --git a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailsTable.module.css b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailsTable.module.css
new file mode 100644
index 00000000000..cb6e31359e9
--- /dev/null
+++ b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailsTable.module.css
@@ -0,0 +1,3 @@
+.fitImage {
+ object-fit: contain;
+}
diff --git a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailsTable.styled.tsx b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailsTable.styled.tsx
deleted file mode 100644
index 2130d430181..00000000000
--- a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailsTable.styled.tsx
+++ /dev/null
@@ -1,9 +0,0 @@
-// eslint-disable-next-line no-restricted-imports
-import styled from "@emotion/styled";
-
-export const FitImage = styled.img`
- max-width: 100%;
- max-height: 18rem;
- object-fit: contain;
- margin: 1rem auto;
-`;
diff --git a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailsTable.tsx b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailsTable.tsx
index 15f670adb92..d5931ccc5f6 100644
--- a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailsTable.tsx
+++ b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetailsTable.tsx
@@ -25,7 +25,7 @@ import type {
} from "metabase-types/api";
import { ExpandableString } from "./ExpandableString";
-import { FitImage } from "./ObjectDetailsTable.styled";
+import S from "./ObjectDetailsTable.module.css";
import type { OnVisualizationClickType } from "./types";
export interface DetailsTableCellProps {
@@ -122,7 +122,16 @@ export function DetailsTableCell({
</span>
{isImage && (
<div>
- <FitImage src={value} alt={value} />
+ <Box
+ component="img"
+ className={S.fitImage}
+ src={value}
+ alt={value}
+ maw="100%"
+ mah="18rem"
+ my="md"
+ mx="auto"
+ />
</div>
)}
</div>