Skip to content

feat: modernize playground, fix wide-screen scroll, add dev server#49

Draft
cdtinney wants to merge 1 commit into
developfrom
cdtinney/modernization-next
Draft

feat: modernize playground, fix wide-screen scroll, add dev server#49
cdtinney wants to merge 1 commit into
developfrom
cdtinney/modernization-next

Conversation

@cdtinney

Copy link
Copy Markdown
Owner

Summary

Continues the Phase 5 modernization work from PR #46. Three concerns:

  • Playground rewrite — convert to TypeScript, drop the deps that disappeared in PR feat!: modernize repo — TypeScript, hooks, GitHub Actions #46 (react-jss, react-json-pretty, prop-types), use React 18's createRoot, and add cards for the new pauseOnHover / loop props.
  • Issue Text does not scroll on a wide screen #19 (wide-screen scroll) — short content on wide containers used to render two copies that fit, so the marquee never scrolled. Component now measures the container via ResizeObserver and renders enough tiles to guarantee overflow in 'always' mode.
  • Dev workflownpm run dev now actually serves docs/ on port 8001 (matching the README) via rollup-plugin-serve.

Component changes (src/index.tsx)

  • Replaced fixed 2-tile rendering with a tileCount state.
  • useLayoutEffect + ResizeObserver recomputes tileCount on mount, content change, and container resize.
  • Animation math uses getTileWidth() = scrollWidth / tileCount instead of width / 2.
  • disableScroll state removed; tileCount === 1 now drives the centered-no-margin render that preserves the A problem with setting scrollWhen #44 fix.

Playground changes

  • playground/src/**/*.{jsx → tsx}
  • New LoopMarquee and PauseOnHoverMarquee example cards
  • Header now links to npmjs.com (closes Add npm link to example page #9)
  • Imports Marquee from ../../../src instead of the pre-built docs/static/lib, so the playground builds without depending on a prior lib build
  • Inlined styles into docs/index.html to avoid needing a rollup CSS plugin
  • Added playground/tsconfig.json extending root with noEmit

Closes

Test plan

  • npm install
  • npm run lint
  • npm test
  • npm run build
  • npm run docs then open docs/index.html and verify:
  • npm run dev then http://localhost:8001 loads with live rebuilds
  • Regenerate and commit docs/static/{index.js,lib/index.js} if shipping to GitHub Pages

Out of scope (left for follow-up)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add npm link to example page

1 participant