Skip to content

Commit 3956939

Browse files
authored
Merge pull request #7 from pancakeswap/feat/perps-simple3
feat(perps): pixel-perfect refinement of Simple Perps
2 parents 1ae0db8 + 83a1721 commit 3956939

273 files changed

Lines changed: 44880 additions & 10148 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.githooks/pre-commit

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
# Block accidental commits of locally-built dist/.
3+
#
4+
# Why: `dist/` is rebuilt by the `rebuild-dist.yml` GitHub Action on every
5+
# push to a non-main branch and committed back as github-actions[bot]. Local
6+
# `pnpm dev:lib` watches and rewrites dist on every src save; if the dev
7+
# `git add -A`, those local builds end up in the commit and fight with the
8+
# bot's clean, deterministic output.
9+
#
10+
# This hook lets src-only commits through and blocks any commit that touches
11+
# dist/. Use `git commit --no-verify` to bypass for genuine emergency
12+
# fixes (the bot will then pick up your dist on the next push anyway).
13+
14+
if git diff --cached --name-only | grep -qE '^dist/'; then
15+
cat >&2 <<'MSG'
16+
17+
✗ Refusing to commit: dist/ files are staged.
18+
19+
dist/ is auto-built and committed by the GitHub Action on push
20+
(.github/workflows/rebuild-dist.yml). Don't ship local builds —
21+
they cause hash drift and pollute the diff.
22+
23+
Un-stage with:
24+
git reset HEAD dist/
25+
26+
If you really need to bypass (emergency, CI broken, etc.):
27+
git commit --no-verify
28+
29+
MSG
30+
exit 1
31+
fi

.github/workflows/rebuild-dist.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Rebuild dist
2+
3+
# Why this exists:
4+
# pancake-frontend imports `@pancakeswap/storybook/widgets` from a git ref,
5+
# resolving to the committed `dist/` (no `prepare` script — that path was
6+
# OOMing on Vercel). That means whenever someone edits `src/` and forgets to
7+
# run `pnpm build:lib` before pushing, downstream consumers see stale code.
8+
# This workflow rebuilds dist on push and commits it back so devs only have
9+
# to touch src/.
10+
#
11+
# Plan B (later, before launch): publish as a real npm package via GitHub
12+
# Packages and pin a version in pancake-frontend; this workflow becomes a
13+
# release/publish job instead of a commit-back job.
14+
15+
on:
16+
push:
17+
branches-ignore:
18+
- 'gh-pages'
19+
paths:
20+
- 'src/**'
21+
- 'package.json'
22+
- 'pnpm-lock.yaml'
23+
- 'vite.lib.config.ts'
24+
- 'tsconfig*.json'
25+
26+
# Default GITHUB_TOKEN can write to the repo with `contents: write`. No PAT
27+
# required.
28+
permissions:
29+
contents: write
30+
31+
# Avoid stacking redundant rebuilds when a branch gets multiple pushes in
32+
# quick succession — the most recent push wins.
33+
concurrency:
34+
group: rebuild-dist-${{ github.ref }}
35+
cancel-in-progress: true
36+
37+
jobs:
38+
rebuild:
39+
runs-on: ubuntu-latest
40+
41+
# Belt-and-braces guard against the bot triggering itself. The
42+
# `[skip ci]` token in the commit message is the primary mechanism
43+
# (GitHub honors it), this `if` catches any path where it gets
44+
# stripped (rebases, force-pushes, etc.).
45+
if: github.actor != 'github-actions[bot]'
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
# Need full ref so we can push back without "shallow update not
51+
# allowed".
52+
fetch-depth: 0
53+
# Use the default token; explicit so the push step inherits it.
54+
token: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- uses: pnpm/action-setup@v4
57+
with:
58+
# pnpm-lock.yaml is v9 → pin pnpm major to match. action-setup@v4
59+
# requires either this `version` key or a `packageManager` field
60+
# in package.json; we don't have the latter.
61+
version: 9
62+
63+
- uses: actions/setup-node@v4
64+
with:
65+
node-version: 20
66+
cache: pnpm
67+
68+
- run: pnpm install --frozen-lockfile
69+
70+
- name: Build library bundle
71+
run: pnpm build:lib
72+
73+
- name: Commit dist if changed
74+
run: |
75+
if [[ -z "$(git status --porcelain dist/)" ]]; then
76+
echo "dist/ unchanged — nothing to commit"
77+
exit 0
78+
fi
79+
git config user.name 'github-actions[bot]'
80+
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
81+
git add dist/
82+
git commit -m "ci: rebuild dist [skip ci]"
83+
git push origin HEAD:${GITHUB_REF#refs/heads/}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ lerna-debug.log*
1111
node_modules
1212

1313
# Build output
14-
dist
14+
# `dist/` is checked in so consumers (pancake-frontend via github:tarball)
15+
# don't run `vite build` during pnpm install — that pulled in every devDep
16+
# (storybook, vitest, playwright, …) and OOM'd Vercel's build container.
1517
dist-ssr
1618
storybook-static
1719

.storybook/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const config: StorybookConfig = {
2626
'@styled-system/should-forward-prop',
2727
'clsx',
2828
'primereact/multiselect',
29-
'primereact/selectitem',
3029
'lodash/noop',
3130
];
3231
return config;

.storybook/preview-head.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<link rel="preconnect" href="https://fonts.googleapis.com">
22
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
33
<link href="https://fonts.googleapis.com/css2?family=Kanit:wght@400;500;600;700;800&display=swap" rel="stylesheet">
4+
<div id="portal-root"></div>

.storybook/preview.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
* are available globally without a .perps-root wrapper.
88
*/
99

10+
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@400;500;600;700;800&display=swap');
11+
1012
html, body {
1113
margin: 0;
1214
padding: 0;
1315
background: var(--pcs-colors-bg, #f0f2f5);
16+
/* Apply Kanit globally so portal content (Modal, DropdownMenu, Tooltip)
17+
* also renders with the PCS font, even when mounted outside .perps-root. */
18+
font-family: 'Kanit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
1419
transition: background 0.15s;
1520
}
1621

.storybook/preview.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import type { Preview, Decorator } from '@storybook/react-vite'
22
import { ThemeProvider as SCThemeProvider } from 'styled-components'
3-
import { ThemeProvider } from '../src/ui/ThemeProvider'
4-
import { pcsTheme } from '../src/ui/components/theme'
3+
import { ThemeProvider } from '../src/design-system/ThemeProvider'
4+
import { pcsTheme } from '../src/primitives/theme'
5+
import { MatchBreakpointsProvider } from '../src/contexts'
6+
import { ModalProvider } from '../src/primitives/Modal'
57
import { PhoneFrame, TabletFrame } from './DeviceFrame'
68
import './preview.css'
79

@@ -10,7 +12,11 @@ const withTheme: Decorator = (Story, context) => {
1012
return (
1113
<ThemeProvider forcedTheme={theme}>
1214
<SCThemeProvider theme={pcsTheme}>
13-
<Story />
15+
<MatchBreakpointsProvider>
16+
<ModalProvider>
17+
<Story />
18+
</ModalProvider>
19+
</MatchBreakpointsProvider>
1420
</SCThemeProvider>
1521
</ThemeProvider>
1622
)

0 commit comments

Comments
 (0)