Slide 1

Slide 1 text

What we've learnt building a DESIGN SYSTEM Lucy Galik in SwiftUI

Slide 2

Slide 2 text

PROPOSAL

Slide 3

Slide 3 text

WORKING GROUP

Slide 4

Slide 4 text

USER RESEARCH

Slide 5

Slide 5 text

GUIDING PRINCIPLES

Slide 6

Slide 6 text

GUIDING PRINCIPLES • Discoverability

Slide 7

Slide 7 text

GUIDING PRINCIPLES • Discoverability • Keep the good stu f

Slide 8

Slide 8 text

GUIDING PRINCIPLES • Discoverability • Keep the good stu ff • no UIKit

Slide 9

Slide 9 text

GUIDING PRINCIPLES • Discoverability • Keep the good stu ff • no UIKit • Accessibility fi rst

Slide 10

Slide 10 text

GUIDING PRINCIPLES • Discoverability • Keep the good stu ff • no UIKit • Accessibility fi rst • Keep it simple

Slide 11

Slide 11 text

GUIDING PRINCIPLES • Discoverability • Keep the good stu ff • no UIKit • Accessibility fi rst • Keep it simple • Limited API

Slide 12

Slide 12 text

Discoverability

Slide 13

Slide 13 text

Discoverability

Slide 14

Slide 14 text

Discoverability • Documentation

Slide 15

Slide 15 text

Discoverability • Documentation • Naming

Slide 16

Slide 16 text

Discoverability • Documentation • Naming • Demo app

Slide 17

Slide 17 text

Discoverability • Documentation • Naming • Demo app • Previews

Slide 18

Slide 18 text

Discoverability • Documentation • Naming • Demo app • Previews • Snapshot Tests

Slide 19

Slide 19 text

Discoverability • Documentation • Naming • Demo app • Previews • Snapshot Tests • Structure

Slide 20

Slide 20 text

Keep the good stuff

Slide 21

Slide 21 text

Keep the good stuff

Slide 22

Slide 22 text

Keep the good stuff @_exported import DesignSystemFoundation

Slide 23

Slide 23 text

Keep the good stuff Theme

Slide 24

Slide 24 text

Keep the good stuff Theme class HostingController: UIHostingController { init( rootView: Content, theme: Theme ) { super.init( rootView: HostingView( content: rootView, theme: theme ) ) } } struct HostingView: View { let theme: Theme let content: Content var body: some View { content .environment(\.theme, theme) } }

Slide 25

Slide 25 text

no UIKit

Slide 26

Slide 26 text

no UIKit

Slide 27

Slide 27 text

no UIKit

Slide 28

Slide 28 text

no UIKit struct CustomButton: View { let title: String let isEnabled: Bool let isLoading: Bool let action: () -> Void init( title: String, isEnabled: Bool, isLoading: Bool, action: @escaping () -> Void ) { // ... } }

Slide 29

Slide 29 text

no UIKit @Environment struct CustomButton: View { let title: String let isEnabled: Bool let isLoading: Bool let action: () -> Void init( title: String, isEnabled: Bool, isLoading: Bool, action: @escaping () -> Void ) { // ... } } struct CustomButton: View { let title: String @Environment(\.isEnabled) var isEnabled @Environment(\.isLoading) var isLoading let action: () -> Void init( title: String, action: @escaping () -> Void ) { // … } }

Slide 30

Slide 30 text

no UIKit ViewModel struct CardViewModel { let icon: String let title: String let subtitle: String let action: () -> Void } struct Card: View { let viewModel: CardViewModel var body: some View { // ... } }

Slide 31

Slide 31 text

no UIKit ViewModel struct CardViewModel { let icon: String let title: String let subtitle: String let action: () -> Void } struct Card: View { let viewModel: CardViewModel var body: some View { // ... } } struct CardViewModel { let icon: String let title: String let subtitle: String let action: () -> Void } extension CardViewModel: View { var body: some View { // ... } }

Slide 32

Slide 32 text

no UIKit ViewModel struct CardViewModel { let icon: String let title: String let subtitle: String let action: () -> Void } struct Card: View { let viewModel: CardViewModel var body: some View { // ... } } struct Card: View { let icon: String let title: String let subtitle: String let action: () -> Void var body: some View { // ... } }

Slide 33

Slide 33 text

no UIKit Styles struct AnotherButton: View { enum Style { case primary case secondary case destructive } let style: Style // ... var body: some View { // ... } var foregroundColor: Color { switch style { // ... } } var backgroundColor: Color { switch style { // ... } }

Slide 34

Slide 34 text

no UIKit Styles struct AnotherButton: View { enum Style { case primary case secondary case destructive } let style: Style // ... var body: some View { // ... } var foregroundColor: Color { switch style { // ... } } var backgroundColor: Color { switch style { // ... } } struct AnotherButton: View { let style: AnotherButtonStyle // ... var body: some View { Button( // ... ) .buttonStyle(style) } } struct AnotherButtonStyle: ButtonStyle { let foregroundColor: Color let backgroundColor: Color func makeBody( configuration: Configuration ) -> some View { // ... } }

Slide 35

Slide 35 text

no UIKit Styles struct AnotherButton: View { let style: AnotherButtonStyle // ... var body: some View { Button( // ... ) .buttonStyle(style) } } struct AnotherButtonStyle: ButtonStyle { let foregroundColor: Color let backgroundColor: Color func makeBody( configuration: Configuration ) -> some View { // ... } }

Slide 36

Slide 36 text

no UIKit Styles struct AnotherButton: View { let style: AnotherButtonStyle // ... var body: some View { Button( // ... ) .buttonStyle(style) } } struct AnotherButtonStyle: ButtonStyle { let foregroundColor: Color let backgroundColor: Color func makeBody( configuration: Configuration ) -> some View { // ... } }

Slide 37

Slide 37 text

no UIKit Styles struct AnotherButton: View { let style: AnotherButtonStyle // ... var body: some View { Button( // ... ) .buttonStyle(style) } } struct AnotherButtonStyle: ButtonStyle { let foregroundColor: Color let backgroundColor: Color func makeBody( configuration: Configuration ) -> some View { // ... } } extension AnotherButtonStyle { static let primary = AnotherButtonStyle( // ...) static let secondary = AnotherButtonStyle( // ... ) static let destructive = AnotherButtonStyle( // ... ) }

Slide 38

Slide 38 text

Accessibility

Slide 39

Slide 39 text

Accessibility

Slide 40

Slide 40 text

Accessibility

Slide 41

Slide 41 text

Accessibility accessibilityRepresentation struct CustomSlider: View { // ... var body: some View { slider() .accessibilityRepresentation { Slider(value: $value, in: range, step: step) } } }

Slide 42

Slide 42 text

Accessibility

Slide 43

Slide 43 text

Accessibility var body: some View { HStack { Image(illustration) Text(title) Text(subtitle) } .accessibilityLabel(accessibilityLabel) }

Slide 44

Slide 44 text

Accessibility var body: some View { HStack { Image(illustration) .accessibilityLabel(illustrationAccessibilityLabel) Text(title) Text(subtitle) } }

Slide 45

Slide 45 text

Accessibility var body: some View { HStack { Image(illustration) .accessibilityHidden(true) Text(title) Text(subtitle) } }

Slide 46

Slide 46 text

Accessibility var body: some View { Button( action: action, label: { title } ) .accessibilityLabel(title) }

Slide 47

Slide 47 text

Accessibility var body: some View { Button( action: action, label: { title } ) .accessibilityLabel(title) }

Slide 48

Slide 48 text

Keep it simple

Slide 49

Slide 49 text

Keep it simple

Slide 50

Slide 50 text

Keep it simple struct Footer: View { let prompt: Text? let callout: Callout? let primary: LargeButton let secondary: LargeButton? let axis: Axis var body: some View { // ... } public init( button: LargeButton ) { // ... } public init( prompt: Text, top: LargeButton, bottom: LargeButton ) { // ... } }

Slide 51

Slide 51 text

Keep it simple struct Footer: View { let prompt: Text? let callout: Callout? let primary: LargeButton let secondary: LargeButton? let axis: Axis var body: some View { // ... } public init( button: LargeButton ) { // ... } public init( prompt: Text, top: LargeButton, bottom: LargeButton ) { // ... } }

Slide 52

Slide 52 text

Limited API

Slide 53

Slide 53 text

Limited API struct Footer: View { // ... init( prompt: Text, top: LargeButton, bottom: LargeButton ) { // ... } }

Slide 54

Slide 54 text

Limited API struct Footer: View { // ... init( prompt: Text, top: LargeButton, bottom: LargeButton ) { // ... } } struct Footer: View { // ... init( prompt: Text, @ViewBuilder top: () -> Primary, @ViewBuilder bottom: () -> Secondary ) { // ... } }

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

and write it down Have a plan

Slide 57

Slide 57 text

Create a team

Slide 58

Slide 58 text

Know your user*

Slide 59

Slide 59 text

but be ready to adjust them Have Guidelines

Slide 60

Slide 60 text

Don’t fight the framework

Slide 61

Slide 61 text

No content