-
Notifications
You must be signed in to change notification settings - Fork 10
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
The future of Fix #3
Comments
Thanks for the kind words :) This project is in an interesting place... The crowds seem to love it in it's current form more than I do, and seem to be using it in a different way than I intend. What the people wantPeople want an alternative to reset or normalize that they can drop into their project as a stylesheet and build on top of. This is where I began. If we were to embrace this we would:
My visionI have come to the conclusion that all global styles are undesirable; each component should style itself from scratch. This has worked wonderfully for me on many projects for over a year now, and is not as audacious as it seems. My vision for the project moving forward is more of a CSS guide for each element. To achieve this, almost everything would be deleted but the readme, which would be structured with a heading and a bullet list of gotchas/code snippets for each element. This would be useful to every dev, whether they use stylesheets or CSS in JS. I have to triage my time, and to be real, I have neglected Fix because it no longer solves a problem I have. Enhancing it from this point is altruistic as all the gotchas and code snippets are burned in my brain and the project is not meant to be an installable dependency. I hesitate to do both options at once, build out the stylesheet and maintain an element CSS guide in the readme. In my experience mentoring developers is as much sharing what to do, as it is enforcing what not to do. |
While we're discussing vision and usage, I might as well mention that I've created my own reset/normalize thing called Vitals which is partially taken from Fix (among other sources). |
@jaydenseric Thanks :) |
Hi, @jaydenseric, i feel confuse about u respond above
and also this one
I want to ask: for such dev situation i just stated, And what the situation that u can neglect the Fix usage ? NOTE: i find out there is a discussion about using component with global css |
@LiTiang Font Awesome is not so awesome for a bunch of reasons. The best way to manage icons these days is with polyfilled SVG with external references. A component's icons live as symbols in a single .svg file within the component's folder: Example. The component styles the icons from scratch, no need for global anything. Sass is dead. Everyone needs to run their stylesheets through PostCSS to get Autoprefixer to work. you can configure PostCSS to do everything Sass can but in one parse, skipping the Sass compiler. Features such as variables now have a spec and are available natively in browsers. Until browser support is universal, start getting used to the new syntax and use CSSNext. This is in line with the Babel JS transpilation approach, as language features start to work natively you can start to run source code directly in browsers without refactoring. In my experience creating tangled relationships between components by attempting to centralize config or mixins is not necessary. Each component can have its own variables; avoid sharing. A common example of what not to do is creating variables such as Take a look at this site I built, the entire stylesheet is 5kb down the wire. You can see the source CSS with variables and all for each component by inspecting the styles in Chrome and clicking the little links that look like Edit May 2017: The link above now redirects to a new website, my example has gone to code heaven. |
@jaydenseric very informative, thank you. I didn't know Sass was on the way out. |
@jaydenseric, awesome info ! So u mean that u will not use such $darkBlue variable in a component file ? And u dont use fix.css right now ? |
@jaydenseric
I also confuse as @LiTiang that how can u neglect Fix in your project ? |
Before
After
|
ok, @jaydenseric, i think i understand about what u said . . . u JUST DONT USE Fix when u dev with components such pattern although component is just nothing, e.g.In Vue, In Angular, so i still dont know if u dont use such global css, so confuse for me . . . |
The future is not CSS-in-JS. Is just a temporary non-standard trick made by javascript developers (not css developers). The future is the standard shadow dom with native incapsulated CSS. Now supported by all webkit browsers and chrome-blink. The future is CSS custom-properties, style-hooks and CSS native mixins. The future is made by standards, not libraries. Libraries like babel, polymer etc, just allow us to use futuristic features right now. A part of this, i'm with you @jaydenseric. @LiTiang If you need to fix a component, just put the fix, and only the fix he needs, inside his scoped code. You don't need a global fix that fix a component that may not exist in the page. The component fix itself when exist. |
@equinusocio Some good CSS-in-JS solutions use vanilla CSS and JS; perfectly valid and in line with web standards. Foolproof web components with scoped CSS and SSR are a while off or may never arrive. Either way, global styles are dead. In both approaches styles apply to individual components. At this time, every developer should be a "JavaScript developer". Lots of standard web features like the canvas and history APIs can only be used via JS. To jump right into the new-school, checkout Next.js. It's very good. The bundled CSS-in-JS solution, styled-jsx, works a lot like the deprecated |
Web components are here. With Polymer 2, HyperHTML, vdom, etc..there is no difference, you can use WC right now with your favourite library and just polyfill some browser (youtube is built on Polymer and use style-hooks to customise components). But, yes, global CSS is now a thing to avoid in 2017. What i don't like of CSS-in-JS is that you don't write CSS at all. You write a pseudo css-like javascript object and you cut off a lot of CSS potentiality, like css custom properties, custom media queries (if you use postcss cssnext) and many other things. I just think that CSS is a great markup language if you know it and how to use it (think like scoped css, BEM, ECSS, SMACSS, ITCSS etc) and you should keep write CSS, not a js object. For that reason, i like css-modules that allow you to write real CSS, and i don't like to hear "CSS-in-JS" when you don't write CSS. Call it "style-in-js" maybe. I agree with you that now CSS should be inside his component whatever library you use. But i like standards, because now i can pick my postcss code and put it everywhere. You can't do the same with a CSS-like javascript object. |
Polymer apps can't be server side rendered (see #3955), React apps can. You could put CSS variable support in CSS in JS solutions, and maybe you already can, but there is no reason to. Since the CSS starts in JS, you can skip that whole process and just generate the styles you want from the start directly from JS variables. A large appeal of the CSS variables API is that it can be interacted with via JS. |
Ah sure, but as you said, you generate CSS from JS, you don't write CSS in JS. The point why generate CSS from JS if you can write directly a better and encapsulated css? By the way polymer is just a library that extends web components API by adding some "cool" helpers, Polymer != web components. You can use web components and shadow DOM with HyperHTML, viperHTML (for server rendering), SkateJS (that will support SSR), JSX or any virtual DOM library. PS: We are off topic? 😂 |
@equinusocio To avoid an essay response to those questions (which will probably lead to more), I think you might find this article helpful. With CSS in JS you are in fact writing CSS. Most of the current solutions don't use inline styles anymore like Radium did, they generate a stylesheet in the With |
@jaydenseric But why i see only stupid example like: const Title = styled.h1`
font-family: Comic Sans MS;
color: blue;
` and never something like: const Card = styled.div`
font-family: Comic Sans MS;
display: flex; /* <- This should be autoprefixed, but how? */
flex-flow: column nowrap;
user-select: none; /* <- This should be autoprefixed, but how? */
background: linear-gradient(
to right,
rgba(248,80,50,1) 0%,
rgba(241,111,92,1) 50%,
rgba(246,41,12,1) 51%,
rgba(240,47,23,1) 71%,
rgba(231,56,39,1) 100%);
` Where i should put a |
@equinusocio These questions are answered in the relevant project readmes. All the popular CSS in JS solutions automatically vendor prefix, so just write standard rules. const Banner = ({heading, text}) => (
<aside>
<h1>{heading}</h1>
<p>{text}</p>
<style jsx>{`
@keyframes enter {
0% {
opacity: 0;
transform: scale(0.95);
}
80% {
transform: scale(1.01);
}
}
aside {
animation: enter 0.25s;
}
h1 {
color: red;
}
p {
color: blue;
}
`}</style>
</aside>
) In my editor, the styles are nicely syntax highlighted. The |
This is a nice solution. Here i have a real and scoped CSS and i can accept that. This is the nicest solution. EDIT: With vscode-styled-jsx i cand o the trick. This is awesome, if i will work inside this context styled-jsx will be the key. |
@equinusocio I use Atom with language-babel, configuring |
You can also import css as external? Web components needs style and js in the same place of template. ATM we build the component by combining |
See vercel/styled-jsx#83. To save everyone's inbox, lets keep further conversation focused on the original issue. |
The future of fix.css? :) |
Hi Jayden,
I really like this approach, do you plan to update - improve the code for this year? For example: basic style for the form elements.
Thanks :)
The text was updated successfully, but these errors were encountered: