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

chore(application-system): Refactoring slider form field #17481

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

HjorturJ
Copy link
Member

@HjorturJ HjorturJ commented Jan 13, 2025

Refactoring slider for field to add more customization and improving layout

Task link

What

Trying to improve the slider layout so it doesnt overlap other field elements by default or its own labels, as well as adding more properties to customize various elements, specifically color of most elements.

Why

Makes it much easier and appealing to use the slider field to other applications.

Screenshots / Gifs

Example application slider form section updated:
image

Before and after for parental leave application sliders (same look, slightly different margins for overlap issues):
image
image

...

image
image

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced Slider component with customizable text and progress overlay colors
    • Added more flexible configuration options for slider fields
  • Improvements

    • Improved type definitions for slider-related interfaces
    • Updated styling to support dynamic theming and CSS variables
    • Added more robust error handling and label validation for sliders
  • Technical Enhancements

    • Made label and calculation style properties optional in slider configurations
    • Expanded date handling capabilities for slider range dates

These updates provide more flexibility and customization options for slider components across the application.

Copy link
Contributor

coderabbitai bot commented Jan 13, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jest > jest-cli > jest-config > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > tempy > del > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning react-native > @react-native/codegen > [email protected]: Glob versions prior to v9 are no longer supported
warning react-native > @react-native/community-cli-plugin > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning react-native > @react-native-community/cli > @react-native-community/cli-tools > [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
warning react-native > @react-native/community-cli-plugin > @react-native/dev-middleware > @rnx-kit/chromium-edge-launcher > [email protected]: Rimraf versions prior to v4 are no longer supported
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.
warning next-auth > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning next-auth > [email protected]: this version is no longer supported
warning next-auth > @next-auth/typeorm-legacy-adapter > typeorm > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > stylus > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > webpack-dev-server > [email protected]: Rimraf versions prior to v4 are no longer supported
warning @nx/next > @nx/webpack > fork-ts-checker-webpack-plugin > [email protected]: this will be v4
warning @nx/next > @nx/webpack > webpack-dev-server > webpack-dev-middleware > [email protected]: this will be v4
warning workspace-aggregator-3941a03d-a8d1-4816-989e-9143ee7f0c1d > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning "@nx/eslint > @nx/js > [email protected]" has unmet peer dependency "@types/node@".
warning "@nx/next > @babel/[email protected]" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "styled-components > babel-plugin-styled-components > @babel/[email protected]" has unmet peer dependency "@babel/core@^7.0.0-0".
warning " > [email protected]" has unmet peer dependency "react-is@>= 16.8.0".
warning "@nx/react > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
warning " > [email protected]" has unmet peer dependency "@types/node@
".
warning " > [email protected]" has incorrect peer dependency "[email protected]".
warning "react-native > @react-native/[email protected]" has unmet peer dependency "@babel/preset-env@^7.1.6".
warning "react-native > @react-native/community-cli-plugin > @react-native/[email protected]" has unmet peer dependency "@babel/core@*".
warning "@vanilla-extract/next-plugin > @vanilla-extract/[email protected]" has unmet peer dependency "webpack@^4.30.0 || ^5.20.2".
warning " > [email protected]" has incorrect peer dependency "react@^16.13.1 || ^17".
warning " > [email protected]" has incorrect peer dependency "react-dom@^16.13.1 || ^17".
warning "next-auth > @next-auth/[email protected]" has unmet peer dependency "@prisma/client@^2.16.1".
warning "@nx/next > [email protected]" has unmet peer dependency "webpack@^5.1.0".

Walkthrough

This pull request introduces enhancements to the Slider component across multiple files in the application's libraries. The changes primarily focus on adding new customization properties (textColor and progressOverlayColor) to the Slider field configuration, updating type definitions, and improving styling flexibility. The modifications span several components and files, ensuring consistent implementation of the new slider customization options throughout the application.

Changes

File Change Summary
libs/application/core/src/lib/fieldBuilders.ts Added textColor and progressOverlayColor properties to buildSliderField function
libs/application/types/src/lib/Fields.ts Updated SliderField interface with optional properties and new color customization options
libs/application/ui-components/src/components/Slider/Slider.css.ts Updated styling imports and references to use theme colors and CSS variables
libs/application/ui-components/src/components/Slider/Slider.tsx Added new props for text and overlay color customization, improved tooltip and label handling
libs/application/ui-fields/src/lib/SliderFormField/SliderFormField.tsx Incorporated new textColor and progressOverlayColor props
libs/application/templates/... Updated slider configurations in example and template files

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • Toti91

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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.

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

codecov bot commented Jan 13, 2025

Codecov Report

Attention: Patch coverage is 1.72414% with 57 lines in your changes missing coverage. Please review.

Project coverage is 35.60%. Comparing base (006bb01) to head (39f5cc4).

Files with missing lines Patch % Lines
...ion/ui-components/src/components/Slider/Slider.tsx 1.75% 56 Missing ⚠️
...fields/src/lib/SliderFormField/SliderFormField.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17481      +/-   ##
==========================================
- Coverage   35.61%   35.60%   -0.02%     
==========================================
  Files        7015     7015              
  Lines      150332   150380      +48     
  Branches    42978    43005      +27     
==========================================
+ Hits        53541    53542       +1     
- Misses      96791    96838      +47     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.33% <ø> (ø)
application-api-files 62.06% <ø> (ø)
application-core 75.66% <ø> (ø)
application-system-api 38.72% <ø> (+<0.01%) ⬆️
application-template-api-modules 27.57% <ø> (ø)
application-templates-accident-notification 27.60% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.79% <ø> (ø)
application-templates-driving-license 18.15% <ø> (ø)
application-templates-estate 13.57% <1.88%> (-0.07%) ⬇️
application-templates-example-payment 24.66% <ø> (ø)
application-templates-financial-aid 14.47% <ø> (ø)
application-templates-general-petition 23.13% <ø> (ø)
application-templates-inheritance-report 6.59% <ø> (ø)
application-templates-marriage-conditions 14.84% <ø> (ø)
application-templates-mortgage-certificate 43.73% <ø> (ø)
application-templates-new-primary-school 21.02% <ø> (ø)
application-templates-parental-leave 29.92% <ø> (ø)
application-types 6.47% <ø> (ø)
application-ui-components 1.17% <0.00%> (-0.05%) ⬇️
application-ui-shell 22.09% <1.85%> (-0.11%) ⬇️
clients-charge-fjs-v2 28.88% <ø> (ø)
judicial-system-backend 55.81% <ø> (ø)
judicial-system-scheduler 71.36% <ø> (ø)
web 2.39% <ø> (ø)

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

Files with missing lines Coverage Δ
libs/application/core/src/lib/fieldBuilders.ts 40.00% <ø> (ø)
...es/parental-leave/src/fields/Duration/Duration.tsx 0.00% <ø> (ø)
libs/application/types/src/lib/Fields.ts 100.00% <ø> (ø)
...fields/src/lib/SliderFormField/SliderFormField.tsx 4.54% <0.00%> (-0.22%) ⬇️
...ion/ui-components/src/components/Slider/Slider.tsx 3.31% <1.75%> (-0.42%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 006bb01...39f5cc4. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jan 13, 2025

Datadog Report

All test runs a860ef0 🔗

10 Total Test Services: 0 Failed, 10 Passed
🔻 Test Sessions change in coverage: 3 decreased, 93 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-web 0 0 0 2 0 6.99s 1 no change Link
api 0 0 0 4 0 2.42s 1 no change Link
application-api-files 0 0 0 2 0 4.26s 1 no change Link
application-core 0 0 0 97 0 14.74s 1 no change Link
application-system-api 0 0 0 46 0 2m 17.33s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 4.71s 1 no change Link
application-templates-accident-notification 0 0 0 140 0 13.34s 1 no change Link
application-templates-criminal-record 0 0 0 2 0 9.55s 1 no change Link
application-templates-driving-license 0 0 0 13 0 12.84s 1 no change Link
application-templates-example-payment 0 0 0 2 0 10.07s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (3)

  • application-ui-shell - jest 28.81% (-0.16%) - Details
  • application-templates-estate - jest 20.29% (-0.13%) - Details
  • application-ui-components - jest 1.54% (-0.07%) - Details

@HjorturJ HjorturJ changed the title chore(application-system): Refactoring slider form field a bit chore(application-system): Refactoring slider form field Jan 14, 2025
@HjorturJ HjorturJ marked this pull request as ready for review January 14, 2025 16:58
@HjorturJ HjorturJ requested review from a team as code owners January 14, 2025 16:58
Copy link
Member

@jonnigs jonnigs left a comment

Choose a reason for hiding this comment

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

LGTM!

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 (5)
libs/application/ui-components/src/components/Slider/Slider.css.ts (1)

1-1: Remove unused import.

The styleVariants import is not used in this file.

-import { keyframes, style, styleVariants } from '@vanilla-extract/css'
+import { keyframes, style } from '@vanilla-extract/css'
libs/application/templates/reference-template/src/forms/exampleForm/simpleInputsSection/sliderSubsection.ts (2)

203-243: Consider using dynamic dates.

The hardcoded dates for 2024 might become outdated. Consider using relative dates based on the current date.

-              date: new Date('2024-01-06'),
+              date: new Date(new Date().setDate(new Date().getDate() + 6)),
-              date: new Date('2024-01-12'),
+              date: new Date(new Date().setDate(new Date().getDate() + 12)),

15-252: Consider grouping similar examples.

The examples could be organized better by grouping similar configurations together (e.g., all tooltip examples, all color examples, etc.).

libs/application/ui-components/src/components/Slider/Slider.tsx (2)

190-192: Use optional chaining for label validation.

The label validation could be simplified using optional chaining.

-  return label && label.singular && label.plural
+  return label?.singular && label?.plural
🧰 Tools
🪛 Biome (1.9.4)

[error] 191-191: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


206-212: Consider enhancing date formatting.

The date formatting could be more robust by:

  1. Adding error handling for invalid dates
  2. Supporting more locale options
 const formatDates = (date: string | Date | undefined): string => {
   if (date === undefined) return ''
+  try {
     if (typeof date === 'string') return date
-    return date.toLocaleDateString('is-IS')
+    return date.toLocaleDateString('is-IS', {
+      year: 'numeric',
+      month: '2-digit',
+      day: '2-digit'
+    })
+  } catch (error) {
+    console.error('Invalid date:', error)
+    return ''
+  }
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 006bb01 and 39f5cc4.

📒 Files selected for processing (7)
  • libs/application/core/src/lib/fieldBuilders.ts (2 hunks)
  • libs/application/templates/parental-leave/src/fields/Duration/Duration.tsx (1 hunks)
  • libs/application/templates/reference-template/src/forms/exampleForm/simpleInputsSection/sliderSubsection.ts (1 hunks)
  • libs/application/types/src/lib/Fields.ts (2 hunks)
  • libs/application/ui-components/src/components/Slider/Slider.css.ts (5 hunks)
  • libs/application/ui-components/src/components/Slider/Slider.tsx (9 hunks)
  • libs/application/ui-fields/src/lib/SliderFormField/SliderFormField.tsx (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • libs/application/templates/parental-leave/src/fields/Duration/Duration.tsx
🧰 Additional context used
📓 Path-based instructions (6)
libs/application/core/src/lib/fieldBuilders.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/ui-fields/src/lib/SliderFormField/SliderFormField.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/types/src/lib/Fields.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/reference-template/src/forms/exampleForm/simpleInputsSection/sliderSubsection.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/ui-components/src/components/Slider/Slider.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/ui-components/src/components/Slider/Slider.css.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🪛 Biome (1.9.4)
libs/application/ui-components/src/components/Slider/Slider.tsx

[error] 191-191: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: build (web)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: build (web)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: build (web)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: build (web)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: build (web)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: build (web)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: build (web)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: build (web)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: build (web)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: build (web)
🔇 Additional comments (12)
libs/application/ui-components/src/components/Slider/Slider.css.ts (2)

29-29: LGTM! Good use of theme color.

Using theme.color.blue400 instead of hardcoded hex value improves consistency and maintainability.


46-46: LGTM! Good use of CSS variables.

Using CSS variables for thumb color enables dynamic theming and improves maintainability.

Also applies to: 66-66, 77-77

libs/application/ui-fields/src/lib/SliderFormField/SliderFormField.tsx (3)

41-42: LGTM! Good addition of color customization props.

The new props textColor and progressOverlayColor align with the PR objectives for enhanced customization.


91-100: LGTM! Safer label handling.

The conditional check for label existence prevents potential runtime errors.


111-112: LGTM! Proper prop forwarding.

The new color props are correctly forwarded to the Slider component.

libs/application/ui-components/src/components/Slider/Slider.tsx (2)

37-51: LGTM! Well-structured color handling.

The ColorValues interface and getColorValues function provide a robust way to handle both hex and theme colors.


219-222: LGTM! Improved tooltip positioning.

The tooltip positioning now correctly handles margin adjustments based on label presence.

libs/application/types/src/lib/Fields.ts (4)

766-766: LGTM: Making calculateCellStyle optional improves flexibility.

This change allows for simpler slider configurations when custom cell styling is not needed.


772-775: LGTM: Making label optional enhances component flexibility.

This change allows for non-labeled sliders, which is useful for cases where labels are not required or are handled externally.


778-784: LGTM: Enhanced type flexibility for date fields.

Supporting both string and Date types for rangeDates improves type flexibility and makes the interface more developer-friendly.


792-793: LGTM: New color customization properties.

The addition of textColor and progressOverlayColor properties enhances the slider's customization capabilities, aligning with the PR's objective to improve visual customization.

libs/application/core/src/lib/fieldBuilders.ts (1)

995-996: LGTM: Builder implementation aligns with interface changes.

The buildSliderField function correctly implements the new color customization properties, maintaining consistency with the SliderField interface.

Also applies to: 1026-1027

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 (2)
libs/application/ui-components/src/components/Slider/Slider.tsx (2)

168-204: Validation functions could be more DRY.

The validation functions have similar patterns and could be refactored to reduce duplication.

Consider consolidating the validation logic:

-const hasAllRequiredForMinMaxLabels = () => {
-  if (showMinMaxLabels) {
-    if (hasValidLabels()) return true
-    throw new Error(
-      'The labels object has to be defined if you want to show the min max labels',
-    )
-  }
-  return false
-}
-
-const hasAllRequiredForTooltip = () => {
-  if (showToolTip) {
-    if (hasValidLabels()) return true
-    throw new Error(
-      'The labels object has to be defined if you want to show the tooltip',
-    )
-  }
-  return false
-}
-
-const hasValidLabels = () => {
-  return label && label.singular && label.plural
-}
-
-const hasAllRequiredForLabels = () => {
-  if (showLabel) {
-    if (hasValidLabels()) return true
-    throw new Error(
-      'The labels object has to be defined if you want to show them',
-    )
-  }
-  return false
-}
+const hasValidLabels = () => label?.singular && label?.plural
+
+const validateLabels = (showFeature: boolean, featureName: string) => {
+  if (showFeature) {
+    if (hasValidLabels()) return true
+    throw new Error(
+      `The labels object has to be defined if you want to show ${featureName}`,
+    )
+  }
+  return false
+}
+
+const hasAllRequiredForMinMaxLabels = () => validateLabels(showMinMaxLabels, 'min max labels')
+const hasAllRequiredForTooltip = () => validateLabels(showToolTip, 'tooltip')
+const hasAllRequiredForLabels = () => validateLabels(showLabel, 'labels')
🧰 Tools
🪛 Biome (1.9.4)

[error] 191-191: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


191-191: Use optional chaining for safer property access.

The current code could benefit from optional chaining to make it more robust.

-return label && label.singular && label.plural
+return label?.singular && label?.plural
🧰 Tools
🪛 Biome (1.9.4)

[error] 191-191: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 006bb01 and 39f5cc4.

📒 Files selected for processing (7)
  • libs/application/core/src/lib/fieldBuilders.ts (2 hunks)
  • libs/application/templates/parental-leave/src/fields/Duration/Duration.tsx (1 hunks)
  • libs/application/templates/reference-template/src/forms/exampleForm/simpleInputsSection/sliderSubsection.ts (1 hunks)
  • libs/application/types/src/lib/Fields.ts (2 hunks)
  • libs/application/ui-components/src/components/Slider/Slider.css.ts (5 hunks)
  • libs/application/ui-components/src/components/Slider/Slider.tsx (9 hunks)
  • libs/application/ui-fields/src/lib/SliderFormField/SliderFormField.tsx (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • libs/application/templates/parental-leave/src/fields/Duration/Duration.tsx
🧰 Additional context used
📓 Path-based instructions (6)
libs/application/ui-fields/src/lib/SliderFormField/SliderFormField.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/types/src/lib/Fields.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/ui-components/src/components/Slider/Slider.css.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/core/src/lib/fieldBuilders.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/ui-components/src/components/Slider/Slider.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/reference-template/src/forms/exampleForm/simpleInputsSection/sliderSubsection.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🪛 Biome (1.9.4)
libs/application/ui-components/src/components/Slider/Slider.tsx

[error] 191-191: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: tests (judicial-system-backend)
🔇 Additional comments (17)
libs/application/ui-components/src/components/Slider/Slider.css.ts (3)

1-1: LGTM! Added styleVariants import.

The addition of styleVariants import from @vanilla-extract/css aligns with the goal of enhancing styling capabilities.


29-29: Good improvement! Using theme colors instead of hardcoded values.

Replacing hardcoded hex value #0061ff with theme.color.blue400 improves maintainability and consistency.


46-46: Nice enhancement! Using CSS variables for dynamic styling.

Replacing hardcoded hex values with CSS variable var(--thumb-color, #00e4ca) enables runtime customization of the thumb color while maintaining a fallback.

Also applies to: 66-66, 77-77

libs/application/ui-fields/src/lib/SliderFormField/SliderFormField.tsx (3)

41-42: LGTM! Added color customization props.

The addition of textColor and progressOverlayColor props enhances the slider's customization capabilities.


91-100: Good improvement! More robust label handling.

The updated label handling with the && operator prevents accessing properties of undefined, making the code more robust.


111-112: LGTM! Passing color props to Slider component.

Correctly passing the new color customization props to the underlying Slider component.

libs/application/templates/reference-template/src/forms/exampleForm/simpleInputsSection/sliderSubsection.ts (4)

15-24: LGTM! Basic slider example.

Good start with a minimal slider configuration.


50-50: Good practice! Using theme colors consistently.

Consistently using theme colors (theme.color.black, theme.color.red600, theme.color.blue200) instead of hardcoded values.

Also applies to: 102-102, 247-247


235-243: LGTM! Well-structured date range configuration.

The date range configuration is well-structured with clear start and end dates, including descriptive messages.


221-224: Good practice! Setting default and current values.

Setting both defaultValue and currentIndex ensures consistent initial state.

libs/application/ui-components/src/components/Slider/Slider.tsx (2)

37-51: LGTM! Well-structured color handling.

The ColorValues interface and getColorValues function provide a robust way to handle both hex and theme colors.


206-212: LGTM! Flexible date handling.

The formatDates function handles both string and Date types, making it more flexible.

libs/application/types/src/lib/Fields.ts (4)

766-766: LGTM! Making calculateCellStyle optional improves flexibility.

The change maintains backward compatibility while allowing simpler slider configurations that don't require custom cell styling.


772-775: LGTM! Making label optional is a good improvement.

The change maintains backward compatibility while allowing sliders without labels.


778-778: LGTM! Supporting both string and Date types provides more flexibility.

The change allows direct usage of Date objects while maintaining compatibility with string dates.

Also applies to: 782-782


792-793: LGTM! New color customization options align with PR objectives.

The addition of optional textColor and progressOverlayColor properties enhances the slider's customization capabilities while maintaining backward compatibility.

libs/application/core/src/lib/fieldBuilders.ts (1)

995-996: LGTM! Builder function correctly handles new color customization options.

The changes properly extract and pass through the new optional properties while maintaining the existing patterns used throughout the file.

Also applies to: 1026-1027

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants