Slide 1

Slide 1 text

Styling React components

Slide 2

Slide 2 text

@siddharthkp

Slide 3

Slide 3 text

@siddharthkp javascript and interfaces

Slide 4

Slide 4 text

CSS syntax

Slide 5

Slide 5 text

React component

Slide 6

Slide 6 text

What if?

Slide 7

Slide 7 text

History lesson

Slide 8

Slide 8 text

1990

Slide 9

Slide 9 text

1996

Slide 10

Slide 10 text

1996 Language for writing styles

Slide 11

Slide 11 text

2003 Separation of content and styles in DOM

Slide 12

Slide 12 text

2005 Semantic HTML

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

2005 Semantic HTML

Slide 15

Slide 15 text

2005 Semantic HTML

Slide 16

Slide 16 text

2005 Semantic HTML

Slide 17

Slide 17 text

2005 Semantic HTML

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

2007

Slide 20

Slide 20 text

2007

Slide 21

Slide 21 text

2007 Isolation

Slide 22

Slide 22 text

2009 OOCSS

Slide 23

Slide 23 text

2009 Lego driven development - Nicole Sullivan

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

2009

Slide 26

Slide 26 text

20099 Components

Slide 27

Slide 27 text

20099 Components

Slide 28

Slide 28 text

There are only two hard things in Computer Science: cache invalidation and naming things. - Phil Karlton

Slide 29

Slide 29 text

2010 - 2013 bem smacss suitcss rscss atomic design

Slide 30

Slide 30 text

2010 - 2013 Component state

Slide 31

Slide 31 text

button button--active list 2010 - 2013 Components of components

Slide 32

Slide 32 text

2010 - 2013 Components of components button button--active list dropdown

Slide 33

Slide 33 text

2010 - 2013

Slide 34

Slide 34 text

2010 - 2013 Co-location

Slide 35

Slide 35 text

2013

Slide 36

Slide 36 text

2005 Semantic HTML

Slide 37

Slide 37 text

2013 React components

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

Learnings from 1996 - 2013 Language for writing styles - CSS Separation of content and styles in DOM Semantic HTML = Good names for elements Isolation Components Co-location

Slide 40

Slide 40 text

1. The React documentation way

Slide 41

Slide 41 text

1. The React documentation way - Inline Styles

Slide 42

Slide 42 text

Language for writing styles - CSS Separation of content and styles Semantic HTML = Good names for elements Isolation Components Co-location No :hover :focus! 1. The React documentation way - Inline Styles

Slide 43

Slide 43 text

1. The React documentation way - Inline Styles

Slide 44

Slide 44 text

1. The React documentation way - Inline Styles Language for writing styles - CSS Separation of content and styles Semantic HTML = Good names for elements Isolation Components Co-location Advanced logic

Slide 45

Slide 45 text

Content (HTML), styling (CSS) and interactions (JS) in one file. If you’re using React, you have access to a more powerful construct than CSS class names, you have components - Micheal Chan, @chantastic What’s so great about co-location anyways?

Slide 46

Slide 46 text

Content (HTML), styling (CSS) and interactions (JS) in one file. - Convenience - Independent entity - Include a component and everything just works™ - Share + reuse components across pages and applications What’s so great about co-location anyways?

Slide 47

Slide 47 text

2. Radium - better inline styles

Slide 48

Slide 48 text

2. Radium - better inline styles ← ES7 decorator More info

Slide 49

Slide 49 text

Language for writing styles - CSS Separation of content and styles Isolation Co-location Advanced logic 2. Radium - better inline styles

Slide 50

Slide 50 text

3. Good old CSS

Slide 51

Slide 51 text

3. Good old CSS Language for writing styles - CSS Separation of content and styles Isolation Co-location Advanced logic

Slide 52

Slide 52 text

4. CSS Modules

Slide 53

Slide 53 text

4. CSS Modules

Slide 54

Slide 54 text

4. CSS Modules Language for writing styles - CSS Separation of content and styles Isolation Co-location Advanced logic

Slide 55

Slide 55 text

5. Aphrodite

Slide 56

Slide 56 text

5. Aphrodite Language for writing styles - CSS Separation of content and styles Isolation Co-location Advanced logic Uses !important

Slide 57

Slide 57 text

6. Glamor

Slide 58

Slide 58 text

6. Glamor ← ES6 spread operator More info

Slide 59

Slide 59 text

6. Glamor Language for writing styles - CSS (beta) Separation of content and styles Isolation Co-location Advanced logic

Slide 60

Slide 60 text

7. styled-components

Slide 61

Slide 61 text

7. styled-components ← ES6 template tagged literals More info

Slide 62

Slide 62 text

Language for writing styles - CSS Separation of content and styles Isolation Co-location Advanced logic Enforces container/presentation pattern 7. styled-components

Slide 63

Slide 63 text

7. styled-components

Slide 64

Slide 64 text

Real CSS Conventions over configuration (styled-components, zeit/next) Simple API - css constructor - attaches styles to highest element in render() Future/Feature request

Slide 65

Slide 65 text

Future/Feature request

Slide 66

Slide 66 text

Update: I created css-constructor to make this possible :) github.com/siddharthkp/css-constructor Future/Feature request

Slide 67

Slide 67 text

Inspired by talks from @rstacruz and @mxstbr Huge props to them!

Slide 68

Slide 68 text

Thanks! @siddharthkp