Skip to content

Commit 819bd20

Browse files
Merlin218黄锦标
authored andcommitted
refactor(OrganizationSwitch): improve popover content and organization list component
1 parent 4f265e7 commit 819bd20

File tree

5 files changed

+39
-17
lines changed

5 files changed

+39
-17
lines changed

frontend/magic-web/src/opensource/layouts/BaseLayout/components/Sider/components/OrganizationSwitch/OrganizationList.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ interface OrganizationListItemProps {
147147
onClose?: () => void
148148
}
149149

150-
function OrganizationList(props: OrganizationListItemProps) {
150+
function OrganizationListComponent(props: OrganizationListItemProps) {
151151
const { onClose } = props
152152

153153
const { styles, cx } = useOrganizationListStyles()
@@ -235,4 +235,6 @@ function OrganizationList(props: OrganizationListItemProps) {
235235
)
236236
}
237237

238-
export default memo(OrganizationList)
238+
const OrganizationList = memo(OrganizationListComponent)
239+
240+
export default OrganizationList

frontend/magic-web/src/opensource/layouts/BaseLayout/components/Sider/components/OrganizationSwitch/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Popover } from "antd"
55
import type { ReactNode } from "react"
66
import { useState, memo } from "react"
77
import { useStyles } from "./styles"
8-
import OrganizationList from "./OrganizationList"
98

109
interface OrganizationSwitchProps {
1110
className?: string
@@ -47,7 +46,14 @@ const OrganizationSwitch = memo(function OrganizationSwitch({
4746
arrow={false}
4847
trigger={["click"]}
4948
autoAdjustOverflow
50-
content={<ComponentRender componentName="OrganizationList" onClose={() => setOpen(false)} />}
49+
content={
50+
<div className={styles.popoverContent}>
51+
<ComponentRender
52+
componentName="OrganizationList"
53+
onClose={() => setOpen(false)}
54+
/>
55+
</div>
56+
}
5157
>
5258
{ChildrenContent}
5359
</Popover>

frontend/magic-web/src/opensource/layouts/BaseLayout/components/Sider/components/OrganizationSwitch/styles.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { createStyles } from "antd-style"
22

33
export const useStyles = createStyles(({ css, isDarkMode, prefixCls, token }) => {
4+
const backgroundColor = isDarkMode
5+
? token.magicColorScales.grey[0]
6+
: token.magicColorScales.white
47
return {
58
popover: css`
69
.${prefixCls}-popover-inner {
@@ -55,7 +58,11 @@ export const useStyles = createStyles(({ css, isDarkMode, prefixCls, token }) =>
5558
flex-shrink: 0;
5659
5760
&.${prefixCls}-menu-item-danger:hover {
58-
background-color: ${isDarkMode ? token.magicColorUsages.danger.default : token.magicColorScales.red[0]} !important;
61+
background-color: ${
62+
isDarkMode
63+
? token.magicColorUsages.danger.default
64+
: token.magicColorScales.red[0]
65+
} !important;
5966
color: ${isDarkMode ? token.magicColorUsages.white : token.magicColorUsages.danger} !important;
6067
}
6168
}
@@ -76,24 +83,31 @@ export const useStyles = createStyles(({ css, isDarkMode, prefixCls, token }) =>
7683
color: white !important;
7784
border: 1px solid ${token.magicColorUsages.border};
7885
`,
86+
popoverContent: css`
87+
width: 300px;
88+
flex-direction: column;
89+
align-items: flex-start;
90+
gap: 10px;
91+
background-color: ${backgroundColor};
92+
box-shadow: 0 4px 14px 0 rgba(0, 0, 0, 0.1), 0 0 1px 0 rgba(0, 0, 0, 0.3);
93+
border-radius: 8px;
94+
`,
7995
}
8096
})
8197

8298
export const useOrganizationListStyles = createStyles(({ isDarkMode, css, token }) => {
83-
const backgroundColor = isDarkMode ? token.magicColorScales.grey[0] : token.magicColorScales.white
99+
const backgroundColor = isDarkMode
100+
? token.magicColorScales.grey[0]
101+
: token.magicColorScales.white
84102
return {
85103
container: css`
86104
display: flex;
87-
width: 400px;
105+
width: 100%;
88106
padding: 10px 0;
89107
flex-direction: column;
90108
align-items: flex-start;
91109
gap: 10px;
92110
border-radius: 12px;
93-
background-color: ${backgroundColor};
94-
box-shadow:
95-
0 4px 14px 0 rgba(0, 0, 0, 0.1),
96-
0 0 1px 0 rgba(0, 0, 0, 0.3);
97111
overflow: hidden;
98112
`,
99113
scroll: css`
@@ -114,7 +128,7 @@ export const useOrganizationListStyles = createStyles(({ isDarkMode, css, token
114128
groupHeader: css`
115129
position: relative;
116130
background-color: ${backgroundColor};
117-
131+
118132
&:before {
119133
content: "";
120134
position: absolute;

frontend/magic-web/src/opensource/pages/login/AccountModal/AccountModal.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Form, Modal, message } from "antd"
1+
import { Form, message } from "antd"
22
import { useMemoizedFn } from "ahooks"
33
import type { Login } from "@/types/login"
44
import { LoginFormValuesMap, OnSubmitFn } from "@/opensource/pages/login/types"
@@ -14,6 +14,7 @@ import MobilePhonePasswordForm from "../components/MobilePhonePasswordForm"
1414
import Footer from "../components/Footer"
1515
import { useUserAgreedPolicy } from "../hooks/useUserAgreedPolicy"
1616
import MagicSpin from "@/opensource/components/base/MagicSpin"
17+
import MagicModal from "@/opensource/components/base/MagicModal"
1718

1819
interface AccountModalProps {
1920
onClose: () => void
@@ -85,7 +86,7 @@ function AccountModal(props: AccountModalProps) {
8586
const dom = <div className={styles.header}>{t("account.create")}</div>
8687

8788
return (
88-
<Modal
89+
<MagicModal
8990
title={dom}
9091
footer={null}
9192
open={open}
@@ -107,7 +108,7 @@ function AccountModal(props: AccountModalProps) {
107108
<Footer agree={agree} onAgreeChange={setAgree} tipVisible />
108109
</div>
109110
</MagicSpin>
110-
</Modal>
111+
</MagicModal>
111112
)
112113
}
113114

frontend/magic-web/src/opensource/pages/login/AccountModal/styles.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export const useStyles = createStyles(({ css, prefixCls }) => {
88
}
99
`,
1010
modalHeader: css`
11-
padding: 20px 24px 0 24px !important;
1211
display: flex;
1312
align-items: center;
1413
`,
@@ -21,7 +20,7 @@ export const useStyles = createStyles(({ css, prefixCls }) => {
2120
layout: css`
2221
width: 100%;
2322
height: 100%;
24-
padding: 40px;
23+
padding: 20px 10px;
2524
`,
2625
header: css`
2726
width: 100%;

0 commit comments

Comments
 (0)