Stack Demo
diff --git a/packages/stack/src/components-page/account-settings.tsx b/packages/stack/src/components-page/account-settings.tsx
index 6147b4629..935cba3ad 100644
--- a/packages/stack/src/components-page/account-settings.tsx
+++ b/packages/stack/src/components-page/account-settings.tsx
@@ -7,8 +7,8 @@ import { yupObject, yupString } from '@stackframe/stack-shared/dist/schema-field
import { generateRandomValues } from '@stackframe/stack-shared/dist/utils/crypto';
import { throwErr } from '@stackframe/stack-shared/dist/utils/errors';
import { runAsynchronously, runAsynchronouslyWithAlert } from '@stackframe/stack-shared/dist/utils/promises';
-import { Button, Container, EditableText, Input, Label, PasswordInput, SimpleTooltip, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Typography } from '@stackframe/stack-ui';
-import { CirclePlus, Contact, Settings, ShieldCheck } from 'lucide-react';
+import { Button, EditableText, Input, Label, PasswordInput, SimpleTooltip, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Typography } from '@stackframe/stack-ui';
+import { CirclePlus, Contact, LogOut, ShieldCheck } from 'lucide-react';
import { TOTPController, createTOTPKeyURI } from "oslo/otp";
import * as QRCode from 'qrcode';
import { useEffect, useState } from 'react';
@@ -16,6 +16,7 @@ import { useForm } from 'react-hook-form';
import * as yup from "yup";
import { CurrentUser, MessageCard, Project, Team, useStackApp, useUser } from '..';
import { FormWarningText } from '../components/elements/form-warning';
+import { MaybeFullPage } from "../components/elements/maybe-full-page";
import { SidebarLayout } from '../components/elements/sidebar-layout';
import { UserAvatar } from '../components/elements/user-avatar';
import { TeamIcon } from '../components/team-icon';
@@ -49,10 +50,10 @@ export function AccountSettings({ fullPage=false }: { fullPage?: boolean }) {
),
},
{
- title: 'Settings',
- subpath: '/settings',
+ title: 'Sign Out',
+ subpath: '/sign-out',
type: 'item',
- icon: Settings,
+ icon: LogOut,
content:
,
},
...(teams.length > 0 || project.config.clientTeamCreationEnabled) ? [{
@@ -88,15 +89,11 @@ export function AccountSettings({ fullPage=false }: { fullPage?: boolean }) {
basePath='/handler/account-settings'
/>;
- if (fullPage) {
- return (
-
- {inner}
-
- );
- } else {
- return inner;
- }
+ return (
+
+ {inner}
+
+ );
}
function ProfileSection() {
@@ -118,6 +115,10 @@ function EmailVerificationSection() {
const user = useUser({ or: 'redirect' });
const [emailSent, setEmailSent] = useState(false);
+ if (!user.primaryEmail) {
+ return null;
+ }
+
return (
<>
@@ -125,19 +126,22 @@ function EmailVerificationSection() {
{user.primaryEmailVerified ? (
Your email has been verified.
) : (
-
Your email has not been verified.
+ <>
+
Your email has not been verified.
+
+ {
+ await user.sendVerificationEmail();
+ setEmailSent(true);
+ }}
+ >
+ {emailSent ? 'Email sent!' : 'Send Verification Email'}
+
+
+ >
)}
-
- {
- await user.sendVerificationEmail();
- setEmailSent(true);
- }}
- >
- {emailSent ? 'Email sent!' : 'Send Verification Email'}
-
-
+
>
);
diff --git a/packages/stack/src/components/elements/maybe-full-page.tsx b/packages/stack/src/components/elements/maybe-full-page.tsx
index 8bdae089b..4bc77dffa 100644
--- a/packages/stack/src/components/elements/maybe-full-page.tsx
+++ b/packages/stack/src/components/elements/maybe-full-page.tsx
@@ -1,15 +1,21 @@
"use client";
-import { Container } from "@stackframe/stack-ui";
+import { Container, cn } from "@stackframe/stack-ui";
import React, { useId } from "react";
import { SsrScript } from "./ssr-layout-effect";
export function MaybeFullPage({
children,
- fullPage=true
+ fullPage=true,
+ size=380,
+ fullVertical=false,
+ containerClassName,
}: {
children: React.ReactNode,
fullPage?: boolean,
+ size?: number,
+ fullVertical?: boolean,
+ containerClassName?: string,
}) {
const uniqueId = useId();
const id = `stack-card-frame-${uniqueId}`;
@@ -34,12 +40,12 @@ export function MaybeFullPage({
minHeight: '100vh',
alignSelf: 'stretch',
display: 'flex',
- alignItems: 'center',
+ alignItems: fullVertical ? 'stretch' : 'center',
justifyContent: 'center',
}}
className="stack-scope"
>
-
+
{children}
diff --git a/packages/stack/src/components/elements/sidebar-layout.tsx b/packages/stack/src/components/elements/sidebar-layout.tsx
index 3d5e76714..47712e92e 100644
--- a/packages/stack/src/components/elements/sidebar-layout.tsx
+++ b/packages/stack/src/components/elements/sidebar-layout.tsx
@@ -15,7 +15,7 @@ export type SidebarItem = {
contentTitle?: React.ReactNode,
}
-export function SidebarLayout(props: { items: SidebarItem[], title?: ReactNode, basePath: string }) {
+export function SidebarLayout(props: { items: SidebarItem[], title?: ReactNode, basePath: string, className?: string }) {
const pathname = usePathname();
const selectedIndex = props.items.findIndex(item => item.subpath && (props.basePath + item.subpath === pathname));
const router = useRouter();
@@ -25,10 +25,10 @@ export function SidebarLayout(props: { items: SidebarItem[], title?: ReactNode,
return (
<>
-