Upgrade to Pro — share decks privately, control downloads, hide ads and more …

I'm over CSS: Function Atomic CSS for the Masses

I'm over CSS: Function Atomic CSS for the Masses

Simplify your build process and increase portability by incorporating a CSS-in-JS solution. Take it further and apply functional concepts to your styles, eliminating the need to ever write CSS again.

Vince Speelman

August 30, 2017
Tweet

More Decks by Vince Speelman

Other Decks in Technology

Transcript

  1. 3 I’M OVER CSS. THERE’S NO SUCH THING AS CSS

    ARCHITECTURE™. CLASSNAMES HOLD NO SEMANTIC VALUE. aka aka
  2. 4 I’M OVER CSS. THERE’S NO SUCH THING AS CSS

    ARCHITECTURE™. CLASSNAMES HOLD NO SEMANTIC VALUE. YOU HAVE BEEN WAY OVERTHINKING IT THIS WHOLE TIME. aka aka aka
  3. 5

  4. 6

  5. 6

  6. 8

  7. 9

  8. 11 HOUSEKEEPING typeof(thisFont) === ‘code’ Feel free to ask questions

    as they come up, but I will have time for questions at the end.
  9. 14 1. styling properties (<button color="red">) 2. styling tag names

    (button) 3. “semantic” class names (.primary-button) I’M OVER CSS.
  10. 15 1. styling properties (<button color="red">) 2. styling tag names

    (button) 3. “semantic” class names (.primary-button) 4. BEM (.button--primary) I’M OVER CSS.
  11. 21 idempotent: unchanged in value following multiplication by itself; THIS

    IS WHY PEOPLE DON’T LEARN FUNCTIONAL PROGRAMMING.
  12. 22 idempotent: unchanged in value following multiplication by itself. idempotent:

    the same input will result in the same output every time. THIS IS WHY PEOPLE DON’T LEARN FUNCTIONAL PROGRAMMING.
  13. 25 FUNCTIONAL ATOMIC CSS our end result will be css

    styles, no matter our approach.
  14. 32 type TweetComponent = { author: string, authorHandle: string, avatar:

    string, date: string, tweet: string, meta?: { banner?: string, caption: string, url: string, }, replies: number, retweets: number, likes: number, };
  15. 33 const Tweet = ({ author, authorHandle, avatar, date, tweet,

    meta: { banner, caption, url, }, replies = 0, retweets = 0, likes = 0, }: TweetComponent) => ( <div> {author} {authorHandle} {avatar} {date} {tweet} {banner} {caption} {url} {replies} {retweets} {likes} </div> );
  16. 34 import Shed from 'react-shed'; const Tweet = ({ …

    }: TweetComponent) => ( <Shed component="div"> {author} {authorHandle} {avatar} {date} {tweet} {banner} {caption} {url} {replies} {retweets} {likes} </Shed> );
  17. 35 import Shed from 'react-shed'; const Tweet = ({ …

    }: TweetComponent) => ( <div.shed> {author} {authorHandle} {avatar} {date} {tweet} {banner} {caption} {url} {replies} {retweets} {likes} </div.shed> );
  18. 42 <div.shed br="1/2" // border-radius: 50%; w="8" // width: scale(8);

    h="8" // height: scale(8); o="h" > <img.shed … /> </div.shed>
  19. 43 scale(8)? scale(8): 11.302rem scale(7): 7.993rem scale(6): 5.653rem scale(5): 3.998rem

    scale(4): 2.827rem scale(3): 1.999rem scale(2): 1.414rem scale(1): 1rem scale(0): 0 scale(.1): 0.707rem scale(.2): 0.5rem scale(.3): 0.354rem
  20. 44 <div.shed br="1/2" // border-radius: 50%; w="8" // width: scale(8);

    h="8" // height: scale(8); o="h" // overflow: hidden; > <img.shed … /> </div.shed>
  21. 48 EMOTION. “emotion minimizes the runtime cost of css-in-js dramatically

    by parsing your styles with PostCSS during compilation instead of at runtime.”
  22. 49 COOL. I DON’T REALLY CARE THAT MUCH, BUT SHOW

    ME THE OUTPUT WHILE YOU’RE TALKING ABOUT IT.
  23. 53 EMOTION DOES ALL OF THE ANNOYING WORK FOR US

    – PRECOMPILING, CONDENSING, PSEUDO-SELECTORS, MEDIA QUERIES, OPTIMIZATION, ETC. IT’S MY FAVORITE CSS-IN-JS SOLUTION OUT THERE.