├── .gitignore
├── CONTRIBUTING.md
├── README.md
├── examples
├── buttons.html
├── debug-grid.html
├── image-placeholder.html
├── nav-menu.html
└── typography.html
├── index.html
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # nyc test coverage
18 | .nyc_output
19 |
20 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
21 | .grunt
22 |
23 | # node-waf configuration
24 | .lock-wscript
25 |
26 | # Compiled binary addons (https://nodejs.org/api/addons.html)
27 | build/Release
28 |
29 | # Dependency directories
30 | node_modules
31 | jspm_packages
32 |
33 | # Optional npm cache directory
34 | .npm
35 |
36 | # Optional REPL history
37 | .node_repl_history
38 | package-lock.json
39 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | **Please read** our
2 | [**contribution guide**](https://github.com/dwyl/contributing)
3 | (_thank you_!).
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Learn Tachyons [](https://github.com/dwyl/learn-tachyons/issues) [](https://hits.dwyl.com/dwyl/learn-tachyons)
2 |
3 | 
4 |
5 | _**Learn** how to use **Tachyons**
6 | to **craft beautiful, 100% responsive,
7 | functional** and **fast User Interface/Experience** (UI/UX)
8 | with **minimal CSS**
9 | in **much less time**._
10 |
11 |
12 | - [_Why_?](#why)
13 | - [_One Minute Summary_](#one-minute-summary)
14 | - [What?](#what)
15 | - [What is _Different_?](#what-is-different)
16 | - [_Bootstrap_ Custom Button (_The Old Way_!)](#bootstrap-custom-button-the-old-way)
17 | - [_Tachyons_ Custom Button (_New Way_!)](#tachyons-custom-button-new-way)
18 | - [What is "_Functional_" CSS?](#what-is-functional-css)
19 | - [Functional CSS is:](#functional-css-is)
20 | - [Functional :innocent:](#functional-innocent)
21 | - [Composable :musical_score: :notes: :musical_keyboard:](#composable-musical_score-notes-musical_keyboard)
22 | - [Immutable :gem: :gem: :gem:](#immutable-gem-gem-gem)
23 | - [Why Tachyons?](#why-tachyons)
24 | - [Easy to Understand and Use](#easy-to-understand-and-use)
25 | - [_Mobile First_ Responsive Design](#mobile-first-responsive-design)
26 | - [Accessibility](#accessibility)
27 | - [A Natural Workflow](#a-natural-workflow)
28 | - [Works well with component based UIs](#works-well-with-component-based-uis)
29 | - [Great Performance that Scales](#great-performance-that-scales)
30 | - [_How_?](#how)
31 | - [Try _Before_ You Commit (3 Easy Steps)](#try-before-you-commit-3-easy-steps)
32 | - [In your Own Project](#in-your-own-project)
33 | - [Learning the ropes](#learning-the-ropes)
34 | - [Responsive modifiers](#responsive-modifiers)
35 | - [Typography](#typography)
36 | - [Layout](#layout)
37 | - [Theming](#theming)
38 | + [Image Placeholder Example](#how-to-create-an-image-placeholder)
39 | + [Responsive Navigation Menu Example](#responsive-navigation-menu)
40 | - [Resources](#resources)
41 | - [Articles](#articles)
42 | - [Questions and Discussions](#questions-and-discussions)
43 | - [Future of Tachyons](#future-of-tachyons)
44 |
45 |
46 | ## _Why_?
47 |
48 | The User Interface (UI) or User Experience (UX)
49 | is the part of your application that
50 | the ***people*** ("_end users_")
51 | _**see** and **interact** with_.
52 | Ensuring that the **UI/UX** is the _**best** it **can be**_,
53 | is _easily_ the ***top priority*** for our Web/Mobile projects.
54 |
55 | Without ~~good~~ ***great UI/UX***
56 | ["_**nothing `else` matters**_"](https://youtu.be/tAGnKpE4NCI)
57 | to the person _using_ your app.
58 | The **UI/UX** is what _**matters**_,
59 | **not** the **programming language**,
60 | what type of **server**,
61 | which "***front-end framework***"
62 | or "**backend infrastructure**" you are using;
63 | ***Nobody cares*** about the "_boring technical details_",
64 | they _only_ care about their **own _experience_** using the app/website.
65 |
66 | 
67 |
68 | ### _One Minute Summary_
69 |
70 | Through _experience_
71 | (_building **many web/mobile** apps large and small
72 | in teams ranging from 2 - **200 people**_),
73 | we have found that:
74 | + _**Hand-writing CSS**_ is _very **time-consuming** and **repetitive**_!
75 | + Using (_most_) CSS "_frameworks_" results in:
76 | + Lots of **Duplication** _where people re-create styles over-and-over_
77 | + "**_Zombie_ Code**" _unused styles that nobody will risk removing_
78 | + **Bloated** apps/sites that take _much_ longer
79 | to develop, load and maintain than they _need_ to.
80 | + **_Functional_ CSS** _ensures_:
81 | + UI is **100% _Predictable_, Consistent**
82 | and _free from_ (_unwanted_) "***Side Effects***"
83 | (_where a change in one place "breaks" something else!_)
84 | + It's ***immediately clear*** from reading ***one***
85 | block of code what the component _does_ and what it looks like.
86 | + **_Updates_** to UI are made in ***One Place/File***. (_see diagram below_)
87 | + **Time** to _develop_ your App's UI ***scales proportionally***
88 | instead of increasing ***exponentially*** the way it does with
89 | most "traditional" CSS frameworks.
90 | + The moment you want anything "_custom_" most CSS frameworks
91 | let you down _badly_ because you have to "_override_",
92 | Tachyons is _made_ for helping you to use your imagination!
93 | The resulting UI will be ***much less code***,
94 | load ***considerably faster*** and be ***far easier to maintain***!
95 |
96 | Tachyons lets you avoid the "_CSS Fire_":
97 |
98 | [](https://twitter.com/iamdevloper/status/753716544949981184 "CSS is easy? - click to see original tweet")
99 |
100 | > Extended discussion on the pros/cons of
101 | Functional CSS & Tachyons:
102 | https://github.com/dwyl/learn-tachyons/issues/1
103 |
104 | ## What?
105 |
106 | 
107 |
108 | Tachyons is a **CSS _Design System_** anyone can learn/use
109 | to craft beautiful, responsive & fast UIs with minimal CSS!
110 | Tachyons has ***all*** the ***building blocks***
111 | you (_your team_) need(s) to
112 | [_build **anything** you can **imagine**_](https://youtu.be/Um-PlX6oPBQ?t=12s "The LEGO Movie Scene: I am a Master Builder!").
113 |
114 | Tachyons embraces a different style than many popular CSS
115 | frameworks known as "***Functional CSS***".
116 |
117 | ### What is _Different_?
118 |
119 | When you use the Bootstrap `primary` button class in your web app,
120 | it _looks_ simple enough on the surface,
121 | you simply add the class to your HTML markup.
122 | Following the example on:
123 | https://getbootstrap.com/docs/4.0/components/buttons/
124 |
125 | ```hmtl
126 |
127 | ```
128 |
129 | 
130 |
131 | Here's is the CSS for that bootstrap `primary` button:
132 |
133 | ```css
134 | .btn-primary {
135 | color: #fff;
136 | background-color: #337ab7;
137 | border-color: #2e6da4;
138 | }
139 |
140 | .btn {
141 | display: inline-block;
142 | padding: 6px 12px;
143 | margin-bottom: 0;
144 | font-size: 14px;
145 | font-weight: 400;
146 | line-height: 1.42857143; /* who needs this level of decimal precision in CSS?! */
147 | text-align: center;
148 | white-space: nowrap;
149 | vertical-align: middle;
150 | -ms-touch-action: manipulation;
151 | touch-action: manipulation;
152 | cursor: pointer;
153 | -webkit-user-select: none;
154 | -moz-user-select: none;
155 | -ms-user-select: none;
156 | user-select: none;
157 | background-image: none;
158 | border: 1px solid transparent;
159 | border-radius: 4px;
160 | }
161 | ```
162 | Visit: https://getbootstrap.com/css/#buttons
163 | (_open your "dev tools"_) then inspect one of the buttons
164 | and see for yourself:
165 | 
166 |
167 |
168 | What a _monolith_! There are a _lot_ of CSS attributes there;
169 | Bootstrap is quite ***opinionated*** about how a button should
170 | look and function.
171 |
172 | If you want to change/customise any aspect
173 | of the button
174 | (_e.g: [font](https://www.cssfontstack.com/Helvetica) or
175 | [color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value)_),
176 | you will need to:
177 | 1. Create a new class in your `app.css` file
178 | (_or whatever your project calls it_)
179 | 2. Define the CSS styles for that custom attribute, e.g:
180 | ```css
181 | .custom-btn-purple-helvetica {
182 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
183 | color: #800080; /* wikipedia.org/wiki/The_Color_Purple */
184 | }
185 | ```
186 | 3. Add the CSS class to the instance of the button you created.
187 | ```html
188 |
190 | ```
191 | This 3-step process is slow and _always_ ends up with more
192 | CSS than if you used pre-existing Tachyons classes. (_see below_) 🌈
193 |
194 | ### _Bootstrap_ Custom Button (_The Old Way_!)
195 |
196 | What if we wanted a button that looks a little different?
197 | We'd most likely need to add another class. e.g:
198 |
199 | ```html
200 |
201 | ```
202 | Which requires us to write quite a lot of custom CSS:
203 |
204 | ```css
205 | .btn-dwyl {
206 | background-color: #46B6AC;
207 | border-color: #46B6AC;
208 | padding: 10px;
209 | text-transform: uppercase;
210 | letter-spacing: 4px;
211 | font-weight: 300;
212 | }
213 | ```
214 |
215 | 
216 |
217 | ### _Tachyons_ Custom Button (_New Way_!)
218 |
219 | Tachyons approaches this with `single utility classes`
220 | (classes that do one thing).
221 | These `single utility classes` encourage
222 | a different way of building UI:
223 | all code is in a single place
224 | the `html`, not the `stylesheet`:
225 |
226 | ```html
227 |
228 | ```
229 |
230 | Each class has one responsibility:
231 | + `bw0` - "border width 0" see:
232 | + `br2` - "border radius 2" see:
233 | + `bg-dwyl-teal` - "background color dwyl teal" (_this is an example of a custom color_)
234 | + `pa2` - "padding all 2"
235 | + `white` - "text color white"
236 | + `fw1` - "font weight 1"
237 | + `tc` - "text align center"
238 | + `ttu` - "text transform uppercase"
239 | + `tracked` - "with letter spacing"
240 |
241 | see: `/examples/buttons.html`
242 |
243 | **Note**: Tachyons does not have _all_-the-colors,
244 | hence we had to define our own.
245 | However given that there is a clear format for defining colors
246 | we defined our own as `bg-dwyl-teal`:
247 | ```css
248 | .bg-dwyl-teal {
249 | background-color: #4DB6AC;
250 | }
251 | ```
252 | This is "_OK_" because it's still a _single-purpose_ class
253 | that we can _re-use_ for any elements that require the teal background.
254 |
255 | ### What is "_Functional_" CSS?
256 |
257 | 
258 |
259 |
260 | You may be thinking:
261 | + How _exactly_ does this make my CSS better?
262 | + Why use this approach when CSS has been written
263 | like the bootstrap example for years?
264 | + Isn't this just like using inline styles?
265 | ([considered by many to be bad practice in CSS](https://stackoverflow.com/questions/2612483/whats-so-bad-about-in-line-css))
266 | + Won't I end up _repeating myself_ in the HTML?
267 |
268 | Let's have a look at some of the core features
269 | and ideas of `Functional CSS` and see if we can
270 | answer some of those questions.
271 |
272 | ## Functional CSS is:
273 |
274 | ### Functional :innocent:
275 |
276 | Small, clear, easy to read classes that
277 | are easy to apply and do _one_ thing.
278 | Having small classes means it's easy to make
279 | a set of **consistent spacing and type
280 | rules** - you end up forcing a beautiful type
281 | scale & rhythm on your design.
282 |
283 | > "_**Good design** (my preferred school of
284 | good design, at least) is **mathsy**,
285 | **rational** and **pure** —and CSS is design— so it
286 | follows that there are a bunch of lessons
287 | we can bring back from FP land into design_." -
288 | [Jon Gold](https://www.jon.gold/2015/07/functional-css) Front-End Wizard @ AirBnB
289 |
290 | ### Composable :musical_score: :notes: :musical_keyboard:
291 |
292 | In Functional Programming you combine (or compose) a bunch of tiny functions together to do bigger things (like lots of notes to make music!). You end up reusing a lot of your code which is great for **performance and consistency**! Just like the button example:
293 |
294 | ```html
295 |