-
-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[account] [docs] Add <Account />
in sidebarFooter
#4255
Changes from 1 commit
38ecc17
7fea561
01c7fa6
49d756a
8098608
6c1c073
f5edc05
43a0978
7277cbf
129b679
f909067
e337ac0
2e321ba
1086869
7938e3f
6807254
c2703a7
884ad56
d76eebf
840362c
c71f5ba
6e34be8
a80df48
882b07b
0b2e4f8
77d8eb7
cb9debf
986298c
eee948a
b93270a
cd6a2a0
81e5304
b94774f
67b83fd
2dc6584
cf1276f
cc743e5
28b71d5
3c01cde
0aff5f9
0363c00
ce95f41
83cd903
96c760c
2ff572d
86fa603
879f7a7
868eb6e
429b3dc
ad12efc
5be7914
637d637
a941719
bdc8e4f
a6b4ba9
1c8523d
7334340
73590d7
07d48a8
4e7fdc8
fcd1025
86a84d9
2a1d6d5
d21ac77
6107c53
58f14d6
3eead4a
4b5f4de
6f1499c
ef3f403
d8fa6be
8603a43
fd826b3
7b86697
299eb7f
81f6346
2aa87b7
64acd1d
5b21e45
01194bc
45f0499
cbe1024
d64ffae
c7949d3
f9a5297
7dd2eb3
1615ae1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import IconButton, { IconButtonProps } from '@mui/material/IconButton'; | |
import MoreVertIcon from '@mui/icons-material/MoreVert'; | ||
import { SessionContext } from '../AppProvider'; | ||
import { useLocaleText } from '../shared/locales/LocaleContext'; | ||
import type { SxProps } from '@mui/material/styles'; | ||
|
||
export type AccountPreviewVariant = 'condensed' | 'expanded'; | ||
|
||
|
@@ -58,6 +59,10 @@ export interface AccountPreviewProps { | |
* @default false | ||
*/ | ||
open?: boolean; | ||
/** | ||
* To override the default `sx` value on the `Stack` component in the "expanded" variant | ||
*/ | ||
sx?: SxProps; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it applies to the expanded variant only? Probably ideally it would apply to any variant to be less confusing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough, we can leave it out for now, adding it will not be a breaking change later |
||
} | ||
|
||
/** | ||
|
@@ -72,7 +77,7 @@ export interface AccountPreviewProps { | |
* - [AccountPreview API](https://mui.com/toolpad/core/api/account-preview) | ||
*/ | ||
function AccountPreview(props: AccountPreviewProps) { | ||
const { slots, variant = 'condensed', slotProps, open, handleClick } = props; | ||
const { slots, variant = 'condensed', slotProps, open, handleClick, sx } = props; | ||
const session = React.useContext(SessionContext); | ||
const localeText = useLocaleText(); | ||
|
||
|
@@ -93,7 +98,7 @@ function AccountPreview(props: AccountPreviewProps) { | |
|
||
if (variant === 'expanded') { | ||
return ( | ||
<Stack direction="row" justifyContent="space-between" spacing={2} padding={2}> | ||
<Stack direction="row" justifyContent="space-between" sx={{ py: 1, px: 2, gap: 2, ...sx }}> | ||
<Stack direction="row" justifyContent="flex-start" spacing={2}> | ||
{avatarContent} | ||
<Stack direction="column" justifyContent="space-evenly"> | ||
|
@@ -113,7 +118,7 @@ function AccountPreview(props: AccountPreviewProps) { | |
size="small" | ||
onClick={handleClick} | ||
{...slotProps?.moreIconButton} | ||
sx={{ alignSelf: 'flex-start', ...slotProps?.moreIconButton?.sx }} | ||
sx={{ alignSelf: 'center', ...slotProps?.moreIconButton?.sx }} | ||
> | ||
<MoreVertIcon fontSize="small" /> | ||
</IconButton> | ||
|
@@ -131,6 +136,7 @@ function AccountPreview(props: AccountPreviewProps) { | |
onClick={handleClick} | ||
aria-label={localeText.iconButtonAriaLabel || 'Current User'} | ||
size="small" | ||
sx={{ width: 'fit-content', margin: '0 auto' }} | ||
aria-controls={open ? 'account-menu' : undefined} | ||
aria-haspopup="true" | ||
aria-expanded={open ? 'true' : undefined} | ||
|
@@ -170,7 +176,17 @@ AccountPreview.propTypes /* remove-proptypes */ = { | |
*/ | ||
slots: PropTypes.shape({ | ||
avatar: PropTypes.elementType, | ||
avatarIconButton: PropTypes.elementType, | ||
moreIconButton: PropTypes.elementType, | ||
}), | ||
/** | ||
* To override the default `sx` value on the `Stack` component in the "expanded" variant | ||
*/ | ||
sx: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), | ||
PropTypes.func, | ||
PropTypes.object, | ||
]), | ||
/** | ||
* The type of account details to display. | ||
* @property {'condensed'} condensed - Shows only the user's avatar. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In these docs demos, opening and closing the popover automatically scrolls unless they have the
disableAutoFocus
prop, maybe we could have that somehow?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find! I've added
disableAutoFocus
as true by default on the Account popover, but overridable by users through theslotProps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'm not 100% sure if we'd need it in a normal app though, maybe it's just a problem in the demo iframes.