Skip to content

Update story for color swatches #488

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

Merged

Conversation

bjarnef
Copy link
Contributor

@bjarnef bjarnef commented May 17, 2023

… with example where label is different than value.

Description

Update the story of color swatches to use array of objects instead to show label can be different than value.

image

while string array still works.

image

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)

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 🤖 🙂

@iOvergaard iOvergaard added the documentation Improvements or additions to documentation label May 22, 2023
@iOvergaard iOvergaard merged commit 5f7da8e into umbraco:v1/contrib May 22, 2023
@bjarnef bjarnef deleted the feature/color-swatches-labels-story branch May 31, 2023 08:46
@bjarnef
Copy link
Contributor Author

bjarnef commented May 31, 2023

@iOvergaard I don't see this story here?
https://uui.umbraco.com/?path=/story/uui-color-swatches--overview

Also did the property change from swatches to swatchesColor?

image

in uui-color-swatch it use a color picker in storybook:

image

but not in story of uui-color-swatches:

image

@iOvergaard
Copy link
Contributor

@bjarnef it is still called "swatches". I needed to invent a new control for Storybook, which I named "swatchesColor" so it doesn't collide with the property of the component. If you check the docs, there is still the "swatches" property and the other one is just a control for Storybook, since we needed to have the data stored somewhere visible.

The "value" field does not use the color picker, because it is the selected value, i.e. the output value of the component, and for purposes of experimenting with the 'value' property, we need to make sure you can type one of the existing colors into the field to have it selected, which would be very hard to "pick" using a color picker. Hope that makes sense.

@bjarnef
Copy link
Contributor Author

bjarnef commented May 31, 2023

It seems the mapping pass in swatchesColor due to the variable name:
https://github.com/umbraco/Umbraco.UI/pull/500/files#diff-57d087d5d487ba9b3141bc5c09bd619b383d6b16b09f8e422de98852789db332R9-R61

I guess the variable should be changes to swatches ... or use the following:

const meta: Meta<typeof UUIColorSwatchesElement> = {
  id: 'uui-color-swatches',
  title: 'Inputs/Color/Color Swatches',
  component: 'uui-color-swatches',
  args: {
    swatches: swatchesColor,
    showLabel: false,
  } as any,
  argTypes: {
    swatches: {
      control: { type: 'array' },
    },
    showLabel: {
      control: { type: 'boolean' },
    },
  } as any,
  parameters: {
    readme: {
      markdown: readme,
    },
    docs: {
      source: {
        code: `<uui-color-swatches></uui-color-swatches>`,
      },
    },
  },
};

@iOvergaard
Copy link
Contributor

The swatches property is specifically an array of UUIColorSwatchElement so it wouldn't make sense to override it with a custom array in Storybook in my opinion, hence the custom control specifically for storybook called something else. That way the original swatches still show up in the documentation and can in theory be interacted with (even though I think Storybook does not support HTML in that way in a control).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community/pr documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants