Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Segment Group #1017

Merged
merged 4 commits into from
Jan 30, 2025
Merged

Add Segment Group #1017

merged 4 commits into from
Jan 30, 2025

Conversation

tszhong0411
Copy link
Owner

@tszhong0411 tszhong0411 commented Jan 30, 2025

Description

Added Segment Group.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Pre-flight Checklist

  • Changes are limited to a single feature, bugfix or chore (split larger changes into separate PRs)
  • pnpm check without any issues
  • I have reviewed contributor guidelines

Screenshots

CleanShot 2025-01-30 at 23 17 20@2x

CleanShot 2025-01-30 at 23 17 29@2x

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced Segment Group component for organizing and navigating between sections
    • Added support for horizontal and vertical segment group layouts
    • Implemented disabled state for segment group items
  • Documentation

    • Created comprehensive documentation for Segment Group component
    • Added usage examples and preview demonstrations
  • Improvements

    • Enhanced build script to include package build process
    • Updated package dependencies

Copy link

linear bot commented Jan 30, 2025

Copy link

changeset-bot bot commented Jan 30, 2025

🦋 Changeset detected

Latest commit: bd30342

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tszhong0411/ui Patch

Not sure what this means? Click here to learn what changesets are.

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

Copy link

vercel bot commented Jan 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 30, 2025 3:56pm
honghongme ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 30, 2025 3:56pm

Copy link

coderabbitai bot commented Jan 30, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/docs/src/components/demos/segment-group/disabled.tsx

Oops! Something went wrong! :(

ESLint: 9.19.0

Error: Cannot find package '/node_modules/@tszhong0411/eslint-config/dist/index.js' imported from /eslint.config.mjs
at legacyMainResolve (node:internal/modules/esm/resolve:207:26)
at packageResolve (node:internal/modules/esm/resolve:826:14)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

apps/docs/src/components/demos/segment-group/segment-group.tsx

Oops! Something went wrong! :(

ESLint: 9.19.0

Error: Cannot find package '/node_modules/@tszhong0411/eslint-config/dist/index.js' imported from /eslint.config.mjs
at legacyMainResolve (node:internal/modules/esm/resolve:207:26)
at packageResolve (node:internal/modules/esm/resolve:826:14)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

apps/docs/src/components/demos/segment-group/vertical.tsx

Oops! Something went wrong! :(

ESLint: 9.19.0

Error: Cannot find package '/node_modules/@tszhong0411/eslint-config/dist/index.js' imported from /eslint.config.mjs
at legacyMainResolve (node:internal/modules/esm/resolve:207:26)
at packageResolve (node:internal/modules/esm/resolve:826:14)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

  • 3 others

Walkthrough

This pull request introduces a new Segment Group component to the @tszhong0411/ui package. The component allows organizing and navigating between sections in a view, with support for horizontal and vertical layouts, disabled states, and customizable items. Documentation, demo components, and necessary configuration updates have been added to integrate the new component into the project's UI library.

Changes

File Change Summary
.changeset/swift-phones-relax.md Added patch for new Segment Group component
apps/docs/src/app/ui/components/segment-group.mdx New documentation file for Segment Group component
apps/docs/src/components/demos/segment-group/ Added demo components: disabled.tsx, segment-group.tsx, vertical.tsx
apps/docs/src/config/links.ts Added new link for Segment Group component documentation
package.json Updated prepare script and tsup dependency version
packages/ui/src/index.ts Added export for Segment Group component
packages/ui/src/segment-group.tsx New implementation of Segment Group component with SegmentGroup, SegmentGroupIndicator, and SegmentGroupItem

Sequence Diagram

sequenceDiagram
    participant User
    participant SegmentGroup
    participant SegmentGroupItem

    User->>SegmentGroup: Initialize with orientation
    SegmentGroup->>SegmentGroupItem: Create items
    SegmentGroupItem-->>SegmentGroup: Render items
    User->>SegmentGroup: Select item
    SegmentGroup->>SegmentGroupItem: Update selected state
Loading

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 0

🧹 Nitpick comments (8)
apps/docs/src/components/demos/segment-group/segment-group.tsx (2)

12-18: Add onChange handler for better interactivity

Consider adding an onChange handler to track segment changes and demonstrate the component's interactive capabilities.

-    <SegmentGroup defaultValue='react'>
+    <SegmentGroup 
+      defaultValue='react'
+      onChange={(details) => console.log('Selected:', details.value)}
+    >

3-8: Consider adding aria-labels for better accessibility

The framework options could benefit from more descriptive aria-labels.

 const frameworks = [
-  { label: 'React', value: 'react' },
-  { label: 'Solid', value: 'solid' },
-  { label: 'Svelte', value: 'svelte' },
-  { label: 'Vue', value: 'vue' }
+  { label: 'React', value: 'react', ariaLabel: 'React Framework' },
+  { label: 'Solid', value: 'solid', ariaLabel: 'Solid Framework' },
+  { label: 'Svelte', value: 'svelte', ariaLabel: 'Svelte Framework' },
+  { label: 'Vue', value: 'vue', ariaLabel: 'Vue Framework' }
 ]
apps/docs/src/components/demos/segment-group/vertical.tsx (1)

3-8: Consider extracting frameworks data to a shared constant

The frameworks array is duplicated across demo files. Consider moving it to a shared constants file to maintain DRY principles.

Create a new file apps/docs/src/components/demos/segment-group/constants.ts:

export const FRAMEWORKS = [
  { label: 'React', value: 'react' },
  { label: 'Solid', value: 'solid' },
  { label: 'Svelte', value: 'svelte' },
  { label: 'Vue', value: 'vue' }
] as const
apps/docs/src/components/demos/segment-group/disabled.tsx (2)

3-8: Consider making disabled state more dynamic

The disabled state is currently hardcoded. Consider making it more dynamic to better demonstrate various use cases.

 const frameworks = [
   { label: 'React', value: 'react' },
   { label: 'Solid', value: 'solid' },
-  { label: 'Svelte', value: 'svelte', disabled: true },
+  { label: 'Svelte', value: 'svelte', disabled: process.env.NODE_ENV === 'production' },
   { label: 'Vue', value: 'vue' }
 ]

12-22: Add disabled state feedback

Consider adding visual feedback or tooltip when users attempt to interact with disabled items.

     <SegmentGroup defaultValue='react'>
       {frameworks.map((framework) => (
         <SegmentGroupItem
           key={framework.value}
           value={framework.value}
           disabled={framework.disabled}
+          title={framework.disabled ? 'This option is currently unavailable' : undefined}
         >
           {framework.label}
         </SegmentGroupItem>
       ))}
     </SegmentGroup>
packages/ui/src/segment-group.tsx (2)

6-23: LGTM! Consider enhancing accessibility.

The SegmentGroup implementation is well-structured with proper props handling and conditional styling.

Consider adding ARIA attributes for better accessibility:

 <SegmentGroupPrimitive.Root
   orientation={orientation}
+  role="tablist"
+  aria-orientation={orientation}
   className={cn(
     'flex items-start',
     orientation === 'horizontal' ? 'gap-4 border-b' : 'flex-col gap-1 border-l',
     className
   )}
   {...rest}
 >

45-65: LGTM! Consider adding keyboard navigation styles.

The implementation handles states well and includes proper accessibility elements.

Consider adding keyboard focus styles for better navigation:

   className={cn(
     'text-muted-foreground hover:text-accent-foreground cursor-pointer font-medium transition-colors',
     'data-[orientation=horizontal]:px-1 data-[orientation=horizontal]:pb-3',
     'data-[orientation=vertical]:px-3 data-[orientation=vertical]:py-1.5',
     'data-[state=checked]:text-foreground',
     'data-[disabled]:text-muted-foreground data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',
+    'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
     className
   )}
.changeset/swift-phones-relax.md (1)

1-5: Consider adding more details to the changeset.

While the patch version is appropriate, the description could be more informative.

Consider expanding the description:

 ---
 '@tszhong0411/ui': patch
 ---
 
-Add Segment Group component
+Add Segment Group component
+
+- Introduces new SegmentGroup component with horizontal/vertical orientations
+- Includes support for disabled states and keyboard navigation
+- Provides proper accessibility features via ARIA attributes
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 640f7f3 and bd30342.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • .changeset/swift-phones-relax.md (1 hunks)
  • apps/docs/src/app/ui/components/segment-group.mdx (1 hunks)
  • apps/docs/src/components/demos/segment-group/disabled.tsx (1 hunks)
  • apps/docs/src/components/demos/segment-group/segment-group.tsx (1 hunks)
  • apps/docs/src/components/demos/segment-group/vertical.tsx (1 hunks)
  • apps/docs/src/config/links.ts (1 hunks)
  • package.json (2 hunks)
  • packages/ui/src/index.ts (1 hunks)
  • packages/ui/src/segment-group.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/docs/src/app/ui/components/segment-group.mdx
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: TypeScript
  • GitHub Check: Knip
  • GitHub Check: Tests
  • GitHub Check: ESLint
🔇 Additional comments (5)
packages/ui/src/index.ts (1)

42-42: LGTM!

The segment-group export is correctly added and maintains the alphabetical ordering of exports.

packages/ui/src/segment-group.tsx (1)

27-41: LGTM! Clean implementation of the indicator.

The indicator component effectively uses data attributes and CSS variables for dynamic positioning and dimensions.

apps/docs/src/config/links.ts (1)

169-172: LGTM! Properly integrated into navigation.

The Segment Group component link is correctly added and maintains alphabetical ordering.

package.json (2)

36-36: LGTM! Improved prepare script.

Adding package builds to the prepare script ensures dependencies are properly built during installation.


82-82: Verify the tsup downgrade impact.

The downgrade from tsup 8.3.6 to 8.3.0 might affect build outputs.

✅ Verification successful

The tsup downgrade from 8.3.6 to 8.3.0 is safe.

All changes between these versions are non-breaking bug fixes and improvements, following semantic versioning principles. The core build functionality remains unchanged.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for breaking changes between tsup versions
npm view [email protected] version
npm view [email protected] version

# Check for any reported issues
gh api graphql -f query='
{
  repository(owner: "egoist", name: "tsup") {
    issues(states: OPEN, first: 5, orderBy: {field: CREATED_AT, direction: DESC}) {
      nodes {
        title
        url
        createdAt
      }
    }
  }
}'

Length of output: 1148


Script:

#!/bin/bash
# Check release notes and commits between versions
gh api graphql -f query='
{
  repository(owner: "egoist", name: "tsup") {
    releases(first: 10, orderBy: {field: CREATED_AT, direction: DESC}) {
      nodes {
        tagName
        description
        createdAt
      }
    }
  }
}'

# Get commit history between versions
gh api repos/egoist/tsup/compare/v8.3.0...v8.3.6

Length of output: 66635

@tszhong0411 tszhong0411 merged commit 7497b37 into main Jan 30, 2025
15 of 18 checks passed
@tszhong0411 tszhong0411 deleted the pack-43-add-segment-group branch January 30, 2025 16:05
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.

1 participant