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

feature/select #70

Merged
merged 57 commits into from
Feb 21, 2024
Merged

feature/select #70

merged 57 commits into from
Feb 21, 2024

Conversation

thatsamsonkid
Copy link
Collaborator

@thatsamsonkid thatsamsonkid commented Dec 7, 2023

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
  • input
  • label
  • menubar
  • navigation-menu
  • popover
  • progress
  • radio-group
  • scroll-area
  • select
  • separator
  • sheet
  • skeleton
  • slider
  • switch
  • table
  • tabs
  • textarea
  • toast
  • toggle
  • tooltip
  • typography

What is the current behavior?

Closes #

Select Primitive

Closes #65

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@thatsamsonkid
Copy link
Collaborator Author

Wanted to open a draft PR to get some initial feedback on what I have so far, so yea let me know what you think
Still pending:

  • HLM versions of everything
  • Scrolling variation of select
  • Verify some of the form field states
  • Tests

@goetzrobin
Copy link
Owner

Awesome! This is a great start! How deep do you want the feedback to go? Just overall if this is going into the right direction or is there any more specific things you'd like me to address?

Thanks for working on this! I am super excited for this!

@thatsamsonkid
Copy link
Collaborator Author

I think overall/high-level for now. Im still tidying up everything. Can definitely do a more in depth one once I think this is closer to being done.

I think one thing I also wanted an opinion on is do you think we should have stories for just brain usage and one with only hlm?

  1. I think to make sure someone can reasonable recreate everything with just brain

2.to make sure hlm is exposing everything it should from underlying brain and just using brain correctly overall? What do you think?

@goetzrobin
Copy link
Owner

So one thing we decided to do going forward is to allow him to depend on brain directly. This means him can use brain components in their own template or via host directives, etc.

However, brain should never depend on helm and we should expose enough information so you can build your own UI lib just with brain components.

Radix UI = Brain
shadcn = Helm

We are implementing both at the same time so we need to be a little more careful, but overall brain should do all the work and him only does some minor additions, adds styles, and improves API surface for those using them together!

Overall, I really like how this is coming along though! I think you are absolutely on the right track!

@goetzrobin
Copy link
Owner

@thatsamsonkid let me know if I can do anything else to help or if you got everything you need for this! This is going to be a great addition 👍

@thatsamsonkid
Copy link
Collaborator Author

Definitely!, I think I was getting hung up on some things for it and just needed a small break from it 😅. Let me verify I pushed everything I have so far and maybe I can get help with some specific things

@thatsamsonkid thatsamsonkid marked this pull request as draft January 6, 2024 14:35
@thatsamsonkid thatsamsonkid changed the title (Draft) - Feature/select feature/select Jan 6, 2024
@thatsamsonkid
Copy link
Collaborator Author

thatsamsonkid commented Jan 8, 2024

Ok I updated this branch with latest and wanted to give an overview of what is remaining for this

So remaining items/issues:

  • Determining minimum number of items to show. Should we have a default. Configurable number. Im a little unsure how radix/shadcn is determining whether to show few options or if you see their "scrolling" example its showing almost as many as possible it seems.But seemingly without any like direct input - need some consensus on this should work i guess

  • Need to fix overlay cdk to open above or below depending on space - could use assistance on this or an example could help me also

  • Showing and hiding the scrolling arrows needs to be fixed mainly an issue with where and how Im setting the dropdown scroll

  • Tests for Select

  • Minor issue with selected option showing as checked. Is only updating after hovering over old option

  • Group heading and section directive styling still needs to be worked on

@goetzrobin

@goetzrobin
Copy link
Owner

Sweet, I'll try to check this out this week! @elite-benni feel free to also take a look at this if you have time :)

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.

Looks pretty good already. Left some comments.

@Component({
selector: 'brn-select-content, hlm-select-content:not(noHlm)',
standalone: true,
imports: [BrnSelectScrollUpDirective, BrnSelectScrollDownDirective, HlmIconComponent],
Copy link
Collaborator

Choose a reason for hiding this comment

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

A Dependency to helm should be avoided.
I am not sure how to achieve this when we want to use the same component as helm selector.

Copy link
Owner

Choose a reason for hiding this comment

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

Agreed! Maybe we can work with content projection here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That is the same problem, that I had with the switch.
When using content projection, the api is not as nice as it would be now. :/
It is already possible to use content projection, hlm Icon is used if no brnSelectScrollUp or brnSelectScrollDown is provided in the content.
So technically this is not a "tight" dependency, it would also work without Hlm.

Copy link
Collaborator Author

@thatsamsonkid thatsamsonkid Jan 17, 2024

Choose a reason for hiding this comment

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

Hmmm I had originally imagined that there would be a default icon and you would only need to provide the up/down icon arrows through projection if you wished to change the default to some other icon or icon family. I see two potential options:

  1. A brnIcon of some sort (would this just be ngIcon lol) - probably would not be different from current hlm really and would of course make ng-icon a dep for this component so probably not the best idea but an idea none the less.

  2. We would have to require the user to project both and up and down icon and maybe throw some warning if they don't (provide both that is) and maybe just keep a placeholder text until hlmIcon contents are provided and or simply just keep this as an optional thing. If you don't provide content we can just leave this "hover scrolling areas" out.

  3. Or just throwing this out another idea we could keep a very simple svg inlined for the the up and down arrows as well

Let me know what you guys think or open to any other suggestions also

Copy link
Collaborator

Choose a reason for hiding this comment

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

For me 2. sounds like the best of these options.
The other option would be to make an helm component that uses the correct content, but this has the disadvantage of adding a new layer again. :/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea I think lets just keep it as optional projections for these "hover scroll areas" optional. I'll make that change and i think just add some console warning if only one is provided not the other.

standalone: true,
host: {
'aria-hidden': 'true',
class: 'flex cursor-default items-center justify-center py-1',
Copy link
Collaborator

Choose a reason for hiding this comment

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

brain should not depend on tailwind

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I may not need these depending on our decision on the up and down arrows. But yes will definitely remove the tw classes

private readonly classNames = signal<ClassValue>('');

// eslint-disable-next-line @angular-eslint/no-input-rename
@Input({ alias: 'class' })
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you use an alias here?

libs/ui/select/helm/src/lib/hlm-select-option.component.ts Outdated Show resolved Hide resolved
@goetzrobin
Copy link
Owner

Agree with @elite-benni's comments! I'll need to find some time to give this the attention it deserves! Thanks for your great work on this @thatsamsonkid! Probably one of the hardest and most impactful primitives! I think we are pretty close on this!!

@thatsamsonkid
Copy link
Collaborator Author

thatsamsonkid commented Jan 23, 2024

Alrighty update on changes, seems never ending for some reason 🥲

Completed Items/fixes:

  • Showing and hiding the scrolling arrows needs to be fixed mainly an issue with where and how Im setting the dropdown scroll

  • Minor issue with selected option showing as checked. Is only updating after hovering over old option

  • Fixed the selections so if multiple selections are made and mutilple value goes from true -> false then selections are cleared. (Turns out cdkListbox does this by default as well so we're on the right track there)

  • Need to fix overlay cdk to open above or below depending on space - could use assistance on this or an example could help me also

  • While I fixed the up/down arrow show hide and made some select "viewport" updates, still needs to be tweaked slightly with up/down arrows covering very first and last options

  • still need some input on how we should determine/configure number of items to show at once by select, not only for default but also for scrollable.

  • In dark mode the select dropdown out line is a bright white. Not entirely sure why

  • Optional group heading sticky

  • Group heading and section directive styling still needs to be worked on

  • Check browser autofill behavior (will resolve as part of combobox/command rework)

  • dir support

  • Tests for Select

  • Select Docs

@goetzrobin @elite-benni

@thatsamsonkid
Copy link
Collaborator Author

Screen.Recording.2024-01-28.at.8.38.24.AM.mov

👀👀👀

@thatsamsonkid thatsamsonkid force-pushed the feature/select branch 2 times, most recently from 7e56025 to 2abc152 Compare February 1, 2024 03:35
imports: [ReactiveFormsModule, BrnSelectImports, HlmSelectImports],
providers: [provideIcons({ radixChevronUp, radixChevronDown })],
template: `
<form [formGroup]="options">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Guess we can remove the form in the example now.
You want me to clean this up?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes please

thatsamsonkid and others added 11 commits February 14, 2024 22:09
1. made stuff that can be readonly readonly
2. marked things as public, protected, private explicitly
3. moved things from taps into subscribes
4. added some early returns instead of nested ifs
5. fixed a weird flickering bug when using arrows
6. fixed minor css issue with very long values
7. introduced input that allows for custom function transforming the raw value
8. introduced icon where it was possible
9. made some computedClass stuff cleaner
FINALLY: HOLY SHIT IS THIS CODE A PIECE OF ART! INCREDIBLE WORK!! I AM IN LOVE WITH THIS COMPONENT
1. missing id on brn-select content
2. select not closing on making a selection in single value mode
1. remove uneeded stories and story clean up
@goetzrobin
Copy link
Owner

@thatsamsonkid anything I can help to get this into main? Keep up the awesome work!

@thatsamsonkid
Copy link
Collaborator Author

I should have some time tomorrow to hopefully wrap up the tests.

Mainly just need to add tests for some of the keyboard actions and scrolling. Then refine docs maybe. I was thinking I should probably add a few useful event outputs like on open/close to start with.

I think autofill is still an issue here but I think I will resolve that once I help convert combobox and command to our own implementation since its very similar.

@goetzrobin

- adds openChanged event emitter
- add test for openChange event
- add test for disabled state
- add test for scroll behavior
- add test for group headings accessibility attributes
docs(select): remove formcontrol from examples and preview
@thatsamsonkid thatsamsonkid marked this pull request as ready for review February 19, 2024 23:14
@thatsamsonkid
Copy link
Collaborator Author

All, I think this might be ready for serious consideration to merge finally!. Do we need to test cli/nx setup? I think docs we can do more but I know we were still looking into how to best format inputs/outputs of the components.

But for now the same level of docs seems to be there now thanks @elite-benni and I think I got a good number of tests there to test the core functionality!

Let me know if anything

@goetzrobin @elite-benni

goetzrobin and others added 6 commits February 20, 2024 15:06
…tyle improvements

seems like contentchildren did not work the way we expected and the trigger always was undefined.
we let the trigger set itself inside the service, which is accessible by the brn-select
component. then we can use the reference to focus the trigger on close
@goetzrobin goetzrobin merged commit e071dae into goetzrobin:main Feb 21, 2024
7 of 9 checks passed
ty-ler pushed a commit to ty-ler/spartan that referenced this pull request Feb 28, 2024
* feat(select): adds functional select brain/hlm cmps/directives

* feat(label): adds label brain

* feat(select): brain select component refinement

- fixes issue with root brain select component not reacting to input changes
- fixes storybook issue args not being passed to component
- comments out stories that still need work

* feat(label): brain label component

* feat: adds directives for scrolling select elements

* chore: select cypress init

* refactor: change brn-select-content to component

* refactor: adds helm selectors to brn-select, brn-select-value

* feat: adds helm select directive

* fix: helm select content directive with brn refactor

* fix: updates select stories

* fix(select): missing brn export

* fix(select): incorrect setter

* fix(select): removes tw class from brn-select-content

* fix(select): removes unused code

* fix(select): tw scroll class

* feat(select): add brn-select-up/down

* feat(select): add hlm select-scroll-up/down

* fix(select): clear selected when multi changes from true to false

* fix(select): change detection issue with selected options

* feat(select): show/hide scroll up/down

* fix(select): hide scrollbar

* feat(select): add arrow scroll up/down

* fix(select): dropdown border dark mode

* feat(select): select-trigger custom icon

* fix(select): option checkmark location

* fix(label): add getter for id

* feat(select): brn group and label

* feat(select): helm select group and label

* fix(select): update scrollable story

* fix(select): selected options value display

* fix(select): multiple value update and selection display

* fix(select): service deselect all options fix

* fix(select): log clean up

* feat(select): sticky labels

* fix(select): multi value selection indentation issue

* refactor: brn-select-content

* fix(select): select ada label and value reading

* docs(select): add the select page with preview and examples

* docs(select): use the correct formcontrolname in srcollable select

* fix(select): allow select to function without explicit ngControl

* fix(select): storybook cleanup

* feat: minor code style improvements and a couple more. see below

1. made stuff that can be readonly readonly
2. marked things as public, protected, private explicitly
3. moved things from taps into subscribes
4. added some early returns instead of nested ifs
5. fixed a weird flickering bug when using arrows
6. fixed minor css issue with very long values
7. introduced input that allows for custom function transforming the raw value
8. introduced icon where it was possible
9. made some computedClass stuff cleaner
FINALLY: HOLY SHIT IS THIS CODE A PIECE OF ART! INCREDIBLE WORK!! I AM IN LOVE WITH THIS COMPONENT

* fix(select): testing surfaced issues

1. missing id on brn-select content
2. select not closing on making a selection in single value mode

* fix: ts config formatting

* feat(select): initial tests

1. remove uneeded stories and story clean up

* docs(select): remove formcontrol from examples and preview

* feat(select): support for dir

- adds openChanged event emitter

* feat(select): additional tests

- add test for openChange event
- add test for disabled state
- add test for scroll behavior
- add test for group headings accessibility attributes

* docs: border css rule

* fix: turn up and down into components and import the icons in there

* fix: add border classes and allow classnames passed to hlm-select

* fix: make focus return to trigger when dropdown closed & minor code style improvements

seems like contentchildren did not work the way we expected and the trigger always was undefined.
we let the trigger set itself inside the service, which is accessible by the brn-select
component. then we can use the reference to focus the trigger on close

* docs: minor improvements to select documentation & examples

* fix: remove unneeded border color rule

---------

Co-authored-by: elite-benni <benjamin.heiss@elite.tirol>
Co-authored-by: robingotz <tug29225@temple.edu>
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.

RFC: Select
4 participants