Slide 1

Slide 1 text

We need a better UI component library Anna Su STYLED SYSTEM

Slide 2

Slide 2 text

Anna Su Front-end engineer

Slide 3

Slide 3 text

的時代 元件化

Slide 4

Slide 4 text

@LEGO

Slide 5

Slide 5 text

可能 重複做 同樣的功能的元件 不同的專案裡

Slide 6

Slide 6 text

同樣的元件 只有 樣式做 調整

Slide 7

Slide 7 text

Button Default Primary Disabled Link button Default Primary Disabled Link button

Slide 8

Slide 8 text

Checkbox Option 1 Option 2 Option 3 Option 1 Option 2 Option 3

Slide 9

Slide 9 text

Your Title Here This is the content area... OK Cancel Your Title Here This is the content area... OK Cancel Modal

Slide 10

Slide 10 text

Carousel

Slide 11

Slide 11 text

⼤大部分元件的⾏行行為是 ⼀一致的

Slide 12

Slide 12 text

所以 有沒有 開發更更快速的⽅方法?

Slide 13

Slide 13 text

2011 Bootstrap 2017 Pure CSS Material UI 2018 Ant Design 2016 Blueprint Semantic UI 2014

Slide 14

Slide 14 text

使⽤用 UI Library 的優缺點

Slide 15

Slide 15 text

Bootstrap Ant Design

Slide 16

Slide 16 text

Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content.

Slide 17

Slide 17 text

Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Desktop Mobile

Slide 18

Slide 18 text

Bootstrap

Slide 19

Slide 19 text

Card title!

Some quick example text to build on the card title and make up the bulk of the card's content. !

!
!
!
… !
… !
!
!
Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content.

Slide 20

Slide 20 text

Card title!

Some quick example text to build on the card title and make up the bulk of the card's content. !

!
!
!
… !
… !
!
!

Slide 21

Slide 21 text

.card-title { … color: rgba(0, 0, 0, 0.85); background-color: white; } .card-text { … color: rgba(0, 0, 0, 0.65); background-color: white; } @media screen and (max-width: 992px) { .card-title { color: white; background-color: rgba(0, 0, 0, 0.7); } .card-text { color: black; background-color: rgba(0, 0, 0, 0.2); } }

Slide 22

Slide 22 text

Ant Design

Slide 23

Slide 23 text

Some quick example text to build on the card title and make up the bulk of the card's conte nt. !

! ! … ! … ! ! Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content.

Slide 24

Slide 24 text

Some quick example text to build on the card title and make up the bulk of the card's conte nt. !

! ! … ! … ! !

Slide 25

Slide 25 text

找到對應的 class 名稱,再覆蓋樣式 但如果需要變更更樣式

Slide 26

Slide 26 text

@media screen and (max-width: 768px) { .ant-card { border: none; } .ant-card-head { background-color: rgba(0, 0, 0, 0.7); color: white; } .ant-card-body { background-color: rgba(0, 0, 0, 0.2); color: black; } }

Slide 27

Slide 27 text

@media screen and (max-width: 768px) { .ant-card { border: none; } .ant-card-head { background-color: rgba(0, 0, 0, 0.7); color: white; } .ant-card-body { background-color: rgba(0, 0, 0, 0.2); color: black; } }

Slide 28

Slide 28 text

使⽤用 UI Library 的優缺點 可以快速完成功能,但是改樣式比較複雜 可以直覺修改 HTML 結構或者 CSS 樣式,但是無法快速完成功能

Slide 29

Slide 29 text

別⼈人做好的元件可以 快速完成功能

Slide 30

Slide 30 text

如果元件需要 客製化樣式?

Slide 31

Slide 31 text

開發與維護 成本提⾼高

Slide 32

Slide 32 text

想要更更 彈性的修改樣式

Slide 33

Slide 33 text

客製化元件 選擇⾃自⾏行行開發

Slide 34

Slide 34 text

客製化元件遇到的問題

Slide 35

Slide 35 text

傳入 props 名稱 不⼀一致

Slide 36

Slide 36 text

Button2 Button1 Label2 Label1

Slide 37

Slide 37 text

Button2 Button1 Button1! const Button = styled.div` color: ${props !=> props.color}; background-color: ${props !=> props.backgroundColor}; border-radius: 10px; cursor: pointer; … `;

Slide 38

Slide 38 text

Label2 Label1 Label1! const Label = styled.div` color: ${props !=> props.fontColor}; border-color: ${props !=> props.borderColor}; border-radius: 10px; … `;

Slide 39

Slide 39 text

Label1! Button2 Button1 Label2 Label1 Button1!

Slide 40

Slide 40 text

!!...! !!...! Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. [email protected] 935-721-3322 Anna Su Front-End Developer

Slide 41

Slide 41 text

客製化樣式需傳入對應的 props 程式碼很 繁冗

Slide 42

Slide 42 text

Button B U T T O N Button

Slide 43

Slide 43 text

Button B U T T O N Button const StyledButton = styled.button` padding: ${(props) !=> props.padding}; margin-left: ${(props) !=> props.marginLeft}; width: ${(props) !=> props.width}; height: ${(props) !=> props.height}; font-size: ${(props) !=> props.fontSize}; font-family: ${(props) !=> props.fontFamily}; line-height: ${(props) !=> props.lineHeight}; border: ${(props) !=> props.border}; border-radius: ${(props) !=> props.borderRadius}; color: ${(props) !=> props.color}; background-color: ${(props) !=> props.backgroundColor}; cursor: pointer; … `;

Slide 44

Slide 44 text

Button B U T T O N Button const StyledButton = styled.button` padding: ${(props) !=> props.padding}; margin-left: ${(props) !=> props.marginLeft}; width: ${(props) !=> props.width}; height: ${(props) !=> props.height}; font-size: ${(props) !=> props.fontSize}; font-family: ${(props) !=> props.fontFamily}; line-height: ${(props) !=> props.lineHeight}; border: ${(props) !=> props.border}; border-radius: ${(props) !=> props.borderRadius}; color: ${(props) !=> props.color}; background-color: ${(props) !=> props.backgroundColor}; cursor: pointer; … `;

Slide 45

Slide 45 text

傳入 props 格式 不⼀一致

Slide 46

Slide 46 text

Error Success

Slide 47

Slide 47 text

Success! Error! Error Success

Slide 48

Slide 48 text

Success! Error! Success! Error Success

Slide 49

Slide 49 text

Button Button Button Default Small Large

Slide 50

Slide 50 text

Button Button Button Default Small Large Button! Button! Button! Button! Button! Button!

Slide 51

Slide 51 text

Button Button Button Default Small Large Button! Button! Button! Button! Button! Button!

Slide 52

Slide 52 text

不同狀狀態顯⽰示不同樣式時 程式碼需要 封裝

Slide 53

Slide 53 text

Danger Primary Default

Slide 54

Slide 54 text

const getTheme = obj !=> status !=> obj[status]; const buttonStyles = { default: { padding: '8px', color: 'white', backgroundColor: 'gray', … }, primary: { padding: '8px', color: 'white', backgroundColor: 'blue', … }, danger: { padding: '8px', color: 'black', backgroundColor: 'tomato', … }, }; const buttonTheme = getTheme(buttonStyles); Danger Primary Default

Slide 55

Slide 55 text

Danger Primary Default Button!; Button!; Button!;

Slide 56

Slide 56 text

Danger Primary Default Button!; Button!; Button!;

Slide 57

Slide 57 text

user payment order validation shop approval driver assignment

Slide 58

Slide 58 text

order validation! user payment! shop approval! driver assignment! user payment order validation shop approval driver assignment

Slide 59

Slide 59 text

order validation! user payment! shop approval! driver assignment! user payment order validation shop approval driver assignment Danger Primary Default Button!; Button!; Button!;

Slide 60

Slide 60 text

RWD 元件開發 複雜

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

const Article = styled.div` width: 100%; … @media (min-width: 567px) { width: 50%; … } @media (min-width: 768px) { width: 25%; … } `;

Slide 63

Slide 63 text

const Article = styled.div` width: 100%; … @media (min-width: 567px) { width: 50%; … } @media (min-width: 768px) { width: 25%; … } `;

Slide 64

Slide 64 text

Anna Su Front-End Developer [email protected] 935-721-3322 [email protected] 935-721-3322 Anna Su Front-End Developer

Slide 65

Slide 65 text

Anna Su Front-End Developer [email protected] 935-721-3322 [email protected] 935-721-3322 Anna Su Front-End Developer const Info = styled.div` display: flex; justify-content: flex-start; margin-bottom: 5px; font-size: 12px; … @media (max-width: 992px) { justify-content: space-between; margin-bottom: 13px; font-size: 14px; … } `;

Slide 66

Slide 66 text

Anna Su Front-End Developer [email protected] 935-721-3322 [email protected] 935-721-3322 Anna Su Front-End Developer const Info = styled.div` display: flex; justify-content: flex-start; margin-bottom: 5px; font-size: 12px; … @media (max-width: 992px) { justify-content: space-between; margin-bottom: 13px; font-size: 14px; … } `;

Slide 67

Slide 67 text

1. 傳入 props 命名不⼀一致 2. 客製化樣式需傳入對應的 props,程式碼很繁冗 3. 不同狀狀態顯⽰示不同樣式時,程式碼需要封裝 4. RWD 元件開發複雜 客製化元件遇到的問題

Slide 68

Slide 68 text

透過 Styled System 建立更更好的元件

Slide 69

Slide 69 text

⼤大幅降低 props 命名不⼀一致的問題

Slide 70

Slide 70 text

consistent styling API

Slide 71

Slide 71 text

Button2 Button1

Slide 72

Slide 72 text

import { color } from 'styled-system'; const Button = styled.div` ${color} … `; Button!

Slide 73

Slide 73 text

import { color } from 'styled-system'; const Button = styled.div` ${color} … `; Button!

Slide 74

Slide 74 text

Label1! Button2 Button1 Label2 Label1 Button1!

Slide 75

Slide 75 text

!!...! !!...! Card title Some quick example text to build on the card title and make up the bulk of the card’s content. Card title Some quick example text to build on the card title and make up the bulk of the card’s content. [email protected] 935-721-3322 Anna Su Front-End Developer

Slide 76

Slide 76 text

更更好的抽象化樣式,程式碼寫得更更少

Slide 77

Slide 77 text

Button B U T T O N Button

Slide 78

Slide 78 text

Button B U T T O N Button const StyledButton = styled.button` padding: ${(props) !=> props.padding}; margin-left: ${(props) !=> props.marginLeft}; width: ${(props) !=> props.width}; height: ${(props) !=> props.height}; font-size: ${(props) !=> props.fontSize}; font-family: ${(props) !=> props.fontFamily}; line-height: ${(props) !=> props.lineHeight}; border: ${(props) !=> props.border}; border-radius: ${(props) !=> props.borderRadius}; color: ${(props) !=> props.color}; background-color: ${(props) !=> props.backgroundColor}; cursor: pointer; … `;

Slide 79

Slide 79 text

Button B U T T O N Button const StyledButton = styled.button` ${space} ${layout} ${typography} ${border} ${color} cursor: pointer; `;

Slide 80

Slide 80 text

