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

fix(time-picker): [time-picker] fixed a button style issue in the Sass theme #2330

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

wuyiping0628
Copy link
Collaborator

@wuyiping0628 wuyiping0628 commented Oct 21, 2024

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)

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:

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

  • New Features

    • Enhanced styles for the time range picker component, including a new footer section and button styles.
    • Introduced new button classes for improved interactivity, including cancel and confirm buttons.
  • Bug Fixes

    • Updated class names for buttons to ensure consistent styling and behavior within the time range picker.

Copy link

coderabbitai bot commented Oct 21, 2024

Walkthrough

The changes in this pull request involve the addition of new styles to the time range picker component in the index.less file, which includes a new footer section and button styles. Additionally, modifications are made to the template sections of two Vue component files, updating button class names to incorporate the new styles. These updates enhance the layout and interactivity of the time range picker without altering its underlying functionality.

Changes

File Path Change Summary
packages/theme-saas/src/time-range/index.less Added new styles for &__footer and &__btn classes, including .cancel and .confirm modifiers.
packages/vue/src/time-range/src/pc.vue Updated cancel button class from tiny-time-range-picker__btn to tiny-time-range-picker__btn cancel.
packages/vue/src/time/src/pc.vue Changed <tiny-button> class from tiny-time-panel__btn to tiny-time-panel__btn cancel conditionally.

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • zzcr

🐇 In the meadow where time does play,
New buttons and styles come out to sway.
With footers and colors, oh what a sight,
The time range picker shines so bright!
So hop along, let’s click and cheer,
For lovely changes are finally here! 🐇✨


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.

@github-actions github-actions bot added the bug Something isn't working label Oct 21, 2024
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

🧹 Outside diff range and nitpick comments (5)
packages/theme-saas/src/time-range/index.less (3)

38-46: LGTM! Consider adding responsive padding.

The footer styles look good and are consistent with the project's styling approach. The flexbox layout is appropriate for positioning footer elements.

Consider adding responsive padding for better mobile experience:

-    @apply py-3 px-4;
+    @apply py-3 px-4 sm:px-6;

48-60: LGTM! Consider adding focus styles for accessibility.

The button styles provide a good base for appearance and are consistent with the project's styling approach.

Consider adding focus styles for better accessibility:

     @apply outline-0;
+    @apply focus:ring-2 focus:ring-color-brand focus:ring-offset-2;

61-75: Enhance cancel button styles for consistency and accessibility.

While the differentiation between cancel and confirm buttons is good, the cancel button lacks hover and focus styles.

Consider adding hover and focus styles to the cancel button for consistency and improved accessibility:

   &.cancel {
     @apply text-color-brand;
     @apply text-left;
     @apply rounded;
+    @apply hover:bg-color-brand hover:bg-opacity-10;
+    @apply focus:ring-2 focus:ring-color-brand focus:ring-offset-2;
   }

   &.confirm {
     @apply text-color-text-inverse;
     @apply bg-color-brand;
     @apply rounded;
+    @apply focus:ring-2 focus:ring-color-brand focus:ring-offset-2;

     &:hover {
       @apply bg-color-brand-hover;
     }
   }
packages/vue/src/time/src/pc.vue (1)

39-41: LGTM! Consider a minor improvement for clarity.

The addition of the 'cancel' class to the button aligns with the PR objective of fixing a button style issue. This change is consistent with the new styles introduced in the index.less file.

For improved readability, consider using a computed property for the button's class. This would make the template cleaner and move the logic to the script section. For example:

<template>
  <tiny-button v-if="!state.showTimePickerButton" :class="cancelButtonClass" @click="handleCancel()">
    {{ t('ui.datepicker.cancel') }}
  </tiny-button>
</template>

<script>
export default {
  // ... other code ...
  computed: {
    cancelButtonClass() {
      return ['tiny-time-panel__btn', 'cancel']
    }
  }
}
</script>

This approach would make it easier to add or modify classes in the future without cluttering the template.

packages/vue/src/time-range/src/pc.vue (1)

81-81: LGTM! Consider applying the same class structure to the confirm button.

The addition of the cancel class to the cancel button is a good improvement for more specific styling. This change follows the BEM (Block Element Modifier) methodology, which is a best practice for CSS naming conventions.

For consistency, consider applying a similar class structure to the confirm button. You could add a confirm class to it as well. For example:

-          :class="{
-            'tiny-time-range-picker__btn': !state.showTimePickerRangeButton,
-            confirm: !state.disabled && !state.showTimePickerRangeButton
-          }"
+          :class="[
+            'tiny-time-range-picker__btn',
+            { confirm: !state.disabled && !state.showTimePickerRangeButton }
+          ]"

This change would make the class structure consistent between the cancel and confirm buttons, improving the overall maintainability of the component.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 65d3aeb and 857f7d8.

📒 Files selected for processing (3)
  • packages/theme-saas/src/time-range/index.less (1 hunks)
  • packages/vue/src/time-range/src/pc.vue (1 hunks)
  • packages/vue/src/time/src/pc.vue (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
packages/theme-saas/src/time-range/index.less (1)

37-76: Summary: Styling changes align with PR objectives and enhance component usability.

The introduced styles for the footer and buttons in the time range picker component successfully address the PR's objective of fixing a button style issue. The changes improve the component's appearance and functionality while maintaining consistency with the project's styling approach.

The suggestions made for accessibility and responsiveness should further enhance the user experience without significantly altering the intended design. These improvements align well with best practices in web development.

@zzcr zzcr merged commit 455332c into opentiny:dev Oct 21, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants