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

Add button and drag to swap colors #227

Merged
merged 15 commits into from
Feb 5, 2025
Merged

Add button and drag to swap colors #227

merged 15 commits into from
Feb 5, 2025

Conversation

jamesnw
Copy link
Contributor

@jamesnw jamesnw commented Dec 11, 2024

Description

Currently not designed, this is to show possibilities.

  • Adds a button to swap
  • Supports dragging from one swatch to the other to swap

Related Issue(s)

#108

Todo

  • Style button on small screens
  • Reduce gutter

@jamesnw jamesnw marked this pull request as ready for review December 11, 2024 17:17
Copy link

netlify bot commented Dec 11, 2024

Deploy Preview for oddcontrast ready!

Name Link
🔨 Latest commit ad9a6f9
🔍 Latest deploy log https://app.netlify.com/sites/oddcontrast/deploys/67a3a43efd827a00085f2f83
😎 Deploy Preview https://deploy-preview-227--oddcontrast.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jamesnw jamesnw linked an issue Dec 16, 2024 that may be closed by this pull request
* main:
  lint
  Bump the dev-minor group across 1 directory with 15 updates
  Bump jsdom from 25.0.1 to 26.0.0 in the dev-major group
  Bump the dev-minor group with 6 updates
  upgrade node and yarn
  Bump the dev-minor group with 6 updates
  Bump the dev-minor group with 7 updates
  Bump the dev-minor group with 12 updates
src/lib/components/colors/Header.svelte Outdated Show resolved Hide resolved
src/lib/components/colors/Header.svelte Outdated Show resolved Hide resolved
src/lib/components/colors/Header.svelte Outdated Show resolved Hide resolved
@mirisuzanne
Copy link
Member

Functionality looks good. I think the button could use some more styling, especially around interactions – since it takes up a lot of space, but only has a small icon. @dvdherron is this something you'd be interested in looking at?

dvdherron and others added 3 commits January 30, 2025 17:31
* main:
  upgrade stylelint
  Bump the dev-minor group with 11 updates
  upgrade all deps
  Bump the dev-major group with 3 updates
@dvdherron
Copy link
Contributor

@mirisuzanne I decreased the size of the button target area and moved the button to be more centered in f2b0be1

image

It also rotates when the colors are stacked
image

Played around with some possible animations but couldn't come up with something that made sense in both orientations. Open to suggestions if you think an animation of some sort should happen. Maybe it just spins on hover or when the colors change?

@dvdherron dvdherron requested a review from mirisuzanne February 3, 2025 17:26
Copy link
Member

@mirisuzanne mirisuzanne left a comment

Choose a reason for hiding this comment

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

Looking pretty good. A swap rotation animation could be fun, but what I was really trying to get at was something more noticeable on hover/focus - to make the click target more obvious. Looking closer, I wonder why we're removing focus rings on all icon buttons currently?


<button type="button" onclick={switchColors} data-btn="icon switch">
<Icon name="switch" />
<span class="sr-only">Click to swap colors</span></button
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<span class="sr-only">Click to swap colors</span></button
<span class="sr-only">Swap colors</span></button

Comment on lines 84 to 85
'bginput switch fginput' auto
'bgslide . fgslide' auto / 1fr min-content 1fr;
Copy link
Member

Choose a reason for hiding this comment

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

I like having the button in the grid, but currently:

  • The column gaps seem quite large, with only that button in between the colors
  • The top (color form) and bottom (color formats/gamuts) grids no longer align

Screenshot 2025-02-03 at 11 59 42 AM

Copy link
Member

@mirisuzanne mirisuzanne left a comment

Choose a reason for hiding this comment

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

lgtm

@jgerigmeyer
Copy link
Member

A swap rotation animation could be fun

I agree that a rotate-180 rotation animation would be cool here, but doesn't need to hold up merge if we don't want to mess with it.

@dvdherron
Copy link
Contributor

Looking pretty good. A swap rotation animation could be fun, but what I was really trying to get at was something more noticeable on hover/focus - to make the click target more obvious. Looking closer, I wonder why we're removing focus rings on all icon buttons currently?

I think we gave the icon buttons custom focus styles in b62fd12 ? @stacyk Might have more to say on that. They generally scale up and change color on keyboard focus.

I added an outline to swap-colors button for now but we can remove that if we want all the icon buttons to match.

@dvdherron
Copy link
Contributor

Added a rotation animation to the button in 3a699a0 And there's now a thin outline on keyboard focus. Should be ready for a final review.

@jamesnw
Copy link
Contributor Author

jamesnw commented Feb 5, 2025

I like the animation! A couple questions-

  • Should we disable it for people with prefers-reduced-motion?
  • I was expecting it to animate on click, not hover- but I guess that would require JS, right? I'm fine either way.

&:focus {
--outline-width: thin;

animation: swap var(--fast) var(--out-back);
Copy link
Member

Choose a reason for hiding this comment

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

The transform property already has a transition on it, so might be simpler to rotate rather than add a full animation:

Suggested change
animation: swap var(--fast) var(--out-back);
transform: rotate(180deg);

Copy link
Contributor

Choose a reason for hiding this comment

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

removed the full animation in ad9a6f9

src/sass/patterns/_buttons.scss Show resolved Hide resolved
src/sass/patterns/_buttons.scss Show resolved Hide resolved
@dvdherron
Copy link
Contributor

I like the animation! A couple questions-

* Should we disable it for people with `prefers-reduced-motion`?

Good call. I'll add a prefers-reduced-motion rule.

* I was expecting it to animate on click, not hover- but I guess that would require JS, right? I'm fine either way.

Yeah, that might make more sense for the animation to happen as the swap is happening. Would that be adding a temporary class to the button? @jamesnw I can clean up the css if you set up the JS.

@mirisuzanne
Copy link
Member

Yeah, that might make more sense for the animation to happen as the swap is happening. Would that be adding a temporary class to the button?

@dvdherron @jamesnw - while I see the logic to it, I don't think that animating on active would be as helpful. At that point we've already taken the action. By doing it on hover, we tell you something about what the action is going to be.

@dvdherron
Copy link
Contributor

* Should we disable it for people with `prefers-reduced-motion`?

Instead of rotating, it just scales a tiny bit for people with prefers-reduced-motion set.

Copy link
Member

@mirisuzanne mirisuzanne left a comment

Choose a reason for hiding this comment

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

looks great!

@jgerigmeyer jgerigmeyer merged commit b653d98 into main Feb 5, 2025
7 checks passed
@jgerigmeyer jgerigmeyer deleted the swap-colors branch February 5, 2025 19:41
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.

I want to easily swap colors (background/foreground)
5 participants