const StyledButton = styled.button` padding: ${(props) !=> props.padding}; margin-left: ${(props) !=> props.marginLeft}; width: ${(props) !=> props.width}; height: ${(props) !=> props.height}; font-size: ${(props) !=> props.fontSize}; font-family: ${(props) !=> props.fontFamily}; line-height: ${(props) !=> props.lineHeight}; border: ${(props) !=> props.border}; border-radius: ${(props) !=> props.borderRadius}; color: ${(props) !=> props.color}; background-color: ${(props) !=> props.backgroundColor}; cursor: pointer; … `; const StyledButton = styled.button` ${space} ${layout} ${typography} ${border} ${color} cursor: pointer; `;

Slide 81

Slide 81 text

import { space, layout, typography, border, color } from 'styled-system'; const StyledButton = styled.button` ${space} ${layout} ${typography} ${border} ${color} cursor: pointer; `;

Slide 82

Slide 82 text

根據不同狀狀態,更更彈性的修改對應樣式

Slide 83

Slide 83 text

Error Success

Slide 84

Slide 84 text

Success! Error Success

Slide 85

Slide 85 text

Danger Primary Default

Slide 86

Slide 86 text

Danger Primary Default import { variant } from 'styled-system' const Button = styled.div` ${variant({ variants: { default: { p: "8px", color: "white", backgroundColor: "gray" … }, primary: { p: "8px", color: "white", backgroundColor: "blue" }, danger: { p: "8px", color: "black", backgroundColor: "tomato" }, } })} `

Slide 87

Slide 87 text

Danger Primary Default Button! Button! Button! Button.defaultProps = { variant: 'default', }

Slide 88

Slide 88 text

