Comments (4)
define:vars
is weird. It only works on the html element the compiler notices on the file. In a page with only components and no html tags, it has no effect at all.
I want to see it deprecated altogether. Maybe we can offer a function as a replacement.
-<div>
+<div style={defineVars({ color })}>
1111
<button type="button">button</button>
</div>
-<style define:vars={{ color }}>
+<style>
button {
color: var(--color)
}
</style>
from roadmap.
I'm all for it!
from roadmap.
I would also like to draw attention to the behavior when you actually set define:vars
along with the is:inline
directive on a style tag.
<style is:inline define:vars={{ cssVar: 'example' }}>...</style>
Compiles to:
<style>--cssVar: 'example';...</style>
This way, you can't use the variable as it was inlined as-is right into the style tag. All you need would be if it either:
- added
:root {}
wrapper around the variables - or offered some way/option that lets you define your own element/wrapper
The first option would be perfect for use in <head>
with inline styles, for example, when you want to set something immediately that you also preload. You can achieve this another (better) way, though.
Although, I don't see a use case for it outside of the <head>
. Just wanted to point out another "questionable" behavior while I was trying to pass a variable used in head and found this open issue among the many closed ones.
I want to see it deprecated altogether. Maybe we can offer a function as a replacement.
In the case of deprecating it, how would the function work for the <script>
tag?
from roadmap.
In the case of deprecating it, how would the function work for the <script> tag?
<script define:vars>
already has a replacement lined up
from roadmap.
Related Issues (20)
- CSS Inlining HOT 4
- Assets: Request for Stricter `getImage()` Attributes HOT 1
- Unable to pass variable from the configuration (integration) to (static file) endpoint HOT 7
- Allow framework components to stream responses or run in parallel HOT 6
- Add a stylesheet feature to the sitemap integration
- Production Dependencies HOT 6
- Support for partials HOT 26
- Incremental Builds HOT 7
- Built-in SVG components HOT 3
- First-party support for a Picture component HOT 9
- i18n routing HOT 19
- Integration hooks for middleware HOT 4
- Support prefetch in core HOT 1
- CSRF Protection #471 HOT 1
- env variables aren't populated even though process.env exists HOT 12
- Improved env handling HOT 59
- Images are not collected in Markdown files when using HTML syntax HOT 1
- Rerouting HOT 1
- Actions HOT 25
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roadmap.