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(style-panel): modify this style-panel styles according to the design craft #853

Merged
merged 70 commits into from
Nov 8, 2024

Conversation

betterdancing
Copy link
Contributor

@betterdancing betterdancing commented Oct 11, 2024

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new TabsGroupConfigurator component for improved tabbed interfaces across various settings.
    • Enhanced NumberConfigurator with unit selection and improved layout.
    • Added support for selecting background types and sizes using the new tabs-group-configurator.
    • New prop teleport in ModalMask.vue for customizable modal positioning.
    • Added new CSS variables for enhanced theming options.
  • Improvements

    • Streamlined user interactions in several components, including ImageSetting and RadialGradient, by replacing tooltips with tabbed selections.
    • Updated styling across components for a more cohesive look and feel, including adjustments to dimensions and colors.
    • Enhanced layout and visual presentation in the BackgroundGroup and TypographyGroup components.
    • Refined typography settings interface for better organization and user interaction.
    • Improved the layout options in LayoutGroup for clarity and usability.
    • Enhanced visual representation of spacing controls in SpacingGroup.
    • Adjusted CSS variables for better theming and consistency across styles.
  • Bug Fixes

    • Fixed input handling in NumericSelect to ensure only valid numeric entries are accepted.
  • Chores

    • Updated internal constants for consistency in label casing and terminology throughout the application.

@betterdancing betterdancing changed the base branch from develop to refactor/develop October 11, 2024 09:33
@github-actions github-actions bot added the refactor-main refactor/develop branch feature label Oct 11, 2024
Copy link
Contributor

coderabbitai bot commented Oct 11, 2024

Walkthrough

This pull request introduces several modifications across various Vue components within the configurator and settings packages. Key changes include enhancements to the NumberConfigurator component for improved unit selection, the introduction of a new TabsGroupConfigurator component, and the replacement of tooltip-based selections with tabbed interfaces in background settings. Additionally, several components have undergone styling updates and structural changes to improve user interaction and visual presentation.

Changes

File Path Change Summary
packages/configurator/src/index.js Imported and exported TabsGroupConfigurator component.
packages/configurator/src/number-configurator/NumberConfigurator.vue Enhanced template with conditional rendering for unit selection; added props for selected unit and unit width.
packages/configurator/src/slider-configurator/SliderConfigurator.vue Updated background color of input element; no changes to functionality.
packages/configurator/src/tabs-group-configurator/TabsGroupConfigurator.vue Introduced new component for managing tabbed interface with collapsible options.
packages/settings/styles/src/components/background/BackgroundGroup.vue Replaced <label> with <span> elements; added new title section in modal.
packages/settings/styles/src/components/background/BackgroundImageGradient.vue Updated gradient colors and adjusted styles for various elements.
packages/settings/styles/src/components/background/BackgroundImageSetting.vue Replaced tooltip with tabs-group-configurator for background type selection.
packages/settings/styles/src/components/background/ImageSetting.vue Streamlined template and logic for background image settings; replaced size selection layout.
packages/settings/styles/src/components/background/RadialGradient.vue Replaced tooltip with tabs-group-configurator for radial size options.
packages/settings/styles/src/components/size/SizeGroup.vue Updated text labels to full terms; replaced tooltip-based overflow options with tabs-group-configurator.
packages/settings/styles/src/components/layout/LayoutGroup.vue Replaced RadioConfigurator with TabsGroupConfigurator, simplifying state management.
packages/settings/styles/src/components/typography/TypographyGroup.vue Restructured typography settings with new layout; added support for multiple properties.
packages/settings/styles/src/Main.vue Introduced isCollapsed prop and handoverGroup method for managing collapse state.
packages/settings/styles/src/components/spacing/SpacingGroup.vue Enhanced SVG elements and styles for spacing controls.
packages/theme/light/base.less Added new CSS variable --ti-lowcode-base-bg-7 for theming.
packages/theme/light/setting-style.less Introduced several new CSS custom properties for setting styles.
packages/settings/styles/src/components/effects/EffectGroup.vue Changed <label> elements to <span> elements for opacity, outline, and cursor settings.
packages/settings/styles/src/components/inputs/ResetButton.vue Updated styling for reset button; removed width property and changed border color.
packages/settings/styles/src/components/position/PositionGroup.vue Added <span> for "定位" text; updated styles for improved presentation.
packages/layout/src/DesignSettings.vue Introduced isCollapsed property for toggling the settings panel visibility.
packages/settings/styles/src/components/inputs/NumericSelect.vue Enhanced input handling with new increment and decrement functionality; restructured suffix layout.
packages/theme/base/src/common.less Added new CSS variable --te-common-text-description for descriptive text color.
packages/common/component/MetaCodeEditor.vue Updated props and error handling for improved functionality and user interface.
packages/configurator/src/color-configurator/ColorConfigurator.vue Introduced computed property inputColor for better color input handling.
packages/settings/styles/src/components/border/BorderGroup.vue Replaced button-group with tabs-group-configurator for style options presentation.
packages/settings/styles/src/components/classNamesContainer/index.vue Adjusted layout and styling for class names container component.
packages/theme/dark/variable.less Updated modal background opacity variable for dark theme.
packages/theme/light/variable.less Updated modal background opacity variable for light theme.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • hexqi
  • chilingling
  • rhlin

Poem

🐇 In the land of colors bright,
Changes hop with pure delight.
Tabs and inputs, all in line,
Making choices feel divine.
With a click, the colors flow,
In this garden, watch them grow! 🌼


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.

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

🧹 Outside diff range and nitpick comments (6)
packages/settings/styles/src/components/inputs/NumericSelect.vue (2)

53-54: Improve null value handling.

The initialization with null is good, but consider adding type validation to ensure consistent behavior.

-const numericalModelValue = ref(props.numericalText || null)
+const numericalModelValue = ref(props.numericalText !== undefined ? String(props.numericalText) : null)

113-123: Consider improving the numeric input styling.

The current styles could be enhanced for better visual hierarchy and consistency.

 :deep(.tiny-numeric) {
   width: 100%;
   .tiny-numeric__input-inner {
     padding-right: 22px;
+    height: 24px;
+    line-height: 24px;
   }

   .tiny-numeric__unit {
     font-size: 12px;
     color: var(--te-common-text-weaken);
     background-color: var(--te-common-bg-default);
+    padding: 0 4px;
+    border-radius: 0 2px 2px 0;
   }
 }
packages/configurator/src/tabs-group-configurator/TabsGroupConfigurator.vue (4)

18-31: Extract popover component to reduce code duplication

The popover logic is duplicated across multiple places in the template. Consider extracting it into a reusable component.

Create a new component TooltipLabel.vue:

<template>
  <span v-if="label && !content">{{ label }}</span>
  <tiny-popover
    v-if="content"
    :effect="effect"
    :placement="placement"
    :visible-arrow="false"
    :content="content"
    trigger="hover"
  >
    <template #reference>
      <span v-if="label">{{ label }}</span>
      <svg-icon v-if="icon" :name="icon" class="bem-Svg"></svg-icon>
    </template>
  </tiny-popover>
</template>

<script setup>
defineProps({
  label: String,
  content: String,
  icon: String,
  effect: String,
  placement: String
})
</script>

Also applies to: 72-85


96-103: Optimize imports for better tree-shaking

Consider importing components directly from their respective modules.

Apply this diff:

-import {
-  Popover as TinyPopover,
-  ButtonGroup as TinyButtonGroup,
-  Button as TinyButton,
-  Dropdown as TinyDropdown,
-  DropdownMenu as TinyDropdownMenu,
-  DropdownItem as TinyDropdownItem
-} from '@opentiny/vue'
+import TinyPopover from '@opentiny/vue/popover'
+import TinyButtonGroup from '@opentiny/vue/button-group'
+import TinyButton from '@opentiny/vue/button'
+import TinyDropdown from '@opentiny/vue/dropdown'
+import TinyDropdownMenu from '@opentiny/vue/dropdown-menu'
+import TinyDropdownItem from '@opentiny/vue/dropdown-item'

