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

General UI improvements #2 #17576

Merged
merged 7 commits into from
Dec 20, 2024
Merged

General UI improvements #2 #17576

merged 7 commits into from
Dec 20, 2024

Conversation

kulczy
Copy link
Member

@kulczy kulczy commented Dec 16, 2024

image image image image image

Summary by CodeRabbit

  • New Features

    • Enhanced visual styling for dropdown items in the sidebar navigation.
    • Improved layout for translation forms with a new three-column display.
  • Bug Fixes

    • Adjusted the active state styling for dropdown items in the menu.
  • Style

    • Modified margin and layout properties across various templates to improve visual spacing and organization.
    • Updated icon rendering in dropdown menus for consistent styling.
    • Adjusted styling for product taxon selection interface and card components.
  • Documentation

    • No changes made.

@kulczy kulczy requested review from a team as code owners December 16, 2024 13:55
@probot-autolabeler probot-autolabeler bot added the Admin AdminBundle related issues and PRs. label Dec 16, 2024
Copy link

coderabbitai bot commented Dec 16, 2024

Walkthrough

The pull request introduces a series of styling and layout modifications across various Twig templates in the Sylius AdminBundle. The changes primarily focus on adjusting CSS classes, margins, and visual representations of form elements, dropdown items, and table components. These modifications aim to refine the user interface by altering column layouts, spacing, and styling of different sections in the admin panel, without fundamentally changing the underlying functionality of the templates.

Changes

File Change Summary
src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_sidebar.scss Updated dropdown item styling with new color properties for background and active states.
src/Sylius/Bundle/AdminBundle/templates/product/form/sections/taxonomy/product_taxons.html.twig Removed "card" class and adjusted div class attributes.
src/Sylius/Bundle/AdminBundle/templates/product_attribute/form/*.html.twig Removed g-col-xl-6 class, replaced with g-col-12 in multiple template files.
src/Sylius/Bundle/AdminBundle/templates/product_option/form/sections/values/*.html.twig Modified column classes and margin settings.
src/Sylius/Bundle/AdminBundle/templates/product_variant/form/content/update/header/actions/price_history.html.twig Added icon dropdown-item-icon class to dropdown item icons.
src/Sylius/Bundle/AdminBundle/templates/product_variant/form/sections/general.html.twig Increased margin-bottom and simplified card structure.
src/Sylius/Bundle/AdminBundle/templates/shared/crud/common/sidebar/menu/menu.html.twig Simplified active state logic for dropdown items.
src/Sylius/Bundle/AdminBundle/templates/shared/helper/table.html.twig Removed <code> tag wrapping for code field rendering.

Poem

🐰 Hop, hop, through the admin's design,
Tweaking margins, making layouts shine!
Classes dance, colors take flight,
Sylius admin, looking just right!
A rabbit's touch of styling delight 🎨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4235ae9 and 38be138.

📒 Files selected for processing (11)
  • src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_sidebar.scss (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product/form/sections/taxonomy/product_taxons.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_attribute/form/configuration.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_attribute/form/general.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_attribute/form/translations.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_option/form/sections/values/value.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_option/form/sections/values/value/translations.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_variant/form/content/update/header/actions/price_history.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_variant/form/sections/general.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/shared/crud/common/sidebar/menu/menu.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/shared/helper/table.html.twig (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (11)
  • src/Sylius/Bundle/AdminBundle/templates/product_variant/form/content/update/header/actions/price_history.html.twig
  • src/Sylius/Bundle/AdminBundle/templates/product_attribute/form/general.html.twig
  • src/Sylius/Bundle/AdminBundle/templates/product_attribute/form/translations.html.twig
  • src/Sylius/Bundle/AdminBundle/templates/product_option/form/sections/values/value.html.twig
  • src/Sylius/Bundle/AdminBundle/templates/product/form/sections/taxonomy/product_taxons.html.twig
  • src/Sylius/Bundle/AdminBundle/templates/product_attribute/form/configuration.html.twig
  • src/Sylius/Bundle/AdminBundle/templates/shared/crud/common/sidebar/menu/menu.html.twig
  • src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_sidebar.scss
  • src/Sylius/Bundle/AdminBundle/templates/shared/helper/table.html.twig
  • src/Sylius/Bundle/AdminBundle/templates/product_option/form/sections/values/value/translations.html.twig
  • src/Sylius/Bundle/AdminBundle/templates/product_variant/form/sections/general.html.twig

🪧 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

@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

🧹 Nitpick comments (3)
src/Sylius/Bundle/AdminBundle/templates/product_variant/form/sections/general.html.twig (1)

27-33: Consider enhancing the properties section

While the layout is functional, consider these accessibility and UX improvements:

  • Add aria-labelledby to group the properties fields with their heading
  • Consider using a fieldset with legend for better semantic structure
-            <div class="mb-4">
-                <h4 class="ui dividing header">{{ 'sylius.ui.properties'|trans }}</h4>
+            <fieldset class="mb-4">
+                <legend class="h4 ui dividing header" id="properties-heading">{{ 'sylius.ui.properties'|trans }}</legend>
+                <div role="group" aria-labelledby="properties-heading">
                 {{ form_row(form.height) }}
                 {{ form_row(form.width) }}
                 {{ form_row(form.depth) }}
                 {{ form_row(form.weight) }}
+                </div>
-            </div>
+            </fieldset>
src/Sylius/Bundle/AdminBundle/templates/product/form/sections/taxonomy/product_taxons.html.twig (1)

5-5: Consider maintaining visual containment

The removal of the "card" class might affect the visual containment of the taxon tree component. Consider using an alternative class or border to maintain clear visual boundaries for this interactive element.

-    <div {{ stimulus_controller('product-taxon-tree', {treeData: this.tree, autoOpen: hookableMetadata.configuration.auto_open}) }}>
+    <div class="border rounded p-3" {{ stimulus_controller('product-taxon-tree', {treeData: this.tree, autoOpen: hookableMetadata.configuration.auto_open}) }}>
src/Sylius/Bundle/AdminBundle/templates/product_option/form/sections/values/value/translations.html.twig (1)

1-3: Consider responsive layout behavior

The change from col-12 to col-3 means 4 translations per row, which might cause layout issues on smaller screens. Consider using responsive column classes (e.g., col-12 col-md-6 col-lg-3) to ensure proper stacking on mobile devices.

-<div class="col-3" {{ sylius_test_html_attribute('option-value-locale', translation_form_key) }}>
+<div class="col-12 col-md-6 col-lg-3" {{ sylius_test_html_attribute('option-value-locale', translation_form_key) }}>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e6490f1 and 4235ae9.

📒 Files selected for processing (11)
  • src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_sidebar.scss (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product/form/sections/taxonomy/product_taxons.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_attribute/form/configuration.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_attribute/form/general.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_attribute/form/translations.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_option/form/sections/values/value.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_option/form/sections/values/value/translations.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_variant/form/content/update/header/actions/price_history.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/product_variant/form/sections/general.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/shared/crud/common/sidebar/menu/menu.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/shared/helper/table.html.twig (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • src/Sylius/Bundle/AdminBundle/templates/product_option/form/sections/values/value.html.twig
  • src/Sylius/Bundle/AdminBundle/templates/product_attribute/form/translations.html.twig
  • src/Sylius/Bundle/AdminBundle/templates/product_attribute/form/general.html.twig
🔇 Additional comments (8)
src/Sylius/Bundle/AdminBundle/templates/product_variant/form/content/update/header/actions/price_history.html.twig (1)

Line range hint 1-33: Verify template usage and styling consistency

Let's ensure this template is used consistently and the styling matches other similar dropdowns in the admin panel.

✅ Verification successful

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

Template follows consistent patterns and styling

The verification shows that:

  • The dropdown pattern with dropdown-item-icon class is consistently used across multiple templates in the admin bundle
  • The price history feature appears in related templates with consistent structure
  • The tabler:eye icon is consistently used with the same class styling (icon dropdown-item-icon) in similar dropdown contexts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for similar dropdown patterns and icon usage in other templates

# Check for other templates using similar dropdown patterns
echo "Checking for similar dropdown patterns..."
rg -l 'dropdown-item-icon' 'src/Sylius/Bundle/AdminBundle/templates'

# Check for other price history related templates
echo "Checking for other price history templates..."
fd -e twig -e html.twig . 'src/Sylius/Bundle/AdminBundle/templates' -x grep -l 'price_history'

# Check for consistent icon usage
echo "Checking for consistent icon usage pattern..."
rg "ux_icon\('tabler:eye'" 'src/Sylius/Bundle/AdminBundle/templates'

Length of output: 4268

src/Sylius/Bundle/AdminBundle/templates/product_attribute/form/configuration.html.twig (1)

5-5: Improved responsive layout

Good simplification of the grid system. Using g-col-12 without the -xl breakpoint ensures consistent full-width layout across all screen sizes, which is appropriate for configuration forms.

src/Sylius/Bundle/AdminBundle/templates/product_variant/form/sections/general.html.twig (1)

11-14: Improved vertical spacing

Good adjustment of margins from mb-3 to mb-4. The increased spacing between form sections improves readability and creates better visual separation between logically grouped fields.

Also applies to: 15-19, 20-26

src/Sylius/Bundle/AdminBundle/templates/product/form/sections/taxonomy/product_taxons.html.twig (1)

Line range hint 8-27: Well-structured filter controls and tree layout

Good improvements:

  • Increased bottom padding (pb-5) provides adequate space for the tree structure
  • Clear visual hierarchy with filter controls
  • Proper use of utility classes for alignment and spacing
  • Semantic use of buttons and input groups
src/Sylius/Bundle/AdminBundle/templates/product_option/form/sections/values/value/translations.html.twig (1)

4-16: LGTM! Well-structured label rendering

The label rendering logic is well-organized with proper spacing and alignment using Bootstrap 5 utilities. The conditional handling of global vs locale-specific labels is clear and maintainable.

src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_sidebar.scss (1)

34-37: LGTM! Consider verifying color contrast ratios.

The color changes for dropdown items improve visual hierarchy:

  • Normal state using $gray-500 provides better visibility than transparent
  • Active state using $primary creates clear distinction
✅ Verification successful

Let me analyze the background color against which these text colors will be used to properly verify the contrast ratios.


Let me check the parent container's background color as the immediate element has a transparent background.


Color contrast appears sufficient for accessibility

The color choices are appropriate for the sidebar context:

  • Text color $gray-500 (#adb5bd) against the dark navbar background (using CSS variable with 0.8 opacity white) provides good contrast for normal state
  • Active state using $primary (#22B99A) against the same background provides even stronger contrast
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if color variables are defined with sufficient contrast ratios
rg -A 1 '(\$gray-500|\$primary):' .

Length of output: 756


Script:

#!/bin/bash
# Check the background color of the sidebar menu items
rg -B 2 -A 2 'background|bg-' src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_sidebar.scss

Length of output: 387


Script:

#!/bin/bash
# Check the entire sidebar styling for background colors
cat src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_sidebar.scss

Length of output: 2163

src/Sylius/Bundle/AdminBundle/templates/shared/crud/common/sidebar/menu/menu.html.twig (1)

92-94: LGTM! Good separation of concerns.

The simplified dropdown item markup is an improvement:

  • Moves styling logic to CSS where it belongs
  • Maintains functionality for external links and target attributes
  • Clean integration with the new SCSS active state styling
src/Sylius/Bundle/AdminBundle/templates/shared/helper/table.html.twig (1)

34-34: Verify the impact of removing the code tag wrapper

The removal of the <code> tag wrapper might affect:

  1. Visual distinction of code values in the table
  2. Semantic meaning of the content
  3. Screen reader behavior

Please ensure that:

  • Code values remain visually distinct from regular text
  • The semantic meaning is preserved through alternative styling
  • Screen readers can properly interpret the content

Let's check if there are any CSS styles that might compensate for the removed <code> tag:

@@ -19,7 +19,7 @@
class="dropdown-item{% if url is not defined %} disabled{% endif %}"
href="{{ url }}"
>
{{ ux_icon(action.icon|default('tabler:eye')) }}
{{ ux_icon(action.icon|default('tabler:eye'), {'class': 'icon dropdown-item-icon'}) }}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix undefined variable and simplify icon usage

The action variable is not defined in this template, which could cause runtime issues. Since this is specifically for viewing price history, we should use the eye icon directly without the undefined variable reference.

Apply this diff to fix the issue:

-{{ ux_icon(action.icon|default('tabler:eye'), {'class': 'icon dropdown-item-icon'}) }}
+{{ ux_icon('tabler:eye', {'class': 'icon dropdown-item-icon'}) }}
📝 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
{{ ux_icon(action.icon|default('tabler:eye'), {'class': 'icon dropdown-item-icon'}) }}
{{ ux_icon('tabler:eye', {'class': 'icon dropdown-item-icon'}) }}

Comment on lines +18 to +33
<div class="input-group">
{{ form_widget(translation_form.value) }}
<button
type="button"
class="btn btn-icon"
data-bs-toggle="tooltip"
data-bs-title="{{ 'sylius.ui.apply_to_all'|trans }}"
data-action="live#action:prevent"
data-live-action-param="applyToAll"
data-live-value-key-param="{{ hookable_metadata.context.value_form_key }}"
data-live-translation-key-param="{{ translation_form_key }}"
{{ sylius_test_html_attribute('apply-to-all') }}
>
{{ ux_icon('tabler:copy-plus') }}
</button>
{{ form_errors(translation_form.value) }}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add accessibility attributes to the action button

The "Apply to all" button needs accessibility improvements. Consider adding aria-label for screen readers and ensuring the tooltip is keyboard accessible.

     <button
         type="button"
         class="btn btn-icon"
+        aria-label="{{ 'sylius.ui.apply_to_all'|trans }}"
         data-bs-toggle="tooltip"
         data-bs-title="{{ 'sylius.ui.apply_to_all'|trans }}"
         data-action="live#action:prevent"
         data-live-action-param="applyToAll"
         data-live-value-key-param="{{ hookable_metadata.context.value_form_key }}"
         data-live-translation-key-param="{{ translation_form_key }}"
         {{ sylius_test_html_attribute('apply-to-all') }}
     >
📝 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
<div class="input-group">
{{ form_widget(translation_form.value) }}
<button
type="button"
class="btn btn-icon"
data-bs-toggle="tooltip"
data-bs-title="{{ 'sylius.ui.apply_to_all'|trans }}"
data-action="live#action:prevent"
data-live-action-param="applyToAll"
data-live-value-key-param="{{ hookable_metadata.context.value_form_key }}"
data-live-translation-key-param="{{ translation_form_key }}"
{{ sylius_test_html_attribute('apply-to-all') }}
>
{{ ux_icon('tabler:copy-plus') }}
</button>
{{ form_errors(translation_form.value) }}
<div class="input-group">
{{ form_widget(translation_form.value) }}
<button
type="button"
class="btn btn-icon"
aria-label="{{ 'sylius.ui.apply_to_all'|trans }}"
data-bs-toggle="tooltip"
data-bs-title="{{ 'sylius.ui.apply_to_all'|trans }}"
data-action="live#action:prevent"
data-live-action-param="applyToAll"
data-live-value-key-param="{{ hookable_metadata.context.value_form_key }}"
data-live-translation-key-param="{{ translation_form_key }}"
{{ sylius_test_html_attribute('apply-to-all') }}
>
{{ ux_icon('tabler:copy-plus') }}
</button>
{{ form_errors(translation_form.value) }}

Comment on lines 34 to 37
{{ sylius_grid_render_field(grid, field, row) }}
{% else %}
{{ sylius_grid_render_field(grid, field, row) }}
{% endif %}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove redundant conditional block

The conditional block for the code field now contains identical code in both branches, making it redundant.

Consider simplifying the code by removing the conditional:

-                {% if field.name == 'code' %}
-                    {{ sylius_grid_render_field(grid, field, row) }}
-                {% else %}
-                    {{ sylius_grid_render_field(grid, field, row) }}
-                {% endif %}
+                {{ sylius_grid_render_field(grid, field, row) }}
📝 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
{{ sylius_grid_render_field(grid, field, row) }}
{% else %}
{{ sylius_grid_render_field(grid, field, row) }}
{% endif %}
{{ sylius_grid_render_field(grid, field, row) }}

Copy link

github-actions bot commented Dec 16, 2024

Bunnyshell Preview Environment deleted

Available commands:

  • /bns:deploy to redeploy the environment

mpysiak
mpysiak previously approved these changes Dec 18, 2024
@Wojdylak Wojdylak merged commit dd339a5 into Sylius:2.0 Dec 20, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin AdminBundle related issues and PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants