Skip to content

Conversation

@bjarnef
Copy link
Contributor

@bjarnef bjarnef commented Sep 22, 2024

Description

This PR add a group property to each color swatch, so uui-color-swatches show color swatches grouped if any.
Currently multi selection is possible as in render a uui-color-swatches component per group. We may need to consider this or if all should be grouped inside component?

The uui-color-swatches as slotted content, which may be useful, but could it has default slotted content based on the array of swatches and just pass to in to a property?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Motivation and context

How to test?

Screenshots (if appropriate)

image

Checklist

  • If my change requires a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@github-actions
Copy link

Hi there @bjarnef, thank you for this contribution! 👍

While we wait for the team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@sonarqubecloud
Copy link

@bjarnef
Copy link
Contributor Author

bjarnef commented Oct 28, 2024

I think we could handle grouping inside <umb-color-swatches> instead.

I tried something like this following, but then each swatch wasn't selectable because it isn't a direct child.

<slot name="header">
<div>
   <slot @slotchange=${this._handleSlotChange}></slot>
</div>

And something like this would make it possible to make one selection in each group, but isolated from each other.

<div>
   <h3>Group</h3>
   <umb-color-swatches></umb-color-swatches>
</div>

@iOvergaard do you have any suggestion how we eventually can group swatches without having e.g. 50 <uui-color-swatch> as direct child elements?

…to feature/color-swatches-grouped

# Conflicts:
#	packages/uui-color-swatches/lib/uui-color-swatches.story.ts
@sonarqubecloud
Copy link

@nielslyngsoe nielslyngsoe self-assigned this Nov 7, 2024
@nielslyngsoe nielslyngsoe self-requested a review November 7, 2024 15:21
@nielslyngsoe
Copy link
Member

Hi @bjarnef

We aim not to make to implementation specific code in the UI Library. In other words I think this is perfectly possible already.

But is a question of the implementations reactivity and layout.

The solution I think would be fine, is having a uui-color-swatches for each group. By sharing the same value of the implementation they would be 'connected' in the sense that once a user clicks a swatch of another group, the value would be changed, meaning the other groups swatches is then no longer be selected.

But reading the code of uui-color-swatches it seems to me like the component is not reactive, a simple test would be: change the value, programmatically(NOT via clicking a swatch, but changing the value of the swatches component) after the elements have been appended as children. — From looking at the code it seems like changing the value does not change what is selected visually. So this is needed for this to work and for other things to work as well.

So we should have that fixed, and then this would not be needed but completely up to each implementation to group/layout swatches as they want.

@bjarnef bjarnef deleted the feature/color-swatches-grouped branch November 20, 2024 08:35
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.

2 participants