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

Math isn't working inside rgba() function #166

Closed
akosarch opened this issue Jun 30, 2021 · 5 comments · Fixed by #226
Closed

Math isn't working inside rgba() function #166

akosarch opened this issue Jun 30, 2021 · 5 comments · Fixed by #226
Labels
bug Something isn't working

Comments

@akosarch
Copy link

Знімок екрана 2021-06-30 о 17 06 41

I want to invert the opacity by subtracting some value from 1 when creating new color with the help of rgba() function. Unfortunately, this doesn't work as expected. However, it works if I define a separate opacity token with this math but not directly inside the rgba() function.

@six7 six7 added the bug Something isn't working label Jul 3, 2021
@electroheadfx
Copy link

I have too a problem with rgba when I reference a color by:
rgba($colors.brand.default, 0.5)
I get a white color, brand.default is : $colors.blue.500
blue.500 is : hsl($colors.blue._hue, 100%, 50%)
and _hue is : 210

@maartensaulx
Copy link

@electroheadfx you can solve this by using a hex color value for your blue.500. Worked for me at least.

@electroheadfx
Copy link

@electroheadfx you can solve this by using a hex color value for your blue.500. Worked for me at least.

yes of course it works, just it doens't support color with utils like : hsl($colors.blue._hue, 100%, 50%), its useful because I dont need to convert in hex, just use the saturation.

@coolmanlume
Copy link

coolmanlume commented Aug 24, 2021

Same issue using hsla:

"TKSC": {
    "color": {
      "cyan~teal": {
        "hue": {
          "value": "177",
          "type": "other"
        },
        "saturation": {
          "value": "44",
          "type": "other"
        },
        "lightness": {
          "value": "41",
          "type": "other"
        }
      }
},
"TKM": {
    "color": {
      "primary.300": {
        "value": "hsla($TKSC.color.cyan~teal.hue, $TKSC.color.cyan~teal.saturation, $TKSC.color.cyan~teal.lightness * 1.2439, 1)",
        "description": "Primary background color light",
        "type": "color"
      }
}

The Token doesn't work:

See screenshot

Also please note that the colors chips (palette) inside the plugin panel are not displaying the calculated colors. I will open another Issue for this soon.

@coolmanlume
Copy link

coolmanlume commented Aug 25, 2021

@six7: FYI if you watch this Loom captured on July 22 you will notice that everything was functioning¹ then.
I Hope that this can help.

(1) Here's the snippet I was using, and doesn't work anymore

$colors.lightness._secondary-bg * 4.5 + 0.175 translates into "15 * 4.5 + 0.175" instead of 45.175 (‹ properly evaluated in the colors.lightness._secondary-AA node)

{
  "colors": {
    "lightness": {
      "_secondary-bg": {
        "value": "25",
        "description": "Lightness of the Secondary background color",
        "type": "color"
      },
      "_secondary-AA": {
        "value": "$colors.lightness._secondary-bg * 4.5 + 0.175",
        "description": "AA lightness of the Secondary text color",
        "type": "color"
      }
    },
    "color": {
      "secondary": {
        "value": "hsl(172,50,$colors.lightness._secondary-bg)",
        "description": "Secondary background color",
        "type": "color"
      }
    },
    "secondary-AA": {
      "value": "hsl(172,50,$colors.lightness._secondary-AA)",
      "description": "AA Color of text on Secondary",
      "type": "color"
    }
  }
}

Also I've noticed that removing the space character after the comma inside the hsl() function sometimes leads to a null eval.

six7 added a commit that referenced this issue Oct 23, 2021
@six7 six7 mentioned this issue Oct 23, 2021
7 tasks
@six7 six7 closed this as completed in #226 Oct 31, 2021
six7 added a commit that referenced this issue Oct 31, 2021
* add initial url sync

* add new provider type

* add form

* add basic functionality

* add working pull

* add push dialog, working state

* added checks for commit message

* add tests

* rework confirm message

* add dirty state

* add test

* fix jsonbin

* remove legacy code

* wip

* fix pullTokens

* add tests

* add first draft of cli script

* fix tests

* add pkg

* working cli tool with github actions

* remove console log

* Add robustness

* bump token-transformer

* prettify ui

* bump release

* add custom branch input to pushDialog

* added loading screen, fixed jsonbin add

* add excludes to token transformer

* add readme to token-transformer

* fix transformer when no excludes are present

* remove token context

* add url sync

* allow users to resize window by dragging corner

* fix url sync

* ignore tokens from style creation that start with _

* fix tooltip render error

* fix tooltip in list mode

* fix resize pointer

* fix #266

* fix colors button row

* fixes #274

* fix / replacement

* fixes #142

* add check for alias

* add token preview in edit

* fix undefined pr state if no file existed

* add editProhibited based on user role

* fix alias value of 0

* add new defaults

* remove spellcheck from inputs

* adds json5 support, fixes #270, fixes #283

* add unique check to names

* fix color opacity values not matching when using 0.5

* fixes #166, fixes #209

* add type to new token creation

* fixes #276

* fixes unique name check

* fix unique name check

* capitalize description in edit form

* introduce new merging function

* fix aliasing of rgba colors

* add new resize icon

* fix capitalization of input labels

* fix name of form

* fix async fn

* correctly saves whole context obj except secret

* add placeholder for value

* fix spec

* fix test

* remove console.log

* fix when no tokens file was present

* integrate style name ignore for updating nodes

* fix ignore part when applying

* fix modal padding except for edit token form

* fix token-transformer

* bump token transformer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants