[Feature Request] Extend `*computed-` and `measure` syntax to ALL CSS properties

Open
#620 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
css, javascript
Domain
frontend

Research direction

Start by locating the implementations of the *computed- property syntax and the measure command, then compare their current behavior with the issue's getComputedStyle example. Done means both forms can retrieve computed values for arbitrary CSS properties, including the color and font-size examples shown.

Written by the indexing model from the issue text.

Description

Right now, the *computed- style property syntax, as well as the measure command seem to assume we’re only interested in knowing the current position and size of an element. In fact, there are many times when we need to know the current, computed value of other properties, too — eg. colours that may be overriden by locally-scoped custom CSS properties, or by specific user interactions, such as using ‘light’ or ‘dark’ mode toggle.

In essence, it would be wonderful if *computed- and measure worked as syntactic sugar for:

function getCurrentPropertyValue(element, property) {
    const styles = window.getComputedStyle(element);
    const property = styles.getPropertyValue(property);
    return property;
}

That way, we’d be able to do things like:

set my *color to contrastColor( my *computed-background-color)
measure my font-size then put it into the next .size-display
Dominant language
JavaScript
Stars
3.8k
Forks
171
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bigskysoftware/_hyperscript

All issues in bigskysoftware/_hyperscript

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.