Skip to content

Conversation

@ricardoantoniocm
Copy link
Contributor

@ricardoantoniocm ricardoantoniocm commented May 21, 2025

Reason for change

This PR addresses several UI and styling inconsistencies, particularly in Dark Mode, across various labeling templates. The primary goal is to modernize and unify the styling of Label Studio UI components and templates by replacing hardcoded CSS values with CSS variables and Tailwind CSS utility classes. This improves maintainability, enables better theme support, and resolves several reported issues where elements were barely visible or not optimized for Dark Mode.

Specifically, this PR resolves the following issues:

  • Content Moderation Template Dark Mode Optimization: The text area in the Content Moderation template was not optimized for Dark Mode, leading to poor visibility of the text and surrounding elements. This fix ensures proper adaptation to Dark Mode.
  • Pairwise Classification Template Item Selection: In Dark Mode, selected items in the Pairwise classification template were not visible due to unoptimized colors. The changes introduce proper styling for selected items in Dark Mode.
  • Conversational Analysis Template Author Names: Author names in the dropdown on the Conversational Analysis template were barely visible in Dark Mode. This PR adjusts the styling to ensure visibility.
  • Ranker Template Dark Mode Optimization: The default text in the Ranker template was barely visible in Dark Mode on both the Preview page and in Quick View. This fix optimizes the template for Dark Mode.
  • Text to Image Generation: The border color for the selected image is adjusted to match the look and feel of the application.

These changes also include:

  • Theme and Style Updates for Consistency and Customization: Replaced hardcoded CSS values with CSS variables and updated box-shadow, border, and background properties to use semantic, theme-driven variables.
  • Annotation Template and Example Adjustments: Updated config files for annotation templates to use the new CSS variables and semantic class names.
  • Code Improvements in Pairwise Tag (Pairwise.js): Refactored setResult logic to support both inline style and Tailwind className-based selection, added interactive classes, and improved error handling.
  • Documentation and Example Updates: Updated markdown documentation to use the new CSS variable-based border colors.
  • Miscellaneous Style Fixes: Updated Paragraphs.module.scss to use CSS variables for border and color properties.

Screenshots

Before:

Pairwise Classification:
image

Author Names:
image

LLM Ranker:
image

Text to Image Generation:
image

After:

Pairwise Classification:
image

Author Names:
image

LLM Ranker:
image

Text to Image Generation:
image

Rollout strategy

This change will be rolled out as part of a standard release. No feature flags or environment variables are required.

Testing

The following testing has been performed:

  • Manual verification of all affected templates (Content Moderation, Pairwise Classification, Conversational Analysis, Ranker) in Dark Mode to ensure that all previously reported visibility issues are resolved.
  • Visual inspection of various UI components across the application to confirm that the transition to CSS variables and Tailwind classes has not introduced any regressions or new visual issues.
  • Functional testing of the Pairwise control component to ensure that item selection and result setting work as expected with the refactored setResult logic.
  • Verification of console logs for any warnings or errors related to missing left or right object references in the Pairwise component.

Detailed steps to reproduce and verify fixes for each ticket are available in the linked Jira issues. Screenshots will be added to confirm the fixes for each template.

Risks

  • Minor Visual Regressions: While care has been taken to ensure consistency, there is a low risk of minor visual regressions in less frequently used parts of the UI due to the widespread change from hardcoded CSS to variables.
  • Performance Impact: The use of CSS variables generally has minimal to no performance impact. However, a slight increase in CSS file size could occur, which is not expected to be significant.

Reviewer notes

  • Please pay close attention to the visual consistency of the updated components, especially in Dark Mode, to ensure all elements are properly styled.
  • Verify the functionality of the Pairwise tag to ensure selections are correctly applied and displayed.
  • Confirm that the transition to CSS variables and Tailwind classes has been applied consistently across the mentioned files.

General notes

This PR represents a significant step towards a more unified and maintainable UI styling system. The adoption of CSS variables and Tailwind CSS will make future theme adjustments and UI enhancements much more efficient.

@ricardoantoniocm ricardoantoniocm self-assigned this May 21, 2025
@netlify
Copy link

netlify bot commented May 21, 2025

Deploy Preview for label-studio-docs-new-theme ready!

Name Link
🔨 Latest commit 646fb9b
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-docs-new-theme/deploys/68309d598db4580008b46976
😎 Deploy Preview https://deploy-preview-7584--label-studio-docs-new-theme.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented May 21, 2025

Deploy Preview for label-studio-storybook ready!

Name Link
🔨 Latest commit 646fb9b
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-storybook/deploys/68309d59b9084f0008da4690
😎 Deploy Preview https://deploy-preview-7584--label-studio-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented May 21, 2025

Deploy Preview for heartex-docs ready!

Name Link
🔨 Latest commit 646fb9b
🔍 Latest deploy log https://app.netlify.com/projects/heartex-docs/deploys/68309d598882f90007cc3fcb
😎 Deploy Preview https://deploy-preview-7584--heartex-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the fix label May 21, 2025
@codecov
Copy link

codecov bot commented May 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.48%. Comparing base (5368279) to head (646fb9b).
Report is 2 commits behind head on develop.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #7584   +/-   ##
========================================
  Coverage    78.48%   78.48%           
========================================
  Files          197      197           
  Lines        16000    16000           
========================================
  Hits         12558    12558           
  Misses        3442     3442           
Flag Coverage Δ
pytests 78.48% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ricardoantoniocm ricardoantoniocm requested a review from Copilot May 21, 2025 16:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes Dark Mode styling and improves maintainability across several Label Studio templates by replacing hardcoded CSS values with CSS variables and Tailwind CSS utility classes.

  • Updated styling in SCSS and YAML configuration files to use theme-driven variables.
  • Refactored the Pairwise component to support both inline style and className-based selection with improved error handling.
  • Updated example annotation JSON to reflect changes in component naming conventions.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
web/libs/editor/src/tags/object/Paragraphs/Paragraphs.module.scss Updated border and text color to use CSS variables.
web/libs/editor/src/tags/control/Pairwise.js Added checks for missing object references and refactored selection styling logic.
web/libs/editor/src/examples/pairwise/annotations/1.json Changed the "to_name" field value to match updated component naming.
label_studio/annotation_templates/ranking-and-scoring/text-to-image/config.yml Replaced hardcoded styles with semantic CSS variables.
label_studio/annotation_templates/natural-language-processing/content-moderation/config.yml Updated the styling in the view components for Dark Mode optimization.
label_studio/annotation_templates/generative-ai/llm-ranker/config.yml Updated ranking component styles using new CSS variable standards.
docs/source/templates/text_to_image.md Demonstrated new style guidelines in documentation.
docs/source/templates/content_moderation.md Updated documentation to align with the new styling conventions.
Comments suppressed due to low confidence (1)

web/libs/editor/src/examples/pairwise/annotations/1.json:10

  • Ensure that the updated 'to_name' value 'txt-2' correctly matches the expected identifier in the associated Pairwise component configuration. If the component still expects 'pw', this change may lead to mismatches in how annotations are linked.
                    "to_name": "txt-2",

…if self.annotation or self.annotation.names is not available.
@ricardoantoniocm ricardoantoniocm marked this pull request as ready for review May 22, 2025 15:08
@ricardoantoniocm ricardoantoniocm changed the title fix: FIT-137: Text area in content moderation template not optimized for dark mode fix: FIT-137: Multiple labeling templates not yet adapted to dark mode May 22, 2025
@netlify
Copy link

netlify bot commented May 22, 2025

Deploy Preview for label-studio-playground ready!

Name Link
🔨 Latest commit 646fb9b
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-playground/deploys/68309d598882f90007cc3fcf
😎 Deploy Preview https://deploy-preview-7584--label-studio-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

let selection = {};

// If selectionstyle is provided, use inline style for backward compatibility.
// Otherwise, use Tailwind semantic classes for selection via className.
Copy link
Collaborator

Choose a reason for hiding this comment

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

That's an interesting approach with tailwind and classnames override! I would simplify it a little: we don't need selection var at this level, just assign it directly in both branches to self._selection. But it's good anyway

@ricardoantoniocm
Copy link
Contributor Author

ricardoantoniocm commented May 23, 2025

/git merge

Workflow run
Successfully merged: rename web/{apps/labelstudio/src/pages/CreateProject/Config/schema.json => libs/core/src/lib/utils/schema/tags.json} (100%)

@ricardoantoniocm ricardoantoniocm merged commit 5218497 into develop May 23, 2025
54 checks passed
@robot-ci-heartex robot-ci-heartex deleted the fb-fit-137/text-area-in-content-moderation-template-not-optimized-for-dark-mode branch May 23, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants