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

Add computedTemplate function #20

Open
aleclarson opened this issue Aug 29, 2023 · 0 comments
Open

Add computedTemplate function #20

aleclarson opened this issue Aug 29, 2023 · 0 comments
Labels
enhancement New feature or request feature: observable Related to the observable engine

Comments

@aleclarson
Copy link
Contributor

import { computedTemplate, ReadonlyRef } from 'alien-dom'

type ColorComponent = string | number | ReadonlyRef<string | number>

function computedRGBA(red: ColorComponent, green: ColorComponent, blue: ColorComponent, alpha: ColorComponent) {
  return computedTemplate`
    rgba(${red}, ${green}, ${blue}, ${alpha})
  `
}
  • The leading/trailing whitespace is removed.
  • Slots can be refs or primitive values (or a function that returns either).
  • Essentially shorthand for:
     computed(() => `rgba(${red}, ${green}, ${blue}, ${alpha})`)
@aleclarson aleclarson added enhancement New feature or request feature: observable Related to the observable engine labels Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature: observable Related to the observable engine
Projects
None yet
Development

No branches or pull requests

1 participant