Skip to content

Commit

Permalink
fix: Docs for SignInPage, misc examples fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bharatkashyap committed Nov 12, 2024
1 parent 41fadd9 commit b4e00a0
Show file tree
Hide file tree
Showing 19 changed files with 1,222 additions and 539 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import { AppProvider } from '@toolpad/core/AppProvider';
import { SignInPage, type AuthProvider } from '@toolpad/core/SignInPage';
import { useTheme } from '@mui/material/styles';

const providers = [
{ id: 'github', name: 'GitHub' },
{ id: 'google', name: 'Google' },
];
const providers = [{ id: 'credentials', name: 'Credentials' }];
// preview-start
const BRANDING = {
logo: (
Expand Down
19 changes: 17 additions & 2 deletions docs/data/toolpad/core/components/sign-in-page/SlotsSignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
TextField,
InputAdornment,
Link,
Alert,
IconButton,
} from '@mui/material';
import AccountCircle from '@mui/icons-material/AccountCircle';
Expand Down Expand Up @@ -95,7 +96,7 @@ function CustomButton() {
fullWidth
sx={{ my: 2 }}
>
Sign In
Log In
</Button>
);
}
Expand All @@ -116,17 +117,31 @@ function ForgotPasswordLink() {
);
}

function Title() {
return <h2 style={{ marginBottom: 8 }}>Login</h2>;
}

function Subtitle() {
return (
<Alert sx={{ mb: 2, px: 1, py: 0.25 }} severity="warning">
We are investigating an ongoing outage.
</Alert>
);
}

export default function SlotsSignIn() {
const theme = useTheme();
return (
<AppProvider theme={theme}>
<SignInPage
signIn={(provider, formData) =>
alert(
`Signing in with "${provider.name}" and credentials: ${formData.get('email')}, ${formData.get('password')}`,
`Logging in with "${provider.name}" and credentials: ${formData.get('email')}, ${formData.get('password')}`,
)
}
slots={{
title: Title,
subtitle: Subtitle,
emailField: CustomEmailField,
passwordField: CustomPasswordField,
submitButton: CustomButton,
Expand Down
19 changes: 17 additions & 2 deletions docs/data/toolpad/core/components/sign-in-page/SlotsSignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
TextField,
InputAdornment,
Link,
Alert,
IconButton,
} from '@mui/material';
import AccountCircle from '@mui/icons-material/AccountCircle';
Expand Down Expand Up @@ -95,7 +96,7 @@ function CustomButton() {
fullWidth
sx={{ my: 2 }}
>
Sign In
Log In
</Button>
);
}
Expand All @@ -116,17 +117,31 @@ function ForgotPasswordLink() {
);
}

function Title() {
return <h2 style={{ marginBottom: 8 }}>Login</h2>;
}

function Subtitle() {
return (
<Alert sx={{ mb: 2, px: 1, py: 0.25 }} severity="warning">
We are investigating an ongoing outage.
</Alert>
);
}

export default function SlotsSignIn() {
const theme = useTheme();
return (
<AppProvider theme={theme}>
<SignInPage
signIn={(provider, formData) =>
alert(
`Signing in with "${provider.name}" and credentials: ${formData.get('email')}, ${formData.get('password')}`,
`Logging in with "${provider.name}" and credentials: ${formData.get('email')}, ${formData.get('password')}`,
)
}
slots={{
title: Title,
subtitle: Subtitle,
emailField: CustomEmailField,
passwordField: CustomPasswordField,
submitButton: CustomButton,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AppProvider } from '@toolpad/core/AppProvider';
import { SignInPage } from '@toolpad/core/SignInPage';
import { createTheme } from '@mui/material/styles';
import { useColorSchemeShim } from 'docs/src/modules/components/ThemeContext';
import { getDesignTokens } from './brandingTheme';
import { getDesignTokens, inputsCustomizations } from './customTheme';

const providers = [
{ id: 'github', name: 'GitHub' },
Expand Down Expand Up @@ -32,6 +32,9 @@ export default function ThemeSignInPage() {
...brandingDesignTokens.palette,
mode: calculatedMode,
},
components: {
...inputsCustomizations,
},
});
// preview-end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AppProvider } from '@toolpad/core/AppProvider';
import { SignInPage, type AuthProvider } from '@toolpad/core/SignInPage';
import { createTheme } from '@mui/material/styles';
import { useColorSchemeShim } from 'docs/src/modules/components/ThemeContext';
import { getDesignTokens } from './brandingTheme';
import { getDesignTokens, inputsCustomizations } from './customTheme';

const providers = [
{ id: 'github', name: 'GitHub' },
Expand Down Expand Up @@ -32,6 +32,9 @@ export default function ThemeSignInPage() {
...brandingDesignTokens.palette,
mode: calculatedMode,
},
components: {
...inputsCustomizations,
},
});
// preview-end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const THEME = createTheme({
...brandingDesignTokens.palette,
mode: calculatedMode,
},
components: {
...inputsCustomizations,
},
});

// ...
Expand Down
Loading

0 comments on commit b4e00a0

Please sign in to comment.