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

[docs] Add signed in state as default on <Account /> docs #3970

Merged
merged 16 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
18 changes: 10 additions & 8 deletions docs/data/toolpad/core/components/account/AccountDemo.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import * as React from 'react';
import { Account, AuthenticationContext, SessionContext } from '@toolpad/core';

const demoSession = {
user: {
name: 'Bharat Kashyap',
email: '[email protected]',
image: 'https://avatars.githubusercontent.com/u/19550456',
},
};

export default function AccountDemo() {
const [session, setSession] = React.useState(null);
const [session, setSession] = React.useState(demoSession);
const authentication = React.useMemo(() => {
return {
signIn: () => {
setSession({
user: {
name: 'Bharat Kashyap',
email: '[email protected]',
image: 'https://avatars.githubusercontent.com/u/19550456',
},
});
setSession(demoSession);
},
signOut: () => {
setSession(null);
Expand Down
18 changes: 10 additions & 8 deletions docs/data/toolpad/core/components/account/AccountDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ import {
Session,
} from '@toolpad/core';

const demoSession = {
user: {
name: 'Bharat Kashyap',
email: '[email protected]',
image: 'https://avatars.githubusercontent.com/u/19550456',
},
};

export default function AccountDemo() {
const [session, setSession] = React.useState<Session | null>(null);
const [session, setSession] = React.useState<Session | null>(demoSession);
const authentication = React.useMemo(() => {
return {
signIn: () => {
setSession({
user: {
name: 'Bharat Kashyap',
email: '[email protected]',
image: 'https://avatars.githubusercontent.com/u/19550456',
},
});
setSession(demoSession);
},
signOut: () => {
setSession(null);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/toolpad/core/components/account/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The `Account` component is a quick and easy way to display an account management

## States

When signed out, the component renders as an inline sign in button within the dashboard layout. If a `session` object is present, the component is rendered as a dropdown containing the user's account details as well as an option to sign out.
If a `session` object is present, the component is rendered as a dropdown containing the user's account details as well as an option to sign out. When signed out, the component renders as an inline sign in button within the dashboard layout.

{{"demo": "AccountDemo.js", "bg": "gradient" }}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"prettier": "pretty-quick --ignore-path .eslintignore",
"prettier:all": "prettier --write . --ignore-path .eslintignore",
"dev": "dotenv cross-env FORCE_COLOR=1 lerna -- run dev --stream --parallel --ignore docs --ignore playground-nextjs --ignore playground-nextjs-pages",
"docs:dev": "pnpm --filter docs dev",
"docs:dev": "./pre-docs-dev.sh && pnpm --filter docs dev",
"docs:build": "pnpm --filter docs build",
"docs:build:api:core": "tsx --tsconfig ./scripts/tsconfig.json ./scripts/docs/buildCoreApiDocs/index.ts",
"docs:build:api:studio": "tsx --tsconfig ./scripts/tsconfig.json ./scripts/docs/buildStudioApi.ts",
Expand Down
11 changes: 11 additions & 0 deletions pre-docs-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

changed_files=$(git diff --name-only HEAD | grep 'docs/data/toolpad/core/.*\.tsx$')

if [ -n "$changed_files" ]
then
echo "Changes detected in .tsx files. Running 'pnpm docs:typescript:formatted'..."
pnpm docs:typescript:formatted
else
echo "No changes detected in .tsx files."
fi
Loading