9
I see a focus on javascript frameworks, to write the css directly in javascript, example...
new Vue({
el : "#style",
data : {
ctn : {
display: "flex",
alignItems: "center",
justifyContent: "center",
flexDirection: "column",
height: "100vh",
},
header : {
fontSize: "20pt",
color: "blue",
},
article : {
fontSize: "13pt",
color: "green",
}
}
})
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<div id="style" :style="ctn">
<header :style="header">Hello world!</header>
<article :style="article">StackOverflow</article>
</div>
This facilitates a lot because it allows the use of variables and functions, but for an extensive project, this practice would imply some problem?
Edit
I recently found this article Peace in css (Medium)
And I realized that this debate is happening vehemently on the internet (As always Brazil is not very familiar).
It depends on your definition of a problem. If you’re going to win the same thing regardless of the maintenance effort, that’s a big problem. But if you earn by hour or by line of code, that’s guaranteed stability for a while. The work you will have to maintain your website’s visual design will only increase more and more.
– Oralista de Sistemas
I’ve never seen any official documentation of Vue recommending this. Even they have a solution to "approximate" the CSS of the JS code, leaving the two in the same file: the single file Components.
– bfavaretto
also never seen, I referred to a focus that I realized, so much so that there are several libs today for this type of technique http://cssinjs.org/? v=V9.0.0
– sannyas