From 132dbfabccf44dbb44b4392a1d44189a422c5dd7 Mon Sep 17 00:00:00 2001 From: Lea Verou Date: Thu, 20 Feb 2025 12:10:43 -0500 Subject: [PATCH] Gray tweaks prototype (#761) Co-authored-by: Lindsay M <126139086+lindsaym-fa@users.noreply.github.com> --- docs/_layouts/palette.njk | 118 +++++--- docs/assets/scripts/sidebar-tweaks.js | 66 ++++- docs/assets/scripts/tweak/data.js | 39 +++ docs/assets/scripts/tweak/util.js | 36 +++ docs/docs/palettes/tweak.css | 63 +++- docs/docs/palettes/tweak.js | 405 ++++++++++++++++++-------- docs/docs/themes/demo.njk | 49 ++-- docs/docs/themes/remix.js | 4 + docs/docs/themes/showcase.css | 5 + src/styles/native/slider.css | 2 + 10 files changed, 591 insertions(+), 196 deletions(-) create mode 100644 docs/assets/scripts/tweak/util.js diff --git a/docs/_layouts/palette.njk b/docs/_layouts/palette.njk index 882d823ac..d06ea3bd9 100644 --- a/docs/_layouts/palette.njk +++ b/docs/_layouts/palette.njk @@ -18,11 +18,15 @@ tweaking: tweaking.chroma, 'tweaking-chroma': tweaking.chroma, 'tweaking-hue': tweaking.chroma, - 'tweaked-chroma': tweaked.chroma, - 'tweaked-hue': tweaked.hue, - 'tweaked-any': tweaked.chroma || tweaked.hue + 'tweaking-gray-chroma': tweaking.grayChroma, + 'tweaked-chroma': tweaked?.chroma, + 'tweaked-hue': tweaked?.hue, + 'tweaked-any': tweaked }" - :style="{ '--chroma-scale': chromaScale }"> + :style="{ + '--chroma-scale': chromaScale, + '--gray-chroma': tweaked?.grayChroma ? grayChroma : '', + }"> {% include 'breadcrumbs.njk' %} @@ -36,6 +40,9 @@
.wa-palette-{{ paletteId }} {% include '../_includes/status.njk' %} + {% if not isPro %} + PRO + {% endif %}
{% if description %}

@@ -48,18 +55,18 @@ {% set maxChroma = 0 %} - + This palette has been tweaked. - {% raw %}{{ tweakHumanReadable }}{% endraw %} + {% raw %}{{ tweakHumanReadable }}{% endraw %} - + Reset - + @@ -81,25 +88,67 @@ {# Initialize to last hue before gray #} {%- set hueBefore = hues[hues|length - 2] -%} {% for hue in hues -%} -{%- set coreColor = palettes[paletteId][hue][palettes[paletteId][hue].maxChromaTint] -%} +{% set coreTint = palettes[paletteId][hue].maxChromaTint %} +{%- set coreColor = palettes[paletteId][hue][coreTint] -%} {%- set maxChroma = coreColor.c if coreColor.c > maxChroma else maxChroma -%} - +{% else %} + +{% endif %} {{ hue | capitalize }} - - {% if hue !== 'gray' %} - {%- set hueAfter = hues[loop.index0 + 1] -%} - {%- set hueAfter = hues[0] if hueAfter == 'gray' else hueAfter -%} - {%- set minShift = hueRanges[hue].min - coreColor.h | round -%} - {%- set maxShift = hueRanges[hue].max - coreColor.h | round -%} + -

- {{ palettes[paletteId][hue].maxChromaTint }} - -
- ` + --wa-color-{{ hue }} + + + ` - {%- set hueBefore = hue -%} - {% else %} -
- {{ palettes[paletteId][hue].maxChromaTint }} -
- {% endif %} {% for tint in tints -%} {%- set color = palettes[paletteId][hue][tint] -%} - -
+ +
@@ -144,7 +193,8 @@