Skip to content
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] New slots and sub-components #4181

Merged
merged 38 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1086869
fix: CI
bharatkashyap Oct 3, 2024
7938e3f
fix: WIP `menuItems` -> `content`
bharatkashyap Oct 3, 2024
6807254
wip: Move demos over
bharatkashyap Oct 3, 2024
c2703a7
fix: Move demos to new API
bharatkashyap Oct 3, 2024
884ad56
wip: Better account switcher
bharatkashyap Oct 7, 2024
d76eebf
fix: CI
bharatkashyap Oct 7, 2024
840362c
Merge branch 'master' into enh/account-3
bharatkashyap Oct 7, 2024
c71f5ba
fix: Complete better account switcher
bharatkashyap Oct 7, 2024
6e34be8
fix: CI
bharatkashyap Oct 7, 2024
0b2e4f8
Merge branch 'master' into enh/account-3
bharatkashyap Oct 7, 2024
77d8eb7
Merge branch 'master' of github.com:mui/mui-toolpad into enh/account-3
bharatkashyap Oct 8, 2024
cb9debf
fix: Redesign solution
bharatkashyap Oct 9, 2024
986298c
fix: CI
bharatkashyap Oct 9, 2024
eee948a
Merge branch 'master' of github.com:mui/mui-toolpad into enh/account-3
bharatkashyap Oct 9, 2024
b93270a
fix: CI
bharatkashyap Oct 9, 2024
cd6a2a0
fix: missed
bharatkashyap Oct 9, 2024
81e5304
Merge branch 'master' of github.com:mui/mui-toolpad into enh/account-3
bharatkashyap Oct 10, 2024
b94774f
Merge branch 'master' of github.com:mui/mui-toolpad into enh/account-3
bharatkashyap Oct 13, 2024
2dc6584
fix: Simplify docs
bharatkashyap Oct 13, 2024
cf1276f
fix: Add test
bharatkashyap Oct 13, 2024
0aff5f9
fix: Move `Divider` out of `AccountDetails`
bharatkashyap Oct 13, 2024
0363c00
fix: Remove `Divider` from `AccountDetails`
bharatkashyap Oct 13, 2024
2ff572d
fix: Move `AccountDetails` into separate component and `slots`
bharatkashyap Oct 13, 2024
429b3dc
fix: Move to completely new component architecture
bharatkashyap Oct 17, 2024
ad12efc
Merge branch 'master' into enh/account-3
bharatkashyap Oct 17, 2024
5be7914
fix: CI
bharatkashyap Oct 17, 2024
637d637
fix: update test, CI
bharatkashyap Oct 17, 2024
a941719
Merge branch 'enh/account-3' of github.com:bharatkashyap/mui-toolpad …
bharatkashyap Oct 17, 2024
bdc8e4f
fix: Pedro review
bharatkashyap Oct 17, 2024
a6b4ba9
Merge branch 'master' of github.com:mui/mui-toolpad into enh/account-3
bharatkashyap Oct 17, 2024
1c8523d
fix: Pedro review
bharatkashyap Oct 17, 2024
7334340
fix: missed
bharatkashyap Oct 17, 2024
9f3ae90
fix: App router support
bharatkashyap Oct 18, 2024
b95b1cf
fix: CI
bharatkashyap Oct 18, 2024
18b0f3a
fix: Jan, Pedro review, CI
bharatkashyap Oct 18, 2024
5d981b8
Merge branch 'master' into enh/account-3
bharatkashyap Oct 18, 2024
ae9d39d
fix: simplify
bharatkashyap Oct 18, 2024
42c97d5
fix: CI
bharatkashyap Oct 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { Account, AuthenticationContext, SessionContext } from '@toolpad/core';
import CustomMenuItems from './CustomMenu';
import CustomMenu from './CustomMenu';

