forge icon indicating copy to clipboard operation
forge copied to clipboard

[ripple] add built-in "selected" state

Open DRiFTy17 opened this issue 1 year ago • 0 comments

Describe the feature: It is common for interactive elements to also provide a "selected" state. This is essentially the same same ripple styles we see now with a persistent background color that uses the primary theme as seen in the example below on a <forge-card>: image

In dark mode it looks like this: image

Describe any alternatives you've considered: This can currently be achieved with the following:

We should potentially look to add this as a built-in selected property on the <forge-ripple> component itself for convenience.

HTML:

<forge-card tabindex="1" role="button" outlined class="my-card my-card--selected">
  <forge-ripple></forge-ripple>
  My selected card
</forge-card>

Sass:

.my-card {
  cursor: pointer;
  @include ripple-theme.states-selected(primary);

  &--selected {
    --mdc-theme-on-surface: var(--mdc-theme-primary);
    --forge-theme-border-color: var(--mdc-theme-primary);
    color: var(--mdc-theme-primary);
  }
}

Additional information: While this is common on cards, it can be applied to any element. The "selected" state of a ripple is essentially the persistent background color only, and we would still need design system guidance to help with the reset of the colors. It may make sense to also add a selected property to the <forge-card> as well to use along side the ripple (essentialy provides the cursor and border styles) but this may be too specific...

DRiFTy17 avatar Mar 23 '23 19:03 DRiFTy17