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

feat(slider): add new slider component draft version #328

Merged
merged 11 commits into from
Aug 8, 2024

Conversation

tsironis13
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Which package are you modifying?

  • accordion
  • alert
  • alert-dialog
  • aspect-ratio
  • avatar
  • badge
  • button
  • calendar
  • card
  • checkbox
  • collapsible
  • combobox
  • command
  • context-menu
  • data-table
  • date-picker
  • dialog
  • dropdown-menu
  • hover-card
  • icon
  • input
  • label
  • menubar
  • navigation-menu
  • pagination
  • popover
  • progress
  • radio-group
  • scroll-area
  • select
  • separator
  • sheet
  • skeleton
  • slider
  • sonner
  • spinner
  • switch
  • table
  • tabs
  • textarea
  • toast
  • toggle
  • tooltip
  • typography

What is the current behavior?

What is the new behavior?

This is the draft version of the new slider component. Since it is my first contribution to this project any feedback, omitted best practices would be really appreciate it, if pointed out.
It contains the backbone infrastructure of the component where each separate component element has their associated functionality and public API. The brain lib is split into 4 main parts (slider, input, track and thumb directives). The most crucial directive is the input one, which is responsible for interacting with the native input element.
Currently, the slider supports only 4 different states (default, disabled, min and max) with the possibility for more to be added in the official first version.
I have added the related Storybook stories; further tests will be added when this draft PR is approved.
The component supports only updating the UI when the value is changed and needs more polishing in order to handle pointer events, directionality changes and be user accessible.
It would be helpful if you give me some insights what else in terms of functionality is needed for the first version (e.g rtl, step).

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Copy link
Collaborator

@thatsamsonkid thatsamsonkid left a comment

Choose a reason for hiding this comment

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

@tsironis13 - Added one comment but this looks great, appreciate the hard work on this!

libs/ui/slider/helm/src/lib/hlm-slider-thumb.component.ts Outdated Show resolved Hide resolved
@tsironis13
Copy link
Contributor Author

Slider is fully accessibly under the slider WAI aria patterns:
https://www.w3.org/WAI/ARIA/apg/patterns/slider/

Copy link
Collaborator

@goetzrobin goetzrobin left a comment

Choose a reason for hiding this comment

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

LGTM! @tsironis13 we should probably create a separate ticket for e2e tests!

Copy link
Collaborator

@elite-benni elite-benni left a comment

Choose a reason for hiding this comment

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

Pretty nice work!
Just wanted to point to things out.

Styling

The styling is not completely matching the shadcn style.
I just mention it, because I know, there are teams using angular and react in one app and use spartan to match shadcn styles.

spartan
image
vs.
shadcn
image

Transitions

To me the transitions feel a little bit clunky when dragging the slider.

@tsironis13
Copy link
Contributor Author

Pretty nice work! Just wanted to point to things out.

Styling

The styling is not completely matching the shadcn style. I just mention it, because I know, there are teams using angular and react in one app and use spartan to match shadcn styles.

spartan image vs. shadcn image

Transitions

To me the transitions feel a little bit clunky when dragging the slider.

@elite-benni the styles are adapted to shadcn ui. In general, I think the separation between styling and functionality makes styles changes really trivial. The idea behind spartan UI primitives is for us as the creators of the components to provide a default style and the consumer of them to adapt the styling according to their needs, isn't it? Or do we need to create initially all the primitives matching the shadcn ui styling?

@goetzrobin
Copy link
Collaborator

@tsironis13 the goal is mimic the shadcn styling out of the box and then let people adjust them as they need in their own repositories

@tsironis13
Copy link
Contributor Author

@thatsamsonkid @goetzrobin @elite-benni I added 2 last core functional features at least for the first version (step and tick marks). Also the styles match the shadcn ones now, but it is very easy to adapt according to our needs in any case.
The slider currently supports the following things:

  • min
  • max
  • disabled state
  • step
  • directionality changes
  • tick marks
  • viewport resizing (not extensively tested on touch devices)
  • fully compatible with slider WAI aria accessibility patterns

I am not going to add any more functionality on this PR unless you would like to do so.
The last thing that is left is to create some component tests under the brain folder(like the select component). I am planning to validate the template driven and reactive form slider compatibility on these tests and as for the storybook e2e testing a new ticket will be created? @goetzrobin

@goetzrobin
Copy link
Collaborator

@tsironis13 sounds good. If you want to add e2e tests as part of this ticket feel free to do so! I was just saying that it's not a blocker IMO if we create a new ticket specifically for e2e tests

@tsironis13
Copy link
Contributor Author

@tsironis13 sounds good. If you want to add e2e tests as part of this ticket feel free to do so! I was just saying that it's not a blocker IMO if we create a new ticket specifically for e2e tests

Just to be on the same page when we are talking about storybook e2e tests, we are referring to component tests that will be placed under the brain folder(like the select component tests)?

@goetzrobin
Copy link
Collaborator

I am talking about adding them here: https://github.com/goetzrobin/spartan/tree/main/apps/ui-storybook-e2e/src/integration

@tsironis13
Copy link
Contributor Author

I am talking about adding them here: https://github.com/goetzrobin/spartan/tree/main/apps/ui-storybook-e2e/src/integration

Ok perfect, I was talking about component tests only. I think, we can implement e2e tests in a separate ticket. I will only add component testing on this PR. Thanks for the clarification!

@goetzrobin
Copy link
Collaborator

Awesome @tsironis13! I'll wait for you to mark the PR as ready for review and then we can merge as soon as you're ready :)

@tsironis13 tsironis13 marked this pull request as ready for review July 25, 2024 06:31
@tsironis13
Copy link
Contributor Author

Awesome @tsironis13! I'll wait for you to mark the PR as ready for review and then we can merge as soon as you're ready :)

@goetzrobin The PR is ready for review after basic component tests addition.

@goetzrobin goetzrobin merged commit 30bf1fa into spartan-ng:main Aug 8, 2024
6 of 9 checks passed
@tsironis13 tsironis13 mentioned this pull request Oct 2, 2024
2 tasks
elite-benni pushed a commit to elite-benni/spartan that referenced this pull request Nov 3, 2024
* feat(slider): add new slider component draft version

* feat(slider): remove non used imports

* feat(slider): adapt code to biome linting

* feat(slider): adapt code to biome linting

* fix(tooltip): when toggleVisibility give nativeElement display:none property (spartan-ng#327)

* feat(slider): features addition and code optimization

Add directionality support, basic focus behavior and appearance, and resize behavior.

* feat(slider): implement full accessible slider according to WAI

* feat(slider): add step and tick mark features, adapt styles to shadcn ui

* feat(slider): add component tests

* feat(slider): remove circular dependencies

---------

Co-authored-by: elite-lucas <115133536+elite-lucas@users.noreply.github.com>
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.

5 participants