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

Enhance: Admin settings page responsive #2475

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

osmansufy
Copy link
Contributor

@osmansufy osmansufy commented Dec 10, 2024

All Submissions:

  • My code follow the WordPress' coding standards
  • My code satisfies feature requirements
  • My code is tested
  • My code passes the PHPCS tests
  • My code has proper inline documentation
  • I've included related pull request(s) (optional)
  • I've included developer documentation (optional)
  • I've added proper labels to this pull request

Changes proposed in this Pull Request:

Related Pull Request(s)

  • Full PR Link

Closes

How to test the changes in this Pull Request:

  • Steps or issue link

Changelog entry

admin panel settings page responsive & update ui design

Detailed Description of the pull request. What was previous behaviour
and what will be changed in this PR.

Settings page responsive for mobile version with drower & search functionality

Before Changes

Describe the issue before changes with screenshots(s).

After Changes

Describe the issue after changes with screenshot(s).

Feature Video (optional)

Link of detailed video if this PR is for a feature.

PR Self Review Checklist:

  • Code is not following code style guidelines
  • Bad naming: make sure you would understand your code if you read it a few months from now.
  • KISS: Keep it simple, Sweetie (not stupid!).
  • DRY: Don't Repeat Yourself.
  • Code that is not readable: too many nested 'if's are a bad sign.
  • Performance issues
  • Complicated constructions that need refactoring or comments: code should almost always be self-explanatory.
  • Grammar errors.

FOR PR REVIEWER ONLY:

As a reviewer, your feedback should be focused on the idea, not the person. Seek to understand, be respectful, and focus on constructive dialog.

As a contributor, your responsibility is to learn from suggestions and iterate your pull request should it be needed based on feedback. Seek to collaborate and produce the best possible contribution to the greater whole.

  • Correct — Does the change do what it’s supposed to? ie: code 100% fulfilling the requirements?
  • Secure — Would a nefarious party find some way to exploit this change? ie: everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities?
  • Readable — Will your future self be able to understand this change months down the road?
  • Elegant — Does the change fit aesthetically within the overall style and architecture?

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a mobile-friendly settings drawer for improved navigation on smaller screens.
    • Enhanced search functionality with a suggestions dropdown based on user input.
  • Bug Fixes

    • Improved layout flexibility of the Settings Banner for better responsiveness.
    • Enhanced styling and responsiveness of admin notices for better usability on smaller screens.
  • Documentation

    • Updated template structure and styling for the Settings page to enhance user experience.

Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

Walkthrough

The changes include the introduction of a new Vue.js component named MobileSettingsDrawer within MobileSettingsList.vue, designed for mobile-friendly settings management. This component allows users to toggle a settings drawer that dynamically displays settings sections. Additionally, modifications to SettingsBanner.vue enhance its layout flexibility without altering functionality. The Settings.vue page has been significantly updated to incorporate the mobile drawer, improve search functionality, and manage visibility states for both the drawer and search suggestions.

Changes

File Change Summary
src/admin/components/Settings/MobileSettingsList.vue Added MobileSettingsDrawer component with props for isOpen, sections, and currentTab; introduced handleTabChange method.
src/admin/components/SettingsBanner.vue Modified CSS to include flex-wrap: wrap; for improved layout flexibility.
src/admin/pages/Settings.vue Updated template and JavaScript logic to implement mobile drawer, added data properties for visibility management, and improved search functionality.
assets/src/less/global-admin.less Enhanced responsiveness of admin notices with new styles for .dokan-admin-notices and its children.
src/admin/components/AdminNotice.vue Added a new <div> to wrap action buttons in the notice component for improved layout organization.

Assessment against linked issues

Objective Addressed Explanation
Ensure responsive design for dokan admin settings (2733)
Improve layout of admin notices for responsiveness (2733)

Suggested labels

QA approved, :+1: Dev Review Done, Upcoming Release

Suggested reviewers

  • mrabbani

Poem

In a drawer that opens with ease,
Settings await, just like a breeze.
Mobile-friendly, oh what a sight,
With tabs to switch, it feels just right.
Click and close, it's all a delight,
Hopping through settings, day or night! 🐇✨


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.

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

🧹 Outside diff range and nitpick comments (6)
src/admin/pages/Settings.vue (5)

18-18: Fix typo in class name from "nab-section" to "nav-section"

The class name "nab-section" appears to be a typo. It should probably be "nav-section" to maintain consistency with other navigation elements.

Apply this diff to correct the class name:

-<div class="nab-section block">
+<div class="nav-section block">

47-56: Enhance accessibility by adding an aria-label to the search input

To improve accessibility for screen reader users, consider adding an aria-label to the search input element. This provides a textual description of the input's purpose.

Apply this diff to add the aria-label:

<input
    type="text"
    id="dokan-admin-search"
    class="w-full px-3 py-2 border-none focus:outline-none focus:ring-0 bg-transparent"
    :placeholder="__('Search e.g. vendor', 'dokan-lite')"
    v-model="searchText"
    @input="searchInSettings"
    ref="searchInSettings"
+   :aria-label="__('Search Settings', 'dokan-lite')"
    />

205-221: Consider renaming 'MobileSettingsList.vue' to 'MobileSettingsDrawer.vue' for clarity

The MobileSettingsDrawer component is exported from MobileSettingsList.vue. Renaming the file to MobileSettingsDrawer.vue would improve consistency and make the codebase easier to navigate.

Remove unused import of 'MobileSettingsList' component

The MobileSettingsList component is imported but not used in the code. Removing this unused import will clean up the code.

Apply this diff to remove the unused import:

-import MobileSettingsList from "admin/components/Settings/MobileSettingsList.vue";

let Loading     = dokan_get_lib('Loading');
let AdminNotice = dokan_get_lib('AdminNotice');

import Fields from "admin/components/Fields.vue"
import SettingsBanner from "admin/components/SettingsBanner.vue";
import UpgradeBanner from "admin/components/UpgradeBanner.vue";
import MobileSettingsDrawer from "admin/components/Settings/MobileSettingsList.vue";

export default {

    name: 'Settings',

    components: {
        MobileSettingsDrawer,
-       MobileSettingsList,
        Fields,
        Loading,
        SettingsBanner,
        UpgradeBanner,
        AdminNotice,
    },

1242-1301: Remove commented-out code to clean up the stylesheet

There's a block of commented-out code from lines 1242 to 1301. Removing unused code enhances readability and maintainability.

Apply this diff to remove the unnecessary code:

-//@media only screen and (max-width: 430px) {
-//    .dokan-settings-wrap {
-//        .nav-tab-wrapper {
-//
-//            .nav-tab {
-//                padding-left: 10px !important;
-//
-//                img {
-//                    margin: 3px 8px 0px 4px;
-//                }
-//
-//                .nav-content {
-//                    .nav-title {
-//                        font-size: 7px;
-//                    }
-//
-//                    .nav-description {
-//                        font-size: 5px !important;
-//                    }
-//                }
-//            }
-//
-//            .nav-tab-active {
-//                &:before {
-//                    width: 2px !important;
-//                }
-//            }
-//        }
-//
-//        .metabox-holder {
-//            width: 100%;
-//
-//            .settings-header {
-//                display: block;
-//
-//                .settings-content {
-//                    .settings-title,
-//                    .settings-description {
-//                        padding-left: 0;
-//                    }
-//                }
-//
-//                .settings-document-button {
-//                    text-align: left;
-//                }
-//            }
-//        }
-//
-//        .search-box {
-//            .dashicons.dashicons-search {
-//                margin-left: 10px;
-//            }
-//
-//            .dokan-admin-search-settings {
-//                font-size: 10px;
-//            }
-//        }
-//    }
-//}

1341-1357: Avoid redundant nested media queries

There's a nested @media (max-width: 768px) inside an existing media query with the same condition starting at line 1302. The inner media query is redundant and can be removed to simplify the CSS.

Apply this diff to eliminate the redundant media query:

-        @media (max-width: 768px) {
             .dokan-settings-wrap {
                 .nav-tab-wrapper {
                     padding: 10px;

                     .mobile-settings-list {
                         margin-top: 1rem;

                         .setting-section {
                             &.active {
                                 border-left: 4px solid #246EFE;
                             }

                             &:hover {
                                 background-color: #f9fafb;
                             }
                         }
                     }
                 }
             }
-        }
src/admin/components/Settings/MobileSettingsList.vue (1)

57-81: Enhance accessibility with ARIA roles and focus management

To improve accessibility, consider adding ARIA roles such as role="dialog" to the drawer container. Additionally, manage focus by trapping it within the drawer when it's open and returning focus to the triggering element when it's closed.

Example modification:

<div
    :class="[
        'fixed top-0 left-0 h-full w-[85%] max-w-[320px] bg-white z-[1000000] transform transition-transform duration-300 ease-in-out',
        isOpen ? 'translate-x-0' : '-translate-x-full'
    ]"
+   role="dialog"
+   aria-modal="true"
>

Implement focus management in the mounted and beforeDestroy lifecycle hooks.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 31194fa and 5319a8b.

📒 Files selected for processing (3)
  • src/admin/components/Settings/MobileSettingsList.vue (1 hunks)
  • src/admin/components/SettingsBanner.vue (1 hunks)
  • src/admin/pages/Settings.vue (9 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/admin/components/SettingsBanner.vue
🔇 Additional comments (3)
src/admin/pages/Settings.vue (2)

115-124: MobileSettingsDrawer component integration looks good

The MobileSettingsDrawer component is properly integrated with the correct props and event handlers, enhancing the mobile user experience.


125-136: Desktop navigation tabs are correctly rendered

The desktop navigation tabs are displayed accurately with appropriate data bindings and event handling.

src/admin/components/Settings/MobileSettingsList.vue (1)

1-54: MobileSettingsDrawer component implementation is well-structured

The MobileSettingsDrawer component is effectively implemented, providing a responsive and user-friendly mobile settings menu. The use of props and event emissions for isOpen, sections, and currentTab ensures flexibility and reusability.

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

🧹 Outside diff range and nitpick comments (3)
src/admin/pages/Settings.vue (3)

21-41: Enhance accessibility of the mobile menu toggle button.

The button implementation is good, but could be improved for better accessibility.

 <button
     class="d-xs:flex md:hidden p-2.5 bg-white border border-gray-200 rounded-lg shadow-sm hover:bg-gray-50 transition-all duration-200 ease-in-out group focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
     @click="openMobileDrawer"
+    aria-expanded="showMobileDrawer"
+    aria-controls="mobile-settings-drawer"
 >
     <svg
         xmlns="http://www.w3.org/2000/svg"
         viewBox="0 0 24 24"
         width="24"
         height="24"
+        aria-hidden="true"
         class="group-hover:scale-110 transition-transform duration-200"
     >

1242-1303: Optimize responsive styling implementation.

The responsive styling could be improved with better organization and maintainability.

+<style lang="less">
+// Variables
+@mobile-breakpoint: 768px;
+@drawer-transition-duration: 0.3s;
+
+// Mixins
+.mobile-only {
+    @media only screen and (max-width: @mobile-breakpoint) {
+        @content;
+    }
+}

 @media only screen and (max-width: 768px) {
     .dokan-settings-wrap {
         .nav-tab-wrapper {
             overflow: inherit !important;
             z-index: 444;
             width: 100% !important;
             padding: 1rem !important;
         }
         
         // ... other styles ...
         
         .slide-enter-active, .slide-leave-active {
-            transition: transform 0.3s ease-out;
+            transition: transform @drawer-transition-duration ease-out;
         }
         
         // Remove duplicate media query
-        @media (max-width: 768px) {
-            .dokan-settings-wrap {
-                // ... duplicate styles ...
-            }
-        }
     }
 }
</style>

Line range hint 1-1304: Consider splitting the component into smaller, more focused components.

The Settings component is quite large and handles multiple responsibilities. Consider extracting some functionality into separate components:

  1. SearchBox component for search functionality
  2. SettingsHeader component for the header section
  3. SettingsNavigation component for the navigation tabs

This would improve maintainability and make the code more testable.

Would you like me to provide an example of how to split this component?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5319a8b and 85187e0.

📒 Files selected for processing (2)
  • src/admin/components/Settings/MobileSettingsList.vue (1 hunks)
  • src/admin/pages/Settings.vue (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/admin/components/Settings/MobileSettingsList.vue

Comment on lines +113 to +121
<transition name="slide">
<MobileSettingsDrawer
:is-open="showMobileDrawer"
:sections="settingSections"
:current-tab="currentTab"
@close="closeMobileDrawer"
@change-tab="changeTab"
/>
</transition>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance mobile drawer usability and accessibility.

The mobile drawer implementation could be improved with better keyboard navigation and click-outside behavior.

 <transition name="slide">
     <MobileSettingsDrawer
         :is-open="showMobileDrawer"
         :sections="settingSections"
         :current-tab="currentTab"
+        :aria-modal="true"
+        :role="dialog"
+        @keydown.esc="closeMobileDrawer"
         @close="closeMobileDrawer"
         @change-tab="changeTab"
     />
 </transition>

 methods: {
     openMobileDrawer() {
         this.showMobileDrawer = true;
+        document.body.style.overflow = 'hidden'; // Prevent background scroll
         this.searchText = '';
         this.validateBlankSearch();
+        this.$nextTick(() => {
+            // Focus first interactive element
+            this.$refs.mobileDrawer.$el.querySelector('button,a').focus();
+        });
     },

     closeMobileDrawer() {
         this.showMobileDrawer = false;
+        document.body.style.overflow = ''; // Restore scroll
     },

+    handleClickOutside(event) {
+        if (this.showMobileDrawer && !this.$refs.mobileDrawer.$el.contains(event.target)) {
+            this.closeMobileDrawer();
+        }
+    },
 },

+mounted() {
+    document.addEventListener('click', this.handleClickOutside);
+},

+beforeDestroy() {
+    document.removeEventListener('click', this.handleClickOutside);
+},

Also applies to: 698-710

Comment on lines +43 to +108
<div class="relative flex-1">
<!-- Search Box -->
<div class="search-section relative w-full mb-4">
<div class="search-box w-full bg-white rounded-md border border-gray-200 flex items-center">
<label for="dokan-admin-search" class="dashicons dashicons-search "></label>
<input
type="text"
autocomplete="off"
id="dokan-admin-search"
class="w-full px-3 py-2 border-none focus:outline-none focus:ring-0 bg-transparent "
:placeholder="__('Search e.g. vendor', 'dokan-lite')"
v-model="searchText"
@input="searchInSettings"
ref="searchInSettings"
/>
<span
v-if="searchText !== ''"
class="dashicons dashicons-no-alt mr-3 text-gray-400 cursor-pointer hover:text-gray-600"
@click.prevent="clearSearch"
></span>
</div>

<!-- Search Suggestions Dropdown -->
<div
v-if="searchText && settingSections.length > 0"
class="d-xs:absolute md:hidden left-0 right-0 top-[calc(100%+4px)] bg-white border border-gray-200 rounded-lg shadow-lg divide-y divide-gray-100 max-h-[280px] overflow-y-auto z-50"
>
<div
v-for="section in settingSections"
:key="section.id"
class="hover:bg-gray-50 transition-colors cursor-pointer"
@click="handleSectionClick(section)"
>
<div class="p-3">
<div class="flex items-center gap-3">
<img
:src="section.icon_url"
:alt="section.title"
class="w-5 h-5"
/>
<div class="flex-1 min-w-0">
<div class="text-sm font-medium text-gray-900 truncate">
{{ section.title }}
</div>
<div class="text-xs text-gray-500 mt-0.5 line-clamp-1">
{{ section.description }}
</div>
</div>
<svg
class="w-4 h-4 text-gray-400 flex-shrink-0"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 5l7 7-7 7"
/>
</svg>
</div>
</div>
</div>
</div>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve search functionality robustness.

The search implementation could be enhanced in several ways:

  1. The debounce delay should be configurable
  2. Add loading state during search
  3. Handle potential search failures
 data () {
     return {
         // ... other data properties
+        searchDebounceDelay: 300, // Configurable delay
+        isSearching: false,
     }
 },
 methods: {
     searchInSettings(input) {
         if (!this.validateBlankSearch()) {
             return;
         }

+        this.isSearching = true;
         if (!this.awaitingSearch) {
-            setTimeout(() => {
+            setTimeout(async () => {
                 let searchText = this.$refs.searchInSettings.value;
                 searchText = searchText.replace(/\s\s+/g,' ').trim().toLowerCase();
                 
                 this.doSearch('');
-                this.doSearch(searchText);
+                try {
+                    await this.doSearch(searchText);
+                } catch (error) {
+                    console.error('Search failed:', error);
+                    // Handle error appropriately
+                } finally {
+                    this.isSearching = false;
+                }
                 this.awaitingSearch = false;
                 this.showSuggestions = true;
-            }, 1000);
+            }, this.searchDebounceDelay);
         }
         this.awaitingSearch = true;
     },

Then update the template to show loading state:

 <div class="search-box w-full bg-white rounded-md border border-gray-200 flex items-center">
     <label for="dokan-admin-search" class="dashicons dashicons-search"></label>
     <input
         type="text"
         autocomplete="off"
         id="dokan-admin-search"
         class="w-full px-3 py-2 border-none focus:outline-none focus:ring-0 bg-transparent"
         :placeholder="__('Search e.g. vendor', 'dokan-lite')"
         v-model="searchText"
         @input="searchInSettings"
         ref="searchInSettings"
+        :disabled="isSearching"
     />
+    <span v-if="isSearching" class="loading-spinner mr-3"></span>
     <span
         v-if="searchText !== ''"
         class="dashicons dashicons-no-alt mr-3 text-gray-400 cursor-pointer hover:text-gray-600"
         @click.prevent="clearSearch"
     ></span>
 </div>

Committable suggestion skipped: line range outside the PR's diff.

@osmansufy osmansufy self-assigned this Dec 12, 2024
@osmansufy osmansufy changed the title Enhance: Admin settiongs page responsive Enhance: Admin settings page responsive Dec 12, 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 (2)
src/admin/pages/Settings.vue (2)

Line range hint 204-254: Clean up scroll event listener on component destruction.

The scroll event listener is added in the created hook but not removed when the component is destroyed, which could lead to memory leaks.

 beforeDestroy() {
     window.removeEventListener('resize', this.updateDocumentWidth);
+    window.removeEventListener('scroll', this.handleScroll);
 }

Line range hint 1107-1306: Optimize styles for better performance.

Consider performance optimizations for the styles:

  1. Combine multiple box-shadow and filter properties
  2. Use transform: translate3d for hardware acceleration
 .search-section {
-    filter: drop-shadow(0px 0.0869484px 0.260845px rgba(0, 0, 0, 0.1)) drop-shadow(0px 0.869484px 1.73897px rgba(0, 0, 0, 0.2));
+    filter: drop-shadow(0px 0.869484px 1.73897px rgba(0, 0, 0, 0.25));

     .dashicons.dashicons-no-alt {
-        transform: translate(0%, -60%);
+        transform: translate3d(0, -60%, 0);
     }
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 85187e0 and 8380a53.

📒 Files selected for processing (1)
  • src/admin/pages/Settings.vue (9 hunks)
🔇 Additional comments (2)
src/admin/pages/Settings.vue (2)

43-108: Previous feedback about search implementation remains applicable.

The search implementation could still benefit from the robustness improvements suggested in the previous review.


113-121: Previous feedback about mobile drawer usability remains applicable.

The mobile drawer implementation could still benefit from the accessibility and usability improvements suggested in the previous review.

Comment on lines +21 to +41
<button
class="d-xs:flex md:hidden p-2.5 bg-white border border-gray-200 rounded-lg shadow-sm hover:bg-gray-50 transition-all duration-200 ease-in-out group focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
@click="openMobileDrawer"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
width="24"
height="24"
class="group-hover:scale-110 transition-transform duration-200"
>
<path
stroke="#246EFE"
stroke-width="2.5"
stroke-linecap="round"
d="M4 6h16M4 12h16M4 18h16"
class="group-hover:stroke-[#1b4fd1]"
/>
</svg>
<span class="sr-only">{{ __('Toggle Settings Menu', 'dokan-lite') }}</span>
</button>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance mobile toggle button accessibility.

The mobile toggle button implementation should include additional ARIA attributes for better screen reader support.

 <button
     class="d-xs:flex md:hidden p-2.5 bg-white border border-gray-200 rounded-lg shadow-sm hover:bg-gray-50 transition-all duration-200 ease-in-out group focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
     @click="openMobileDrawer"
+    :aria-expanded="showMobileDrawer"
+    aria-controls="mobile-settings-drawer"
+    v-tooltip="__('Toggle Settings Menu', 'dokan-lite')"
 >

Committable suggestion skipped: line range outside the PR's diff.

@osmansufy osmansufy requested a review from mrabbani December 12, 2024 05:09
@osmansufy osmansufy added Type: Enhancement Needs: Dev Review It requires a developer review and approval labels Dec 12, 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: 3

🧹 Outside diff range and nitpick comments (4)
assets/src/less/global-admin.less (3)

258-262: Consider using CSS Grid for better responsive layout.

The flex-direction column layout with gap is good, but CSS Grid could provide more flexibility for complex responsive layouts.

.notice-content {
-    flex-direction: column;
-    align-items: start !important;
-    gap: 1rem;
+    display: grid;
+    grid-template-columns: 1fr;
+    grid-gap: 1rem;
+    align-items: start;
}

Line range hint 1107-1167: Enhance search input accessibility.

The search input styling could benefit from improved accessibility features.

input {
    width: 100%;
    height: 48px;
    border: none;
    display: block;
    padding: 0 45px 0 0;
    background: transparent;
    font-weight: 400;
    font-family: Roboto, sans-serif;
+    -webkit-appearance: none;
+    appearance: none;

    &:focus {
        outline: none;
        box-shadow: none;
        border-color: transparent;
+        box-shadow: 0 0 0 2px rgba(36, 110, 254, 0.2);
    }
+    
+    &::placeholder {
+        color: rgba(60, 60, 67, 0.6);
+        opacity: 1;
+    }
}

Line range hint 1242-1300: Optimize mobile responsive styles.

The mobile styles could be improved for better maintainability and performance.

  1. Use CSS custom properties for breakpoints
  2. Consolidate duplicate selectors
  3. Remove unnecessary !important flags
+:root {
+    --mobile-breakpoint: 768px;
+    --tablet-breakpoint: 1024px;
+}

-@media only screen and (max-width: 768px)
+@media only screen and (max-width: var(--mobile-breakpoint))
.dokan-settings-wrap {
    .nav-tab-wrapper {
-        overflow: inherit !important;
-        z-index: 444;
-        width: 100% !important;
-        padding: 1rem !important;
+        overflow: visible;
+        z-index: 10;
+        width: 100%;
+        padding: 1rem;
    }
    // ... rest of the styles
}
src/admin/pages/Settings.vue (1)

251-254: Consider using Vuex for state management.

The component manages multiple pieces of state that could be shared across components. Using Vuex would improve state management and component communication.

Consider moving the following state to Vuex:

  • screenWidth
  • showMobileDrawer
  • showSuggestions
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8380a53 and 4ff866f.

📒 Files selected for processing (2)
  • assets/src/less/global-admin.less (2 hunks)
  • src/admin/pages/Settings.vue (9 hunks)
🔇 Additional comments (2)
assets/src/less/global-admin.less (1)

290-308: ⚠️ Potential issue

Standardize responsive breakpoints.

The breakpoint range (376px-576px) leaves a 1px gap with the previous media query (max-width: 375px). This could cause layout issues.

-@media screen and (min-width: 376px) and (max-width: 576px)
+@media screen and (min-width: 375px) and (max-width: 576px)

Likely invalid or redundant comment.

src/admin/pages/Settings.vue (1)

698-710: Add debounce to search functionality.

The search implementation could benefit from debouncing to prevent excessive API calls.

This issue was previously identified in a past review comment. Please refer to the existing suggestion for implementing debounced search functionality.

Comment on lines 267 to 274
align-items: start;
padding: 10px 20px;
.dokan-message {
margin: 0 0 0 23px;
div{
max-height: 50px;
overflow: scroll;
}
margin: 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve scroll behavior for message content.

Using overflow: scroll forces scrollbars even when unnecessary. Consider using overflow-y: auto for better UX.

.dokan-message {
    margin: 0;
    div {
-        max-height: 50px;
-        overflow: scroll;
+        max-height: 50px;
+        overflow-y: auto;
    }
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
align-items: start;
padding: 10px 20px;
.dokan-message {
margin: 0 0 0 23px;
div{
max-height: 50px;
overflow: scroll;
}
margin: 0;
align-items: start;
padding: 10px 20px;
.dokan-message {
margin: 0;
div {
max-height: 50px;
overflow-y: auto;
}

Comment on lines +1287 to +1295
.setting-section {
&.active {
border-left: 4px solid #246EFE;
}

.nav-description {
font-size: 8px !important;
&:hover {
background-color: #f9fafb;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance mobile navigation accessibility.

The mobile navigation could benefit from improved keyboard navigation and ARIA attributes.

.setting-section {
+    position: relative;
+    outline: none;

    &.active {
        border-left: 4px solid #246EFE;
+        background-color: rgba(36, 110, 254, 0.05);
    }

    &:hover {
        background-color: #f9fafb;
    }

+    &:focus-visible {
+        box-shadow: 0 0 0 2px #246EFE;
+    }
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.setting-section {
&.active {
border-left: 4px solid #246EFE;
}
.nav-description {
font-size: 8px !important;
&:hover {
background-color: #f9fafb;
}
}
.setting-section {
position: relative;
outline: none;
&.active {
border-left: 4px solid #246EFE;
background-color: rgba(36, 110, 254, 0.05);
}
&:hover {
background-color: #f9fafb;
}
&:focus-visible {
box-shadow: 0 0 0 2px #246EFE;
}
}

Comment on lines +1274 to +1279
.slide-enter-active, .slide-leave-active {
transition: transform 0.3s ease-out;
}
}
}
.slide-enter, .slide-leave-to {
transform: translateX(-100%);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve transition performance.

The current transition implementation might cause layout thrashing. Consider using transform-based animations for better performance.

.slide-enter-active, .slide-leave-active {
-    transition: transform 0.3s ease-out;
+    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
+    will-change: transform;
}

.slide-enter, .slide-leave-to {
    transform: translateX(-100%);
+    pointer-events: none;
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.slide-enter-active, .slide-leave-active {
transition: transform 0.3s ease-out;
}
}
}
.slide-enter, .slide-leave-to {
transform: translateX(-100%);
}
.slide-enter-active, .slide-leave-active {
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
will-change: transform;
}
.slide-enter, .slide-leave-to {
transform: translateX(-100%);
pointer-events: none;
}

assets/src/less/global-admin.less Outdated Show resolved Hide resolved
Comment on lines +258 to +262
.notice-content{
flex-direction: column;
align-items: start !important;
gap: 1rem;
}
Copy link
Member

Choose a reason for hiding this comment

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

This section is also used for 576px. Could remove this replication?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@media only screen and (max-width: 375px) for very small screen
@media screen and (min-width: 376px) and (max-width: 576px) for small screen.

two separate scrreen bhai .

as it is not conflicted code ,we can skip.

@@ -276,21 +287,33 @@

@media screen and (min-width: 376px) and (max-width: 576px) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we care about (min-width: 376px) in the above code section? Pls see the recommended screen sizes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bhai,
@media screen was impliment prev PR .
I think we can skip this refactor as it is working

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

🧹 Nitpick comments (1)
src/admin/components/AdminNotice.vue (1)

16-21: Consider improving accessibility for action buttons.

While the structural change is good, consider enhancing accessibility:

-<div>
+<div class="dokan-notice-actions" role="group" aria-label="Notice Actions">

This change would:

  • Add semantic meaning to the button group
  • Improve screen reader navigation
  • Follow ARIA best practices
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4ff866f and 71e6b10.

📒 Files selected for processing (2)
  • assets/src/less/global-admin.less (2 hunks)
  • src/admin/components/AdminNotice.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • assets/src/less/global-admin.less
🔇 Additional comments (1)
src/admin/components/AdminNotice.vue (1)

16-21: Verify CSS changes for the new action buttons wrapper.

The addition of a wrapper div around action buttons might require corresponding CSS changes to maintain proper styling, especially for mobile responsiveness.

✅ Verification successful

The wrapper div is consistent with existing CSS styles

The CSS inspection shows that the admin notice component already has styles handling div elements within .dokan-message, including specific mobile-friendly rules for content overflow:

.dokan-message {
    div {
        max-height: 50px;
        overflow: auto;
    }
    margin: 0;
}

The addition of the wrapper div around action buttons aligns with the existing CSS structure and mobile responsiveness implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for related CSS changes in global-admin.less and other style files

# Search for CSS selectors targeting notice action buttons
rg -t less "dokan-admin-notice.*dokan-btn" 

# Search for any new CSS rules added for the action buttons wrapper
rg -t less "dokan-message.*div" 

Length of output: 78


Script:

#!/bin/bash
# Let's try different search patterns to find CSS related to admin notices and buttons

# Search for CSS rules related to admin notices
rg -t less "\.dokan-admin-notice"

# Search for button styles within admin-related CSS
rg -t less "\.dokan-btn"

# Search for any CSS files that might contain relevant styles
fd -e less -e css

Length of output: 5960


Script:

#!/bin/bash
# Let's check the specific CSS rules for admin notices and their buttons in global-admin.less

# Get the content of admin notice styles with context
rg -A 10 "\.dokan-admin-notice \{" assets/src/less/global-admin.less

# Check for any mobile/responsive styles for admin notices
rg -A 10 "@media.*dokan-admin-notice" assets/src/less/global-admin.less
rg -A 10 "@media.*dokan-admin-notice" assets/src/less/responsive.less

Length of output: 1521

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Dev Review It requires a developer review and approval Type: Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants