Skip to content

Feat(docsite): Display component list#2552

Open
literat wants to merge 18 commits intomainfrom
feat/docsite-component-listing
Open

Feat(docsite): Display component list#2552
literat wants to merge 18 commits intomainfrom
feat/docsite-component-listing

Conversation

@literat
Copy link
Copy Markdown
Collaborator

@literat literat commented Mar 19, 2026

Description

Adds a /components page to the docsite that displays all Spirit Design System components with
two browsing modes:

  • Alphabetical (default) — flat grid of all components sorted A–Z
  • Categorical — components grouped into 11 categories (Actions, Content, Feedback, Forms,
    Layout, Media and Icons, Navigation, Overlays, Structure, Typography, Utilities)

Users toggle between views using a centered SegmentedControl. The sort state is persisted in
the URL via ?sort=categorical (the default alphabetical mode keeps the URL clean with no query
param).

Key implementation details

  • URL state management: Introduces nuqs (added to the frontend yarn
    catalog) as the standard URL state library for the docsite. It's purpose-built for Next.js App
    Router with typed parsers and automatic default-value removal.
  • Component architecture: The listing is split into focused components — ComponentGrid
    (shared grid), AlphabeticalComponentList, CategoricalComponentList, ComponentList (client
    component reading URL state), and ComponentSortToggle.
  • Shared hook: useComponentsSortQueryState extracts the sort parser so it's defined once
    and reused across components.
  • Utility function: groupComponentsByCategory is a pure, testable utility for mapping
    components to their categories.
  • Slug conversion: componentNameToSlug / slugToComponentName handle PascalCase ↔
    kebab-case conversion including UNSTABLE_ prefix support.
  • Testing: Jest is set up for the docsite with unit tests for categories (no duplicates,
    alphabetical order, no empty categories), slug conversion, component repository, and category
    grouping.

Additional context

  • Component detail pages (/components/[slug]) are not yet implemented — card links will 404
    for now. This is planned as a follow-up.
  • The nuqs adapter (NuqsAdapter) wraps the root AppProvider and client components using
    useSearchParams are wrapped in <Suspense> as required by Next.js static generation.

Issue reference

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 19, 2026

Deploy Preview for spirit-design-system-docsite ready!

Name Link
🔨 Latest commit 59f17bc
🔍 Latest deploy log https://app.netlify.com/projects/spirit-design-system-docsite/deploys/69cc123af078470008276697
😎 Deploy Preview https://deploy-preview-2552--spirit-design-system-docsite.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 19, 2026

Deploy Preview for spirit-design-system canceled.

Name Link
🔨 Latest commit 59f17bc
🔍 Latest deploy log https://app.netlify.com/projects/spirit-design-system/deploys/69cc123a5e1e4e0008b1c298

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 19, 2026

Deploy Preview for spirit-design-system-storybook canceled.

Name Link
🔨 Latest commit 59f17bc
🔍 Latest deploy log https://app.netlify.com/projects/spirit-design-system-storybook/deploys/69cc123a308d880008d90d0e

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 19, 2026

Deploy Preview for spirit-design-system-storybook canceled.

Name Link
🔨 Latest commit 05b74c9
🔍 Latest deploy log https://app.netlify.com/projects/spirit-design-system-storybook/deploys/69bc3ccceb183b000797cff7

@github-actions github-actions bot added the feature New feature or request label Mar 19, 2026
@literat literat force-pushed the feat/docsite-component-listing branch from 05b74c9 to 367baa8 Compare March 25, 2026 09:01
Copilot AI review requested due to automatic review settings March 25, 2026 09:01
Copy link
Copy Markdown

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 adds a “Components” listing to the docsite by reading the available Spirit Web React component directories, rendering them as cards, and wiring up Jest so the new utilities/repository code are tested in the monorepo.

Changes:

  • Add a /components page in the docsite that renders a grid of component cards.
  • Introduce slug ↔ component-name conversion helpers with Jest unit tests.
  • Add a components repository (filesystem-based) with tests, and register the docsite Jest project + scripts.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
