-
Notifications
You must be signed in to change notification settings - Fork 0
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
Onboarding people #1
Comments
I am interested (okay - you might have guess that - just for demo purpose ;) ). |
I'm interested in following the discussions but i've got a LOT of word to do on React Native right now, so don't expect much from my end :) |
Hey y'all, very interested in contributing. I work on Radium (https://github.com/FormidableLabs/radium). |
I'm not really involved in the CSS aspect of React in any way, but I do have one comment: I think the name "VirtualCSS" is somewhat confusing honestly. Comparing it to the virtual DOM approach is somewhat misleading because the virtual DOM is tightly tied to the idea of optimizing performance by diffing and only touching the DOM when possible. "VirtualCSS" makes me expect a similar technique, but maybe that's just me. I had not heard of JSS before but it seems like that might a better place to have a bunch of discussion because they already have a working tool that people use in production: https://github.com/jsstyles/react-jss |
@jlongster, you made good points there - thanks for them!
Without getting a too long naming debate started, I think VirtualCSS might be right as it is also about performance and optimising the style definitions. But I agree a different name might make more sense and I am happy for suggestions :)
From my first look at JSS I get the feeling it fits better as a possible frontend that uses a VirtualCSS implementation for the low-level parts (CSS optimisation, mounting, ...) and a good idea is to see what APIs needs to be supported by a core library to get JSS supported. Maybe let's wait before making such a move until I have made up my mind and wrote the promised reply to @gaearon about the differences between jss and my outlined idea in the blog post. |
@jviereck Sounds great, absolutely don't take my words too seriously. Often the initial connotations with a new name wears off pretty quickly, so if others like it, I think it's fine. I look forward to seeing what you flesh this out into. |
I'm interested. @jlongster that's a fair point about the VDOM and performance. I think of the 'virtual' aspect though as being more about decoupling the way you write your app from the environment it will run in - with performance being one of the benefits. The React README was recently changed to emphasize the abstraction over the diffing, but I'd guess that most people still think of it as being primarily about performance. Off the top of my head, some of the different aspects to think about are:
Other major concerns that I haven't listed above? |
So React Style started last year, before all the CSS-in-JS madness really took off - there have already been a ton of discussions, and I've tried really hard to push everything into the right direction. Obviously, I'm very happy with the current direction and where it's going:
Issues we do have:
I think we nailed it pretty good, but yes I might have some bias ;-). So I'm totally up for discussions and exchange of ideas! Hope to steal some good ideas - and hope you guys do the same. |
I like this idea a lot. It should solve a lot of issues most developers have with global CSS. I'm definitely on board, as the project's goals coincide with some things I'm working on. Components with compartmentalization is the future of the web, so it only makes sense that their styles are confined just the same and without any real performance hit. Any actual code written for this yet? I have a few ideas that should allow changes to be made as usual via browsers' native CSS tools while updating the respective JSX, although a separate file would probably be less hacky. |
@SanderSpies - Adding support for the 'styles' attribute so that clients the styling can switch between or mix inline CSS and classes is useful but currently requires monkey-patching React.createElement(). Can you see a way to avoid this? |
cc @kof |
/cc @ianobermiller |
I've been experimenting with styling react components for a while now, and the current state of that is reflected in Cesium (see Button example usage), the core ideas of which I'm working on incorporating into Radium. I'm not sure I buy all of your premises, I'd love if you could expand on (or defend) these:
Finally, and @robertknight has already brought this up, I think the two most difficult issues to solve when using classes are:
React Style handles this by creating these giant selectors, like I've personally given up generating classes and actual CSS, and have instead turned my focus to emulating all the nice things we then forgo, like states (:hover, :focus, :active), media queries (which I've always found to be painful in CSS, but that's just my opinion), animations (Cesium actually uses an injected stylesheet for these, which I don't mind so much). This way, you solve the overriding/specificity issues once and for all, and always have the full power of JavaScript at your disposal (no difference between "static" and "dynamic" styles, for example). -- Thanks for the mention, @alexlande! |
Nice idea. I'm interested. |
Pure inline styles would be great, but not everyone is a fan of that. I'm also not convinced it's the right solution at the moment. I don't think that merging style objects every render, especially when animating, is desirable. CSS classes are ideal for immutable styles, inline styles are great for mutable styles. Doing as little as possible during render is important. React Style also has some work to do here, pseudo classes branch has already improved a bit on this. We could probably do better though. |
I think we need to support preprocessers. People have a need to reduce or change syntax or add features like autoprefix or use features from upcoming css spec via 4to3 cssnext. |
Aside from @SanderSpies comments about making render() as cheap as possible, I can also see other problems with emulating pseudo-selectors, media queries etc. in JS. For example, a recent talk at London React described the way that for the Tesco mobile shopping side, they render the site isomorphically and turn off JavaScript for old devices. CSS media queries could still work in such an environment, roll-your-own implementations in JS won't. Additionally, the logic for implementing some pseudo-selectors is not as trivial as some people think and attempts to do the same with event listeners are likely to omit at least some of the native behaviors. I suspect it would be like the CSS equivalent of using hashbangs for URLs that lots of sites tried a few years ago. |
I've been both excited and disappointed by the react's inline style approach. I'd love to be involved with this. |
I'm very interested! I'm a designer & developer, been working with React for nearly a year and have recently been very involved in researching and using as many CSS in JS options and I can find. |
Hi there, thanks a lot for all the great responses and the time you put into writing them. I don't know exactly what's the best way to write a proper response (especially as I am getting a bit sick at the moment) - let’s hope the response is helpful to move the brainstorming further. In this response I try to explain why I want a system to be able to create a CSS file at the end and outline that to achieve this the way styles can be defined in an JS-To-CSS must be restricted. I give an outline what these restrictions could look like and I would love to hear back from you what you think about it. It might be important to note that my experience with building web apps is biased towards large scale apps. In such environments you have different constraints compared to when building a smaller website for a client. For instance, using only inline styles like in Because there is already a lot of CSS tooling I would love to see a soultion that enables to reuse the tools as much as it makes sense. Also, if there is a way to support preprocessors like SASS in any way, this is something I find worth considering given the big community and knowledge around these tools. For now I will use JS in my examples to declare the styles but I don't think this is a real limiting factor as converting a CSS-definition-string to the equivalent JS-object is doable. As of the feature set I think VirtualCSS should allow developers to write any kind of CSS as long as the CSS does not use cascading selectors or element selectors (like To generate CSS from JS style definitions, the requirement is to scan the JS code and be able to determine all the style definitions and usages statically (at build time) without actually running the JS code. (This was not so much clear to me before @robertknight asked me about it). At first it seems this cannot be done by any of the existing CSS-In-JS libraries. For instance (using the var StyleSheet = require('react-style');
var res = (function() {
var i = math.random() * 100;
while (i— > 0) {
var ButtonStyles = StyleSheet.create({
primary: {
backgroundColor: 'rgb(0, 120, ' + i + ')',
color: '#fff'
}
});
}
return ButtonStyles;
})();
module.exports = ButtonStyles; makes it impossible to figure out the style definitions statically. But this looks like a completely made up case (on purpose :P ) and I expect most style definitions to look more along the lines of this: var StyleSheet = require('react-style');
var ButtonStyles = StyleSheet.create({
basic: {
backgroundColor: 'rgb(0, 120, 120)',
color: '#fff'
}
}
module.exports = ButtonStyles; That is the definition of a style happens at the top level of the module and there are no variables involved in the object passed to var StyleSheet = require('react-style');
var ButtonStyles = require('button-styles');
// Create a new set of styles that inherit from the previous ButtonStyles.
var FancyButtonStyles = StyleSheet.cascade(ButtonStyles, {
basic: {
fontWeight: 'bold'
},
'basic:hover': {
fontSize: '20px'
}
});
class FancyButton extends React.Component {
render() {
var colorStyle = this.props.colorStyle;
return <div className={FancyButtonStyles.basic} style={colorStyle}>
Lore Ipsum
</div>
}
} This should also be possible to be analyised statically as well. Note that where the first idea with VirtualCSS was to be able to combine statically and dynamic changing styles this solution opts for a simpler setup: If the developer want to use dynamic changing styles, they have to do this by specifing inline styles themselfs. That doesn't look like a too bad limitation to me. The restriction to disallow any values on the object passed to // ---
// In file: 'css-utils.js'
var createSimpleButton = function(baseColor) {
return {
backgroundColor: 'rgb(0, 120, 120)',
color: baseColor
};
}
module.exports = { createSimpleButton: createSimpleButton};
// ---
// In file 'button-styles.js'
var StyleSheet = require('react-style');
var cssUtils = rquire('css-utils');
var ButtonStyles = StyleSheet.create({
basic: cssUtils.createSimpleButton('#fff');
}
module.exports = ButtonStyles; This becomes a bit more complicated to analyse statically and involves running the As you can see, there are certain restrictions on how to define the style sheets and what to use as their arguments. The build system generating the CSS files (aka VirtualCSS) has to check if the developer plays by the restricted rules and if there is a violation raise an error to the user. Although I use So the question to ask might be this: Do you think to build such a tool, that checks if the developer follows certain restrictions and if they do get the ability to generate an optimised CSS output is a good idea or do you think this is not useful in reality? Please let me know what you think. Also not, that I emphasized in what I am interested in building. That doesn't mean there are other options and if you have different opinions, feel free to express them - I am more than happy to reconsider my decision making :) |
Have only started reading, but wanted to say one thing:
Supporting no-js + server-side rendering completely with Radium is 100% a goal/very important to me, and for that case something like VirtualCSS seems like the correct solution (to cover media queries, animations, and browser state pseudo-selectors like Have discussed that a little bit here: FormidableLabs/radium#53 I don't expect Radium to start using a |
@jviereck Regarding the optimization of the CSS file for size, it might be worth it (in advance, for testing) to put together something that generates large semi-random CSS files, both optimized versions and unoptimized versions, and then compare the size after GZIP compression. It may not even be necessary (or worth the time and effort) to add a bunch of complex optimization logic if GZIP is able to reduce it to a comparable size. |
@timbur good thought, glad you bring it up!!! Are you interested in doing such an experiment and report back you findings? For the architecture of VirtualCSS is made up of three more-or-less independent parts anyway:
For a first version the step 2) can definitely be left out first and then later depending out the research finding added later if it makes sense. |
@alexlande, thanks a lot for the clarification. I was under the impression that Radium sees JS as the solution to support media queries and pseudo classes. The Issue you link looks very interesting and from what I've read goes into the same direction as what proposed above. |
Also, @jviereck everything you mentioned in your last (long) comment is spot on. :) Although, maybe I misunderstood what you were saying, but I'm not sure how I feel about the practicality of trying to analyze JS to extract the CSS. I'm also not sure when I might have time to try out the optimization comparisons. I will most likely be contributing soon in some other form, however. |
What about the idea to use template strings with a annotation about what css dialect is used. var x = `@css4
html: {
color: #aaa;
}
`; var y = `@stylus
html
color #aaa
`; It should be possible to find such code in AST when Espree or similar libraries are used. |
Hi everybody, I am a maintainer of jss.
|
The major trade-offs I experienced was between,
And
@fibric 👍 Relay is using template strings for specifying GraphQL queries as seen here - https://facebook.github.io/react/blog/2015/03/19/building-the-facebook-news-feed-with-relay.html#whats-the-ltstorygt . So I guess, if we have something like this, class Component extends React.Component { /*...*/ }
Stylesheet.create(Component, {
styles: scss`
/* ... */
`
}); with tag specifying the css dialect, it could either be seen as an obstruction to using with Relay, or an advantage only. I'm not able to speculate about it. Also, as @robertknight mentioned, it might require monkey-patching React.createElement or an abstraction over the component definition which might lead to |
@boopathi - React Style styling is not connected to a component. Styles can be defined anywhere, but should preferably be done at the module level. |
On the other hand if there is a strong issue with writing css in json. There might be a less preprocessor which will parse from components (like in your example) and converts them to json syntax which can be then used by jss. |
@dmitry I am actually planning on using BEM style classes, although I didn't know that's what it's called! See my questions at https://github.com/js-next/react-style/issues/108#issuecomment-92885761. They're probably pretty newbie questions so maybe someone here can answer them for me. The main things I wanted to take from |
@timbur - we're going for the following syntax:
Most people seem to prefer this above other ways of defining pseudo classes. Note that by default we only will support a subset of pseudo classes - as we want to maintain optimal support for both inline styles and compile to CSS. Also moving to JS has an advantage - removing the extra layer of SASS or LESS. It's now just JavaScript which you are using already anyway. Adding SASS or LESS like syntax seems to me like going into the wrong direction. As for using certain functions of LESS, if you go here: https://github.com/less/less.js/tree/master/lib/less/functions there's a whole bunch of functions that you can extract and use with any CSS-in-JS solution today (might need some changes here and there though). |
I see, thanks! I should have taken a closer look at |
Actually upon another review, I didn't miss the |
@timbur for example:
will result in Btw: the |
Is there a consensus as to whether the direction is towards inline styles, compiling CSS, or a hybrid? |
@DUBERT Compiled CSS is the way to go for 99% of use cases, but a hybrid is necessary for maximum flexibility. @SanderSpies So when you have different states of |
@DUBERT I agree with @timbur. For the most cases compiled CSS will be enough, but to engage most people to Look one of the BEM implementation`s in react.js: https://github.com/albburtsev/bem-cn |
leaving you guys, not interested in yet another static css generation tool. |
@kof I don't think that's the goal. But I do think it's necessary for it to be possible (and easy). |
Yet I am against generating static css at all, as I tried to express already. |
@kof I am more in your camp, there. You will probably be interested in Radium, and my WIP pull request to simplify the syntax in particular. I think it is great that so many people in the community are interested in solving styles for React components, different approaches are certainly welcome! |
@kof Maybe @jviereck can clarify, but my understanding is that the goal here is to provide something that other libraries can use as a base, and it may not even be a tangible library itself, possibly somewhat of a pattern like Flux. "Compiled" doesn't mean "static" (at least not in this context). I checked out |
At this point I think it is good to summarize what I think the goals and non-goals of VirtualCSS should be. Please let me know if you disagree with any of the following points. Goals
Non-Goals
With this, yes, @kof and @ianobermiller I think the goals of VirtualCSS is not aligned with what you are looking for, which I can understand. As @ianobermiller wrote it:
I couldn't express my thinking better :) Personally I am very interested to follow along the development of
Engaging more people to VirtualCSS sounds great supporting both (inline styles and complied CSS) does not come for free. If someone wants to write code to support both, that's great. From my side I can only say I am very short on spare time at the moment and don't have the resources to move forward with supporting both. Also |
To the people that are interested to follow the project: Is there consensus on the goals and non-goals I mentioned above? If not please let me know, otherwise I assume this is what we move forward with and try to continue developing a first WIP in PR #4. Thanks for all your comments and questions so far - they really helped to shape the project - keep them coming :) |
I'd only modify point 2 to read:
I think it's important to be able to do this: display: -webkit-flex;
display: flex; Especially since the prefixed version is a requirement on iOS right now. |
Thanks @joeybaker for the comment. I have updated the README.md of the repo to include the goals and included your feedback there as well. Also, I've added a new point to the goals that is
Let me know if you have any thoughts about this. |
I want to add myself to the list. I'm the author of React Inline: https://github.com/martinandert/react-inline |
@jviereck I think that a build steps that removes the style declarations from the final javascript bundles is also needed. Since the styles would be "exported" as a static css file they won't be needed anymore at runtime but will add to the total "weight" of your app. |
Doing a small hacking evening, I managed to get a minimal runtime system in PR #4 up and running that generates valid output for the inline style definitions - that is, if you run the webpack server you will get the same styling/visual output as the one in Let me know if you have any feedback or questions. @nickdima, about your question, yes. |
Many people dislike the name "VirtualCSS' and therefore I've just opened issued #5 to brainstorm a better name. Any suggestions are highly welcome :) |
I'd also like to add myself to the list. I'm a CS student focusing on front-end and design. |
I read your medium post and it was fascinating. This is an issue I've been tinkering with for a long time and I'd love to get involved in this project. I'm working for a company that is looking into some way to allow styles to be defined within the components to which they apply and, so far, your proposal is the most attractive solution I've seen. If you'd like some help, please let me know (feel free to contact me via email: evanmicahstern@gmail.com). |
Since I started this projected many other "CSS in JS" solutions have emerged. Also, my personal interests have shifted. Therefore, I decided to mark this project/VirtualCss as "No Maintenance Intended" per commit 7bd5c27. Thanks to all the comments on this project and the energy people put into it. Feel free to ping me in case you have any further questions. Best regards, Julian |
Use this issue to express your interest to this project. I am than happy to give admin rights to anyone that wants to help out with this idea.
The text was updated successfully, but these errors were encountered: