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

feat: add resizable and ColPage component #5188

Merged
merged 2 commits into from
Dec 19, 2024

Conversation

mynetfan
Copy link
Collaborator

@mynetfan mynetfan commented Dec 19, 2024

Description

  1. 在shadcn-ui中添加resizable组件
  2. Page组件的基础上扩展一个双列布局组件ColPage,支持拖拽改变宽度、左侧折叠等功能,以及配套Demo

Type of change

Please delete options that are not relevant.

  • 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)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced the GripVertical icon to the icon set.
    • Added ResizableHandle and ResizablePanelGroup components for enhanced layout flexibility.
    • Implemented the ColPage component for a customizable dual-column layout.
    • New route ColPageDemo added to showcase the dual-column layout in the examples section.
  • Documentation

    • Expanded localization options with new entries for "resize" and "layout" in English and Chinese JSON files.

Copy link

changeset-bot bot commented Dec 19, 2024

⚠️ No Changeset found

Latest commit: 093db98

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.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

Copy link
Contributor

coderabbitai bot commented Dec 19, 2024

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.

packages/@core/base/icons/src/lucide.ts

Oops! Something went wrong! :(

ESLint: 9.16.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/node_modules/@vben/eslint-config/dist/index.mjs' imported from /eslint.config.mjs
at finalizeResolution (node:internal/modules/esm/resolve:257:11)
at moduleResolve (node:internal/modules/esm/resolve:914:10)
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)

Walkthrough

This pull request introduces a comprehensive set of changes focused on enhancing the UI layout and component system. The modifications include adding a new resizable column page component (ColPage), expanding icon exports, and introducing new routing and localization configurations. The changes primarily revolve around creating a flexible, two-column layout with resizable panels, supporting dynamic width adjustments, and providing a new example implementation in the playground.

Changes

File Path Change Summary
@core/base/icons/src/lucide.ts Added GripVertical icon export
@core/ui-kit/shadcn-ui/src/ui/index.ts Added export for resizable module
@core/ui-kit/shadcn-ui/src/ui/resizable/ New components: ResizableHandle.vue, ResizablePanelGroup.vue, updated index.ts
effects/common-ui/src/components/col-page/ New ColPage component with types.ts, index.ts, and col-page.vue
effects/common-ui/src/components/page/ Updated page.vue and types.ts with new PageProps interface
playground/src/locales/langs/ Added localization entries for resize and layout
playground/src/router/routes/modules/examples.ts Added new route for ColPageDemo
playground/src/views/examples/layout/col-page.vue New example view demonstrating ColPage component

Sequence Diagram

sequenceDiagram
    participant User
    participant ColPage
    participant ResizablePanelGroup
    participant ResizablePanel
    participant ResizableHandle

    User->>ColPage: Interact with layout
    ColPage->>ResizablePanelGroup: Configure panel group
    ResizablePanelGroup->>ResizablePanel: Set panel properties
    ResizablePanelGroup->>ResizableHandle: Configure handle
    User->>ResizableHandle: Resize panels
    ResizableHandle->>ResizablePanelGroup: Update panel sizes
Loading

Possibly related PRs

Suggested Labels

feature

Suggested Reviewers

  • vince292007
  • anncwb

Poem

🐰 Resizable panels dance and sway,
Columns stretch in a flexible play,
Icons grip, handles slide with grace,
A layout that adapts to every space,
Code rabbits rejoice in design today! 🎉


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 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@mynetfan mynetfan changed the title Feat/add resizable component feat: add resizable and ColPage component Dec 19, 2024
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: 4

🧹 Nitpick comments (12)
packages/effects/common-ui/src/components/col-page/index.ts (1)

1-2: LGTM! Consider documenting component composition.

The export structure aligns well with the existing Page component pattern. Since this is a new feature, consider adding a README.md in the col-page directory to document the component's relationship with Page and resizable components.

A README.md would help developers understand:

  • Component hierarchy (ColPage -> Page)
  • Integration with resizable components
  • Usage examples and best practices
packages/@core/ui-kit/shadcn-ui/src/ui/resizable/index.ts (1)

3-3: Consider pinning radix-vue version.

Since we're relying on a specific component (SplitterPanel) from radix-vue, it would be beneficial to ensure version compatibility.

Consider:

  • Adding radix-vue version to peerDependencies
  • Documenting minimum required version
  • Adding version compatibility tests
packages/effects/common-ui/src/components/page/types.ts (1)

1-11: Documentation and type constraints could be improved

Consider the following improvements:

  1. Add JSDoc comments for all properties to improve documentation
  2. Consider adding string literal types for class properties to constrain possible values
  3. Translate the Chinese comment to English for consistency
 export interface PageProps {
+  /** Title of the page */
   title?: string;
+  /** Description text for the page */
   description?: string;
+  /** CSS class(es) to apply to the content container */
-  contentClass?: string;
+  contentClass?: `${string}`;
   /**
-   * 根据content可见高度自适应
+   * Automatically adjust height based on visible content
    */
   autoContentHeight?: boolean;
+  /** CSS class(es) to apply to the header */
-  headerClass?: string;
+  headerClass?: `${string}`;
+  /** CSS class(es) to apply to the footer */
-  footerClass?: string;
+  footerClass?: `${string}`;
 }
packages/effects/common-ui/src/components/col-page/types.ts (1)

4-8: Translate Chinese comments to English

For consistency, translate the Chinese comments to English.

   /**
-   * 左侧宽度
+   * Left panel width
    * @default 30
    */

   /**
-   * 右侧宽度
+   * Right panel width
    * @default 70
    */

Also applies to: 14-16

packages/@core/ui-kit/shadcn-ui/src/ui/resizable/ResizablePanelGroup.vue (2)

13-15: Consider adding explicit return type for props.

For better type safety and documentation, consider adding an explicit return type to the props definition:

-const props = defineProps<
-  { class?: HTMLAttributes['class'] } & SplitterGroupProps
->();
+type ResizablePanelGroupProps = { class?: HTMLAttributes['class'] } & SplitterGroupProps;
+const props = defineProps<ResizablePanelGroupProps>();

26-38: Consider enhancing accessibility attributes.

The component could benefit from additional ARIA attributes to improve accessibility:

 <SplitterGroup
   v-bind="forwarded"
+  role="group"
+  aria-label="Resizable panel group"
   :class="
     cn(
       'flex h-full w-full data-[panel-group-direction=vertical]:flex-col',
       props.class,
     )
   "
 >
   <slot></slot>
 </SplitterGroup>
packages/@core/ui-kit/shadcn-ui/src/ui/resizable/ResizableHandle.vue (3)

34-37: Consider extracting the long class string into a constant.

The inline class string is quite long and could be harder to maintain. Consider extracting it into a constant or utility function for better maintainability.

+const baseClasses = 'bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1 [&[data-orientation=vertical]>div]:rotate-90 [&[data-orientation=vertical]]:h-px [&[data-orientation=vertical]]:w-full [&[data-orientation=vertical]]:after:left-0 [&[data-orientation=vertical]]:after:h-1 [&[data-orientation=vertical]]:after:w-full [&[data-orientation=vertical]]:after:-translate-y-1/2 [&[data-orientation=vertical]]:after:translate-x-0';

 <SplitterResizeHandle
   v-bind="forwarded"
   :class="
     cn(
-      'bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1 [&[data-orientation=vertical]>div]:rotate-90 [&[data-orientation=vertical]]:h-px [&[data-orientation=vertical]]:w-full [&[data-orientation=vertical]]:after:left-0 [&[data-orientation=vertical]]:after:h-1 [&[data-orientation=vertical]]:after:w-full [&[data-orientation=vertical]]:after:-translate-y-1/2 [&[data-orientation=vertical]]:after:translate-x-0',
+      baseClasses,
       props.class,
     )
   "

1-48: Add component documentation.

Consider adding JSDoc comments to document:

  • Component purpose and usage
  • Props description
  • Events emitted
  • Example usage
+/**
+ * ResizableHandle Component
+ * 
+ * A customizable resize handle component that supports both horizontal and vertical orientations.
+ * Integrates with radix-vue's SplitterResizeHandle for resize functionality.
+ *
+ * @component
+ * @example
+ * <ResizableHandle
+ *   withHandle
+ *   class="my-custom-class"
+ * />
+ */
 <script setup lang="ts">

40-46: Consider adding aria-label for accessibility.

The handle div should have an aria-label to improve accessibility for screen readers.

 <div
   class="bg-border z-10 flex h-4 w-3 items-center justify-center rounded-sm border"
+  aria-label="Resize handle"
 >
packages/effects/common-ui/src/components/col-page/col-page.vue (1)

25-41: Optimize slot delegation performance

The slot delegation logic recalculates on every render. Consider memoizing the filtered slot names.

-const delegatedSlots = computed(() => {
+const delegatedSlots = computed(() => {
+  if (!slots) return [];
+  return Object.keys(slots).filter(key => !['default', 'left'].includes(key));
+});
-  const resultSlots: string[] = [];
-
-  for (const key of Object.keys(slots)) {
-    if (!['default', 'left'].includes(key)) {
-      resultSlots.push(key);
-    }
-  }
-  return resultSlots;
-});
playground/src/views/examples/layout/col-page.vue (1)

17-27: Consider using ref instead of reactive for primitive values

Using reactive for an object of primitives can lead to unwanted proxy overhead. Consider using ref for individual values.

-const props = reactive({
+const props = {
+  leftCollapsedWidth: ref(5),
+  leftCollapsible: ref(true),
+  leftMaxWidth: ref(50),
+  leftMinWidth: ref(20),
+  leftWidth: ref(30),
+  resizable: ref(true),
+  rightWidth: ref(70),
+  splitHandle: ref(false),
+  splitLine: ref(false),
-});
playground/src/router/routes/modules/examples.ts (1)

240-250: Consider grouping layout-related examples under a dedicated section.

Since this is introducing a new layout component example, consider restructuring to group future layout-related examples:

 {
+  name: 'LayoutExamples',
+  path: '/examples/layout',
+  meta: {
+    icon: 'material-symbols:layout-outline',
+    title: $t('examples.layout.title'),
+  },
+  children: [
     {
       name: 'ColPageDemo',
       path: '/examples/layout/col-page',
       component: () => import('#/views/examples/layout/col-page.vue'),
       meta: {
         badge: 'Alpha',
         badgeVariants: 'destructive',
         icon: 'material-symbols:horizontal-distribute',
         title: $t('examples.layout.col-page'),
       },
     },
+  ],
 },

This structure would:

  • Provide better organization for layout-related examples
  • Make it easier to add more layout examples in the future
  • Maintain consistency with other example categories like forms and tables
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1853ba1 and 093db98.

📒 Files selected for processing (16)
  • packages/@core/base/icons/src/lucide.ts (1 hunks)
  • packages/@core/ui-kit/shadcn-ui/src/ui/index.ts (1 hunks)
  • packages/@core/ui-kit/shadcn-ui/src/ui/resizable/ResizableHandle.vue (1 hunks)
  • packages/@core/ui-kit/shadcn-ui/src/ui/resizable/ResizablePanelGroup.vue (1 hunks)
  • packages/@core/ui-kit/shadcn-ui/src/ui/resizable/index.ts (1 hunks)
  • packages/effects/common-ui/src/components/col-page/col-page.vue (1 hunks)
  • packages/effects/common-ui/src/components/col-page/index.ts (1 hunks)
  • packages/effects/common-ui/src/components/col-page/types.ts (1 hunks)
  • packages/effects/common-ui/src/components/index.ts (1 hunks)
  • packages/effects/common-ui/src/components/page/index.ts (1 hunks)
  • packages/effects/common-ui/src/components/page/page.vue (2 hunks)
  • packages/effects/common-ui/src/components/page/types.ts (1 hunks)
  • playground/src/locales/langs/en-US/examples.json (1 hunks)
  • playground/src/locales/langs/zh-CN/examples.json (1 hunks)
  • playground/src/router/routes/modules/examples.ts (1 hunks)
  • playground/src/views/examples/layout/col-page.vue (1 hunks)
🔇 Additional comments (13)
packages/effects/common-ui/src/components/page/index.ts (1)

1-2: LGTM! Verify type exports usage.

The export pattern is clean and follows best practices. The addition of type exports supports the new ColPage component integration.

✅ Verification successful

LGTM! Type exports are correctly used by ColPage component

The type exports from page/types.ts are properly used by the ColPage component, which extends PageProps interface. This is verified by:

  • ColPage component imports and extends PageProps from page/types.ts
  • The types are correctly used in the implementation
  • No other issues found with the type exports
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of exported types across the codebase
# Expected: Find references to types from this module in ColPage implementation

# Search for imports from this module
rg -t typescript -t vue "from ['\"].*components/page['\"]"

Length of output: 99


Script:

#!/bin/bash
# Search for imports from page component with ripgrep
# Using more generic pattern without file type flags
rg "from ['\"].*components/page['\"]"

# Also search for potential relative imports
rg "from ['\"]\.\.?/page['\"]"

Length of output: 155


Script:

#!/bin/bash
# Let's check for any files that might be using the Page component or its types
# Search for 'Page' or 'PageProps' usage in the codebase
rg "Page(Props)?" --type-add 'vue:*.vue' --type vue --type ts

# Also check the content of the types file to understand what's being exported
cat packages/effects/common-ui/src/components/page/types.ts

Length of output: 24047

packages/@core/ui-kit/shadcn-ui/src/ui/resizable/index.ts (1)

1-3: LGTM! Verify radix-vue integration.

The export structure is clean and the component naming is intuitive. The aliasing of SplitterPanel to ResizablePanel provides a more consistent API.

✅ Verification successful

Radix Vue integration verified, but version management needs attention

The integration is correctly set up across multiple packages (@vben/docs, @vben-core/composables, @vben-core/shadcn-ui), but all are using "catalog:" as the version specifier. This appears to be a monorepo-specific version management approach, likely using a version catalog or workspace-level dependency management.

  • packages/@core/ui-kit/shadcn-ui/src/ui/resizable/index.ts: The integration is valid and working as intended
  • Consider documenting the version management strategy in the repository's documentation if not already present
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify radix-vue dependency and integration
# Expected: Find package.json with radix-vue dependency

# Check for radix-vue in package.json files
fd package.json | xargs jq -r 'select(.dependencies["radix-vue"] != null) | "Found radix-vue in \(.name): \(.dependencies["radix-vue"])"'

Length of output: 281


Script:

#!/bin/bash
# Let's check the actual version specified in package.json files
fd package.json | xargs cat | grep -A 2 '"radix-vue":'

# Also check if there are any peer dependencies specified
fd package.json | xargs cat | grep -A 5 '"peerDependencies":'

Length of output: 518

packages/effects/common-ui/src/components/index.ts (1)

3-3: LGTM!

The new export for col-page is correctly placed and follows the established pattern.

packages/effects/common-ui/src/components/col-page/types.ts (1)

1-26: Verify width calculations

The default values and width constraints should be verified to ensure they work correctly together.

✅ Verification successful

Let's search for the actual implementation and usage of these props to verify the width calculations.


Width calculations are properly implemented and constrained

The implementation shows that the width calculations are working correctly:

  • Default values are properly set (leftWidth: 30, rightWidth: 70)
  • The component uses ResizablePanelGroup with proper constraints:
    • leftMinWidth, leftMaxWidth, leftCollapsedWidth are properly bound
    • rightMinWidth, rightMaxWidth, rightCollapsedWidth are properly bound
  • The playground example demonstrates proper validation:
    • Left min/max width constraints are enforced (min: 1%, max: 100%)
    • Slider ensures min width can't exceed max width - 1
    • Max width can't be less than min width + 1
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of ColPageProps to verify width calculations
ast-grep --pattern 'const $props = defineProps<ColPageProps>()' -A 10

Length of output: 71


Script:

#!/bin/bash
# Search for files that import and use ColPageProps
rg -l "ColPageProps" --type ts

# Search for implementation of width calculations
rg "leftWidth|rightWidth" --type ts -A 5

Length of output: 1132


Script:

#!/bin/bash
# Let's look for the actual component implementation to see how these widths are used
fd "col-page" --type f --extension vue --extension tsx --extension jsx

# Also search for any computed styles or width calculations
rg "style.*width" --type vue --type tsx --type jsx -A 5

Length of output: 270


Script:

#!/bin/bash
# Let's examine the component implementation files we found
cat packages/effects/common-ui/src/components/col-page/col-page.vue
cat playground/src/views/examples/layout/col-page.vue

Length of output: 5647

packages/@core/ui-kit/shadcn-ui/src/ui/index.ts (1)

19-19: LGTM!

The new export for the resizable component follows the established pattern and is properly integrated with the existing exports.

packages/@core/base/icons/src/lucide.ts (1)

31-31: LGTM!

The GripVertical icon export is appropriately added and follows the established pattern. The icon choice is semantically correct for its intended use in the resizable handle component.

packages/@core/ui-kit/shadcn-ui/src/ui/resizable/ResizablePanelGroup.vue (1)

1-38: Well-structured component with good TypeScript integration!

The component is well-implemented with proper:

  • TypeScript support
  • Props forwarding
  • Utility class usage
  • Slot implementation
playground/src/locales/langs/zh-CN/examples.json (1)

63-64: LGTM! Translation is accurate and consistent.

The Chinese translation "双列布局" (two-column layout) accurately represents the feature's purpose and maintains consistency with the English version.

packages/@core/ui-kit/shadcn-ui/src/ui/resizable/ResizableHandle.vue (1)

14-19: LGTM! Props are well-typed and documented.

The TypeScript interface extends SplitterResizeHandleProps appropriately while adding custom props for flexibility.

playground/src/locales/langs/en-US/examples.json (1)

60-64: LGTM! Translations are clear and consistent.

The English translations are professional and maintain consistency with the Chinese localization file. Both the "Resize" and "ColPage Layout" entries accurately describe their respective features.

packages/effects/common-ui/src/components/page/page.vue (1)

2-2: LGTM! Type refactoring improves reusability

Moving from inline Props interface to a separate PageProps type improves type reusability and maintainability.

Let's verify the PageProps type definition:

Also applies to: 20-20

✅ Verification successful

Let me verify the original Props interface to ensure all properties are included in the new PageProps type.


Based on the verification results, I can now generate the final response:

Type refactoring is correctly implemented

The PageProps interface in types.ts contains all necessary properties:

  • Optional title, description for page metadata
  • Optional styling classes (contentClass, headerClass, footerClass)
  • Optional autoContentHeight flag with documentation

The component correctly uses these props through defineProps() with proper default value for autoContentHeight.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify PageProps type contains all necessary properties
ast-grep --pattern 'export interface PageProps {
  $$$
}'

Length of output: 910


Script:

#!/bin/bash
# Get the original Props interface definition from git history
git log -p packages/effects/common-ui/src/components/page/page.vue | grep -A 20 "interface Props"

Length of output: 0


Script:

#!/bin/bash
# Alternative: Search for Props interface in current file
ast-grep --pattern 'interface Props {
  $$$
}' packages/effects/common-ui/src/components/page/page.vue

Length of output: 104


Script:

#!/bin/bash
# Check component usage of props
rg -A 5 "defineProps|withDefaults" packages/effects/common-ui/src/components/page/page.vue

Length of output: 253

packages/effects/common-ui/src/components/col-page/col-page.vue (2)

19-23: 🛠️ Refactor suggestion

Consider validating width props

The default widths (30/70) add up to 100%, but there's no runtime validation to ensure user-provided values maintain this constraint.

Consider adding a validator:

+const validateWidths = ({ leftWidth, rightWidth }: ColPageProps) => {
+  return leftWidth + rightWidth === 100;
+};
+
 const props = withDefaults(defineProps<ColPageProps>(), {
   leftWidth: 30,
   rightWidth: 70,
   resizable: true,
+}, {
+  leftWidth: validateWidths,
+  rightWidth: validateWidths,
 });

69-105: Verify ResizablePanel accessibility

The resizable panels should maintain ARIA attributes for accessibility.

Consider adding ARIA labels to improve accessibility:

 <ResizablePanelGroup class="w-full" direction="horizontal">
   <ResizablePanel
     ref="leftPanelRef"
+    aria-label="Left panel"
     :collapsed-size="leftCollapsedWidth"
     :collapsible="leftCollapsible"
     :default-size="leftWidth"
   >
   <!-- ... -->
   </ResizablePanel>
   <ResizablePanel
+    aria-label="Right panel"
     :collapsed-size="rightCollapsedWidth"
     :collapsible="rightCollapsible"
     :default-size="rightWidth"
   >
   <!-- ... -->
   </ResizablePanel>
 </ResizablePanelGroup>

@mynetfan mynetfan merged commit acd87b2 into vbenjs:main Dec 19, 2024
14 of 15 checks passed
@mynetfan mynetfan deleted the feat/add-resizable-component branch December 19, 2024 12:37
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