Skip to content

Commit

Permalink
[account] New slots and sub-components (#4181)
Browse files Browse the repository at this point in the history
  • Loading branch information
bharatkashyap authored Oct 18, 2024
1 parent cb458c2 commit 45d2188
Show file tree
Hide file tree
Showing 52 changed files with 2,761 additions and 750 deletions.
127 changes: 0 additions & 127 deletions docs/data/toolpad/core/components/account/AccountCustom.js

This file was deleted.

133 changes: 0 additions & 133 deletions docs/data/toolpad/core/components/account/AccountCustom.tsx

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as React from 'react';
import { AuthenticationContext, SessionContext } from '@toolpad/core/AppProvider';
import { Account } from '@toolpad/core/Account';

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

export default function AccountCustomLocaleText() {
const [session, setSession] = React.useState(demoSession);

const authentication = React.useMemo(() => {
return {
signIn: () => {
setSession({
user: {
name: 'Bharat Kashyap',
email: 'bharatkashyap@outlook.com',
image: 'https://avatars.githubusercontent.com/u/19550456',
},
});
},
signOut: () => {
setSession(null);
},
};
}, []);

return (
<AuthenticationContext.Provider value={authentication}>
<SessionContext.Provider value={session}>
{/* preview-start */}
<Account
localeText={{
signInLabel: 'लॉग इन',
signOutLabel: 'लॉग आउट',
}}
/>
{/* preview-end */}
</SessionContext.Provider>
</AuthenticationContext.Provider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import * as React from 'react';
import {
AuthenticationContext,
Session,
SessionContext,
} from '@toolpad/core/AppProvider';
import { Account } from '@toolpad/core/Account';

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

export default function AccountCustomLocaleText() {
const [session, setSession] = React.useState<Session | null>(demoSession);

const authentication = React.useMemo(() => {
return {
signIn: () => {
setSession({
user: {
name: 'Bharat Kashyap',
email: 'bharatkashyap@outlook.com',
image: 'https://avatars.githubusercontent.com/u/19550456',
},
});
},
signOut: () => {
setSession(null);
},
};
}, []);

return (
<AuthenticationContext.Provider value={authentication}>
<SessionContext.Provider value={session}>
{/* preview-start */}
<Account
localeText={{
signInLabel: 'लॉग इन',
signOutLabel: 'लॉग आउट',
}}
/>
{/* preview-end */}
</SessionContext.Provider>
</AuthenticationContext.Provider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Account
localeText={{
signInLabel: 'लॉग इन',
signOutLabel: 'लॉग आउट',
}}
/>
Loading

0 comments on commit 45d2188

Please sign in to comment.