Skip to content

Commit 8a06b65

Browse files
committed
fix: playwright
1 parent 822f039 commit 8a06b65

File tree

11 files changed

+196
-179
lines changed

11 files changed

+196
-179
lines changed

apps/web/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ node_modules/
1414
/playwright-report/
1515
/blob-report/
1616
/playwright/.cache/
17+
18+
.wrangler
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { defineGlobalStyles } from '@pandacss/dev';
2+
3+
// https://unpkg.com/nprogress@0.2.0/nprogress.css
4+
export const globalLoaderCss = defineGlobalStyles({
5+
'#nprogress': {
6+
pointerEvents: 'none',
7+
},
8+
9+
'#nprogress .bar': {
10+
background: 'black',
11+
position: 'fixed',
12+
zIndex: 99999,
13+
top: 0,
14+
left: 0,
15+
width: '100%',
16+
height: '1px',
17+
},
18+
19+
'#nprogress .peg': {
20+
display: 'block',
21+
position: 'absolute',
22+
right: '0px',
23+
width: '100px',
24+
height: '100%',
25+
opacity: 1.0,
26+
transform: 'rotate(3deg) translate(0px, -4px)',
27+
},
28+
29+
'#nprogress .spinner': {
30+
display: 'block',
31+
position: 'fixed',
32+
zIndex: 1031,
33+
top: '15px',
34+
right: '15px',
35+
},
36+
37+
'.nprogress-custom-parent': {
38+
overflow: 'hidden',
39+
position: 'relative',
40+
},
41+
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { useEffect } from 'react';
2+
import { useNavigation } from 'react-router';
3+
4+
import NProgress from 'nprogress';
5+
6+
import { useOnMount } from '@leather.io/ui';
7+
8+
const config = {
9+
color: '#000',
10+
minimum: 0.1,
11+
showSpinner: false,
12+
easing: 'linear',
13+
speed: 200,
14+
trickle: true,
15+
trickleSpeed: 200,
16+
};
17+
18+
export function GlobalLoader() {
19+
const navigation = useNavigation();
20+
21+
useEffect(() => {
22+
let timeOut: ReturnType<typeof setTimeout> | null = null;
23+
24+
if (navigation.state !== 'idle') {
25+
timeOut = setTimeout(() => NProgress.start(), 280);
26+
} else if (navigation.state === 'idle') {
27+
if (timeOut) clearTimeout(timeOut);
28+
NProgress.done();
29+
}
30+
31+
return () => {
32+
if (timeOut) clearTimeout(timeOut);
33+
};
34+
}, [navigation.state]);
35+
36+
useOnMount(() => void NProgress.configure(config));
37+
38+
return null;
39+
}

apps/web/app/root.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import leatherUiStyles from '@leather.io/ui/styles?url';
1313

1414
import type { Route } from './+types/root';
1515
import stylesheet from './app.css?url';
16+
import { GlobalLoader } from './layouts/nav/global-loader';
1617
import { Nav } from './layouts/nav/nav';
1718

1819
export function links() {
@@ -32,6 +33,7 @@ export function Layout({ children }: { children: React.ReactNode }) {
3233
<Links />
3334
</head>
3435
<styled.body display="flex" height="100vh">
36+
<GlobalLoader />
3537
<Nav />
3638
<styled.main>{children}</styled.main>
3739
<ScrollRestoration />

apps/web/package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,23 @@
1414
"@leather.io/sdk": "workspace:*",
1515
"@leather.io/ui": "workspace:*",
1616
"@leather.io/utils": "workspace:*",
17-
"@react-router/node": "7.2.0",
18-
"@react-router/serve": "7.2.0",
17+
"@react-router/node": "7.3.0",
18+
"@react-router/serve": "7.3.0",
1919
"isbot": "5.1.17",
20+
"nprogress": "0.2.0",
2021
"react": "19.0.0",
2122
"react-dom": "19.0.0",
22-
"react-router": "7.2.0",
23-
"react-router-dom": "7.2.0"
23+
"react-router": "7.3.0"
2424
},
2525
"devDependencies": {
2626
"@cloudflare/workers-types": "4.20250303.0",
2727
"@originjs/vite-plugin-commonjs": "1.0.3",
2828
"@pandacss/dev": "0.53.1",
29-
"@playwright/test": "1.50.1",
30-
"@react-router/cloudflare": "7.2.0",
31-
"@react-router/dev": "7.2.0",
29+
"@playwright/test": "1.51.0",
30+
"@react-router/cloudflare": "7.3.0",
31+
"@react-router/dev": "7.3.0",
3232
"@types/node": "22.13.5",
33+
"@types/nprogress": "0.2.3",
3334
"@types/react": "19.0.10",
3435
"@types/react-dom": "19.0.4",
3536
"react-router-devtools": "1.1.6",

apps/web/panda.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { defineConfig } from '@pandacss/dev';
22

3+
import { globalLoaderCss } from './app/layouts/nav/global-loader.styles';
4+
35
export default defineConfig({
46
// Whether to use css reset
57
preflight: true,
@@ -10,6 +12,8 @@ export default defineConfig({
1012
'./node_modules/@leather.io/ui/dist-web/**/*.{js,jsx,ts,tsx}',
1113
],
1214

15+
globalCss: globalLoaderCss,
16+
1317
presets: ['@leather.io/panda-preset'],
1418

1519
jsxFramework: 'react',

apps/web/playwright.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default defineConfig({
1414
reporter: 'html',
1515

1616
use: {
17-
baseURL: 'http://127.0.0.1:3000',
17+
baseURL: 'http://127.0.0.1:8787',
1818
trace: 'on-first-retry',
1919
},
2020

@@ -36,8 +36,8 @@ export default defineConfig({
3636
],
3737

3838
webServer: {
39-
command: 'pnpm start',
40-
url: 'http://127.0.0.1:3000',
39+
command: 'pnpm wrangler dev',
40+
url: 'http://127.0.0.1:8787',
4141
reuseExistingServer: !process.env.CI,
4242
},
4343
});

apps/web/tsconfig.node.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extends": "./tsconfig.json",
3-
"include": ["vite.config.ts", "panda.config.ts", "playwright.config.ts"],
3+
"include": ["vite.config.ts", "panda.config.ts", "playwright.config.ts", "**/*.styles.ts"],
44
"compilerOptions": {
55
"composite": true,
66
"strict": true,

packages/ui/src/exports.web.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ export { Highlighter, type HighlighterProps } from './components/highlighting/hi
4040
export { Prism, type PrismType } from './components/highlighting/clarity-prism.shared';
4141
export { Slider } from './components/slider/slider.web';
4242
export { useClipboard } from './utils/use-clipboard.web';
43+
export { useOnMount } from './utils/use-on-mount.shared';

0 commit comments

Comments
 (0)