From 2e0b69fc35194d95366fe53979e64a0aa60ddfe8 Mon Sep 17 00:00:00 2001 From: Colin Tinney Date: Tue, 28 Apr 2026 03:55:22 -0700 Subject: [PATCH] feat: modernize playground, fix wide-screen scroll, add dev server Playground (Phase 5): - Rewrite from JSX/react-jss/react-json-pretty/prop-types to TypeScript - Add example cards for pauseOnHover and loop props - Inline styles into docs/index.html (no rollup CSS plugin needed) - Switch entry to React 18 createRoot - Import Marquee from src/ instead of pre-built lib output - Add npm install link in header (closes #9) - Add playground/tsconfig.json for type-checking Component (closes #19): - Render N copies of children to fill the container so wide-screen short content still scrolls in 'always' mode - Replace fixed 2-tile math with tileCount-driven measurement - Use ResizeObserver to re-measure on container resize - Replace disableScroll state with tileCount === 1 (preserves #44 fix) Dev workflow: - Add rollup-plugin-serve so npm run dev serves docs/ on port 8001 --- config/rollup.config.dev.mjs | 7 +- config/rollup.config.docs.mjs | 2 +- docs/index.html | 71 +++++++++ package.json | 1 + playground/src/components/ExampleCard.jsx | 80 ---------- playground/src/components/ExampleCard.tsx | 23 +++ playground/src/components/Header.jsx | 33 ----- playground/src/components/Header.tsx | 15 ++ ...LeftMarquee.jsx => DefaultLeftMarquee.tsx} | 7 +- ...ghtMarquee.jsx => DefaultRightMarquee.tsx} | 7 +- playground/src/examples/LoopMarquee.tsx | 15 ++ .../src/examples/PauseOnHoverMarquee.tsx | 15 ++ .../{ShortMarquee.jsx => ShortMarquee.tsx} | 7 +- ...gMarquee.jsx => ShortScrollingMarquee.tsx} | 7 +- playground/src/index.jsx | 65 -------- playground/src/index.tsx | 29 ++++ playground/src/styles.css | 4 - playground/tsconfig.json | 9 ++ src/__tests__/index.test.tsx | 6 + src/index.tsx | 139 +++++++++--------- 20 files changed, 266 insertions(+), 276 deletions(-) delete mode 100644 playground/src/components/ExampleCard.jsx create mode 100644 playground/src/components/ExampleCard.tsx delete mode 100644 playground/src/components/Header.jsx create mode 100644 playground/src/components/Header.tsx rename playground/src/examples/{DefaultLeftMarquee.jsx => DefaultLeftMarquee.tsx} (67%) rename playground/src/examples/{DefaultRightMarquee.jsx => DefaultRightMarquee.tsx} (65%) create mode 100644 playground/src/examples/LoopMarquee.tsx create mode 100644 playground/src/examples/PauseOnHoverMarquee.tsx rename playground/src/examples/{ShortMarquee.jsx => ShortMarquee.tsx} (67%) rename playground/src/examples/{ShortScrollingMarquee.jsx => ShortScrollingMarquee.tsx} (63%) delete mode 100644 playground/src/index.jsx create mode 100644 playground/src/index.tsx delete mode 100644 playground/src/styles.css create mode 100644 playground/tsconfig.json diff --git a/config/rollup.config.dev.mjs b/config/rollup.config.dev.mjs index 15b8514..c9857f5 100644 --- a/config/rollup.config.dev.mjs +++ b/config/rollup.config.dev.mjs @@ -2,6 +2,7 @@ import resolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; import babel from '@rollup/plugin-babel'; import replace from '@rollup/plugin-replace'; +import serve from 'rollup-plugin-serve'; import externals from './externals.mjs'; const paths = { @@ -10,7 +11,7 @@ const paths = { outputFile: 'docs/static/lib/index.js', }, playground: { - input: 'playground/src/index.jsx', + input: 'playground/src/index.tsx', outputFile: 'docs/static/index.js', }, }; @@ -62,5 +63,9 @@ export default [{ preventAssignment: true, 'process.env.NODE_ENV': JSON.stringify('development'), }), + serve({ + contentBase: 'docs', + port: 8001, + }), ], }]; diff --git a/config/rollup.config.docs.mjs b/config/rollup.config.docs.mjs index 61c3045..2cb8722 100644 --- a/config/rollup.config.docs.mjs +++ b/config/rollup.config.docs.mjs @@ -11,7 +11,7 @@ const paths = { outputFile: 'docs/static/lib/index.js', }, playground: { - input: 'playground/src/index.jsx', + input: 'playground/src/index.tsx', outputFile: 'docs/static/index.js', }, }; diff --git a/docs/index.html b/docs/index.html index e5d8ebb..3deb24a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -7,6 +7,77 @@ react-double-marquee +