A place to cache linked articles (think custom and personal wayback machine)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.md 18KB

1 년 전
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. title: When Our Tools Hold Us Back
  2. url: https://www.oddbird.net/2022/11/11/platform-tools/
  3. hash_url: 28c9baf3ff21fbc616ccf13776104ccd
  4. <p>The
  5. <a href="https://almanac.httparchive.org/en/2022/">2022 Web Almanac</a>
  6. has been out for a while,
  7. and (as always)
  8. it’s an interesting<span class="widont"> </span>read.</p>
  9. <p>There are more than 20 chapters this year,
  10. and I haven’t read them all.
  11. But I did enjoy the chapters on
  12. <a href="https://almanac.httparchive.org/en/2022/css"><span class="caps">CSS</span></a>
  13. (by Rachel Andrew)
  14. and <a href="https://almanac.httparchive.org/en/2022/fonts">webfonts</a>
  15. (by Bram Stein).
  16. Both authors note a similar trend –
  17. <strong>many usage patterns
  18. that refuse to change from year to year
  19. can be explained by popular<span class="widont"> </span>tools</strong>.</p>
  20. <p>I’ve noticed that same effect elsewhere,
  21. and I want to dig into it a bit –
  22. the various ways our tooling
  23. can change (and limit)
  24. the web platform features we<span class="widont"> </span>use.</p>
  25. <p class="anchor-link-wrapper">
  26. <h2 id="the-worst-color-formats" tabindex="-1">The worst color<span class="widont"> </span>formats</h2>
  27. </p>
  28. <p>According to the Almanac data,
  29. the most common color formats on the web
  30. are <span class="caps">HEX</span> (<code>#C71585</code>),
  31. short-form <span class="caps">HEX</span> (<code>#c18</code>),
  32. and then old-school
  33. <code>rgba(199, 21, 133, 0.8)</code>.</p>
  34. <p>But why are we still using
  35. the oldest and least legible
  36. color formats,
  37. when better formats are well-supported?
  38. <span class="caps">HSL</span> is more human-readable than <span class="caps">HEX</span>,
  39. and the <code>rgb()</code> function
  40. now supports alpha transparency
  41. without switching to <code>rgba()</code>.</p>
  42. <p>Alternately, if we like <span class="caps">HEX</span> so much,
  43. why don’t we use the alpha-<span class="caps">HEX</span> syntax
  44. (<code>#C7158599</code>)
  45. that’s been supported for several years.
  46. Why aren’t these options gaining<span class="widont"> </span>popularity?</p>
  47. <p>It’s hard to say for sure,
  48. but I have a multi-part<span class="widont"> </span>guess.</p>
  49. <p class="anchor-link-wrapper">
  50. <h2 id="how-design-tokens-intervene" tabindex="-1">How design tokens<span class="widont"> </span>intervene</h2>
  51. </p>
  52. <p>First, colors are <em>design tokens</em>,
  53. and often get set as custom properties
  54. or build-tool variables
  55. at the start of a project.
  56. Once the tokens are established,
  57. we don’t spend much time looking at
  58. the actual color syntax underneath.
  59. I don’t ever interact directly
  60. with the <span class="caps">HEX</span> code <code>#E60073</code> –
  61. I can just reference
  62. <code>var(--brand-pink)</code>.
  63. So we focus our attention on the naming conventions
  64. rather than the underlying color syntax,
  65. which is hidden from<span class="widont"> </span>view.</p>
  66. <p class="anchor-link-wrapper">
  67. </p>
  68. <p>I think there’s also a tooling component here.
  69. Many graphic design tools are a step removed
  70. from the web platform.
  71. While some do try to export <span class="caps">HTML</span>/<span class="caps">CSS</span>,
  72. only a few consider that
  73. the core goal of the tool.
  74. Even then, there’s been a long-term disconnect
  75. between a web that’s responsive,
  76. and our almost completely static design<span class="widont"> </span>tools.</p>
  77. <p>A few tools have started to provide
  78. <em>flexbox-like</em> ‘responsive’ layouts,
  79. but I haven’t seen anything <em><span class="caps">CSS</span>-grid-like</em>.
  80. Most don’t even have
  81. basic support for relative or fluid units.
  82. Rachel notes in the Almanac
  83. that most lengths on the web
  84. are defined in <code>px</code>.
  85. Is that because authors intentionally avoid <code>em</code>/<code>rem</code>,
  86. or because the mockups that we receive from designers
  87. are all limited to <code>px</code> by our design<span class="widont"> </span>tools?</p>
  88. <p>I’ve <a href="https://twitter.com/TerribleMia/status/1446262147772682260">commented on this before</a>:</p>
  89. <blockquote>
  90. <p>The least responsive part
  91. of Responsive Web Design
  92. is the design tools.
  93. This needs to<span class="widont"> </span>change.</p>
  94. </blockquote>
  95. <p>When it comes to color spaces/gamuts,
  96. design tools vary in support.
  97. Looking at some of the big<span class="widont"> </span>players:</p>
  98. <ul>
  99. <li><strong>Adobe <span class="caps">XD</span></strong>
  100. supports <span class="caps">HEX</span>, <span class="caps">RGB</span>, and <span class="caps">HSB</span>.
  101. <strong>Illustrator</strong> adds <span class="caps">CMYK</span> and a grayscale option,
  102. while <strong>Photoshop</strong> also supports extended gamuts
  103. such as Display P3,
  104. and perceptually-uniform<span class="widont"> </span><span class="caps">LAB</span>.</li>
  105. <li><strong>Figma</strong>
  106. (now also owned by Adobe)
  107. provides <span class="caps">HEX</span>, <span class="caps">RGB</span>,
  108. ‘<span class="caps">CSS</span>’ (which is <code>rgba()</code>),
  109. <span class="caps">HSL</span>, and<span class="widont"> </span><span class="caps">HSB</span>.</li>
  110. <li><strong>Sketch</strong>
  111. shows <span class="caps">HSB</span>, <span class="caps">HEX</span>, and<span class="widont"> </span><span class="caps">RGB</span>(a).</li>
  112. </ul>
  113. <p>I don’t know of any popular design tools
  114. that provide <span class="caps">LCH</span>,
  115. or the newer okLAB/okLCH variants,
  116. let alone <em>relative</em> colors
  117. defined as a function of mixing or adjusting
  118. other underlying<span class="widont"> </span>colors.</p>
  119. <p>And when it comes to copying our colors
  120. out of a design tool,
  121. the options are generally 6-digit <span class="caps">HEX</span>,
  122. or copying individual channel values,
  123. one at a time.
  124. Either way,
  125. converting our colors
  126. into a more human-friendly syntax
  127. would often be an extra step,
  128. and may not be worth the<span class="widont"> </span>effort.</p>
  129. <p>Since all legacy colors on the web
  130. rely on a single color model (<span class="caps">RGB</span>)
  131. and gamut (sRGB),
  132. there has been little <em>meaningful</em> difference
  133. between formats (until now).
  134. Once we used a graphic interface
  135. to pick the color we want,
  136. it maybe didn’t matter
  137. what format we copy-pasted into
  138. a variable<span class="widont"> </span>somewhere.</p>
  139. <p>But what’s the designer path
  140. towards using new, extended color spaces in <span class="caps">CSS</span>?
  141. Can they ever gain traction on the web
  142. without first finding support in our design tools?
  143. I’m not<span class="widont"> </span>sure.</p>
  144. <p class="anchor-link-wrapper">
  145. </p>
  146. <p>Code tools also play a role in<span class="widont"> </span>this.</p>
  147. <p>Sass, for example,
  148. relies on the same
  149. <em>interchangeability</em> of legacy web formats.
  150. No matter what syntax an author chooses,
  151. Sass will store the value as <span class="caps">RGB</span>,
  152. and then allow manipulation
  153. in any other <span class="caps">CSS</span> format.
  154. But at the end of the day,
  155. <em><span class="caps">CSS</span> output is always generated
  156. in whatever format has the widest browser<span class="widont"> </span>support</em>.</p>
  157. <p>It doesn’t matter to Sass
  158. what syntax authors use
  159. for their <em>input value</em>,
  160. the <em>output value</em> is always
  161. either <span class="caps">HEX</span> or a color name when opaque,
  162. with <code>rgba()</code> for handling transparency.
  163. Very few people need that level
  164. of legacy browser support,
  165. but it’s not hurting anything<span class="widont"> </span>either.</p>
  166. <p>Not yet, at least.
  167. This will all change going forward,
  168. as we add
  169. <a href="https://sass-lang.com/blog/request-for-comments-color-spaces">Sass support for more color spaces and<span class="widont"> </span>gamuts</a>.</p>
  170. <p>In this case,
  171. the Almanac may give us misleading info
  172. about what syntax authors <em>prefer</em>.
  173. For all we know,
  174. authors might be <em>working primarily in <span class="caps">HSL</span></em>,
  175. and we wouldn’t see that
  176. in the production code at all.
  177. In fact,
  178. one of the most popular complaints
  179. on the Sass issue tracker is
  180. a request for <span class="caps">HSL</span><span class="widont"> </span>output.</p>
  181. <p>But this is a distinction
  182. with very little at stake.
  183. So long as authors can use their favorite format –
  184. and the output really does
  185. provide the same <em>meaning</em> as the input –
  186. it’s not a barrier for authors
  187. using the latest color formats.
  188. We’re just making that harder to<span class="widont"> </span>see.</p>
  189. <p class="anchor-link-wrapper">
  190. <h2 id="extending-vs-replacing-a-language" tabindex="-1">Extending vs replacing a<span class="widont"> </span>language</h2>
  191. </p>
  192. <p>In Sass,
  193. we have a strict policy
  194. that <em>valid <span class="caps">CSS</span> is always valid Sass</em>.
  195. If authors use syntax that we don’t recognize,
  196. we pass that along to <span class="caps">CSS</span>.
  197. We can check for obvious parsing errors,
  198. but only the browser can determine
  199. if it’s a supported feature.
  200. While we provide <em>extra</em> Sass support
  201. for colors that we understand,
  202. authors can use new <span class="caps">CSS</span> color formats in Sass
  203. without us releasing any new features.
  204. Sass may not understand those colors for a time,
  205. but it will leave them untouched in the <span class="caps">CSS</span><span class="widont"> </span>output.</p>
  206. <p>Similarly,
  207. Sass hasn’t added support
  208. for either <code>@layer</code> or <code>@container</code> –
  209. and there may not be any reason to.
  210. I’m already using both in my Sass,
  211. without any<span class="widont"> </span>issue.</p>
  212. <p>There have been unfortunate exceptions on occasion
  213. (see <code>min()</code> and <code>max()</code> for example),
  214. but we’ve worked very hard to remove those limitations
  215. when they crop up.
  216. The tool should never stand between
  217. authors and the underlying<span class="widont"> </span>language.</p>
  218. <p>Last month,
  219. I spoke about <code>@layer</code> for
  220. <a href="https://aneventapart.com/event/denver-2022">An Event Apart Denver</a>.
  221. During the Q&amp;A session after my talk,
  222. someone asked,
  223. “How can I use this with <span class="caps">CSS</span>-in-<span class="caps">JS</span> tools?”
  224. And the truth is…
  225. <em>I don’t know</em>.
  226. It depends entirely on the<span class="widont"> </span>tool.</p>
  227. <p>Single-file components in tools like Svelte <span class="amp">&amp;</span> Vue
  228. are <em>technically</em> <span class="caps">CSS</span>-in-<span class="caps">JS</span>,
  229. but allow writing arbitrary/plain <span class="caps">CSS</span>.
  230. I would expect (hope?) that
  231. <code>@layer</code> should <em>just work</em> in that context
  232. (similar to using<span class="widont"> </span>Sass).</p>
  233. <p>But many <span class="caps">CSS</span>-in-<span class="caps">JS</span> tools
  234. and utility frameworks
  235. are more invasive –
  236. replacing some or most <span class="caps">CSS</span> with a proprietary syntax.
  237. They don’t provide <em>additions</em> to the language,
  238. but a whole new language
  239. that stands directly between us
  240. and the basic <span class="caps">CSS</span> functionality we need.
  241. There’s no option to write <span class="caps">CSS</span> directly,
  242. we have to rely on the tool to do it for us.
  243. <em>If the tool can’t do something,
  244. neither can the authors using it.
  245. All we can do is<span class="widont"> </span>wait</em>.</p>
  246. <p>I even ran into this issue
  247. by simply hosting my personal site
  248. on Netlify,
  249. which provides minification
  250. for deployed assets like <span class="caps">CSS</span>.
  251. That seems like a great feature!
  252. But the specific <span class="caps">CSS</span> minifier that they use
  253. is somewhat overeager,
  254. and began stripping out all my new
  255. <a href="https://css-tricks.com/css-cascade-layers/"><code>@layer</code></a> rules.
  256. I had to turn off the minification step
  257. in order to publish my entirely-valid<span class="widont"> </span><span class="caps">CSS</span>.</p>
  258. <p>That shouldn’t be the case.
  259. Minifiers shouldn’t need to understand
  260. all the new features that land in <span class="caps">CSS</span>.
  261. This is similar to the issue with
  262. <a href="/2022/08/04/zero-units/">removing units from zero</a>,
  263. or Harry Roberts’ recent warnings around
  264. <a href="https://csswizardry.com/2022/09/critical-css-not-so-fast/">Critical <span class="caps">CSS</span></a>.
  265. In a language like <span class="caps">CSS</span> –
  266. where order is meaningful,
  267. and duplicate properties are a useful feature –
  268. it’s risky for automated build tools
  269. to try and be <em>clever</em> about minification.
  270. I don’t know that a <span class="caps">CSS</span> minifier
  271. should do much more than white-space<span class="widont"> </span>management.</p>
  272. <p class="anchor-link-wrapper">
  273. </p>
  274. <p>In regard to web fonts,
  275. Bram points out
  276. that authors are not taking full advantage
  277. of variable fonts –
  278. we’re mostly changing the font weights,
  279. and selecting from standard<span class="widont"> </span>values.</p>
  280. <p>As someone who has spent hours
  281. searching through lists of variable fonts,
  282. that doesn’t surprise me much.
  283. Most variable fonts are either experimental display fonts
  284. without a lot of practical use,
  285. or they only provide a single weight axis.
  286. While I love having all my weights in a single file
  287. and smoothly transitioning from one weight to another,
  288. <em>specialty weights</em> are not a high priority for me.
  289. I’ll start using more powerful font variables
  290. once there are more fonts available
  291. with more interesting variables to<span class="widont"> </span>manipulate.</p>
  292. <p>Most of us are also using
  293. the over-complicated <code>font-feature-settings</code> property,
  294. instead of the simpler <code>font-variant</code>.
  295. I’ve been doing that on my site as<span class="widont"> </span>well!</p>
  296. <p>Why did I think that was the best approach?
  297. Likely because that’s the generated output
  298. recommended by
  299. <a href="https://wakamaifondue.com/">Wakamai Fondue</a> –
  300. a popular tool for inspecting font capabilities.
  301. It’s a great tool,
  302. filling a much-needed gap,
  303. but I wonder how the usage stats would change
  304. if they updated their output<span class="widont"> </span><span class="caps">CSS</span>?</p>
  305. <p>Maybe even more common,
  306. much of the web is built using <span class="caps">CSS</span> libraries
  307. like Bootstrap,
  308. or third-party themes
  309. provided by a site-builder or <span class="caps">CMS</span>.
  310. The influence of both
  311. WordPress and Bootstrap is clear
  312. throughout the Almanac data.
  313. When Rachel notes the popularity of
  314. flexbox (very popular) vs grid (not so much),
  315. I wonder how much of that
  316. can be traced back to
  317. Bootstrap ‘grids’
  318. <a href="https://getbootstrap.com/docs/5.2/layout/grid/">being built in<span class="widont"> </span>flexbox</a>.</p>
  319. <p>I don’t think that’s the only factor.
  320. It’s possible authors have settled on flexbox as <em>good-enough</em>,
  321. and they don’t think it’s worth their time
  322. learning another technique.
  323. I can understand that,
  324. but it’s unfortunate.
  325. I think people are missing out
  326. on one of the coolest features
  327. added to <span class="caps">CSS</span> <em>ever</em>.</p>
  328. <p class="anchor-link-wrapper">
  329. </p>
  330. <p>When we talk about web trends,
  331. I often hear people refer back to
  332. the idea of ‘pace layers’ on the<span class="widont"> </span>web:</p>
  333. <p><figure class="embed">
  334. <figcaption class="caption">Described by <a href="https://adactio.com/">Jeremy Keith</a>
  335. in his <a href="https://speaking.adactio.com/87IIn1">Building talk</a>
  336. a few years<span class="widont"> </span>back.</figcaption></figure></p>
  337. <p>In context,
  338. Jeremy is not just referring to
  339. the web languages themselves –
  340. <span class="caps">JS</span> isn’t necessarily changing faster than <span class="caps">CSS</span> –
  341. but also the <em>ecosystems</em> of these languages.
  342. The closer we get to the core functionality of the web,
  343. the slower each language/ecosystem is likely to change.
  344. Even within a given language,
  345. we expect our tools and conventions (<em>fashion</em>)
  346. to move faster than the languages<span class="widont"> </span>themselves.</p>
  347. <p>But that can only happen
  348. if the tools are designed to
  349. sit on top of their underlying languages.
  350. Once the tools stand <em>between</em> us and the language,
  351. we become entirely reliant on tool-builders
  352. to determine what features are<span class="widont"> </span>available.</p>
  353. <p>When our primary tools
  354. intervene so strongly
  355. between us and our ‘materials’ –
  356. the core web languages –
  357. we can accidentally flip the pace layers of the web
  358. on their head.
  359. Suddenly <span class="caps">CSS</span> is able to move faster than the ecosystem,
  360. and we’re stuck waiting on our tools to catch up
  361. with well-supported platform<span class="widont"> </span>features.</p>
  362. <p>That’s not how a healthy ecosystem should<span class="widont"> </span>behave.</p>
  363. <p class="anchor-link-wrapper">
  364. </p>
  365. <p>I am asked quite often
  366. what I think about <span class="caps">CSS</span>-in-<span class="caps">JS</span>
  367. or utility-first frameworks,
  368. or even <span class="caps">CSS</span> libraries <span class="amp">&amp;</span> conventions
  369. more generally.
  370. And I try to stay out of any spicy flame wars,
  371. or gate-keeping<span class="widont"> </span>nonsense.</p>
  372. <p>For myself?
  373. I don’t find many of these tools useful.
  374. They don’t solve a problem that I have.
  375. But different projects and different teams
  376. have different needs,
  377. and might find different tools useful.
  378. There’s no single ‘correct’ approach
  379. for writing all <span class="caps">CSS</span><span class="widont"> </span>everywhere.</p>
  380. <p>As long as it results in an
  381. accessible, resilient,
  382. and performant experience for users:
  383. <em>use whatever tools work best for<span class="widont"> </span>you</em>.</p>
  384. <p>(Anyone marketing their product
  385. as <em>The Only Solution™️</em> to some
  386. <em>Essential Problem with <span class="caps">CSS</span>™️</em>
  387. is selling you a religion,
  388. not a<span class="widont"> </span>tool.)</p>
  389. <p>It’s not my job to judge
  390. what tools are useful for other web developers.
  391. But it is my job to
  392. help people think about the <span class="caps">CSS</span> choices they make.
  393. So in that spirit, please<span class="widont"> </span>consider:</p>
  394. <p>⚠️🚨⚠️
  395. When tools intervene
  396. between you and your access to the web platform,
  397. <strong>proceed with caution</strong>.
  398. Ask not only: <em>How well does it work?</em>
  399. But also: <em>How well does it fail?</em>
  400. Not only: <em>What features do they provide?</em>
  401. But also: <em>What features do they prevent?</em><span class="widont"> </span>⚠️🚨⚠️</p>