yarn.lock Adds lock entries for docsite testing/tooling deps (jest, ts-node, npm-run-all2).
jest.config.ts Registers apps/docsite/jest.config.ts in the root Jest projects list.
apps/docsite/tsconfig.test.json Adds a Jest-focused TS config for ts-node/Jest config loading.
apps/docsite/src/domains/routing/routes.ts Adds a routes.component() helper that slugifies component names.
apps/docsite/src/domains/components/utils/componentSlug.ts Implements componentNameToSlug and slugToComponentName.
apps/docsite/src/domains/components/utils/__tests__/componentSlug.test.ts Unit tests for slug conversion.
apps/docsite/src/domains/components/ui/ComponentCard.tsx Adds a card UI for a component entry, including a link.
apps/docsite/src/domains/components/repositories/componentsRepository.ts Reads component directories from packages/web-react via Node fs.
apps/docsite/src/domains/components/repositories/__tests__/componentsRepository.test.ts Unit tests for the repository behavior.
apps/docsite/src/app/(documentation)/components/page.tsx New Next.js page that renders the component list grid.
apps/docsite/package.json Adds docsite test scripts and devDependencies for Jest tooling.
apps/docsite/jest.config.ts Adds Jest preset + @local/* mapper for docsite tests.

Copilot AI review requested due to automatic review settings March 25, 2026 10:49
Copy link
Copy Markdown

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

Copilot reviewed 22 out of 23 changed files in this pull request and generated 4 comments.

Copilot AI review requested due to automatic review settings March 25, 2026 11:17
Copy link
Copy Markdown

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

Copilot reviewed 24 out of 25 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings March 25, 2026 11:43
Copy link
Copy Markdown

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

Copilot reviewed 26 out of 27 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings March 25, 2026 12:35
@literat literat force-pushed the feat/docsite-component-listing branch from c12c30d to 77c5c01 Compare March 25, 2026 12:42
Copy link
Copy Markdown

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

Copilot reviewed 27 out of 28 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings March 26, 2026 06:26
@literat literat requested review from adamkudrna and crishpeen March 26, 2026 06:26
Copy link
Copy Markdown

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

Copilot reviewed 27 out of 28 changed files in this pull request and generated 2 comments.

const components: string[] = fetchAllComponents();

return (
<Container>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this should be in a Section too

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will this be a default for every page? If yes, it should go to layout.ts.


export const COMPONENT_CATEGORIES: Record<string, string[]> = {
Actions: ['ActionGroup', 'Button', 'ButtonLink', 'ControlButton', 'Link', 'SkipLink', 'SplitButton'],
Content: ['Accordion', 'Avatar', 'Card', 'EmptyState', 'Item', 'Pill', 'PricingPlan', 'Tag', 'Timeline'],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

interactive tag is action too 😂

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You can suggest different categories. And I think this will definitely change in the future. So maybe we can have a long topic about this... :-)

<Grid elementType="ul" cols={{ mobile: 2, tablet: 3 }}>
{Array.from({ length: SKELETON_ITEMS_COUNT }, (_, index) => (
<li key={index} className="d-grid">
<SkeletonShape width={0} height={66} borderRadius="200" UNSAFE_style={{ width: '100%' }} />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
<SkeletonShape width={0} height={66} borderRadius="200" UNSAFE_style={{ width: '100%' }} />
<SkeletonShape width="100%" height={66} borderRadius="200" />

not possible? Of not we should allow it

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not possible, the number is required. Do we want to allow this?

Comment on lines +4 to +5
// Reset to Node resolution for Jest compatibility
// @see: https://www.typescriptlang.org/tsconfig/#moduleResolution
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

comment in JSON :O

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copilot AI review requested due to automatic review settings March 31, 2026 15:25
Copy link
Copy Markdown

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

Copilot reviewed 28 out of 29 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings March 31, 2026 16:14
Copy link
Copy Markdown

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

Copilot reviewed 29 out of 30 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings March 31, 2026 16:35
Copy link
Copy Markdown

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

Copilot reviewed 29 out of 30 changed files in this pull request and generated 1 comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants