Skip to content

Add shorthand way of getting inline style or getComputedStyle property #134

Closed

Description

@bob2517

Need a handy way of referencing an inline style property. This has come up on a work project but there's a workaround so no major rush.

Possible syntax could be {:property}. Eg.

.myDiv:click {
    $rememberColor: "{:color}";    /* gets existing color and assigns to regular variable as a string */
    color: green;
}
.something:click {
    myDiv {
        color: {$rememberColor};
    }
}

Needs to work on any style. This is not the same solution as using CSS variables, which would work fine too.

This wouldn't be a variable type. Like the attribute {@...} syntax it can't be assigned to anything. It's just a way of getting values.

Activity

  1. self-assigned this
    on Mar 26, 2021
  2. bob2517 commented on Oct 3, 2022

    @bob2517
    MemberAuthor

    Probably worth doing a getComputedStyle variant for this too.

    Maybe {::color} for that, which would follow the attribute @, property @@ convention. Basically doubling up the colon for the calculated value.

  3. bob2517 commented on Mar 10, 2024

    @bob2517
    MemberAuthor

    Note to self: getComputedStyle returns a live CSSStyleDeclaration object, which could be remembered during an event flow to avoid doing it more than once for an element. Would just need to clean it up at the end of each event flow for the sake of SPA memory if that method is employed.

  4. added this to the 2.16.0 milestone on Mar 10, 2024
  5. changed the title [-]Add way of getting style property[/-] [+]Add shorthand way of getting defined style or getComputedStyle property[/+] on Mar 10, 2024
  6. changed the title [-]Add shorthand way of getting defined style or getComputedStyle property[/-] [+]Add shorthand way of getting inline style or getComputedStyle property[/+] on Apr 14, 2024
  7. added
    done on branchThis issue has been committed to the latest branch, and will get merged with the next release
    docs to doDocumentation still needs doing before this can get released
    and removed
    in progressThis issue is currently being worked on
    on Apr 14, 2024
  8. bob2517 commented on Apr 14, 2024

    @bob2517
    MemberAuthor

    Closing pending release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

docs to doDocumentation still needs doing before this can get releaseddone on branchThis issue has been committed to the latest branch, and will get merged with the next release

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions