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
Migrate EmptyState component off Emotion to a CSS module (#75420)
Andrei Chernykh640d66680958
diff --git a/frontend/src/metabase/common/components/EmptyState/EmptyState.module.css b/frontend/src/metabase/common/components/EmptyState/EmptyState.module.cssindex d9e8bee1e3d..fad95215de0 100644--- a/frontend/src/metabase/common/components/EmptyState/EmptyState.module.css+++ b/frontend/src/metabase/common/components/EmptyState/EmptyState.module.css@@ -1,3 +1,18 @@-.EmptyStateFooter:not(:empty) {- margin-top: 1rem;+.footer:not(:empty) {+ margin-top: var(--mantine-spacing-md);+}++.illustration {+ margin-bottom: var(--mantine-spacing-md);+}++/* Defaults to "md" spacing; "sm" stays at 1rem even above the small breakpoint */+@media (--breakpoint-min-sm) {+ .illustration {+ margin-bottom: var(--mantine-spacing-xl);+ }++ .illustration[data-spacing="sm"] {+ margin-bottom: var(--mantine-spacing-md);+ }}diff --git a/frontend/src/metabase/common/components/EmptyState/EmptyState.styled.tsx b/frontend/src/metabase/common/components/EmptyState/EmptyState.styled.tsxdeleted file mode 100644index 414cea9934a..00000000000--- a/frontend/src/metabase/common/components/EmptyState/EmptyState.styled.tsx+++ /dev/null@@ -1,31 +0,0 @@-// eslint-disable-next-line no-restricted-imports-import styled from "@emotion/styled";--import { breakpointMinSmall } from "metabase/styled-components/theme";--export const EmptyStateHeader = styled.div`- display: flex;- flex-direction: column;- align-items: center;- justify-content: center;- text-align: center;-`;--export const EmptyStateActions = styled.div`- display: flex;- align-items: center;- margin: 0 auto;-`;--export interface EmptyStateIllustrationProps {- spacing: "sm" | "md";-}--export const EmptyStateIllustration = styled.div<EmptyStateIllustrationProps>`- margin-bottom: 1rem;-- /* Defaults to "md" spacing, "sm" forces always 1rem */- ${breakpointMinSmall} {- margin-bottom: ${(props) => (props.spacing === "sm" ? "1rem" : "2rem")};- }-`;diff --git a/frontend/src/metabase/common/components/EmptyState/EmptyState.tsx b/frontend/src/metabase/common/components/EmptyState/EmptyState.tsxindex 6de6a1fa892..160bc6dc174 100644--- a/frontend/src/metabase/common/components/EmptyState/EmptyState.tsx+++ b/frontend/src/metabase/common/components/EmptyState/EmptyState.tsx@@ -1,15 +1,11 @@+import cx from "classnames";+import { Link } from "metabase/common/components/Link";import CS from "metabase/css/core/index.css";-import { Button, Flex, Icon, Text, isValidIconName } from "metabase/ui";+import { Box, Button, Flex, Icon, Text, isValidIconName } from "metabase/ui";import type { IconName } from "metabase-types/api";import S from "./EmptyState.module.css";-import {- EmptyStateActions,- EmptyStateHeader,- EmptyStateIllustration,- type EmptyStateIllustrationProps,-} from "./EmptyState.styled";// Don't break existing empty states// TODO - remove these and update empty states with proper usage of illustrationElement@@ -48,7 +44,7 @@ type EmptyStateProps = {className?: string;icon?: IconName;image?: string;- spacing?: EmptyStateIllustrationProps["spacing"];+ spacing?: "sm" | "md";};export const EmptyState = ({@@ -65,14 +61,14 @@ export const EmptyState = ({...rest}: EmptyStateProps) => (<div className={className}>- <EmptyStateHeader>+ <Flex direction="column" align="center" justify="center" ta="center">{illustrationElement && (- <EmptyStateIllustration- className="empty-state-illustration"- spacing={spacing}+ <Box+ className={cx("empty-state-illustration", S.illustration)}+ data-spacing={spacing}>{illustrationElement}- </EmptyStateIllustration>+ </Box>)}<div>{isValidIconName(icon) && <LegacyIcon icon={icon} {...rest} />}@@ -88,12 +84,12 @@ export const EmptyState = ({{message}</Text>)}- </EmptyStateHeader>+ </Flex>{/* TODO - we should make this children or some other more flexible way toadd actions*/}<Flex>- <EmptyStateActions className={S.EmptyStateFooter}>+ <Flex className={S.footer} align="center" mx="auto">{action && link && (<Link to={link} target={link.startsWith("http") ? "_blank" : ""}><Button variant="filled">{action}</Button>@@ -104,7 +100,7 @@ export const EmptyState = ({{action}</Button>)}- </EmptyStateActions>+ </Flex></Flex></div>);