const getTheme = obj !=> status !=> obj[status]; const buttonStyles = { default: { padding: '8px', color: 'white', backgroundColor: ‘gray', … }, primary: { padding: '8px', color: 'white', backgroundColor: ‘blue', … }, danger: { padding: '8px', color: 'black', backgroundColor: ‘tomato', … }, }; const buttonTheme = getTheme(buttonStyles); import { variant } from 'styled-system' const Button = styled.div` ${variant({ variants: { default: { p: "8px", color: "white", backgroundColor: "gray" … }, primary: { p: "8px", color: "white", backgroundColor: "blue" }, danger: { p: "8px", color: "black", backgroundColor: "tomato" }, } })} `

Slide 89

Slide 89 text

Button!; Button!; Button!; Button! Button! Button! Button.defaultProps = { variant: 'default', }

Slide 90

Slide 90 text

靈活的處理理 RWD 樣式

Slide 91

Slide 91 text

No content

Slide 92

Slide 92 text

const breakpoints = ['576px', '768px'];

Slide 93

Slide 93 text

const breakpoints = ['576px', '768px'];

Slide 94

Slide 94 text

const Article = styled.div` width: 25%; … @media (min-width: 567px) { width: 50%; … } @media (min-width: 768px) { width: 100%; … } `; const breakpoints = ['576px', '768px'];

Slide 95

Slide 95 text

Anna Su Front-End Developer [email protected] 935-721-3322 [email protected] 935-721-3322 Anna Su Front-End Developer

Slide 96

Slide 96 text

Anna Su Front-End Developer [email protected] 935-721-3322 [email protected] 935-721-3322 Anna Su Front-End Developer import { flexbox, space, typography } from 'styled-system'; const Info = styled.div` display: flex; ${flexbox} ${space} ${typography} `; !

Slide 97

Slide 97 text

透過 theme 快速變更更主題樣式

Slide 98

Slide 98 text

theme.js const theme = { breakpoints: ['992px'], space: [0, 4, 8, 16, 24, 32, 64], fontSizes: [12, 14, 16, 20, 24, 32], colors: { black: '#000', blacks: ['#ccc', '#999'] white: '#fff', primary: '#456000', }, button: { !!... }, breadcrumb: { !!... } … pagination: { !!... } }

Slide 99

Slide 99 text

import React from 'react'; import { ThemeProvider } from 'styled-components'; import theme from './theme'; const App = props !=> ( {!/* application elements !*/} ! ) export default App;

Slide 100

Slide 100 text

import React from 'react'; import { ThemeProvider } from 'styled-components'; import theme from './theme'; const App = props !=> ( {!/* application elements !*/} ! ) export default App; const theme = { breakpoints: ['992px'], space: [0, 4, 8, 16, 24, 32, 64], fontSizes: [12, 14, 16, 20, 24, 32], colors: { black: '#000', blacks: ['#ccc', '#999'] white: '#fff', primary: '#456000', }, button: { !!... }, breadcrumb: { !!... } … pagination: { !!... } }

Slide 101

Slide 101 text

Slide 102

Slide 102 text

const theme = { breakpoints: ['992px'], space: [0, 4, 8, 16, 24, 32, 64], fontSizes: [12, 14, 16, 20, 24, 32], colors: { black: '#000', blacks: ['#ccc', '#999'] white: '#fff', primary: '#456000', }, button: { !!... }, breadcrumb: { !!... } … pagination: { !!... } }

Slide 103

Slide 103 text

const theme = { breakpoints: ['992px'], space: [0, 4, 8, 16, 24, 32, 64], fontSizes: [12, 14, 16, 20, 24, 32], colors: { black: '#000', blacks: ['#ccc', '#999'] white: '#fff', primary: '#456000', }, button: { !!... }, breadcrumb: { !!... } … pagination: { !!... } }

Slide 104

Slide 104 text

const theme = { breakpoints: ['992px'], space: [0, 4, 8, 16, 24, 32, 64], fontSizes: [12, 14, 16, 20, 24, 32], colors: { black: '#000', blacks: ['#ccc', '#999'] white: '#fff', primary: '#456000', }, button: { !!... }, breadcrumb: { !!... } … pagination: { !!... } }

Slide 105

Slide 105 text

const theme = { breakpoints: ['992px'], space: [0, 4, 8, 16, 24, 32, 64], fontSizes: [12, 14, 16, 20, 24, 32], colors: { black: '#000', blacks: ['#ccc', '#999'] white: '#fff', primary: '#456000', }, button: { !!... }, breadcrumb: { !!... } … pagination: { !!... } }

Slide 106

Slide 106 text

const theme = { breakpoints: ['992px'], space: [0, 4, 8, 16, 24, 32, 64], fontSizes: [12, 14, 16, 20, 24, 32], colors: { black: '#000', blacks: ['#ccc', '#999'] white: '#fff', primary: '#456000', }, button: { !!... }, breadcrumb: { !!... } … pagination: { !!... } }

Slide 107

Slide 107 text

透過 theme 搭配 variant 快速修改不同狀狀態的樣式

Slide 108

Slide 108 text

Button B U T T O N Button Default Small Large Button Button Button Primary Default Danger Button Button Button Other button themes

Slide 109

Slide 109 text

const theme = { breakpoints: ['992px'], space: [0, 4, 8, 16, 24, 32, 64], fontSizes: [12, 14, 16, 20, 24, 32], colors: { !!... }, buttons: { default: { !!... }, primary: { color: "white", backgroundColor: "blue", … '&:hover': { !!... }, '&:active': { !!... }, '&:disabled': { !!... }, }, danger: { !!... }, size: { default: { !!... }, large: { height: 40, !!... }, small: { !!... }, }, }, … } Button Button Button Button Button Button

Slide 110

Slide 110 text

Button! const Button = styled.button` display: inline-flex; align-items: center; justify-content: center; cursor: pointer; !!... ${buttonStyle} ${buttonSizeStyle} `; const buttonStyle = variant({ key: 'buttons', }); const buttonSizeStyle = variant({ prop: 'size', key: 'buttons.size', }); Button Button Button Primary Default Danger

Slide 111

Slide 111 text

const buttonStyle = variant({ key: 'buttons', }); const theme = { breakpoints: ['992px'], space: [0, 4, 8, 16, 24, 32, 64], fontSizes: [12, 14, 16, 20, 24, 32], colors: { !!... }, buttons: { default: { !!... }, primary: { color: "white", backgroundColor: "blue", … '&:hover': { !!... }, '&:active': { !!... }, '&:disabled': { !!... }, }, danger: { !!... }, }, … } Button Button Button Primary Default Danger

Slide 112

Slide 112 text

Button! const Button = styled.button` display: inline-flex; align-items: center; justify-content: center; cursor: pointer; !!... ${buttonStyle} ${buttonSizeStyle} `; const buttonStyle = variant({ key: 'buttons', }); const buttonSizeStyle = variant({ prop: 'size', key: 'buttons.size', }); Button Button Button Default Small Large

Slide 113

Slide 113 text

Button Button Button Default Small Large const buttonSizeStyle = variant({ prop: 'size', key: 'buttons.size', }); const theme = { breakpoints: ['992px'], space: [0, 4, 8, 16, 24, 32, 64], fontSizes: [12, 14, 16, 20, 24, 32], colors: { !!... }, buttons: { … size: { default: { !!... }, large: { height: "40px", !!... }, small: { !!... }, }, }, … }

Slide 114

Slide 114 text

透過 theme 更更彈性的調整 RWD 樣式

Slide 115

Slide 115 text

No content

Slide 116

Slide 116 text

No content

Slide 117

Slide 117 text

const theme = { !!... card: { !!... wrapper: { vertical: { flexDirection: 'column', }, horizontal: { flexDirection: 'row', }, }, } }

Slide 118

Slide 118 text

const cardWrapperStyle = variantResponsive({ key: 'card.wrapper', }); const Card = styled.a` position: relative; display: flex; overflow: hidden; ${cardWrapperStyle} … `;

Slide 119

Slide 119 text

… !

Slide 120

Slide 120 text

透過 themeGet 拿到 theme 的值 統⼀一管理理共⽤用樣式

Slide 121

Slide 121 text

6 5 4 3 2 1 6 5 4 3 2 1 6 5 4 3 2 1 6 5 4 3 2 1

Slide 122

Slide 122 text

const theme = { breakpoints: ['992px'], space: [0, 4, 8, 16, 24, 32, 64], fontSizes: [12, 14, 16, 20, 24, 32], !!... pagination: { item: { fontSize: "14px", color: "blue", backgroundColor: "transparent", border: { top: 0, left: 0, right: 0, bottom: "2px", }, borderRadius: 0, !!... }, !!... } … }; 6 5 4 3 2 1 6 5 4 3 2 1 6 5 4 3 2 1 6 5 4 3 2 1

Slide 123

Slide 123 text

6 5 4 3 2 1 6 5 4 3 2 1 6 5 4 3 2 1 6 5 4 3 2 1 const PaginationItem = styled.li` display: inline-block; cursor: pointer; user-select: none; !!... font-size: ${themeGet('pagination.item.fontSize')}; color: ${themeGet('pagination.item.color')}; background-color: ${themeGet('pagination.item.backgroundColor')}; border-top: ${themeGet('pagination.item.border.top')}; border-right: ${themeGet('pagination.item.border.right')}; border-bottom: ${themeGet('pagination.item.border.bottom')}; border-left: ${themeGet('pagination.item.border.left')}; border-radius: ${themeGet('pagination.item.borderRadius')}; `;

Slide 124

Slide 124 text

const theme = { breakpoints: ['992px'], space: [0, 4, 8, 16, 24, 32, 64], fontSizes: [12, 14, 16, 20, 24, 32], !!... pagination: { item: { fontSize: "14px", color: "blue", backgroundColor: "transparent", border: { top: 0, left: 0, right: 0, bottom: "2px", }, borderRadius: 0, !!... }, !!... } … }; const PaginationItem = styled.li` display: inline-block; cursor: pointer; user-select: none; !!... font-size: ${themeGet('pagination.item.fontSize')}; color: ${themeGet('pagination.item.color')}; background-color: ${themeGet('pagination.item.backgroundColor')}; border-top: ${themeGet('pagination.item.border.top')}; border-right: ${themeGet('pagination.item.border.right')}; border-bottom: ${themeGet('pagination.item.border.bottom')}; border-left: ${themeGet('pagination.item.border.left')}; border-radius: ${themeGet('pagination.item.borderRadius')}; `;

Slide 125

Slide 125 text

6 5 4 3 2 1 const theme = { !!... pagination: { item: { fontSize: "14px", color: "blue", backgroundColor: "transparent", border: { top: 0, left: 0, right: 0, bottom: "2px", }, borderRadius: 0, !!... }, } … }; const theme = { !!... pagination: { item: { fontSize: "14px", color: "orange", backgroundColor: "transparent", border: { top: "1px", left: "1px", right: "1px", bottom: "1px", }, borderRadius: "50%", !!... }, } … }; 6 5 4 3 2 1

Slide 126

Slide 126 text

6 5 4 3 2 1 const theme = { !!... pagination: { item: { fontSize: "14px", color: "blue", backgroundColor: "transparent", border: { top: 0, left: 0, right: 0, bottom: "2px", }, borderRadius: 0, !!... }, } … }; const theme = { !!... pagination: { item: { fontSize: "14px", color: "orange", backgroundColor: "transparent", border: { top: "1px", left: "1px", right: "1px", bottom: "1px", }, borderRadius: "50%", !!... }, } … }; 6 5 4 3 2 1

Slide 127

Slide 127 text

const theme = { !!... pagination: { item: { fontSize: "14px", color: "white", backgroundColor: "green", border: { top: 0, left: 0, right: 0, bottom: 0, }, borderRadius: "50%", !!... }, } … }; const theme = { !!... pagination: { item: { fontSize: "14px", color: "white", backgroundColor: "blue", border: { top: 0, left: 0, right: 0, bottom: 0, }, borderRadius: "5px", !!... }, } … }; 6 5 4 3 2 1 6 5 4 3 2 1

Slide 128

Slide 128 text

const theme = { !!... pagination: { item: { fontSize: "14px", color: "white", backgroundColor: "green", border: { top: 0, left: 0, right: 0, bottom: 0, }, borderRadius: "50%", !!... }, } … }; const theme = { !!... pagination: { item: { fontSize: "14px", color: "white", backgroundColor: "blue", border: { top: 0, left: 0, right: 0, bottom: 0, }, borderRadius: "5px", !!... }, } … }; 6 5 4 3 2 1 6 5 4 3 2 1

Slide 129

Slide 129 text

1. ⼤大幅降低 props 命名或格式不⼀一致的問題 2. 更更好的抽象化樣式,程式碼變得更更少 3. 根據不同狀狀態,更更彈性的修改對應樣式 4. 靈活的處理理 RWD 樣式 5. 透過 theme 快速變更更主題樣式 解決的問題 Styled System

Slide 130

Slide 130 text

使⽤用 Styled System 開發專案的⼼心得

Slide 131

Slide 131 text

我們需要有 Style Guide 客製化元件以前

Slide 132

Slide 132 text

@84colors @venngage

Slide 133

Slide 133 text

@Twitter

Slide 134

Slide 134 text

做出來來的畫⾯面可能跟設計師想的 不⼀一樣 如果沒有 Style Guide

Slide 135

Slide 135 text

可以在開發時,更更全⾯面思考該如何抽象化樣式 Design system

Slide 136

Slide 136 text

No content

Slide 137

Slide 137 text

No content

Slide 138

Slide 138 text

No content

Slide 139

Slide 139 text

No content

Slide 140

Slide 140 text

No content

Slide 141

Slide 141 text

https://jxnblk.com/ https://styled-system.com https://www.lego.com https://blog.twitter.com/developer https://unsplash.com/ https://www.flaticon.com/ Reference