141-143: Improve type handling in getItemWidth

The function unnecessarily parses a number prop back to integer.

Apply this diff:

 const getItemWidth = (collapsed = false) => {
-  return `${parseInt(props.labelWidth, 10) + (collapsed ? 15 : 0)}`
+  return props.labelWidth + (collapsed ? 15 : 0)
 }

190-196: Improve style maintainability with CSS variables

Use CSS variables for better theme management and maintainability.

Apply this diff:

+:root {
+  --tab-height: 24px;
+  --tab-font-size: 12px;
+  --tab-border-radius: 4px;
+  --tab-max-width: 210px;
+  --tab-z-index: 9999;
+}

 .tab-container {
-  max-width: 210px;
-  height: 24px;
-  font-size: 12px;
+  max-width: var(--tab-max-width);
+  height: var(--tab-height);
+  font-size: var(--tab-font-size);
   background-color: var(--ti-lowcode-setting-style-tab-bg-color);
   display: flex;
-  border-radius: 4px;
+  border-radius: var(--tab-border-radius);
 }

 .tiny-dropdown-menu {
   // ...
-  z-index: 9999;
+  z-index: var(--tab-z-index);
   box-shadow: 0 0 10px 0 var(--te-common-border-default);
 }

Also applies to: 273-274

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f66542f and 19ba1f3.

📒 Files selected for processing (7)
  • packages/common/component/MetaCodeEditor.vue (3 hunks)
  • packages/configurator/src/color-configurator/ColorConfigurator.vue (4 hunks)
  • packages/configurator/src/slider-configurator/SliderConfigurator.vue (2 hunks)
  • packages/configurator/src/tabs-group-configurator/TabsGroupConfigurator.vue (1 hunks)
  • packages/settings/styles/src/components/inputs/NumericSelect.vue (4 hunks)
  • packages/theme/dark/variable.less (1 hunks)
  • packages/theme/light/variable.less (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • packages/theme/dark/variable.less
  • packages/theme/light/variable.less
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/common/component/MetaCodeEditor.vue
  • packages/configurator/src/color-configurator/ColorConfigurator.vue
  • packages/configurator/src/slider-configurator/SliderConfigurator.vue
🔇 Additional comments (4)
packages/settings/styles/src/components/inputs/NumericSelect.vue (3)

3-16: ⚠️ Potential issue

Improve accessibility and user experience of the numeric input.

The current implementation has several UX concerns:

  1. Hiding the unit on hover reduces accessibility and usability
  2. Using hover state on touch devices is problematic

Remove the hover-based unit visibility:

 <tiny-numeric
   v-model="numericalModelValue"
   :placeholder="placeholder"
   controls-position="right"
   :unit="numericalSuffix"
   :empty-value="null"
   allow-empty
-  @mouseover="isNumericHover = true"
-  @mouseleave="isNumericHover = false"
   @focus="focus = true"
   @blur="focus = false"
   @change="change"
 >
 </tiny-numeric>

59-62: ⚠️ Potential issue

Remove hover-dependent suffix logic.

The suffix should always be visible for better accessibility and user experience.

 const numericalSuffix = computed(() => {
   const val = String(numericalModelValue.value).toLowerCase()
-  if (isNumericHover.value) {
-    return ''
-  }
   return val === 'auto' || val === 'none' || percentageReg(val) ? '-' : props.suffix
 })

125-134: ⚠️ Potential issue

Remove redundant suffix styles.

These styles are now handled by the tiny-numeric component and should be removed to prevent conflicts.

-.suffix-wrap {
-  .suffix-text {
-    font-size: 12px;
-    color: var(--te-common-text-weaken);
-  }
-
-  &:hover {
-    .suffix-text {
-      display: none;
-    }
-  }
-}
packages/configurator/src/tabs-group-configurator/TabsGroupConfigurator.vue (1)

105-130: 🛠️ Refactor suggestion

Add validation for props

The props lack proper validation which could lead to runtime errors.

Apply this diff:

 const props = defineProps({
   modelValue: {
     type: String,
     default: ''
   },
   valueKey: {
     type: String,
     default: ''
   },
   effect: {
     type: String,
+    validator: (value) => ['dark', 'light'].includes(value),
     default: 'dark'
   },
   placement: {
     type: String,
+    validator: (value) => [
+      'top', 'top-start', 'top-end',
+      'bottom', 'bottom-start', 'bottom-end'
+    ].includes(value),
     default: 'top'
   },
   labelWidth: {
     type: Number,
+    validator: (value) => value > 0,
     default: 63
   },
   options: {
     type: Array,
     default: () => [],
+    validator: (value) => value.every(item => 
+      typeof item === 'object' && 
+      'value' in item &&
+      (item.label !== undefined || item.icon !== undefined)
+    )
   }
 })

Likely invalid or redundant comment.

@chilingling chilingling added the ready_for_review This PR requires more reviews label Nov 7, 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: 1

🧹 Outside diff range and nitpick comments (3)
packages/settings/styles/src/components/inputs/NumericSelect.vue (1)

67-71: Improve watch handler for numericalText.

The current watch handler might cause unnecessary updates and doesn't handle edge cases properly.

   watch(
     () => props.numericalText,
     (newValue) => {
-      numericalModelValue.value = newValue || null
+      // Only update if values are different to prevent unnecessary renders
+      const currentValue = numericalModelValue.value
+      const newProcessedValue = newValue || null
+      if (String(currentValue) !== String(newProcessedValue)) {
+        numericalModelValue.value = newProcessedValue
+      }
     }
   )
packages/settings/styles/src/components/background/BackgroundImageSetting.vue (1)

115-134: Add property validation to prevent runtime errors

While the method correctly handles the new data structure, it would benefit from validation to ensure all required properties are present before accessing them.

Consider adding validation:

 const selectType = (value) => {
+  if (!value?.styleComponent) {
+    console.warn('Missing required styleComponent property')
+    return
+  }
   let styleObj = {}

   if (value.styleComponent === 'ImageSetting') {
+    if (!value.imageUrl || !value.position || !value.size) {
+      console.warn('Missing required ImageSetting properties')
+      return
+    }
     styleObj = {
       [BACKGROUND_PROPERTY.BackgroundImage]: `url(${value.imageUrl})`,
       [BACKGROUND_PROPERTY.BackgroundPosition]: value.position,
       [BACKGROUND_PROPERTY.BackgroundSize]: value.size
     }
   } else {
+    if (!value.imageUrl) {
+      console.warn('Missing required imageUrl property')
+      return
+    }
     styleObj = {
       [BACKGROUND_PROPERTY.BackgroundImage]: value.imageUrl,
       [BACKGROUND_PROPERTY.BackgroundPosition]: null,
       [BACKGROUND_PROPERTY.BackgroundSize]: null,
       [BACKGROUND_PROPERTY.BackgroundRepeat]: null,
       [BACKGROUND_PROPERTY.BackgroundAttachment]: null
     }
   }
packages/settings/styles/src/components/background/ImageSetting.vue (1)

147-156: Consider optimizing setBackgroundSize method

The method could be simplified by extracting the string transformation logic into a helper function to reduce code duplication.

+ const formatDimension = (value, suffix) => {
+   const lowered = value.toLowerCase()
+   return lowered === 'auto' ? lowered : `${lowered}${suffix}`
+ }

 const setBackgroundSize = () => {
-  const isAutoWidth = state.width.toLocaleLowerCase() === 'auto'
-  const isAutoHeight = state.height.toLocaleLowerCase() === 'auto'
-  const width = isAutoWidth ? state.width.toLocaleLowerCase() : `${state.width.toLocaleLowerCase() + state.widthSuffix}`
-  const height = isAutoHeight
-    ? state.height.toLocaleLowerCase()
-    : `${state.height.toLocaleLowerCase() + state.heightSuffix}`
+  const width = formatDimension(state.width, state.widthSuffix)
+  const height = formatDimension(state.height, state.heightSuffix)

   updateStyle({ [BACKGROUND_PROPERTY.BackgroundSize]: `${width} ${height}` })
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 19ba1f3 and 8249af4.

⛔ Files ignored due to path filters (2)
  • packages/design-core/assets/style-panel-collapsed.svg is excluded by !**/*.svg
  • packages/design-core/assets/style-panel-expand.svg is excluded by !**/*.svg
📒 Files selected for processing (9)
  • packages/configurator/src/color-configurator/ColorConfigurator.vue (4 hunks)
  • packages/configurator/src/number-configurator/NumberConfigurator.vue (3 hunks)
  • packages/configurator/src/tabs-group-configurator/TabsGroupConfigurator.vue (1 hunks)
  • packages/layout/src/DesignSettings.vue (4 hunks)
  • packages/settings/styles/src/components/background/BackgroundGroup.vue (11 hunks)
  • packages/settings/styles/src/components/background/BackgroundImageSetting.vue (6 hunks)
  • packages/settings/styles/src/components/background/ImageSetting.vue (8 hunks)
  • packages/settings/styles/src/components/inputs/NumericSelect.vue (4 hunks)
  • packages/theme/light/setting-style.less (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/configurator/src/color-configurator/ColorConfigurator.vue
  • packages/configurator/src/number-configurator/NumberConfigurator.vue
  • packages/configurator/src/tabs-group-configurator/TabsGroupConfigurator.vue
  • packages/layout/src/DesignSettings.vue
  • packages/settings/styles/src/components/background/BackgroundGroup.vue
  • packages/theme/light/setting-style.less
🔇 Additional comments (9)
packages/settings/styles/src/components/inputs/NumericSelect.vue (1)

111-124: Improve transitions and color contrast.

The current styles have a few issues:

  1. The transition property only specifies duration without properties
  2. The background color variable might not provide sufficient contrast
   transition: 0.3s;
+  transition: border-color 0.3s, background-color 0.3s;
   &.focus {
     border-color: var(--te-common-border-default);
   }
   :deep(.tiny-numeric) {
     width: 100%;
     .tiny-numeric__input-inner {
       padding-right: 22px;
+      // Ensure sufficient contrast with background
+      background-color: var(--te-common-bg-primary);
     }
packages/settings/styles/src/components/background/BackgroundImageSetting.vue (4)

5-13: LGTM: Clean implementation of TabsGroupConfigurator

The replacement of tooltip-based selection with TabsGroupConfigurator is well implemented with proper prop bindings and event handling.


30-30: LGTM: Proper import and component registration

The TabsGroupConfigurator is correctly imported and registered as a component.

Also applies to: 46-46


75-106: LGTM: Well-structured type definitions

The typeLists data structure has been improved with:

  • Clear property naming (content, icon)
  • Consistent value object structure for each type
  • Appropriate default values for required properties

Line range hint 216-225: LGTM: Clean and consistent styling

The line class styles are well-implemented using:

  • Project's CSS naming conventions
  • Theme variables for colors
  • Proper scoping and positioning
packages/settings/styles/src/components/background/ImageSetting.vue (4)

22-27: LGTM! Clean implementation of TabsGroupConfigurator

The TabsGroupConfigurator components are consistently implemented across size, repeat, and fixed options, providing a unified interface for user selections.

Also applies to: 56-61, 65-70


29-50: LGTM! Well-structured width/height controls

The implementation of width and height controls using InputSelect provides good user control with appropriate disable states based on the size selection.


244-245: LGTM! Consistent border styling

The border and border-radius styles are appropriately defined and use the correct CSS variables for consistency.

Also applies to: 329-330


76-77: Verify integration with tiny-engine-configurator

Please ensure that the TabsGroupConfigurator component from @opentiny/tiny-engine-configurator is properly tested with all the options and edge cases.

✅ Verification successful

TabsGroupConfigurator integration appears consistent and well-established

The component is being used consistently across multiple style-related components in the codebase:

  • Layout settings (LayoutGroup.vue)
  • Typography settings (TypographyGroup.vue)
  • Size settings (SizeGroup.vue)
  • Effects settings (EffectGroup.vue)
  • Border settings (BorderGroup.vue)
  • Background settings (ImageSetting.vue, BackgroundImageSetting.vue, RadialGradient.vue)

The package is properly declared as a dependency in all relevant package.json files, including settings/styles. The implementation pattern is consistent across all these components, suggesting established usage patterns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other usages of TabsGroupConfigurator to ensure consistent implementation

# Search for other TabsGroupConfigurator usages
echo "Checking TabsGroupConfigurator usage patterns:"
rg -A 2 "TabsGroupConfigurator" --type vue

# Search for related test files
echo -e "\nChecking for related test files:"
fd -e spec.js -e test.js -e spec.ts -e test.ts | rg -i "tabsgroupconfigurator|imagesetting"

Length of output: 348


Script:

#!/bin/bash
# Let's try a different approach to search for the component usage and tests

# Search for TabsGroupConfigurator usage with ripgrep without file type restriction
echo "Checking TabsGroupConfigurator usage patterns:"
rg "TabsGroupConfigurator" -l

# Search for imports from tiny-engine-configurator
echo -e "\nChecking imports from tiny-engine-configurator:"
rg "from ['|\"]@opentiny/tiny-engine-configurator['|\"]" -A 2

# Search for test files in a different way
echo -e "\nChecking for related test files:"
find . -type f \( -name "*test*.js" -o -name "*test*.ts" -o -name "*spec*.js" -o -name "*spec*.ts" \) -exec grep -l -i "tabsgroupconfigurator\|imagesetting" {} \;

# Check if the package is properly declared in package.json
echo -e "\nChecking package.json for dependency:"
find . -name "package.json" -exec grep -l "@opentiny/tiny-engine-configurator" {} \;

Length of output: 9178

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

🧹 Outside diff range and nitpick comments (3)
packages/settings/styles/src/Main.vue (1)

132-136: Consider a more declarative approach for handoverGroup.

The current implementation mutates the array directly with shift(). Consider a more declarative approach that creates a new array instead.

-    const handoverGroup = (actives) => {
-      if (props.isCollapsed) {
-        activeNames.value = actives.length > 1 ? actives.shift() : actives
-      }
-    }
+    const handoverGroup = (actives) => {
+      if (props.isCollapsed) {
+        activeNames.value = actives.length > 1 ? [actives[0]] : actives
+      }
+    }
packages/configurator/src/tabs-group-configurator/TabsGroupConfigurator.vue (2)

132-137: Convert refs to computed properties for better reactivity.

Some refs could be computed properties to automatically react to changes.

Apply this diff:

-const picked = ref(null)
+const picked = ref(props.modelValue)
 const uncollapsedOptions = computed(() => props.options.filter((option) => !option.collapsed))
 const collapsedOptions = computed(() => props.options.filter((option) => option.collapsed))
-const foldsOptions = ref([])
+const foldsOptions = computed(() => 
+  collapsedOptions.value.length > 1 ? collapsedOptions.value.slice(1) : []
+)
-const selectedCollapsedOption = ref(null)
+const selectedCollapsedOption = computed(() => 
+  collapsedOptions.value.length ? collapsedOptions.value[0] : null
+)
 const isCollapsedSelected = ref(false)

236-267: Add transitions for smoother UX.

Add transitions for hover and selected states.

Apply this diff:

     .tiny-dropdown {
       display: flex;
       justify-content: center;
       align-items: center;
       height: 24px;
+      transition: background-color 0.2s ease, color 0.2s ease;
       background-color: var(--ti-lowcode-base-bg-5);
       color: var(--te-common-text-weaken);
       &.selected {
         background-color: var(--ti-lowcode-base-gray-101);
         color: var(--te-common-text-primary);
         border-radius: 4px;
       }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8249af4 and 1f4004d.

⛔ Files ignored due to path filters (2)
  • packages/design-core/assets/style-panel-collapsed.svg is excluded by !**/*.svg
  • packages/design-core/assets/style-panel-expand.svg is excluded by !**/*.svg
📒 Files selected for processing (5)
  • packages/configurator/src/number-configurator/NumberConfigurator.vue (3 hunks)
  • packages/configurator/src/tabs-group-configurator/TabsGroupConfigurator.vue (1 hunks)
  • packages/layout/src/DesignSettings.vue (4 hunks)
  • packages/settings/styles/src/Main.vue (6 hunks)
  • packages/theme/light/setting-style.less (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/configurator/src/number-configurator/NumberConfigurator.vue
  • packages/layout/src/DesignSettings.vue
  • packages/theme/light/setting-style.less
🔇 Additional comments (3)
packages/settings/styles/src/Main.vue (3)

30-30: LGTM: Event handler addition enhances collapse functionality.

The addition of the @change="handoverGroup" event handler to <tiny-collapse> properly implements the collapsible behavior control.


Line range hint 108-125: LGTM: Well-structured prop and computed property implementation.

The isCollapsed prop and activeNames computed property are well-implemented, providing a clean way to control the collapse state.


264-270: LGTM: Consistent use of CSS variables.

The new .dots class follows the project's CSS variable pattern, using --te-common-border-checked for theming consistency. This aligns with the existing usage of CSS variables throughout the component.

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

🧹 Outside diff range and nitpick comments (3)
packages/settings/styles/src/components/background/ImageSetting.vue (3)

22-27: Enhance accessibility for TabsGroupConfigurator components

The new tab group components need ARIA attributes to improve accessibility for screen readers.

Add aria-label attributes to describe the purpose of each tab group:

 <tabs-group-configurator
   :options="BACKGROUND_SIZE_OPTIONS"
   :modelValue="state.sizeSelected"
   label-width="67"
+  aria-label="Background size options"
   @update:modelValue="selectSize"
 ></tabs-group-configurator>

 <tabs-group-configurator
   :options="REPEAT_OPTIONS"
   :modelValue="state.repeat"
   label-width="50"
+  aria-label="Background repeat options"
   @update:modelValue="selectRepeat"
 ></tabs-group-configurator>

 <tabs-group-configurator
   :options="FIXED_OPTIONS"
   :modelValue="state.fixedSelected"
   label-width="98"
+  aria-label="Background attachment options"
   @update:modelValue="selectFixed"
 ></tabs-group-configurator>

Also applies to: 56-61, 65-70


190-197: Add validation to selectRepeat and selectFixed functions

The functions should validate input values against allowed options to prevent invalid states.

Add validation checks:

 const selectRepeat = (value) => {
+  if (!REPEAT_OPTIONS.some(option => option.value === value)) {
+    console.warn(`Invalid repeat value: ${value}`)
+    return
+  }
   state.repeat = value
   updateStyle({ [BACKGROUND_PROPERTY.BackgroundRepeat]: value })
 }

 const selectFixed = (value) => {
+  if (!FIXED_OPTIONS.some(option => option.value === value)) {
+    console.warn(`Invalid fixed value: ${value}`)
+    return
+  }
   state.fixedSelected = value
   updateStyle({ [BACKGROUND_PROPERTY.BackgroundAttachment]: value })
 }

244-245: Optimize image-wrap border styles

The border properties can be consolidated for better performance and maintainability.

Consolidate the border properties:

-  border: 1px dotted var(--te-common-border-default);
-  border-radius: 4px;
+  border: 1px dotted var(--te-common-border-default);
+  border-radius: var(--te-border-radius-small, 4px);

Consider using a design system variable for border-radius to maintain consistency across components.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1f4004d and 12127ac.

📒 Files selected for processing (1)
  • packages/settings/styles/src/components/background/ImageSetting.vue (9 hunks)

@hexqi hexqi merged commit ea73bff into opentiny:refactor/develop Nov 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready_for_review This PR requires more reviews refactor-main refactor/develop branch feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants