Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
HowAboutWe for Couples Views & Styles Patterns
Search
Rebecca Miller-Webster
March 27, 2013
Programming
0
71
HowAboutWe for Couples Views & Styles Patterns
in Rails
Rebecca Miller-Webster
March 27, 2013
Tweet
Share
More Decks by Rebecca Miller-Webster
See All by Rebecca Miller-Webster
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.2k
Trust & Teams: 2019 Chicago CTO Summit
rmw
2
320
Refactoring Trust on Your Team (CTO Summit 2018)
rmw
1
1.4k
Trust and Teams: GORUCO 2017
rmw
0
250
Becoming an Engineer Leader Panel Intro Slide
rmw
0
310
Frameworks for Feedback (Long version) - 2016 May Self Conference
rmw
2
940
Frameworks for Feedback (2015 May - RailsConf)
rmw
1
510
Frameworks for Feedback - DevOpsDays Chicago
rmw
0
920
Tech Talk 101: Topic Generation
rmw
0
390
Other Decks in Programming
See All in Programming
CSC305 Lecture 09
javiergs
PRO
0
310
モテるデスク環境
mozumasu
3
1.3k
コード生成なしでモック処理を実現!ovechkin-dm/mockioで学ぶメタプログラミング
qualiarts
0
260
なぜGoのジェネリクスはこの形なのか? - Featherweight Goが明かす設計の核心
qualiarts
0
250
釣り地図SNSにおける有料機能の実装
nokonoko1203
0
200
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
610
NixOS + Kubernetesで構築する自宅サーバーのすべて
ichi_h3
0
1.2k
フロントエンド開発のためのブラウザ組み込みAI入門
masashi
7
3.5k
TFLintカスタムプラグインで始める Terraformコード品質管理
bells17
2
360
Range on Rails ―「多重範囲型」という新たな選択肢が、複雑ロジックを劇的にシンプルにしたワケ
rizap_tech
0
6.8k
CSC509 Lecture 06
javiergs
PRO
0
270
GC25 Recap: The Code You Reviewed is Not the Code You Built / #newt_gophercon_tour
mazrean
0
110
Featured
See All Featured
Balancing Empowerment & Direction
lara
5
700
Code Review Best Practice
trishagee
72
19k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
116
20k
A designer walks into a library…
pauljervisheath
209
24k
Visualization
eitanlees
149
16k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Building Adaptive Systems
keathley
44
2.8k
What's in a price? How to price your products and services
michaelherold
246
12k
RailsConf 2023
tenderlove
30
1.3k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
2.9k
Transcript
Overview of Couples Views/Styles HowAboutWe Server 1 pointer March 26,
2013
• logic in views is harder to test • views
are difficult to reason about Problem: Our Views are messy WTF is happening here??
Fix #0: SASS and View Styleguide! https://github.com/howaboutwe/sass-style-guide
NOT DESIGN Markup is about content
None
Use SASS THE GOOD PARTS
None
Variables are your friend
Mixin it up ... WITH
Decorators & Helpers WHEN SHIT GETS COMPLICATED
Decorators Logic moves with the OBJECT Helpers Logic moves with
the VIEW
Move logic out of views When • if statements •
ternary • lots of states • It hurts my head Then Generate in (testable) code • Classes • Copy • Html attributes
This
TO
How?
Generate classes
Move classes up
None
Generate Copy
Encapsulate repetition in partials Sometimes zero Sometimes one Sometimes two
None
Generate html attributes From TO WITH
Our current pattern • Use & enforce styleguide for SASS
& views • Markup is about content not design • Use SASS ◦ variables ◦ mixins • Move classes up & design changes to CSS • Use decorators (or helpers) to: ◦ Generate classes ◦ Generate copy ◦ Generate HTML attributes