Skip to content

Commit 5d7aab4

Browse files
fomalhautbN2D4
andauthored
Better dashboard onboarding process (#604)
<img width="719" alt="image" src="https://github.com/user-attachments/assets/1a9d10a9-a571-4c61-9702-4cfb4d2efa1c" /> <!-- Make sure you've read the CONTRIBUTING.md guidelines: https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md --> <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Enhances dashboard onboarding with a new setup page, refactors metrics components, and improves UI components and code organization. > > - **Behavior**: > - Introduces `SetupPage` in `setup-page.tsx` for onboarding, with framework selection and key generation. > - Replaces `OnboardingDialog` with `SetupPage` for a more interactive onboarding experience. > - `PageClient` in `page-client.tsx` now toggles between `SetupPage` and `MetricsPage` based on user count. > - **UI Components**: > - Adds `CodeBlock` component in `code-block.tsx` for displaying code snippets with syntax highlighting. > - Enhances `EnvKeys` in `env-keys.tsx` to support downloading keys and displaying them in tabs. > - Introduces `InlineCode` component in `inline-code.tsx` for inline code styling. > - **Refactoring**: > - Moves metrics-related components to `(overview)/(metrics)` directory. > - Renames and reorganizes files for better structure, e.g., `globe.tsx` and `line-chart.tsx`. > - Updates `SidebarLayout` and `PageLayout` for improved layout handling. > - **Dependencies**: > - Adds `react-syntax-highlighter` and its types to `package.json` for code highlighting. > - **Misc**: > - Updates `theme.tsx` to improve theme watching logic. > - Fixes minor issues and improves code readability across several files. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup> for 194d1ef. You can [customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN --> --------- Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
1 parent e6bf381 commit 5d7aab4

31 files changed

Lines changed: 1202 additions & 289 deletions

File tree

apps/dashboard/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"react-globe.gl": "^2.28.2",
4343
"react-hook-form": "^7.53.1",
4444
"react-icons": "^5.0.1",
45+
"react-syntax-highlighter": "^15.6.1",
4546
"recharts": "^2.14.1",
4647
"svix": "^1.32.0",
4748
"svix-react": "^1.13.0",
@@ -55,6 +56,7 @@
5556
"@types/node": "20.17.6",
5657
"@types/react": "19.0.12",
5758
"@types/react-dom": "19.0.4",
59+
"@types/react-syntax-highlighter": "^15.5.13",
5860
"autoprefixer": "^10.4.17",
5961
"glob": "^10.4.1",
6062
"import-in-the-middle": "^1.12.0",
Lines changed: 4 additions & 0 deletions
Loading

apps/dashboard/public/next-logo.svg

Lines changed: 8 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/(metrics)/page-client.tsx

Lines changed: 0 additions & 128 deletions
This file was deleted.

apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/(metrics)/globe.tsx renamed to apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/(overview)/(metrics)/globe.tsx

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
import { useThemeWatcher } from '@/lib/theme';
12
import useResizeObserver from '@react-hook/resize-observer';
23
import { useUser } from '@stackframe/stack';
34
import { getFlagEmoji } from '@stackframe/stack-shared/dist/utils/unicode';
45
import { Typography } from '@stackframe/stack-ui';
56
import dynamic from 'next/dynamic';
67
import { RefObject, use, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
78
import { GlobeMethods } from 'react-globe.gl';
9+
import { globeImages } from '../(utils)/utils';
810

911
// https://github.com/vasturiano/react-globe.gl/issues/1#issuecomment-554459831
1012
const Globe = dynamic(() => import('react-globe.gl').then((mod) => mod.default), { ssr: false });
11-
const countriesPromise = import('./country-data.geo.json');
13+
const countriesPromise = import('../(utils)/country-data.geo.json');
1214

1315
function useSize(target: RefObject<HTMLDivElement | null>) {
1416
const [size, setSize] = useState<DOMRectReadOnly>();
@@ -73,20 +75,7 @@ export function GlobeSection({ countryData, totalUsers, children }: {countryData
7375
const user = useUser({ or: "redirect" });
7476
const displayName = user.displayName ?? user.primaryEmail;
7577

76-
const [isLightMode, setIsLightMode] = useState<boolean | null>(null);
77-
// eslint-disable-next-line react-hooks/exhaustive-deps
78-
useEffect(() => {
79-
const updateIsLightMode = () => {
80-
const shouldBeLight = getComputedStyle(document.documentElement).getPropertyValue('color-scheme') === 'light';
81-
if (shouldBeLight !== isLightMode) {
82-
setIsLightMode(shouldBeLight);
83-
}
84-
resumeRender();
85-
};
86-
updateIsLightMode();
87-
const interval = setInterval(updateIsLightMode, 10);
88-
return () => clearInterval(interval);
89-
}, [isLightMode]);
78+
const { theme, mounted } = useThemeWatcher();
9079

9180
// Chromium's WebGL is much faster than other browsers, so we can do some extra animations
9281
const [isFastEngine, setIsFastEngine] = useState<boolean | null>(null);
@@ -172,16 +161,12 @@ export function GlobeSection({ countryData, totalUsers, children }: {countryData
172161
</div>
173162
</div>
174163
)}
175-
{isLightMode !== null && isFastEngine !== null && (
164+
{mounted && isFastEngine !== null && (
176165
<Globe
177166
key={errorRefreshCount}
178167
ref={globeRef}
179168
backgroundColor='#00000000'
180-
globeImageUrl={
181-
isLightMode
182-
? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAAaADAAQAAAABAAAAAQAAAAD5Ip3+AAAADUlEQVQIHWO48vjffwAI+QO1AqIWWgAAAABJRU5ErkJggg=='
183-
: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAAaADAAQAAAABAAAAAQAAAAD5Ip3+AAAADUlEQVQIHWPgF9f8DwAB1wFPLWQXmAAAAABJRU5ErkJggg=='
184-
}
169+
globeImageUrl={globeImages[theme]}
185170
width={globeSize?.[0] ?? 64}
186171
height={128 + (globeSize?.[1] ?? 0)}
187172
onGlobeReady={() => {
@@ -226,7 +211,7 @@ export function GlobeSection({ countryData, totalUsers, children }: {countryData
226211
const highlight = isFastEngine && country.properties.ISO_A2_EH === selectedCountry?.code;
227212

228213
if (Number.isNaN(value) || value === null || maxColorValue < 0.0001) {
229-
if (isLightMode) {
214+
if (theme === 'light') {
230215
return `hsl(210, 17.20%, ${highlight ? '55.5%' : '45.5%'})`;
231216
} else {
232217
if (value === null && maxColorValue < 0.0001) {
@@ -238,7 +223,7 @@ export function GlobeSection({ countryData, totalUsers, children }: {countryData
238223
}
239224
}
240225
const scaled = value / maxColorValue;
241-
if (isLightMode) {
226+
if (theme === 'light') {
242227
return `hsl(${175 * (1 - scaled)}, 100%, ${20 + 40 * scaled + (highlight ? 10 : 0)}%)`;
243228
} else {
244229
return `hsl(240, 84%, ${24 + 60 * scaled + (highlight ? 10 : 0)}%)`;

apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/(metrics)/line-chart.tsx renamed to apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/(overview)/(metrics)/line-chart.tsx

File renamed without changes.

0 commit comments

Comments
 (0)