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 AccountHeader and AccountLayout from Emotion to Mantine (#73423)
Andrei Chernykh576bea93e639
diff --git a/frontend/src/metabase/account/app/components/AccountHeader/AccountHeader.module.css b/frontend/src/metabase/account/app/components/AccountHeader/AccountHeader.module.cssnew file mode 100644index 00000000000..c97860cf08b--- /dev/null+++ b/frontend/src/metabase/account/app/components/AccountHeader/AccountHeader.module.css@@ -0,0 +1,23 @@+.root {+ border-bottom: 1px solid var(--mb-color-border);+}++/* Doubled selector for higher specificity to override the inner styled UserAvatar */+.avatar.avatar {+ width: 3em;+ height: 3em;+}++@media (--breakpoint-min-sm) {+ .avatar.avatar {+ width: 4em;+ height: 4em;+ }+}++@media (--breakpoint-min-md) {+ .avatar.avatar {+ width: 5em;+ height: 5em;+ }+}diff --git a/frontend/src/metabase/account/app/components/AccountHeader/AccountHeader.styled.tsx b/frontend/src/metabase/account/app/components/AccountHeader/AccountHeader.styled.tsxdeleted file mode 100644index a9efad5bb83..00000000000--- a/frontend/src/metabase/account/app/components/AccountHeader/AccountHeader.styled.tsx+++ /dev/null@@ -1,61 +0,0 @@-// eslint-disable-next-line no-restricted-imports-import styled from "@emotion/styled";--import { UserAvatar } from "metabase/common/components/UserAvatar";-import {- breakpointMinMedium,- breakpointMinSmall,-} from "metabase/styled-components/theme";--export const AccountHeaderRoot = styled.div`- display: flex;- flex-direction: column;- justify-content: center;- align-items: center;- padding-top: var(--mantine-spacing-sm);- border-bottom: 1px solid var(--mb-color-border);- background-color: var(--mb-color-background-primary);-- ${breakpointMinSmall} {- padding-top: var(--mantine-spacing-md);- }-`;--export const HeaderSection = styled.div`- display: flex;- flex-direction: column;- align-items: center;- padding: var(--mantine-spacing-md);-- ${breakpointMinMedium} {- padding: 4rem;- }-`;--export const HeaderTitle = styled.h2`- font-size: 1rem;- text-align: center;- margin-bottom: var(--mantine-spacing-xs);-`;--export const HeaderSubtitle = styled.h3`- text-align: center;- color: var(--mb-color-text-secondary);-`;--export const HeaderAvatar = styled(UserAvatar)`- width: 3em;- height: 3em;- margin-bottom: var(--mantine-spacing-sm);-- ${breakpointMinSmall} {- width: 4em;- height: 4em;- margin-bottom: var(--mantine-spacing-md);- }-- ${breakpointMinMedium} {- width: 5em;- height: 5em;- }-`;diff --git a/frontend/src/metabase/account/app/components/AccountHeader/AccountHeader.tsx b/frontend/src/metabase/account/app/components/AccountHeader/AccountHeader.tsxindex 618c7946cf3..06a2b6e9558 100644--- a/frontend/src/metabase/account/app/components/AccountHeader/AccountHeader.tsx+++ b/frontend/src/metabase/account/app/components/AccountHeader/AccountHeader.tsx@@ -3,17 +3,13 @@ import { useMemo } from "react";import { t } from "ttag";import { Radio } from "metabase/common/components/Radio";+import { UserAvatar } from "metabase/common/components/UserAvatar";import { PLUGIN_IS_PASSWORD_USER } from "metabase/plugins";+import { Box, Flex, Title, rem } from "metabase/ui";import { getFullName } from "metabase/utils/user";import type { User } from "metabase-types/api";-import {- AccountHeaderRoot,- HeaderAvatar,- HeaderSection,- HeaderSubtitle,- HeaderTitle,-} from "./AccountHeader.styled";+import S from "./AccountHeader.module.css";type AccountHeaderProps = {user: User;@@ -46,18 +42,34 @@ export const AccountHeader = ({const userFullName = getFullName(user);return (- <AccountHeaderRoot data-testid="account-header">- <HeaderSection>- <HeaderAvatar user={user} />- {userFullName && <HeaderTitle>{userFullName}</HeaderTitle>}- <HeaderSubtitle>{user.email}</HeaderSubtitle>- </HeaderSection>+ <Flex+ className={S.root}+ data-testid="account-header"+ direction="column"+ justify="center"+ align="center"+ bg="background-primary"+ pt={{ base: "sm", sm: "md" }}+ >+ <Flex direction="column" align="center" p={{ base: "md", md: rem(64) }}>+ <Box mb={{ base: "sm", sm: "md" }}>+ <UserAvatar user={user} className={S.avatar} />+ </Box>+ {userFullName && (+ <Title order={2} fz="md" ta="center" mb="xs">+ {userFullName}+ </Title>+ )}+ <Title order={3} fz="md" fw="normal" ta="center" c="text-secondary">+ {user.email}+ </Title>+ </Flex><Radiovalue={path}variant="underlined"options={tabs}onChange={onChangeLocation}/>- </AccountHeaderRoot>+ </Flex>);};diff --git a/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.styled.tsx b/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.styled.tsxdeleted file mode 100644index 7a887dc65e4..00000000000--- a/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.styled.tsx+++ /dev/null@@ -1,14 +0,0 @@-// eslint-disable-next-line no-restricted-imports-import styled from "@emotion/styled";--import { breakpointMinSmall } from "metabase/styled-components/theme";--export const AccountContent = styled.div`- margin: 0 auto;- padding: var(--mantine-spacing-sm);-- ${breakpointMinSmall} {- width: 540px;- padding: var(--mantine-spacing-xl) var(--mantine-spacing-md);- }-`;diff --git a/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.tsx b/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.tsxindex c0ba0993bb7..a8585b38876 100644--- a/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.tsx+++ b/frontend/src/metabase/account/app/components/AccountLayout/AccountLayout.tsx@@ -1,12 +1,11 @@import type { Path } from "history";import type { ReactNode } from "react";+import { Box, rem } from "metabase/ui";import type { User } from "metabase-types/api";import { AccountHeader } from "../AccountHeader";-import { AccountContent } from "./AccountLayout.styled";-interface AccountLayoutProps {user: User | null;path?: string;@@ -31,7 +30,14 @@ const AccountLayout = ({path={path}onChangeLocation={onChangeLocation}/>- <AccountContent>{children}</AccountContent>+ <Box+ mx="auto"+ px={{ base: "sm", sm: "md" }}+ py={{ base: "sm", sm: "xl" }}+ w={{ base: "100%", sm: rem(540) }}+ >+ {children}+ </Box></div>);};diff --git a/frontend/src/metabase/common/components/UserAvatar/UserAvatar.styled.tsx b/frontend/src/metabase/common/components/UserAvatar/UserAvatar.styled.tsxindex 35384788567..dc6e2bf1b8b 100644--- a/frontend/src/metabase/common/components/UserAvatar/UserAvatar.styled.tsx+++ b/frontend/src/metabase/common/components/UserAvatar/UserAvatar.styled.tsx@@ -8,6 +8,7 @@ export interface AvatarProps {height?: string[];width?: string[];bg?: string;+ className?: string;}export const Avatar = styled.div<AvatarProps>`