CSS dynamic variables #495

Closed
opened 2026-02-20 10:18:05 -05:00 by deekerman · 6 comments
Owner

Originally created by @96LawDawg on GitHub (Mar 14, 2022).

Originally assigned to: @ArnoldSmith86 on GitHub.

When I was testing the new dragging property, I set up a widget with the following css:

"css": {
    "default": {
      "background-color": "${PROPERTY dragColor}"
    }
  }

dragColor was a custom property set on the widget by another routine. It was either the playerColor or it was null. The css handled the switch from null to the color just fine. But when the dragColor changed back to null, the css dynamic variable didn't react. If instead of going to null, I set the dragColor to "white", it worked fine. If I set the dragColor to false, it worked fine.

Refreshing the browser window when dragColor was null did reset the background. Not sure if this is intended behavior or an issue when css dynamic variables encounter a null. @robartsd ?

Originally created by @96LawDawg on GitHub (Mar 14, 2022). Originally assigned to: @ArnoldSmith86 on GitHub. When I was testing the new `dragging` property, I set up a widget with the following css: ```JSON "css": { "default": { "background-color": "${PROPERTY dragColor}" } } ``` `dragColor` was a custom property set on the widget by another routine. It was either the `playerColor` or it was null. The css handled the switch from null to the color just fine. But when the `dragColor` changed back to null, the css dynamic variable didn't react. If instead of going to null, I set the `dragColor` to "white", it worked fine. If I set the `dragColor` to false, it worked fine. Refreshing the browser window when `dragColor` was null did reset the background. Not sure if this is intended behavior or an issue when css dynamic variables encounter a null. @robartsd ?
deekerman 2026-02-20 10:18:05 -05:00
Author
Owner

@robartsd commented on GitHub (Mar 14, 2022):

@ArnoldSmith86 wrote the code for CSS dynamic variables, so he would be more familiar with how it works. Based on what you describe, my guess is that properties being deleted from a widget (setting a property to null causes it to be deleted) are not checked to see if those properties are used in the CSS. I'm pretty sure that this is unintended, since the display should always be the same after a refresh.

@robartsd commented on GitHub (Mar 14, 2022): @ArnoldSmith86 wrote the code for CSS dynamic variables, so he would be more familiar with how it works. Based on what you describe, my guess is that properties being deleted from a widget (setting a property to `null` causes it to be deleted) are not checked to see if those properties are used in the CSS. I'm pretty sure that this is unintended, since the display should always be the same after a refresh.
Author
Owner

@robartsd commented on GitHub (Mar 15, 2022):

I'm also experiencing a problem using CSS dynamic variables if the CSS property for a card comes from the deck.

@robartsd commented on GitHub (Mar 15, 2022): I'm also experiencing a problem using CSS dynamic variables if the CSS property for a card comes from the deck.
Author
Owner

@ArnoldSmith86 commented on GitHub (Mar 15, 2022):

I'm also experiencing a problem using CSS dynamic variables if the CSS property for a card comes from the deck.

Do you have an example? And is it fixed in #1148?

@ArnoldSmith86 commented on GitHub (Mar 15, 2022): > I'm also experiencing a problem using CSS dynamic variables if the CSS property for a card comes from the deck. Do you have an example? And is it fixed in #1148?
Author
Owner

@robartsd commented on GitHub (Mar 15, 2022):

I'm working on transportationDeck for Fun with Transit. css property in cardTypes or cardDefaults does not work, but same property set directly in the card does work. I'll work on a test case.

@robartsd commented on GitHub (Mar 15, 2022): I'm working on `transportationDeck` for [Fun with Transit](https://virtualtabletop.io/T2R_NewYork). `css` property in `cardTypes` or `cardDefaults` does not work, but same property set directly in the card does work. I'll work on a test case.
Author
Owner

@ArnoldSmith86 commented on GitHub (Mar 15, 2022):

If it works in the PR, we don't need a test case, I guess.

@ArnoldSmith86 commented on GitHub (Mar 15, 2022): If it works in the PR, we don't need a test case, I guess.
Author
Owner

@robartsd commented on GitHub (Mar 15, 2022):

Sorry, I was mistaken. I was not using the correct syntax.

@robartsd commented on GitHub (Mar 15, 2022): Sorry, I was mistaken. I was not using the correct syntax.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/virtualtabletop#495
No description provided.