Skip to content

feat: add shared ui package#477

Merged
luxass merged 7 commits intomainfrom
shared-ui
Jan 21, 2026
Merged

feat: add shared ui package#477
luxass merged 7 commits intomainfrom
shared-ui

Conversation

@luxass
Copy link
Member

@luxass luxass commented Jan 19, 2026

🔗 Linked issue

📚 Description

This PR will split the ShadCN UI from Web to be a shared package. This is because we wanna use it for the upcoming pipeline UI.

Summary by CodeRabbit

  • Improvements

    • Consolidated UI styling and components for more consistent visuals and theming across the app.
    • Improved character page loading via route-level data prefetching.
  • Bug Fixes

    • Corrected multiple typos and wording in type and doc comments for clearer documentation.
  • Chores

    • Introduced a shared UI package and associated config, license, and build metadata.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 19, 2026

⚠️ No Changeset found

Latest commit: f07dac3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the apps: web Changes related to the Website. label Jan 19, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Created a new internal shared UI package (@ucdjs-internal/shared-ui) and migrated the web app to consume its components, utils, and styles via new path aliases; updated many import paths, tsconfigs, and added package/tooling/config files. One route added a loader to prefetch character data.

Changes

Cohort / File(s) Summary
API Type Updates
apps/api/wrangler-types.d.ts
Bumped runtime header version and fixed multiple typos in JSDoc comments; no type/signature changes.
Web config & aliases
apps/web/package.json, apps/web/components.json, apps/web/tsconfig.json, tooling/tsconfig/base.json
Added imports/aliases for shared UI, workspace dependency for @ucdjs-internal/shared-ui, updated Tailwind CSS path and removed many TS compiler options in apps/web/tsconfig.json.
Global styles
apps/web/src/globals.css, packages/shared-ui/src/styles/globals.css
Replaced in-repo global CSS with single import from shared-ui; added comprehensive shared-ui global stylesheet.
Shared UI package manifest & tooling
packages/shared-ui/package.json, packages/shared-ui/tsconfig.json, packages/shared-ui/tsconfig.build.json, packages/shared-ui/tsdown.config.ts, packages/shared-ui/turbo.json, packages/shared-ui/eslint.config.js, packages/shared-ui/README.md, packages/shared-ui/LICENSE
New package manifest, export map, TS and build configs, tsdown and turbo configs, ESLint config, README, and license added.
Shared UI public API
packages/shared-ui/src/index.ts, packages/shared-ui/src/components/index.ts, packages/shared-ui/src/lib/utils.ts, packages/shared-ui/src/hooks/use-mobile.ts
Added entrypoint re-exports, component barrel, cn utility (class merging), and useIsMobile hook.
Shared UI component sources
packages/shared-ui/src/ui/*
Added/adjusted many UI component files and updated internal import aliases to #... (alert-dialog, avatar, badge, breadcrumb, button, card, combobox, dropdown-menu, field, input, input-group, label, select, separator, sheet, sidebar, skeleton, textarea, tooltip).
Web import migrations (components & routes)
apps/web/src/components/**, apps/web/src/routes/** (e.g., file-explorer, layout, versioned routes, search, index, codepoint-inspector)
Replaced local UI imports with @ucdjs-internal/shared-ui/components and swapped many internal aliases to #...; mostly module-resolution changes, no logic changes.
File-explorer & related updates
apps/web/src/components/file-explorer/*, apps/web/src/routes/file-explorer/*, apps/web/src/functions/files.ts
Migrated imports to new aliases/shared-ui; minor path fixes for function/type imports.
Route loader addition
apps/web/src/routes/v/$version/u/$hex.tsx
Added a route-level loader that ensures characterQueryOptions(params.hex, params.version) is prefetched via context.queryClient.ensureQueryData. Public Route export updated to include loader.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

pkg: shared

"I hop and tidy every import line,
Shared buttons, cards, and styles now shine,
Aliases snug, one CSS to hold,
A rabbit's cheer — our UI's bold! 🐇✨"

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add shared ui package' directly and clearly summarizes the main change: extracting ShadCN UI into a new shared package for reuse.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 19, 2026

🌏 Preview Deployments

Application Status Preview URL
API ⏭️ Skipped N/A
Website ⏭️ Skipped N/A
Documentation ⏭️ Skipped N/A

Built from commit: f07dac3aa001797c5d74648dc5195de2d19d066c


🤖 This comment will be updated automatically when you push new commits to this PR.

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/shared-ui/src/hooks/use-mobile.ts 0.00% 11 Missing ⚠️
packages/shared-ui/src/lib/utils.ts 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@luxass luxass marked this pull request as ready for review January 21, 2026 16:46
Copilot AI review requested due to automatic review settings January 21, 2026 16:46
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extracts ShadCN UI components from the web application into a new shared package @ucdjs-internal/shared-ui to enable reuse across multiple UCD.js projects, specifically for the upcoming pipeline UI.

Changes:

  • Created new @ucdjs-internal/shared-ui package with UI components, hooks, utilities, and styles
  • Updated web app to import UI components from the shared package instead of local files
  • Migrated global CSS to the shared-ui package and updated web app to import from there

Reviewed changes

Copilot reviewed 66 out of 69 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/shared-ui/* New shared UI package containing extracted ShadCN components, utilities, hooks, and global styles
apps/web/src/routes/**/*.tsx Updated imports to use @ucdjs-internal/shared-ui/components instead of local UI components
apps/web/src/components/**/*.tsx Updated imports to use shared UI package for all UI components
apps/web/tsconfig.json Simplified configuration by removing redundant compiler options now in base config
apps/web/package.json Added dependency on @ucdjs-internal/shared-ui workspace package and subpath imports configuration
apps/web/components.json Updated ShadCN configuration to point to shared-ui package aliases
apps/web/src/globals.css Replaced all CSS with single import from shared-ui package
tooling/tsconfig/base.json Added TypeScript path mappings for shared-ui package exports
pnpm-lock.yaml Updated dependencies with new shared-ui package and React linting plugin versions
apps/api/wrangler-types.d.ts Auto-generated types file updated with spelling corrections
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions bot added the apps: api Changes related to the API. label Jan 21, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/web/src/routes/v/$version/u/$hex.tsx (1)

24-26: Return the promise from the loader to enable proper prefetching.

The ensureQueryData call returns a promise, but since it's not returned, TanStack Router won't wait for the data before completing navigation. While useSuspenseQuery will still work (Suspense handles the loading state), this defeats the purpose of prefetching in the loader.

Suggested fix
   loader: ({ context, params }) => {
-    context.queryClient.ensureQueryData(characterQueryOptions(params.hex, params.version));
+    return context.queryClient.ensureQueryData(characterQueryOptions(params.hex, params.version));
   },
🤖 Fix all issues with AI agents
In `@packages/shared-ui/LICENSE`:
- Around line 1-21: Update the copyright year in the LICENSE file: replace the
incorrect copyright header string "Copyright (c) 2026-PRESENT Lucas Nørgård"
with "Copyright (c) 2025-PRESENT Lucas Nørgård" so it matches the parent
repository and the other packages.

In `@packages/shared-ui/README.md`:
- Line 18: Unindent the "## 📄 License" heading so it starts at the beginning of
the line (remove any leading spaces/tabs) to satisfy markdownlint rule MD023 and
ensure it is recognized as a top-level heading; locate the line containing "##
📄 License" and remove indentation so the line begins with "##".
🧹 Nitpick comments (3)
packages/shared-ui/src/styles/globals.css (1)

1-133: Verify Tailwind @source covers all class-bearing files in shared-ui.
If class names live outside src/ui, they won’t be scanned and styles can be missing. Consider widening the glob if needed.

🧩 Optional glob expansion
-@source "../ui/**/*.{ts,tsx}";
+@source "../**/*.{ts,tsx}";
packages/shared-ui/src/hooks/use-mobile.ts (1)

1-19: Consider initializing from matchMedia to avoid first-render false/flicker.
This keeps SSR/client consistent and reduces layout shifts on mobile.

♻️ Suggested refinement
-  const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined);
+  const [isMobile, setIsMobile] = React.useState<boolean | undefined>(() => {
+    if (typeof window === "undefined") return undefined;
+    return window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`).matches;
+  });

   React.useEffect(() => {
+    if (typeof window === "undefined") return;
     const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
     const onChange = () => {
-      setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
+      setIsMobile(mql.matches);
     };
     mql.addEventListener("change", onChange);
-    setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
+    setIsMobile(mql.matches);
     return () => mql.removeEventListener("change", onChange);
   }, []);
apps/web/src/components/file-explorer/explorer-toolbar.tsx (1)

1-2: Consider using a path alias for the type import.

Line 1 uses a relative path ("../../routes/file-explorer/$") while the cn utility on line 2 uses the #lib/utils alias. For consistency with the migration pattern used elsewhere in this PR, consider using a path alias if one is configured for route types.

@luxass luxass merged commit 6d90cb5 into main Jan 21, 2026
30 of 32 checks passed
@luxass luxass deleted the shared-ui branch January 21, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apps: api Changes related to the API. apps: web Changes related to the Website.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant