-
-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Polish
SignInPage
and docs (#3935)
- Loading branch information
1 parent
1bf3d97
commit a684350
Showing
13 changed files
with
330 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
docs/data/toolpad/core/components/sign-in-page/ThemeSignInPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as React from 'react'; | ||
import { AppProvider, SignInPage } from '@toolpad/core'; | ||
import { createTheme } from '@mui/material/styles'; | ||
import { useColorSchemeShim } from 'docs/src/modules/components/ThemeContext'; | ||
import { getDesignTokens } from './brandingTheme'; | ||
|
||
const providers = [ | ||
{ id: 'github', name: 'GitHub' }, | ||
{ id: 'google', name: 'Google' }, | ||
{ id: 'credentials', name: 'Email and Password' }, | ||
]; | ||
|
||
const signIn = async (provider) => { | ||
const promise = new Promise((resolve) => { | ||
setTimeout(() => { | ||
console.log(`Sign in with ${provider.id}`); | ||
resolve(); | ||
}, 500); | ||
}); | ||
return promise; | ||
}; | ||
|
||
export default function ThemeSignInPage() { | ||
const { mode, systemMode } = useColorSchemeShim(); | ||
const calculatedMode = (mode === 'system' ? systemMode : mode) ?? 'light'; | ||
const brandingDesignTokens = getDesignTokens(calculatedMode); | ||
// preview-start | ||
const THEME = createTheme({ | ||
...brandingDesignTokens, | ||
palette: { | ||
...brandingDesignTokens.palette, | ||
mode: calculatedMode, | ||
}, | ||
}); | ||
// preview-end | ||
|
||
return ( | ||
// preview-start | ||
<AppProvider theme={THEME}> | ||
<SignInPage signIn={signIn} providers={providers} /> | ||
</AppProvider> | ||
// preview-end | ||
); | ||
} |
44 changes: 44 additions & 0 deletions
44
docs/data/toolpad/core/components/sign-in-page/ThemeSignInPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as React from 'react'; | ||
import { AuthProvider, AppProvider, SignInPage } from '@toolpad/core'; | ||
import { createTheme } from '@mui/material/styles'; | ||
import { useColorSchemeShim } from 'docs/src/modules/components/ThemeContext'; | ||
import { getDesignTokens } from './brandingTheme'; | ||
|
||
const providers = [ | ||
{ id: 'github', name: 'GitHub' }, | ||
{ id: 'google', name: 'Google' }, | ||
{ id: 'credentials', name: 'Email and Password' }, | ||
]; | ||
|
||
const signIn: (provider: AuthProvider) => void = async (provider) => { | ||
const promise = new Promise<void>((resolve) => { | ||
setTimeout(() => { | ||
console.log(`Sign in with ${provider.id}`); | ||
resolve(); | ||
}, 500); | ||
}); | ||
return promise; | ||
}; | ||
|
||
export default function ThemeSignInPage() { | ||
const { mode, systemMode } = useColorSchemeShim(); | ||
const calculatedMode = (mode === 'system' ? systemMode : mode) ?? 'light'; | ||
const brandingDesignTokens = getDesignTokens(calculatedMode); | ||
// preview-start | ||
const THEME = createTheme({ | ||
...brandingDesignTokens, | ||
palette: { | ||
...brandingDesignTokens.palette, | ||
mode: calculatedMode, | ||
}, | ||
}); | ||
// preview-end | ||
|
||
return ( | ||
// preview-start | ||
<AppProvider theme={THEME}> | ||
<SignInPage signIn={signIn} providers={providers} /> | ||
</AppProvider> | ||
// preview-end | ||
); | ||
} |
13 changes: 13 additions & 0 deletions
13
docs/data/toolpad/core/components/sign-in-page/ThemeSignInPage.tsx.preview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const THEME = createTheme({ | ||
...brandingDesignTokens, | ||
palette: { | ||
...brandingDesignTokens.palette, | ||
mode: calculatedMode, | ||
}, | ||
}); | ||
|
||
// ... | ||
|
||
<AppProvider theme={THEME}> | ||
<SignInPage signIn={signIn} providers={providers} /> | ||
</AppProvider> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.