const demoSession = {
user: {
Expand All @@ -10,7 +10,7 @@ const demoSession = {
},
};

export default function AccountSlots() {
export default function AccountSlotsAccountSwitcher() {
const [session, setSession] = React.useState(demoSession);
const authentication = React.useMemo(() => {
return {
Expand All @@ -28,7 +28,7 @@ export default function AccountSlots() {
<SessionContext.Provider value={session}>
<Account
slots={{
menuItems: CustomMenuItems,
content: CustomMenu,
}}
/>
</SessionContext.Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
SessionContext,
Session,
} from '@toolpad/core';
import CustomMenuItems from './CustomMenu';
import CustomMenu from './CustomMenu';

const demoSession = {
user: {
Expand All @@ -15,7 +15,7 @@ const demoSession = {
},
};

export default function AccountSlots() {
export default function AccountSlotsAccountSwitcher() {
const [session, setSession] = React.useState<Session | null>(demoSession);
const authentication = React.useMemo(() => {
return {
Expand All @@ -33,7 +33,7 @@ export default function AccountSlots() {
<SessionContext.Provider value={session}>
<Account
slots={{
menuItems: CustomMenuItems,
content: CustomMenu,
}}
/>
</SessionContext.Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<SessionContext.Provider value={session}>
<Account
slots={{
menuItems: CustomMenuItems,
content: CustomMenu,
}}
/>
</SessionContext.Provider>
Expand Down
114 changes: 114 additions & 0 deletions docs/data/toolpad/core/components/account/AccountSlotsInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import * as React from 'react';
import {
Avatar,
Button,
Divider,
Typography,
Stack,
IconButton,
} from '@mui/material';
import WalletIcon from '@mui/icons-material/AccountBalance';
import SendIcon from '@mui/icons-material/Send';
import ShoppingCart from '@mui/icons-material/ShoppingCart';
import CopyIcon from '@mui/icons-material/ContentCopy';

import { Account, AuthenticationContext, SessionContext } from '@toolpad/core';

const demoSession = {
user: {
name: 'Bharat Kashyap',
email: 'bharatkashyap@outlook.com',
image: 'https://avatars.githubusercontent.com/u/19550456',
},
};

const mockData = {
address: '0x1234...5678',
balance: '1,234.56 ETH',
usdBalance: '$2,345,678.90 USD',
};

function CryptoWalletInfo() {
return (
<div>
<Stack spacing={2} sx={{ width: 300, p: 2 }}>
<Stack direction="row" spacing={2} alignItems="center">
<Avatar sx={{ bgcolor: 'primary.main' }}>
<WalletIcon />
</Avatar>
<Stack>
<Typography
variant="subtitle1"
fontWeight="bold"
sx={{ display: 'flex', alignItems: 'center' }}
>
{mockData.address}
<IconButton size="small" sx={{ ml: 1 }}>
<CopyIcon fontSize="small" />
</IconButton>
</Typography>
<Typography variant="body2" color="text.secondary">
Main Account
</Typography>
</Stack>
</Stack>
<Divider />
<Stack>
<Typography variant="h6" fontWeight="bold">
{mockData.balance}
</Typography>
<Typography variant="body2" color="text.secondary">
{mockData.usdBalance}
</Typography>
</Stack>

<Stack direction="row" spacing={2}>
<Button
variant="contained"
fullWidth
disableElevation
color="primary"
startIcon={<SendIcon />}
>
Send
</Button>
<Button
variant="outlined"
fullWidth
disableElevation
startIcon={<ShoppingCart />}
>
Buy
</Button>
</Stack>
</Stack>
<Divider />
</div>
);
}

export default function AccountSlotsInfo() {
const [session, setSession] = React.useState(demoSession);
const authentication = React.useMemo(() => {
return {
signIn: () => {
setSession(demoSession);
},
signOut: () => {
setSession(null);
},
};
}, []);

return (
<AuthenticationContext.Provider value={authentication}>
<SessionContext.Provider value={session}>
<Account
slots={{
content: CryptoWalletInfo,
}}
/>
</SessionContext.Provider>
</AuthenticationContext.Provider>
);
}
119 changes: 119 additions & 0 deletions docs/data/toolpad/core/components/account/AccountSlotsInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import * as React from 'react';
import {
Avatar,
Button,
Divider,
Typography,
Stack,
IconButton,
} from '@mui/material';
import WalletIcon from '@mui/icons-material/AccountBalance';
import SendIcon from '@mui/icons-material/Send';
import ShoppingCart from '@mui/icons-material/ShoppingCart';
import CopyIcon from '@mui/icons-material/ContentCopy';

import {
Account,
AuthenticationContext,
SessionContext,
Session,
} from '@toolpad/core';

const demoSession = {
user: {
name: 'Bharat Kashyap',
email: 'bharatkashyap@outlook.com',
image: 'https://avatars.githubusercontent.com/u/19550456',
},
};

const mockData = {
address: '0x1234...5678',
bharatkashyap marked this conversation as resolved.
Show resolved Hide resolved
balance: '1,234.56 ETH',
usdBalance: '$2,345,678.90 USD',
};

function CryptoWalletInfo() {
return (
<div>
<Stack spacing={2} sx={{ width: 300, p: 2 }}>
<Stack direction="row" spacing={2} alignItems="center">
<Avatar sx={{ bgcolor: 'primary.main' }}>
<WalletIcon />
</Avatar>
<Stack>
<Typography
variant="subtitle1"
fontWeight="bold"
sx={{ display: 'flex', alignItems: 'center' }}
>
{mockData.address}
<IconButton size="small" sx={{ ml: 1 }}>
<CopyIcon fontSize="small" />
</IconButton>
</Typography>
<Typography variant="body2" color="text.secondary">
Main Account
</Typography>
</Stack>
</Stack>
<Divider />
<Stack>
<Typography variant="h6" fontWeight="bold">
{mockData.balance}
</Typography>
<Typography variant="body2" color="text.secondary">
{mockData.usdBalance}
</Typography>
</Stack>

<Stack direction="row" spacing={2}>
<Button
variant="contained"
fullWidth
disableElevation
color="primary"
startIcon={<SendIcon />}
>
Send
</Button>
<Button
variant="outlined"
fullWidth
disableElevation
startIcon={<ShoppingCart />}
>
Buy
</Button>
</Stack>
</Stack>
<Divider />
</div>
);
}

export default function AccountSlotsInfo() {
const [session, setSession] = React.useState<Session | null>(demoSession);
const authentication = React.useMemo(() => {
return {
signIn: () => {
setSession(demoSession);
},
signOut: () => {
setSession(null);
},
};
}, []);

return (
<AuthenticationContext.Provider value={authentication}>
<SessionContext.Provider value={session}>
<Account
slots={{
content: CryptoWalletInfo,
}}
/>
</SessionContext.Provider>
</AuthenticationContext.Provider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<AuthenticationContext.Provider value={authentication}>
<SessionContext.Provider value={session}>
<Account
slots={{
content: CryptoWalletInfo,
}}
/>
</SessionContext.Provider>
</AuthenticationContext.Provider>
Loading
Loading