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 UserAvatar, Unsubscribe and UploadInput off Emotion (#83894)
Andrei Chernykh9a81ed47222b
diff --git a/frontend/src/metabase/common/components/Unsubscribe.module.css b/frontend/src/metabase/common/components/Unsubscribe.module.cssnew file mode 100644index 00000000000..f01ee1ecab9--- /dev/null+++ b/frontend/src/metabase/common/components/Unsubscribe.module.css@@ -0,0 +1,7 @@+.logo {+ height: 4rem;+}++.shadow {+ box-shadow: 0 1px 15px var(--mb-color-shadow-default);+}diff --git a/frontend/src/metabase/common/components/Unsubscribe.styled.tsx b/frontend/src/metabase/common/components/Unsubscribe.styled.tsxdeleted file mode 100644index 31b2ac1b0bf..00000000000--- a/frontend/src/metabase/common/components/Unsubscribe.styled.tsx+++ /dev/null@@ -1,65 +0,0 @@-// eslint-disable-next-line eslint-js/no-restricted-imports-import styled from "@emotion/styled";--import { MetabotLogo } from "metabase/common/components/MetabotLogo";-import { breakpointMinSmall } from "metabase/styled-components/theme";-import { Icon } from "metabase/ui";-import { alpha } from "metabase/ui/colors";--export const StyledMetabotLogo = styled(MetabotLogo)`- height: 4rem;-`;--export const LayoutRoot = styled.div`- position: relative;- display: flex;- min-height: 100%;- background-color: var(--mb-color-background_page-secondary);-`;--export const LayoutBody = styled.div`- position: relative;- flex: 1;-`;--export const LayoutIllustration = styled.div<{- backgroundImageSrc: string;-}>`- position: absolute;- top: 0;- left: 0;- width: 100%;- height: 100%;- background-image: ${({ backgroundImageSrc }) =>- `url("${backgroundImageSrc}")`};- background-size: 100% auto;- background-repeat: no-repeat;- background-position: right bottom;-`;--export const LayoutCard = styled.div`- width: 100%;- margin-top: 1.5rem;- padding: 2.5rem 1.5rem;- background-color: var(--mb-color-background_page-primary);- box-shadow: 0 1px 15px var(--mb-color-shadow-default);- border-radius: 6px;- min-height: 20rem;- min-width: 35rem;- display: flex;- flex-direction: column;- align-items: center;- justify-content: center;-- ${breakpointMinSmall} {- width: 30.875rem;- padding: 2.5rem 3.5rem;- }-`;--export const CheckmarkIcon = styled(Icon)`- border-radius: 100%;- padding: 1rem;- color: var(--mb-color-core-brand);- background: ${() => alpha("core-brand", 0.3)};-`;diff --git a/frontend/src/metabase/common/components/Unsubscribe.tsx b/frontend/src/metabase/common/components/Unsubscribe.tsxindex a6e6b451794..ebf3ef85413 100644--- a/frontend/src/metabase/common/components/Unsubscribe.tsx+++ b/frontend/src/metabase/common/components/Unsubscribe.tsx@@ -13,19 +13,13 @@ import { ExternalLink } from "metabase/common/components/ExternalLink";import { LighthouseIllustration } from "metabase/common/components/LighthouseIllustration";import { LoadingAndErrorWrapper } from "metabase/common/components/LoadingAndErrorWrapper";import { LogoIcon } from "metabase/common/components/LogoIcon";+import { MetabotLogo } from "metabase/common/components/MetabotLogo";import { useSelector } from "metabase/redux";import { useSearchParams } from "metabase/router";import { getLoginPageIllustration } from "metabase/selectors/whitelabel";-import { Button, Center, Stack, Text } from "metabase/ui";+import { Box, Button, Center, Flex, Icon, Stack, Text } from "metabase/ui";-import {- CheckmarkIcon,- LayoutBody,- LayoutCard,- LayoutIllustration,- LayoutRoot,- StyledMetabotLogo,-} from "./Unsubscribe.styled";+import S from "./Unsubscribe.module.css";const ERRORS = {MISSING_REQUIRED_PARAMETERS: "missing required parameters",@@ -140,7 +134,9 @@ function SuccessfulRequestWrapper({}: SubscriptionWrapperProps) {return (<Stack align="center">- <CheckmarkIcon name="check" size={30} />+ <Center bg="background_surface-brand-subtle" p="lg" bdrs="100%">+ <Icon name="check" size={30} c="core-brand" />+ </Center><Text fw={700} c="text-secondary" mb="0.75rem" ta="center">{text}</Text>@@ -226,32 +222,52 @@ function useUnsubscribeRequest({function UnsubscribeRoot({ children }: { children: JSX.Element }) {const loginPageIllustration = useSelector(getLoginPageIllustration);return (- <LayoutRoot>+ <Flex pos="relative" mih="100%" bg="background_page-secondary">{loginPageIllustration &&(loginPageIllustration.isDefault ? (<LighthouseIllustration />) : (- <LayoutIllustration+ <Boxdata-testid="unsubscribe-page-illustration"- backgroundImageSrc={loginPageIllustration.src}+ pos="absolute"+ inset={0}+ bgsz="100% auto"+ bgr="no-repeat"+ bgp="right bottom"+ style={{ backgroundImage: `url("${loginPageIllustration.src}")` }}/>))}- <LayoutBody>+ <Box pos="relative" flex={1}><Center mih={"100%"} miw={"100%"}><Stack><LogoIcon height={65}></LogoIcon>- <LayoutCard>{children}</LayoutCard>+ <Flex+ className={S.shadow}+ direction="column"+ align="center"+ justify="center"+ w={{ base: "100%", sm: "30.875rem" }}+ miw="35rem"+ mih="20rem"+ mt="xl"+ py="xxxl"+ px={{ base: "xl", sm: "3.5rem" }}+ bg="background_page-primary"+ bdrs="xs"+ >+ {children}+ </Flex></Stack></Center>- </LayoutBody>- </LayoutRoot>+ </Box>+ </Flex>);}function ErrorDisplay() {return (<Stack align="center" gap="xxs" aria-label="error message">- <StyledMetabotLogo variant="sad" />+ <MetabotLogo className={S.logo} variant="sad" /><Textfw={700}fz="md"diff --git a/frontend/src/metabase/common/components/UserAvatar/UserAvatar.module.css b/frontend/src/metabase/common/components/UserAvatar/UserAvatar.module.cssnew file mode 100644index 00000000000..d42ce0eb7dd--- /dev/null+++ b/frontend/src/metabase/common/components/UserAvatar/UserAvatar.module.css@@ -0,0 +1,8 @@+/* A class rather than style props, so consumers can override the size */+.avatar {+ width: 3em;+ height: 3em;+ border-radius: 999px;+ background-color: var(--mb-color-core-brand);+ flex-shrink: 0;+}diff --git a/frontend/src/metabase/common/components/UserAvatar/UserAvatar.styled.tsx b/frontend/src/metabase/common/components/UserAvatar/UserAvatar.styled.tsxdeleted file mode 100644index bc88c26bec4..00000000000--- a/frontend/src/metabase/common/components/UserAvatar/UserAvatar.styled.tsx+++ /dev/null@@ -1,26 +0,0 @@-// eslint-disable-next-line eslint-js/no-restricted-imports-import styled from "@emotion/styled";--import { color } from "metabase/ui/utils/colors";--export interface AvatarProps {- color?: string;- height?: string[];- width?: string[];- bg?: string;- className?: string;-}--export const Avatar = styled.div<AvatarProps>`- color: var(--mb-color-text-primary-inverse);- width: 3em;- height: 3em;- display: flex;- justify-content: center;- align-items: center;- border-radius: 999px;- font-weight: 900;- line-height: 1;- background-color: ${({ bg = color("core-brand") }) => bg};- flex-shrink: 0;-`;diff --git a/frontend/src/metabase/common/components/UserAvatar/UserAvatar.tsx b/frontend/src/metabase/common/components/UserAvatar/UserAvatar.tsxindex e06e8651021..c9730967f04 100644--- a/frontend/src/metabase/common/components/UserAvatar/UserAvatar.tsx+++ b/frontend/src/metabase/common/components/UserAvatar/UserAvatar.tsx@@ -1,12 +1,19 @@+import cx from "classnames";+import {type PartialGroup,type PartialTenant,type PartialUser,prepareInitials,} from "metabase/common/utils/user";+import { Center } from "metabase/ui";++import S from "./UserAvatar.module.css";-import type { AvatarProps } from "./UserAvatar.styled";-import { Avatar as StyledAvatar } from "./UserAvatar.styled";+interface AvatarProps {+ bg?: string;+ className?: string;+}interface UserAvatarProps extends AvatarProps {user: PartialUser;@@ -22,7 +29,18 @@ interface TenantProps extends AvatarProps {export function UserAvatar({user,- ...props+ bg,+ className,}: UserAvatarProps | GroupProps | TenantProps) {- return <StyledAvatar {...props}>{prepareInitials(user) || "?"}</StyledAvatar>;+ return (+ <Center+ className={cx(S.avatar, className)}+ c="text-primary-inverse"+ fw={900}+ lh={1}+ style={bg ? { backgroundColor: bg } : undefined}+ >+ {prepareInitials(user) || "?"}+ </Center>+ );}diff --git a/frontend/src/metabase/common/components/upload/UploadInput.tsx b/frontend/src/metabase/common/components/upload/UploadInput.tsxindex fcde5822d62..e5defbba064 100644--- a/frontend/src/metabase/common/components/upload/UploadInput.tsx+++ b/frontend/src/metabase/common/components/upload/UploadInput.tsx@@ -1,12 +1,8 @@-// eslint-disable-next-line eslint-js/no-restricted-imports-import styled from "@emotion/styled";import { type InputHTMLAttributes, forwardRef } from "react";-import { DEFAULT_UPLOAD_INPUT_ID } from "./constants";+import { Box } from "metabase/ui";-const StyledUploadInput = styled.input`- display: none;-`;+import { DEFAULT_UPLOAD_INPUT_ID } from "./constants";interface IUploadInputProps extends InputHTMLAttributes<HTMLInputElement> {id?: string;@@ -18,7 +14,9 @@ export const UploadInput = forwardRef<HTMLInputElement, IUploadInputProps>(ref,) {return (- <StyledUploadInput+ <Box+ component="input"+ display="none"data-testid={id}id={id}ref={ref}