<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Uri Kutner on Medium]]></title>
        <description><![CDATA[Stories by Uri Kutner on Medium]]></description>
        <link>https://medium.com/@urikutner?source=rss-a96e346f027------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*RTN-3kik6cszSPee.</url>
            <title>Stories by Uri Kutner on Medium</title>
            <link>https://medium.com/@urikutner?source=rss-a96e346f027------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 02:26:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@urikutner/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Processed Food Score]]></title>
            <link>https://medium.com/@urikutner/the-processed-food-score-00802a8f6c98?source=rss-a96e346f027------2</link>
            <guid isPermaLink="false">https://medium.com/p/00802a8f6c98</guid>
            <category><![CDATA[health]]></category>
            <category><![CDATA[nutrition]]></category>
            <category><![CDATA[ultra-processed-food]]></category>
            <category><![CDATA[organic]]></category>
            <dc:creator><![CDATA[Uri Kutner]]></dc:creator>
            <pubDate>Thu, 02 Apr 2026 19:13:06 GMT</pubDate>
            <atom:updated>2026-04-16T18:11:59.583Z</atom:updated>
            <content:encoded><![CDATA[<h3>How “Unprocessed” Is Your Food, Really?</h3><h4>A new score finally shows what nutrition labels hide</h4><p>Isn’t it weird that whole flour and bleached white flour have almost the same label, though we know one is much more natural than the other?<br>Similar calories, similar protein, and if anything, the white one has <em>more</em> vitamins listed. So which one is better?</p><p>Most of us know intuitively that whole wheat flour is healthier. But if you had to explain why, you’d struggle. The label doesn’t tell you that the white flour has residual chemical bleaching agents, that its biological structure was systematically destroyed in the process of making it, or that those added vitamins are synthetic replacement for the ones that were stripped out.<br>Is it better or worse? The difference is small on any given day. Across a lifetime of eating, it adds up and compounds, possibly shortening healthspan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UGTjQD4s8uO_-EGHTVB8rg.png" /></figure><p>We have remarkably precise tools to measure what a food contains. We have almost no measurement for what was done to it.</p><h3>Introducing: processing score</h3><p>The idea is simple — add a number per each operation the ingredient goes through.<br>In our example, we start with farmed wheat. It is already more industrialized from wild grain, with fertilizers and insecticides, and more complex than simple fruits, so we give it a score of 3.</p><p>3: base wheat.<br>+1: cleaning. We sift it, de-stone it, magnetize it to remove any metal bits, and scour it to remove the outer “fuzz” and dust.<br>+2: Tampering. Wheat is soaked for several hours to add moisture so it will grind more<br>+8: milling. The wheat is ground (whole or separately and then recombined) into a powder, partly breaking its structure.<br>+1: Sifting, rapid cooling, and packaging.</p><p><strong>Total score — 15</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V4fTq18N4zCowZcU2w_7eA.png" /></figure><h4>Bleached Flour</h4><p>The process is similar, but has more steps:</p><p>5: base wheat (x1.5 industrial)<br>+1: cleaning<br>+2: Tampering<br>+2: Separation and purification — cracking the grains open, undesired parts removed using air or nylon sheets and sold separately<br>+12: repeated milling to produce a fine powder.<br>+50: Bleaching. The flour goes through a chemical process to make it white, and break down its proteins to make it better for baking. This is not allowed in some countries, and instead replaced by a longer oxygenation process that is arguably less harmful.<br>+15: Enrichment. Because the bran and germ were removed during the purification step, the flour loses 80% of its nutritional value, and additives like iron, vitamin B, and sometimes calcium, are added to compensate.<br>+1: Sifting, cooling and packaging.</p><p>The resulting bleached white flour is incredibly fine and silky, with a shelf life of over a year, since there are no natural oils left to go rancid.</p><p><strong>Total score — 88</strong>. That’s almost 6x more processed.</p><p>Same material, different process, very different scores.<br>The same logic applies across the supermarket.</p><p><strong>Cold pressed olive oil scores about 13</strong>:<br>Olives (4) are washed (+1), crushed into a paste (+5?), mixed until smaller oil droplets coalesce into larger ones (+1), separated using centrifuges (+1), and finally purified through another vertical centrifuge (+1).</p><p><strong>Canola oil RBD processing scores about 177:</strong><br>Rapeseeds (3) are dehulled and flaked (+2), conditioned with steam (+3), and mechanically pressed (+3). The remaining oil is extracted using hexane solvent (+45), then degummed with acid (+18), neutralised with lye (+18), bleached (+50), and finally deodorised at 200°C+ (+35) — because after all that chemistry, the smell has to go.</p><p>I’d still use it for frying once in a while because it is cost effective, but I wouldn’t put it in any sandwich I make.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A5xGWpMUNqtjaJA69F3Zlw.jpeg" /><figcaption>Industrial production of cheese. (From Wikipedia)</figcaption></figure><h3>What are we measuring here?</h3><p>Is a score of 88 high? not very.<br>We are measuring how intact and available is the biological nutrient structure of the ingredient.</p><p>Foods go through a lot of processes before we eat them — mechanical, chemical, thermal, enzymatic. The more we break the ingredients down on a molecular level, the less “alive” and nutritious it is.<br>Can our body digest and use more synthetic forms of foods? absolutely.<br>Is it as good as something that is entirely natural and organic? I’m not sure.</p><p>The underlying assumption is that nutrients in their natural state are fully compatible with our cells — they have always been part of human and animal diets, and our biology is built around them. Processing erodes that compatibility: it breaks nutrient structures and introduces know toxic molecules (albeit, in minute scale) that are harmful at the cellular level.</p><p>Some processing is crucial. Pasteurisation, cooking, fermentation. Butter is processed, so is cheese, yogurt, bread, wine. Processing is not inherently bad — it’s what makes food safe, storable and often delicious.<br>The score doesn’t say “this is not edible”. It says “how is how far it travelled from its original state”. What you do with that information is up to you.</p><p>It’s also not a health score, rather, it’s another nutritional fact that could be vital for our health.<br>A granola bar, a glass of whiskey, and some artisan aged cheese might have a similar score, but one of those is clearly a better food choice. On the other hand, fresh pear is much better than a pear extract cake.</p><h3>Let’s make it standard</h3><p>Caloric labeling became fully mandatory in the US in 1994 (whaaat? that recent?). Before that, people had very limited means to know what nutrients were in their foods. Ingredients lists only came about in 1938.<br>A 200 calorie apple and a 200 calorie cookie are not the same thing, but it made people more informed about what was hiding in their foods.</p><p>We can do the same thing for processing. It’s pretty simple to score your product when you know exactly how you make it. Given a list of operations and their weights, any food producer could calculate it easily and deterministically. We can even round it off to hide “secret formulas”.</p><blockquote>I wouldn’t mind if this caught on as the Kutner Score, or Ku units. Just putting it out there.</blockquote><p>A standards authority could define the scoring in a much more accurate and appropriate form, and keep it easy to calculate. The number will go on the label, right next to calories.</p><p>Regulators won’t be telling anyone what to eat. They would just make something opaque visible, and differentiate natural products from more maximalist industrial ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*58enn_HKBEKHBMP3gehTHA.jpeg" /><figcaption>Mustard in various processed levels (from Wikipedia)</figcaption></figure><h4>What about NOVA?</h4><p>There is an existing system called <strong>NOVA</strong> that classifies foods into four categories: unprocessed, processed culinary ingredients, processed &amp; combined foods, and ultra-processed foods.</p><p>It’s a useful framework, but blunt. A fresh salad with olive oil lands is considered “processed food”, but drops to minimally processed if you eat them separately. It hides just how big the difference between fresh food and some man made products really is.</p><p>This score is more informative and continuous — the difference between a 15 and a 300 actually means something. It’s easy to calculate deterministically from known operations, and harder to argue over.</p><p>This system (<em>I’m really up for Kutner units or K Score if you’re for it</em>) is more informative, continuous, really easy to calculate, and is harder to mess around with.</p><h3>What do real foods actually score?</h3><blockquote>(This part is mostly reference. feel free to skim over)</blockquote><p><strong>These scores are approximations based on publicly available production methods and reasonable assumptions about standard industrial processes.</strong></p><p>A standards authority with access to exact formulations, ingredient sourcing, and processing parameters would produce more correct numbers. I used Claude to help develop and calculate these scores.</p><h4>Base ingredients</h4><p>Everything starts somewhere. Before any human intervention, every food ingredient has a baseline score reflecting its biological complexity — how many metabolic steps nature took to produce it, how much accumulated biological structure it carries, and how far it already sits from a simple plant in sunlight.</p><p>A fresh strawberry is about as close to ideal raw biological matter as food gets. It grows in sunlight, converts it to sugar, and you eat it. It scores <strong>1</strong>.x§</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lxZTGy8HOxKb06o3iAEg2g.png" /></figure><p>As ingredients become biologically more complex— their base score rises. It&#39;s an acknowledgment that red meat carries more biological complexity history than a carrot, and that history is full of cellular degradation our bodies have to handle.</p><ul><li>Water, mineral salt: <strong>0</strong></li><li>Fresh fruit (strawberry, apple, pear): <strong>1</strong></li><li>Vegetables, roots, leafy greens (carrot, spinach, potato): <strong>2</strong></li><li>Grains, legumes (wheat, chickpea, lentil, soy): <strong>2</strong></li><li>High-fat plants (olive, avocado, coconut): <strong>3</strong></li><li>Honey (raw): <strong>4</strong></li></ul><p>Animal products (might need to be higher)</p><ul><li>Milk, eggs: <strong>6</strong></li><li>Poultry, fish: <strong>8</strong></li><li>Red meat (beef, lamb): <strong>14</strong></li></ul><p><strong>Industrial farming: ×1.5</strong></p><p>Applied to any ingredient produced under industrial farming conditions — synthetic fertilisers, pesticides, antibiotics, growth hormones, tight living, unnatural feed.<br>You could argue about the multipliers of organic and free-range variants.</p><h4>Mechanical operations</h4><p>Physical restructuring without changing molecular chemistry. The least interventionist category.</p><ul><li>Rinsing / washing: <strong>+1</strong></li><li>Cutting / chopping: <strong>+2</strong></li><li>Crushing / pressing: <strong>+3</strong></li><li>Sieving / straining: <strong>+2</strong></li><li>Centrifugation: <strong>+4</strong></li><li>Grinding / milling: <strong>+8</strong></li><li>Industrial extrusion (shaping under pressure): <strong>+12</strong></li><li>High-pressure homogenisation: <strong>+18.</strong></li><li>Fractioning / wet milling: <strong>+35</strong>.</li></ul><h4><strong>Thermal operations</strong></h4><p>Heat denatures proteins, triggers chemical reactions, and progressively destroys biological structure. Damage accumulates over time but slows as the material stabilises.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UWEmSY0PjUxEK0GYNTZXCA.jpeg" /><figcaption>Baking in a hot oven (from Wikipedia)</figcaption></figure><p>Formula: coefficient × √(duration in minutes)</p><ul><li>Pasteurisation (72°C for 15 sec, or 135°C UHT flash): standard <strong>+8</strong></li><li>Sous vide (65°C) / gentle internal cooking: <strong>2x</strong> <em>(2h: +28)</em></li><li>Simmering (~94°C): <strong>6x</strong> <em>(90min stew: +57)</em></li><li>Boiling / steaming (100°C): <strong>8x</strong> <em>(12min pasta: +28)</em></li><li>Baking / roasting (internal temperature): <strong>4x</strong> <em>(45min: +27)</em></li><li>Maillard / char (usually surface only): <strong>15x</strong> <em>(10min grill: +47)</em></li></ul><p>Note: you’d notice that most forms of cooking usually reach very limited internal heat. For example, a loaf of bread or a grilled slab of meat might char on the outside, but reach limited temperatures on the inside.</p><p>We apply the calculation based on the relative weight.</p><p><strong>Freezing / drying:</strong></p><ul><li>Flash freezing: <strong>+5</strong>.</li><li>Spray drying: <strong>+20</strong></li><li>Freeze drying: <strong>+12</strong></li></ul><h4><strong>Chemical operations</strong></h4><p>Direct molecular intervention using external agents. Breaks and forms molecular bonds in ways that are largely irreversible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2QjnV5Mfr2fwqWFx3zmZaw.jpeg" /></figure><ul><li>Vinegar pickling: <strong>+8</strong></li><li>Nitrate curing: <strong>+18</strong></li><li>Acid / base treatment: <strong>+18</strong></li><li>Isomerisation: <strong>+25</strong>.</li><li>pH precipitation (clarification): <strong>+28</strong></li><li>Solvent extraction (e.g. hexane): <strong>+45</strong></li><li>Deodorising: <strong>+35</strong></li><li>Hydrolysis (acid or enzymatic): <strong>+40</strong>.</li><li>Bleaching: <strong>+50</strong></li><li>Interesterifaction / Starch modification: <strong>+45</strong></li><li>Hydrogenation: <strong>+60</strong></li></ul><h4><strong>Biological operations</strong></h4><p>Fermentation, aging, and brining transform food through living organisms or enzymatic activity. Gentler than industrial chemistry, but accumulate meaningfully over time. Biological activity plateaus as the environment stabilises — hence the logarithmic curve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gw4qcXQu5rUXWzvE2oU5oA.jpeg" /><figcaption>Sourdough starter (Wikipedia)</figcaption></figure><p>Formula: coefficient × ln(duration in hours)</p><ul><li>Aging (dry): <strong>0.8x</strong> <em>(6 months: +6.7)</em></li><li>Natural fermentation / brining: <strong>1.2x</strong> <em>(12h sourdough: +3, 6 month soy sauce: +10)</em></li></ul><h4>Additives:</h4><p>Additives are ingredients in their own right and have their own score, but their impact to food might be dramatically bigger than their relative weight. They can actively restructure the food matrix or interact with the body at concentrations under even 1%.<br>There are a lot of those, so here is a partial list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_RILtQF-Pa1nCjM-_l8F0A.jpeg" /></figure><ul><li>Natural colors (annatto, beet extract, beta-carotene): <strong>+3</strong></li><li>Salt (home-cooked levels): <strong>+3</strong>; industrial levels: <strong>+8</strong></li><li>Natural preservatives (citric acid, vitamin E): <strong>+10</strong></li><li>Industrial enzymatic treatment: <strong>+10</strong></li><li>Natural emulsifiers (lecithin, pectin, guar gum): <strong>+12</strong></li><li>Anti-caking agents (silicon dioxide): <strong>+15</strong></li><li>Humectants (glycerol, sorbitol): <strong>+20</strong></li><li>Flavour enhancers (MSG, disodium inosinate, guanylate): <strong>+20</strong></li><li>Phosphate salts (sodium tripolyphosphate, used in processed meat and cheese): <strong>+30</strong>.</li><li>Preservatives, synthetic (BHA, BHT, TBHQ, sodium benzoate): <strong>+35</strong></li><li>Synthetic colours (tartrazine, Red 40, Brilliant Blue): <strong>+35</strong></li><li>Emulsifiers (carrageenan, polysorbate 80, CMC, DATEM): <strong>+40</strong></li><li>Artificial sweeteners (aspartame, sucralose, acesulfame-K): <strong>+50</strong></li><li>Synthetic flavour compounds (ethyl vanillin, diacetyl, isoamyl acetate): <strong>+55</strong></li></ul><h4><strong>Combining ingredients</strong></h4><p>A dish score is the sum of its ingredients by weight, plus any operations applied to the dish as a whole.</p><p>Dish score = Σ(mass fraction × ingredient score) + Σ(dish operations)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3gcfJQfsFcWr2Co3Pmg95g.jpeg" /><figcaption>Making pancakes (<a href="https://commons.wikimedia.org/wiki/File:HK_Pancake_cooking_Sept-2010_Step_005_Mixing_all_ingredients_with_eggs_water_Chicken_powder.JPG">from Wikipedia</a>)</figcaption></figure><p>Example — sourdough bread:</p><p>flour 60% (11), water 37% (2), salt 2% (3), starter 1% (11)<br>→ weighted mean <strong>7.5</strong>.<br>Add fermentation 12h (+3), baking 45min internal (+27), Maillard crust 15% mass (+15)</p><p><strong>total: ~53</strong></p><p>(I am thinking a ingredients count as a flat bonus is called for, because ingredients do interact with each other)</p><h4><strong>Minimally processed foods</strong></h4><p>Single ingredients, one or two operations. Recognisably close to their source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rlBpe7tsQSa1LMGS-PVHyw.png" /></figure><ul><li>Tap water: <strong>3</strong> (filtration + chlorination)</li><li>🍊 Fresh squeezed orange juice: <strong>7</strong> (pressing + sieving)</li><li>🍯 Raw honey: <strong>11</strong> (enzymatic conversion + evaporation + straining)</li><li>Spices (dried, ground): <strong>11</strong> (drying + grinding)</li><li>🫒 Cold pressed olive oil: <strong>13</strong> (washing + crushing + malaxation + centrifugation)</li><li>Whole wheat flour: <strong>15</strong> (cleaning + tempering + milling + sifting)</li><li>Plain yogurt (organic): <strong>17</strong> (pasteurisation + fermentation 8h)</li><li>🍋 Preserved lemon: <strong>24</strong> (brining 30 days)</li><li>Sauerkraut: <strong>28</strong> (shredding + brining 4 weeks)</li><li>Muesli (raw oats + dried fruit): <strong>~28</strong></li><li>Hard boiled eggs: <strong>28</strong></li><li>🥩 Dry aged beef (grass fed) 30 day: <strong>30</strong> (aging only)</li><li>🍣 Steamed salmon, 15min: <strong>~32</strong>.</li><li>🧈 Butter (organic): <strong>33</strong> (pasteurisation + churning + centrifugation)</li><li>Prosciutto: <strong>37</strong> (salt curing + natural preservatives + aging)</li><li>Regular White flour (non-bleached): <strong>36</strong> (separation + milling + oxygenation)</li><li>🐔 Quick fried chicken breast: <strong>~37</strong></li><li>Cottage cheese: <strong>39</strong></li></ul><h4><strong>Moderately processed foods</strong></h4><p>Multiple operations or combined ingredients, still recognisably derived from their source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hwz-20M2Jzqf20dTaAo3Dg.png" /></figure><ul><li>Home made soy milk: <strong>42</strong> (soaking + grinding + boiling + sieving)</li><li>Fine white flour (non-bleached): <strong>45</strong> (same but milled finely)</li><li>🧀 Gouda: <strong>46</strong> (Pasteurisation + renneting + pressing + brining + aging 6 months)</li><li>🥩 Steak, grilled medium: <strong>~46</strong></li><li>Original margarine from beef tallow (Mège-Mouriès, 1869): <strong>50</strong><br>(Remember this when you get to the modern margarine)</li><li>🍞 Whole wheat sourdough bread: <strong>53</strong></li><li>Palm oil crude: <strong>55</strong> (pressing + boiling + centrifugation)<br>Note: contains saturated fats.</li><li>Smoked salmon:<strong> ~5</strong>5 (brining + smoking)</li><li>Tofu: <strong>55</strong> (soy milk process + coagulation + pressing)</li><li>Tempeh: <strong>55</strong> (cooking + fermentation 48h)</li><li>Traditional soy sauce: <strong>60</strong></li><li>🫘🥫 Canned beans: <strong>~60</strong> (beans + brining + high heat sterilisation)</li><li>🍗 Roast chicken (45min): <strong>~61</strong></li><li>🥖 White bread (non-bleached flour): <strong>65</strong></li><li>🥜 Natural peanut butter: <strong>68</strong> (roasting + grinding)</li><li>Tahini: <strong>71</strong> (roasting + grinding + sieving)</li><li>🍗 Fried chicken (breaded, home): <strong>~75</strong></li><li>White sugar (non-bleached): <strong>80</strong></li><li>Instant oats: <strong>~85</strong></li><li>Commercial yogurt flavored: <strong>~85</strong></li><li>Bleached white flour (US): <strong>88</strong></li><li>Beef stew: <strong>~88</strong></li><li>Commercial plain soy milk: <strong>91</strong> (industrial process + additives)</li><li>🍖 Braised beef, 90min: <strong>~99</strong></li></ul><h4><strong>Heavily processed foods</strong></h4><p>Products that go through significant chemical intervention, multiple stages, or substantial departure from source ingredients. The processing score starts telling a story the label doesn’t.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ztDpFze4FEckGkRz3Y3yA.png" /></figure><ul><li>🥤 Coca Cola: <strong>~100</strong></li><li>🌽 High Fructose Corn Syrup: <strong>~113</strong></li><li>Lemon concentrate: <strong>~120</strong></li><li>Ketchup EU: <strong>~120</strong></li><li>🥓 Bacon: <strong>~121</strong> (when fried: <strong>~150</strong>)</li><li>Slow cooked lamb, 4 hours: <strong>~126<br></strong>(up for debate, but yes, it is actually processed, just in home setting)</li><li>Ketchup US (w/ HFCS): <strong>~130</strong></li><li>🍞 Commercial white bread: <strong>~130</strong></li><li>🍊 Commercial orange juice: <strong>~135</strong></li><li>Corn flakes: <strong>120–180</strong></li><li>Sliced deli meat: <strong>~145</strong></li><li>White sugar (US; bleached): <strong>~153</strong></li><li>🏋️ Plain protein powder: <strong>~158</strong></li><li>Commercial white bread (US; bleached flour): <strong>~160</strong></li><li>Industrial soy oil: <strong>170</strong></li><li>Palm oil refined: <strong>175</strong></li><li>Canola oil: <strong>177</strong> (full RBD process)</li><li>🧀 American cheese: <strong>~185</strong></li><li>Commercial peanut butter: <strong>~190</strong></li><li>🍫 Sweetened milk drink (chocolate milk, commercial): <strong>~199</strong></li></ul><h4><strong>Ultra:</strong></h4><p>Products engineered in every aspect — taste, texture, nutritional profile, shelf life, and cost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ryu9j68v3Dr4F_-5CYWPhQ.jpeg" /></figure><ul><li>Mayonnaise commercial: <strong>~220</strong></li><li>Nutella: <strong>217–260</strong></li><li>Instant coffee mix: <strong>~226</strong></li><li>Canned soup with additives: <strong>~236</strong></li><li>Cereal bar: <strong>~240</strong></li><li>🍫 Chocolate bar: <strong>~257</strong></li><li>Commercial soft serve ice cream: <strong>~261</strong></li><li>Instant noodles: <strong>~270</strong></li><li>🍟 Reconstructed fried potato chips (Pringles/Doritos): <strong>~280</strong></li><li>Packaged bakeries (cookies, croissants, Oreos, muffins): <strong>220–278</strong></li><li>Chicken nuggets, reheated: <strong>~272</strong></li><li>Protein bar flavored: <strong>~280</strong></li><li>🌭 Hot dogs: <strong>~298</strong></li><li>Skittles: <strong>~299</strong></li><li>🍕 Frozen pizza: <strong>~300</strong></li><li>Meal replacement shake: <strong>~307</strong></li><li>Sugary kid cereal: <strong>~309</strong></li><li>Chewing gum, flavored: <strong>~313</strong></li><li>Reformed ham (spam): <strong>~321</strong></li><li>Energy drink: <strong>~330</strong></li><li>M&amp;M: <strong>~335</strong></li><li>Baby formula: <strong>~382<br></strong>(yes, baby formulas are some of the most engineered foods we have)</li><li>Vegan nuggets: <strong>~388</strong></li><li>🍽️ TV Dinner: <strong>~420</strong></li><li>Margarine: <strong>~445</strong></li></ul><h4>Baby formulas:</h4><p>I feel this subject is too delicate to be influenced by this score before rigorous real world research. The companies making the formulas clearly put enormous thought into nutritional completeness and quality, and in my research I found some alternative products claiming to be organic, and produce a lower score.</p><p>Using this score might optimize their production to produce better food for our young ones, and definitely could produce a category of “premium low-processed”.</p><h3>How much should we take?</h3><p>What’s the healthy level of processed-food (<strong>Ku </strong>× mass) intake?<br>That’s a harder question, but definitely an answerable one. It depends on body size, total food consumed, and some assumptions about how much synthetic material a body can handle before accumulating damage.</p><p>From what I can tell, lower is better — you don’t want to build yourself out of cardboard. I guess the ideal would be to keep most foods below a score of 100, while allowing some foods in the 100–200 range, with room for exceptions once in a while.</p><p>But, setting the actual recommendation is an important question that would set food production goals and standards. Answering it would be pretty difficult without proper research, so I’m leaving this one open for the standardizers.</p><p>Phew, that was long!<br>Actually looking up the products, assigning score and re-adjusting the formulas too much longer than I anticipated.</p><p>Do you have any thoughts? Would you want me to score inedible stuff like petrol, and Ikea furniture? Let me know in a comment!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00802a8f6c98" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simply explaining the Weak Force]]></title>
            <link>https://medium.com/@urikutner/simply-explaining-the-weak-force-965dc9e49313?source=rss-a96e346f027------2</link>
            <guid isPermaLink="false">https://medium.com/p/965dc9e49313</guid>
            <category><![CDATA[quantum-physics]]></category>
            <category><![CDATA[physics]]></category>
            <category><![CDATA[science]]></category>
            <dc:creator><![CDATA[Uri Kutner]]></dc:creator>
            <pubDate>Thu, 12 Mar 2026 17:44:36 GMT</pubDate>
            <atom:updated>2026-03-16T21:47:38.976Z</atom:updated>
            <content:encoded><![CDATA[<p><em>The force responsible for the sun, your existence, and almost nothing else you’ve heard of</em></p><blockquote><strong><em>I’m not a physicist. I could be extremely wrong. I asked Claude to explain it in plain but accurate language, and then tried to oversimplify it for you. If you find errors, I want to know.</em></strong></blockquote><p>The weak force has a reputation for being incomprehensible. Not because it’s genuinely mysterious — but because almost every explanation buries the simple thing under jargon and math, and no one quite articulated it yet.</p><p>Here’s the simple thing: mainly:<br><strong>The weak force changes what “flavor” particles are</strong>.</p><p>It also acts as an attraction/repulsion force like the electric force, but in scales too small to have an effect.<br>Because of this, a better name for it might be “The Small Force”, and I recon it might actually be pretty strong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*JAabZ0hlBghI6WWOXMcmjA.png" /></figure><h3><strong>What the weak force actually does</strong></h3><p>Really, it has only three interactions:</p><p><strong>The W- interaction</strong> <strong>— </strong>a neutron “spontaneously” becomes a proton, releasing an electron, an antineutrino, and energy.<br>This is called “beta decay”, and it’s so energetically favorable that a free neutron floating in empty space will decay within about 15 minutes.<br>No trigger needed. Just time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*D2lWO3ousQ_u1vmcP71kmA.png" /><figcaption>W- interaction</figcaption></figure><pre>neutron --W⁻--&gt; proton + electron + antineutrino + energy</pre><p><strong>The W⁺ interaction — </strong>the reverse. Under extreme pressure and heat, a proton absorbs energy and becomes a neutron, releasing a positron, and a neutrino. In the sun, this is the necessary first step in the creation of deuterium (hydrogen with an extra neutron) and nuclear fusion. Without it, the sun doesn’t burn.</p><pre>proton + electron + antineutrino + energy --W⁺--&gt; neutron<br><br>more correctly defined as:<br>proton + energy --W⁺--&gt; neutron + positron + neutrino<br><br>For atomic fusion, this means:<br><br>h1(proton + electron) + h1 + energy<br>  --W⁺--&gt; h2 (proton + neutron + electron) + neutrino<br><br>h2 + h2 --fusion--&gt; He4 + energy</pre><p><strong>The Z interaction</strong> — a particle interacts with another particle without either of them changing identity. Only momentum and energy are exchanged. This sounds boring until you realize neutrinos have no electric charge and don’t interact via the strong force — the Z interaction is the <em>only</em> way a neutrino can nudge anything without being absorbed.</p><h3><strong>The unit of the weak force: flavor</strong></h3><p>Every force acts on something. Gravity acts on mass. Electromagnetism acts on charge. The weak force acts on <strong>flavor</strong> — or more technically, <strong>weak isospin</strong>.</p><p>Electric charge is a single axis. A proton is +1, an electron is -1, and they attract each other. Simple.</p><p>Weak isospin is two-dimensional. Instead of a single number, particles occupy one of four states, which can be written as vectors:</p><ul><li><strong>[1, 0] — </strong>up quark, neutrino</li><li><strong>[0, 1] — </strong>down quark, electron</li><li><strong>[-1, 0]</strong> — anti-up quark, antineutrino</li><li><strong>[0, -1]</strong>— anti-down quark, positron</li></ul><p>The W boson <em>rotates </em>a particle between these states. [1,0] becomes [0,1]. That rotation is the entire weak force. There’s no equivalent in electromagnetism, because you need more than one axis to rotate.</p><p>Attraction and repulsion also happens. It’s not noticeable because the W and Z boson decay too fast.</p><p>This means the weak force genuinely cannot distinguish between a down quark and an electron — they’re both [0,1]. The difference between them is invisible to the weak force. Only the strong force can tell them apart, because quarks carry color charge and electrons don’t.</p><h4><strong>Beta decay in the new language</strong></h4><p>With this notation, beta decay becomes clearer:</p><pre>(neutron: [1,0], *[0,1]*, [0,1]) →<br>(proton: [1,0], *[1,0]*, [0,1]) + W⁻ →<br>(proton: [1,0], *[1,0]*, [0,1]) + (electron: [0,1]) + (antineutrino: -[1,0]) + energy</pre><p>One down quark flips to an up quark.<br>The W- boson carries away the difference and materializes as an electron and antineutrino. Everything else is conservation of weak isospin. The antineutrino isn’t a byproduct — it’s required by spin conservation. Pauli predicted its existence in 1930 purely because the energy accounting didn’t close without something invisible carrying the remainder.</p><p>Wild, isn’t it?</p><h4><strong>Why we barely notice it</strong></h4><p>The W and Z bosons are extraordinarily massive — about 80–90 times the mass of a proton. In accordance with mass/energy preservation, they cannot last long. The weak force operates at distances roughly 1000 times smaller than a proton. At those scales the interaction happens and is over before anything else can respond.</p><p>This is also why it <em>looks</em> weak. At the energy scales we live at, it barely reaches anything. But at high enough energies — the kind that existed just after the Big Bang, or that we recreate briefly in particle colliders — the weak force and electromagnetism become indistinguishable. They’re the same force. Unexplained, the Higgs field changed as the universe cooled, giving only W and Z bosons this large mass, which is what split one unified force into the two we observe today. Mass is not an intrinsic property of particles — it’s how strongly each particle couples to this background Higgs field. Photons don’t couple to it at all, which is why they’re massless and travel at C.</p><h3><strong>The symmetry ladder</strong></h3><p>Here’s where it gets structurally beautiful. Each force can be described by its symmetry group — the mathematical object describing which rotations leave the force unchanged:</p><ul><li><strong>U(0)</strong> — gravity (spacetime geometry itself, not a rotation in the traditional sense)</li><li><strong>U(1)</strong> — electromagnetism (one-dimensional phase rotation, one carrier: the photon)</li><li><strong>SU(2)</strong> — weak force (two-dimensional rotation, three carriers: W+, W-, Z)</li><li><strong>SU(3)</strong> — strong force (three-dimensional rotation, eight carriers: the gluons)</li></ul><p>The pattern — 0, 1, 2, 3 — suggests these aren’t four different things. They’re the same underlying structure at different scales of complexity. Electroweak unification confirms this at least for U(1) and SU(2): they’re experimentally proven to be one force at high enough energies. Physicists suspect SU(3) unifies with them at even higher energies, though this hasn’t been confirmed. Gravity remains the outsider that doesn’t yet fit.</p><p>One way to read this ladder: <em>symmetry is the actual fundamental thing</em>, and forces are just what different amounts of it look like.</p><h4><strong>The handedness problem</strong></h4><p>The weak force a unique property that sets it apart from every other force in nature: <strong>it only works on left-handed particles.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*znoUUmCH58DCg6IyZJdjfw.png" /></figure><p>Every particle has a property called chirality — loosely, it has one of two possible directions. The weak force exclusively couples to left-handed matter particles and right-handed antimatter particles. Their mirrors are completely invisible to it.</p><p>What this handedness really means is not yet clear, and remains only a mathematical property right now. Physicists use the more intuitive property “helicity” that is defined by whether the particle’s “spin” “with” or “against” the direction of particle as it moves through space. (yes those are a lot of loaded terms)</p><p>However helicity is only an approximation, because it changes with the speed of the observer — faster observer would “see” the particle moving backwards, but have the same spin.<br>This means that particles would either interact with the weak force or not, based on the observer’s relative speed. Two observers could see different things.</p><p>As physics sees it, the universe has a genuine, built-in asymmetry — left chirality vs right chirality, and helicity is only an approximation.</p><p>If you filmed a weak interaction and played its mirror image, the mirror version would never occur in nature. No other force has this property.</p><p>The consequences are enormous. Matter and antimatter <em>should have</em> been produced in equal amounts at the Big Bang, annihilating completely and leaving nothing but photons. Scientists say you exist because the weak force’s handedness asymmetry gave matter and advantage roughly one part per billion. Every atom in your body is that rounding error.</p><h4>The <em>Chirality Helicity Catastrophe hypothesis</em></h4><p>One unsupported hypothesis: chirality doesn’t exist, and helicity is the actual mechanism of weak force handedness.</p><p>The Standard Model says the weak force only couples to left-handed particles as defined by chirality, but offers no physical explanation for why.<br>Helicity — the alignment of a particle’s spin with its direction of motion — is frame-dependent: a faster particle observing a slower one sees its helicity flipped. In subatomic terms, “a faster observer” isn’t abstract — it means a faster particle physically present and interacting with it.</p><p>The hypothesis is therefore:</p><blockquote>Weak interactions are suppressed by faster particles in the local environment.</blockquote><p>The evidence is suggestive.</p><ul><li>Bound quarks in the atom nuclei are permanently bathed in gluons traveling at c — faster than any particle with mass can ever move. Nuclear neutrons don’t decay.</li><li>Free neutrons, lacking that external gluon field, decay in 15 minutes.</li><li>The top quark decays weakly before its gluon field fully forms — the one quark without the shield, and the only one that immediately decays weakly.</li><li>Neutron stars present a harder case for the Standard Model. Nothing prevents antineutrinos from escaping a neutron star — they interact with almost nothing. If weak decay were merely suppressed by filled energy states, the star should still bleed mass slowly through antineutrino emission. The Standard Model’s answer — Pauli exclusion blocks the products — describes a result, not a mechanism. This hypothesis describes a mechanism: the neutron star’s dense, fast, radiation-filled environment suppresses weak interactions at the source.</li></ul><p>The Standard Model explains each case separately. This hypothesis explains them with one mechanism. “Faster particles suppress Weak interactions” is itself an unexplained cause — but it is at least an explained mechanism, which is more than chirality currently offers.</p><p><em>There is </em><strong><em>no formal mathematical backing</em></strong><em> this, and no experiment has been designed to test it. If you’re a physicist and this is obviously wrong — or interesting — both responses are welcome.</em></p><h3><strong>The open questions</strong></h3><p>This is where established physics ends and honest uncertainty begins.</p><ul><li><strong>Why does [1,0] have more energy than [0,1] in some cases but not others?</strong> The mass values of quarks and leptons are just measured and plugged into the Standard Model. Nobody derives them from anything deeper. The Higgs field gives particles mass, but why each particle couples to the Higgs with a specific strength is unexplained.</li><li><strong>The Higgs field dictates everything but explains nothing.</strong></li><li><strong>Why are there three generations?</strong> The pattern repeats three times — (neutrino, electron), (up, down), (charm, strange), (top, bottom).<br>Each generation heavier than the last. The first — has no color charge. The Standard Model accepts this without explaining it. Three generations. Three color charges in the strong force. The same number appearing twice might be coincidence. It might not be.</li><li><strong>What are neutrinos, really?</strong> They oscillate between three flavors as they travel — which is only possible if they have mass — but the Standard Model originally predicted them to be massless. We don’t know the mechanism that gives them mass. Right-handed neutrinos, if they exist, would interact with nothing whatsoever — no electromagnetic force, no strong force, no weak force — making them completely undetectable except gravitationally. These “sterile neutrinos” are one of the more compelling dark matter candidates.</li><li><strong>Could there be deeper structure?</strong> Quarks were predicted from symmetry patterns before they were confirmed experimentally. The three-generation pattern of leptons and quarks looks similar to how quark patterns revealed the strong force’s structure. If sub-quark particles, known as “preons”, exist, they’d explain generation structure the way quarks explained the hadron zoo. We haven’t found them — but we may simply lack the energy to break that deep.</li><li><strong>Could the symmetry ladder continue?</strong> SU(6), which contains SU(3)×SU(2) as subgroups, is a candidate unification group. String theory suggests infinitely many force-like structures at increasingly high energies, each requiring more energy to access than the last — similar to how different numbers of protons make different atoms, except the fundamental unit is symmetry itself, not protons. Most combinations would be unstable, like heavy elements. We’d be living near the bottom of an infinite periodic table of forces, able to see only the first few rows.</li></ul><h3><strong>What the weak force is, in one paragraph</strong></h3><p>The weak force is a rotation in a two-dimensional internal space called weak isospin.<br>It flips particles between two states — <strong>up-type</strong> and <strong>down-type</strong> — by exchanging massive carrier particles called <strong>W and Z bosons</strong>.<br>We know it only acts on left-handed particles, which is why the universe is made of matter rather than nothing. In high enough energies it unifies with electromagnetism, separates from it in low energies by the Higgs field, and probably unified with the strong force at even higher energies we can’t yet reach. It operates at scales smaller than a proton, lasts for timescales too short to name, and is responsible for the energy of the sun, radioactive decay, and your existence.</p><p>It’s called the weak force because its carriers are heavy and its range is short. A better name might have been <strong>the small force</strong>. The strength, if you could reach it, might surprise us.</p><p><em>Thanks to Claude for the lengthy conversation and explainations that this article is based on, and for putting it together.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=965dc9e49313" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The complete and simple guide to interactive element states]]></title>
            <link>https://medium.com/@urikutner/the-complete-and-simple-guide-to-interactive-element-states-8c456b1aac17?source=rss-a96e346f027------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c456b1aac17</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[interaction]]></category>
            <category><![CDATA[accessibility]]></category>
            <dc:creator><![CDATA[Uri Kutner]]></dc:creator>
            <pubDate>Wed, 12 Jul 2023 16:18:57 GMT</pubDate>
            <atom:updated>2023-07-19T12:33:06.026Z</atom:updated>
            <content:encoded><![CDATA[<h3>HTML Interactivity &amp; States</h3><p>Interactions are little signs that tell your user — “hey! you are interacting with an element. Your actions have consequences”. They empower visitors, and guide them through the things you want them to accomplish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LtPexpUGupjSPFwh3YZw3A.png" /><figcaption>The many interactions of a button. Live demo <a href="https://kutneruri.github.io/demo-interactions/">here</a>!</figcaption></figure><p>And yet, many websites and elements don’t bother making any interactions at all. It’s rather sad really, because these little interaction are simple to add, and makes things a lot more intuitive for the user.</p><h3>When to use interactions?</h3><p>This one is more simple than you’d think. <strong>If the user <em>can interact</em> with the element, the element should respond</strong>. Newton’s first law, or something.</p><p>Ain’t that simple? Now, let’s see it in code:</p><pre>function Button({ onClick, interactive = !!onClick, ...props }) {<br>  const classes = [props.className, interactive &amp;&amp; interactiveStyles]<br>    .filter(x =&gt; !!x)<br>    .join(&quot; &quot;);<br><br>  return &lt;button {...props} onClick={onClick} className={classes}/&gt;;<br>}</pre><p>I find having onClick is a good enough indicator that an element has an action, though it can be enabled manually.</p><h3>How to signal interactivity?</h3><p>You can tell if an interaction is good, if it will work in a movie scene.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*yGafA2mWtW7C9o-SPWS8LA.gif" /><figcaption>If Tom Cruise would, could you?</figcaption></figure><p>If a movie audience can <strong>understand what’s happening without thinking too hard</strong>, then <strong>your users should be able to do the same</strong> with your product, and even bystanders just sitting nearby. This can make your application intuitive, pleasant, and a beacon of quality that everyone will want to use. Basically, it will be Steve Job level product. 😎</p><p>The rule is rather simple:</p><blockquote>if an element is <strong>actionable</strong>, it should be <strong><em>prominent</em></strong>.<br>This is particularly true when the user is <strong>actively interacting</strong> with the element!</blockquote><p>While you want to minimize the overall attention grabbing, you do want to draw the user’s attention to actionable items, as actions have consequences. If you don’t want the clutter, just remove the element — tuck it in a menu if you have to.</p><p>We have a couple of tools for this in our utility belt. To draw attention to actionable elements, we can leverage the human eye’s sensitivity to motion, change, contrast, size, etc.<br>I will delve into these factors in a separate article.</p><h3>What interactions should we have?</h3><p>Let’s start with the obvious:</p><pre>.interactive {<br>  cursor: pointer; // duh<br>  user-select: none; // to prevent accidental copying. use with care<br>}<br><br>.interactive:disabled {<br>  cursor: not-allowed; // opinionated, but quite common<br>}</pre><p>Then, you should make sure every way the user can interact is be visually represented. Just follow this check list! 🙂</p><h4>:resting</h4><p>This is the state where you element starts, and what designers always provide. Remember, even a resting item should be <strong>more prominent than regular elements</strong>, because it is hinting actionability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*cKeKY27RXlZM7MxqBJjLmg.png" /><figcaption>Initial state — no animation</figcaption></figure><h4>:hover</h4><p>If a user can click on a button, he should know that <strong>BEFORE</strong> clicking on it.<br>This behavior might be very <em>important in VR devices</em> 😉.</p><p>Some older touch devices used to emulate :hover when pressing on the element, and then require a second press to actually activate it.<br>If this is a <strong>concern for you, consider disabling :hover styles</strong> in mobile. (You can use special media queries, but it might be easier to add a special class to the root).</p><figure><img alt="Interactive element when hovered" src="https://cdn-images-1.medium.com/max/580/1*UYGChJ-QMEheLg0OHp9BFg.gif" /><figcaption>“click me Seymour! 🪴”</figcaption></figure><p>I would <strong>discourage moving the element during the hover effect</strong>, (ie by using transform: translate() or shrink using scale()), because it can move the element away from the cursor (in some edge cases), and cause visible gitter.</p><h4>:active (clicking, pressing)</h4><p>This one is pretty straightforward, reacting to the user action, but I think the hidden message here is to remind the user he can still disengage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*Hc6GRhCyc3Ku-BBzYmp5Ew.gif" /></figure><p>In this active effect, I added a shake animation after a delay, to let the user know the button is still being pressed. After holding down the button, I disengage by moving the cursor outside. This can also be done when navigating by keyboard by jumping to the next element.</p><h4>:focus (keyboard navigation)</h4><p>Precise cursor or touch controls are not the only way to navigate the app. many users <strong>opt to use they keyboard </strong>for its efficiency, <strong>especially around forms</strong>, and some are forced to use joystick inputs like in car multimedia or TV remotes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*389mBOHwp-4F9copkraTXQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*1xS3eDJXsr3oi4MP9rvDuQ.jpeg" /><figcaption>For some users, a joystick controller is the only option</figcaption></figure><p>Historically, Browsers have been using outline, a kind of a second border that marks the focused element. Some people hate it, and in very rare edge cases it can get really ugly, which is why some developer choose to <strong>remove it altogether, which is a big no-no</strong>.<br>I used square corners and a shadow, in addition to the built-in outline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*GFB5O0oEJD5oSS5Q_8h2kw.gif" /><figcaption>keep your eyes on the ball</figcaption></figure><p>You can use the :focus-visible selector, which will only show up when actually using the keyboard, or for any element which supports keyboard input (like a text input). Browser support is limited, refer to this <a href="https://css-tricks.com/focus-visible-and-backwards-compatibility/">css trick</a>:</p><pre>button:focus { /* some exciting button focus styles */ }<br>button:focus:not(:focus-visible) {<br>    /* undo all the above focused button styles<br>       if the button has focus but the browser wouldn&#39;t normally<br>       show default focus styles */<br>}<br>button:focus-visible { /* some even *more* exciting button focus styles */ }</pre><p>In this example, I left out the default outline behavior, which seems quite nice, so it will still work in older browser without additional code.</p><h4>:disabled</h4><p>Disabling an element signifies that it exists (duh), but cannot yet be interacted with. We can easily indicate that with a simple 0.38 opacity, and possibly a loss of saturation (graying it out), which lowers its prominence (contrast) and “vitality”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*1YaZ-T4baRLT78GnrVFyxQ.gif" /></figure><p>Remember to undo other interactions styles when disabled!</p><h3>Non standart interactions</h3><p>While not standard, I also like having these interactions:</p><h4>Loading</h4><p>This is an easy win — for long asynchronous actions, we can show a loader to hint that the interaction is still ongoing. Very intuitive for the user, and it alleviates the need for a separate spinner.</p><p>You can use the promise from the action (ie, the return value of the onClick) to know how long the action is running.<br>It seems wise to also (optionally) disable the element while loading.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*9TA1Sdb8j3uL41KUUi9QJQ.gif" /></figure><h4>:checked (“activated” or on/off)</h4><p>Often referred to as “on/off”, :checked is more common than you’d expect. Think of a “shuffle” button, or a search filter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*WyA_WKdVWBfP-vdRsGEMPg.gif" /><figcaption>Shuffle button in Spotify has on/off states</figcaption></figure><p>Ideally, you should <strong>implement it with a hidden input and a label</strong>, but you might get away with role=&quot;switch&quot; and aria-checked=&quot;true.<br>Remember, <strong>not all users will perceive visual cues</strong>, so using a real checkbox (even if hidden) or the aria/role properties will make a big difference.</p><p>When it comes to naming, I have found two options: checked, which is more like the standard html, and on={boolean}, which is more intuitive.<br>Interestingly enough, MaterialUI v2 had “selected”, “activated”, and “on/off” states, but later streamlined to just “activated” in v3 — minimalism wins, I guess.<br>I find that activated is more confusing than helpful, because some people mistake it for the :active pseudo-selector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*GWXpPIV7oVM0iY3PXAj26A.gif" /><figcaption>“Wax on, wax off 🥋🧽”</figcaption></figure><p>In this case, I’ve used ● (full dot) and ○ (empty dot) to signify the state, with an added touch of inset shadow for depth. Ideally, the two states should be symmetrical in design.</p><p>Remember, this is just one approach, and your design could vary wildly depending on the use case.</p><h4>Dragged</h4><p>Dragging is a less common interaction, though it is still prevalent. Styling will adhere to your specific use case, though it is common to include a <strong>handle</strong> (to hint of draggability), and use an <strong>elevation effect</strong> with shadows while dragging.</p><h4>Error and Success</h4><p>Another easy win is a built-in success and error states. They effectively communicate that the action started by this element has come to completion or failure, and frees the developer from additional feedback.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*fWpzTnKksyMr-SyeatNG1Q.gif" /></figure><p>I used a state machine to show a success message when the action promise is resolved, and a error message when it is rejected. The success message goes away automatically, the error requires another click to reset.<br>I used Intents (see separate article <a href="https://medium.com/@urikutner/powerful-design-with-priority-intent-39b3e04b7c6d">here</a>) to color the element, though it needs a little bit more tinkering (for example, a danger button shouldn’t turn green “success” when it completes. Maybe neutral gray instead)</p><h3>What’s next?</h3><p>I had a lot of fun researching this paper, playing around with states, and refining my experience from the last 11 years. I hope you liked it too, and of course, if I missed anything, let me know of your insights.</p><p>You can find all of the source code here. Have fun!<br><a href="https://github.com/KutnerUri/demo-interactions">https://github.com/KutnerUri/demo-interactions</a></p><p>Want a live demo? no problem!<br><a href="https://kutneruri.github.io/demo-interactions/">https://kutneruri.github.io/demo-interactions/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c456b1aac17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Powerful design with Priority & Intent]]></title>
            <link>https://medium.com/@urikutner/powerful-design-with-priority-intent-39b3e04b7c6d?source=rss-a96e346f027------2</link>
            <guid isPermaLink="false">https://medium.com/p/39b3e04b7c6d</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[ux-design]]></category>
            <category><![CDATA[design-system-tips]]></category>
            <dc:creator><![CDATA[Uri Kutner]]></dc:creator>
            <pubDate>Tue, 13 Jun 2023 13:21:37 GMT</pubDate>
            <atom:updated>2023-07-15T10:59:31.669Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using ‘priority’ and ‘intent’ to instill semantic meaning in design system variants.</h4><p>In this article, we delve into a systematic and efficient approach for managing variants in a design system. By using two semantic metrics — “priority” and “intent” — we can bring consistency and intuitive design across all use cases.</p><p>Handling variants in a design system is a UI/UX challenge. Initially, a design system may use one component <em>look</em> for all needs. But as designers create more <em>looks</em>, this leads to an inconsistency that degrades user experience and maintenance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oODOgbsLYSVr2ywViHpOpA.png" /><figcaption>The many variants of a button (from bit.cloud)</figcaption></figure><p>These <em>variants</em> often arise on-the-fly from adapting a component to specific needs without much thought, causing missing user interactions, theming issues, and maintenance burden.<br>Initially, I grouped all variants in one folder, extracting shared code for uniformity. Yet, it still felt cluttered. Then, I realized these variants were all the same component, just with different “priority” and “intent”.<br>Adding these parameters enable controlled, consistent adaptation.</p><p>Here’s an example:</p><pre>&lt;Button&gt;default button&lt;/Button&gt;<br><br>&lt;Button priority=&quot;cta&quot;&gt;BUY NOW!&lt;/Button&gt;<br><br>&lt;Button priority=&quot;low&quot; intent=&quot;danger&quot;&gt;delete post&lt;/Button&gt;</pre><p>As you can see, the code expresses the buttons <em>purpose</em> rather than their <em>appearance</em> (form follows function, if you’d like). This simplifies theming with clearer design tokens, and it facilitates seamless design replacement:</p><pre>// old design &#39;idustrial&#39;<br>import { Button } from &#39;industrial-design&#39;;<br><br>// new design &#39;modern&#39;<br>// seamlessly replaces &#39;modern&#39;<br>// thanks to the common interface<br>// (html button + priority + intent)<br>//<br>// just find &amp; replace<br>import { Button } from &#39;modern-design&#39;;<br><br>// remember to visually inspect!<br>&lt;Button&gt;default button&lt;/Button&gt;<br>&lt;Button priority=&quot;cta&quot;&gt;BUY NOW!&lt;/Button&gt;<br>&lt;Button intent=&quot;danger&quot; priority=&quot;low&quot;&gt;delete post&lt;/Button&gt;</pre><p>Let’s explore this system’s implementation and advantages.</p><h4>A word about “Primary” and “accent”</h4><p>Before we proceed, we need to talk about the term “primary”.<br>The term “primary color” in design can be misleading, as it suggests it is the default, but in reality, it’s used more for emphasis. Instead, let’s use the term <strong><em>accent color</em></strong>, which truly represents its eye-catching role. This redefinition will be very useful in the implementation phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*Lu6UtrpFcXY6eFwk3h_hUw.png" /><figcaption>A room designed with a baby-yellow (accent) on a white-gray background</figcaption></figure><p>With that out of the way, let’s get started!</p><h3>Priority</h3><p><em>Priority</em> communicates a component’s <strong><em>prominence</em></strong>, or its its capacity to demand attention and stands out. We can implement priority with various visual aspects, like accent colors, border, or a backdrop.</p><figure><img alt="video demonstrating how the button looks under the 3 priorities" src="https://cdn-images-1.medium.com/max/700/1*_AakAOGjpJysd102rh0BXA.gif" /></figure><p>Using priority is as simple as:</p><pre>&lt;Button priority=&quot;low&quot;&gt;low&lt;/Button&gt;<br>&lt;Button&gt;medium&lt;/Button&gt;<br>&lt;Button priority=&quot;cta&quot;&gt;Call To Action&lt;/Button&gt;</pre><p>High <strong>priority elements pave a path</strong> for your user, and therefor your application should have <strong>no more than one <em>call to action</em></strong> at any give view. <em>Default priority</em> form the core of the user experience, while <em>low-priority</em> elements are ideal when you have a lot of small interactive options.</p><p>Deciding on the terms for these priorities posed a challenge. Simple terms like <em>“low”</em>, <em>“medium”</em>, and <em>“high”</em> are prone to misuse. Making <em>“default”</em> synonymous with “medium” and offering a short <em>“low”</em> and an explicit <em>“CTA” </em>seemed to strike a balanced middle ground.</p><p>Your project may call for different terms, and if that’s the case, I’d love to hear your ideas. <strong>Please share your thoughts in the comments below.</strong></p><p>In implementing these variants, I utilized HTML data properties together with static CSS. This is a little easier to debug and has good performance, streamlining the design workflow. It looks like this:</p><pre>// button.module.scss<br><br>.button {<br>  //...<br><br>  &amp;[data-priority=&quot;low&quot;] {<br>    border: 2px solid transparent;<br>    background: transparent;<br>    color: var(--accent-color);<br>    //...<br>  }<br><br>  &amp;[data-priority=&quot;medium&quot;] {<br>    border: 2px solid var(--accent-color);<br>    background: transparent;<br>    color: var(--accent-color);<br>    //...<br>  }<br><br>  &amp;[data-priority=&quot;cta&quot;] {<br>    border: 2px solid var(--accent-color);<br>    background: var(--background-accent);<br>    color: var(--on-accent);<br>    //...<br>  }<br>}</pre><pre>export const ModernButton = ({ priority = &quot;low&quot;, ...props }: Props) =&gt; (<br>  &lt;button data-priority={priority} className={styles.button} {...props} /&gt;<br>);</pre><h3>Intent</h3><p>“Intent” communicates the semantic meaning of an element. Unlike <em>Priority</em>, which influences the prominence of an element, <em>Intent </em>controls its meaning, or rather, the emotion associated with it.</p><pre>&lt;Message intent=&quot;success&quot;&gt;Operation Successful&lt;/Message&gt;<br>&lt;Message intent=&quot;danger&quot;&gt;Something Went Wrong&lt;/Message&gt;</pre><p>Intents are most simply expressed through color, but they can extend to unique styles too. For instance, a “warning” intent might include an exclamation mark symbol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*fCQh5A1I8dhLYX-rJSAvHg.gif" /></figure><p>Semantic naming is vital for intents. Using “warning” instead of “yellow” ensures a consistent interpretation of the component’s intent across various themes, independent of the actual color used.<br>For example, check out these components as they turn cyberpunk:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SkbB42Os9dbBTfhHAPMiDQ.gif" /><figcaption>Intents could be rendered differently in different themes and designs. Never call them by their form!</figcaption></figure><p>Here is an example implementation of intent:</p><pre>[data-priority=&quot;low&quot;] {<br>  [data-intent=&quot;success&quot;] {<br>    color: var(--success-color);<br>  }<br>}<br><br>[data-priority=&quot;medium&quot;] {<br>  [data-intent=&quot;danger&quot;] {<br>    color: var(--danger-color);<br>    background: var(--danger-bg-color);<br>    border-color: var(--danger-color);<br>  }<br>}<br><br>[data-priority=&quot;cta&quot;] {<br>  [data-intent=&quot;warning&quot;] {<br>    color: var(--on-warning-color);<br>    border-color: var(--warning-color);<br>    background: var(--warning-bg-color);<br>  }<br>}<br><br>// 6 more cases... </pre><p>Does it seem repetitive? Yes, it does. But remember, this level of detail in CSS lets you fine-tune styles for each variant, and SASS scripting can do the heavy lifting (just ask ChatGPT!).</p><p>More interestingly, we can leverage CSS variables and the cascading nature of CSS for a more elegant solution — as we will see in the next section.</p><h4>Cascadability</h4><p>One of the remarkable aspects of this system is its ability to apply themes across entire component trees.<br>By <strong>leveraging the inherent cascading</strong> nature of CSS, we can establish a “micro-theme” of consistent aesthetics and functionality over composite components. A good example of cascading themes would be a dashboard, where different sections can adapt their look based on the overall system status. This mechanism streamlines the theming process, without having to write so much boilerplate.</p><pre>// accents.module.css<br>.danger {<br>  --accent-color: var(--danger-color);<br>  --on-accent-color: var(--on-danger-color);<br>  --accent-bg-color: var(--danger-bg-color);<br>}<br><br>// ...</pre><pre>// app.tsx<br>import accents from &#39;accents.module.css&#39;;<br><br>function Dashboard({ statuses }) {<br>  return &lt;div&gt;<br>    &lt;StatusCard className={accents[statuses.all]} /&gt;<br>    &lt;StatusCard className={accents[statuses.deployment]} /&gt;<br>    {/* ... */}<br>  &lt;/divs&gt;;<br>}</pre><p>In this example, we pass the status prop to the Dashboard component. It then applies the appropriate accent class to the StatusCard, and all child components inherit the same style and adapt seamlessly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bKOrfBCugp4mkkYYuvhBeQ.gif" /><figcaption>Applying different accents to all of the components in Card D.</figcaption></figure><p>In my experience, these cascading styles are enough to cover most cases, though you may still want the more granular approach from the previous section. For example, it can tweak form inputs, and icon-status.</p><h4>Crafting Intents</h4><p>Even though we often use intents like <em>‘default’, ‘neutral’, ‘success’, ‘warning’,</em> and <em>‘danger’</em>, you can still be creative.</p><p>I personally like using intents based on <em>Magic: The Gathering</em> or the <em>Wu-xing </em>philosophy. Their completeness make the intents more robust. For instance, I improved the terminology by using <em>“danger”</em> instead of <em>“error”.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6qCAcdVcDEYp286L7c0jPg.png" /><figcaption>A word cloud for MTG’s 5 elements, based on the moral foundation of each color</figcaption></figure><p>What I like about it is that every color carries a certain emotion and moral ideal, which helps communicating the intent to the user.</p><p>Remember that you can make every color either positive or negative, depending on the project style and design choices!</p><h3>Retaining State</h3><p>One of the approaches I tried was to create a distinct components for each variant, as a good for separation of concerns. Yet, given how React and the DOM function, this actually disrupts user experience!<br>For instance:</p><pre>function SettingsPage() {<br> const [isModified, setModified] = useState(false);<br> return isModified ? &lt;CTAButton&gt;Save&lt;/CTAButton&gt; : &lt;Button&gt;Save&lt;/Button&gt;;<br>}</pre><p>Toggling will cause React to unmount CTAButton and mount Button<strong>, breaking ongoing animations and state</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*rEtiERwpNKgHJSRw9W8skQ.gif" /><figcaption>Losing state and transition when swapping components</figcaption></figure><p>In contrast, this unified system might demand more in maintenance, but it gives us the critical benefit of keeping the state intact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*hp-iuGKCnvRNK2qab9MO_g.gif" /><figcaption>Smooth transition within the same component</figcaption></figure><p>You can also arguably claim that it makes the code more readable:</p><pre>function SettingsPage() {<br> const [isModified, setModified] = useState(false);<br> return &lt;Button priority={isModified ? “cta” : undefined}&gt;Save&lt;/Button&gt;;<br>}</pre><p>For maintenance, the key lies in a minimal well thought design. If your variants still get too complex, I suggest separating the styles into different files.</p><h3>Interaction States</h3><p>Designing interaction states is an integral part of component design, and it is <strong>essential to include them when creating variants</strong>.</p><p>You can read all about it in <a href="https://medium.com/@urikutner/the-complete-and-simple-guide-to-interactive-element-states-8c456b1aac17">this article</a>!</p><h3>Conclusion</h3><p>We delved into the benefit of ‘priority’ and ‘intent’ in design systems. <em>‘</em><strong><em>Priority</em></strong><em>’</em> controls visual <em>prominence</em> and efficiently guides user attention. <em>‘</em><strong><em>Intent</em></strong><em>’</em> adds meaning, enhancing <em>semantics</em>. Despite their obvious value, these principles are rare in design. I hope they’ll be widespread by the time you read this.</p><p>Naming can be tough,<strong> if you have some ideas, share your thoughts</strong>! Also, if you found this insight useful, please clap and subscribe for more.</p><p>Happy designing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39b3e04b7c6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The new JS-in-CSS]]></title>
            <link>https://medium.com/@urikutner/the-new-js-in-css-5fd9908a48ea?source=rss-a96e346f027------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fd9908a48ea</guid>
            <category><![CDATA[linaria]]></category>
            <category><![CDATA[next-generation]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[css-in-js]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Uri Kutner]]></dc:creator>
            <pubDate>Mon, 29 May 2023 16:28:11 GMT</pubDate>
            <atom:updated>2023-06-05T08:21:20.552Z</atom:updated>
            <content:encoded><![CDATA[<p>A Shift in CSS Technologies</p><blockquote>TL;DR:</blockquote><blockquote>This article dives into Linaria, an underappreciated tool that uses JavaScript to generate CSS statically. The result? Regular CSS code with optimal performance. If this piques your interest or you find it useful, don’t forget to give a clap at the end. Read on to learn more about this JS-in-CSS revolution.</blockquote><p>Historically, CSS has evolved significantly. It started as a simple language for styling web pages, was enhanced in 2006 with <a href="https://sass-lang.com/"><em>SASS</em></a>, and as the scale of web development grew, we faced issues such as class name clashes. This issue naturally led to the development of <a href="https://github.com/css-modules/css-modules"><em>CSS Modules</em></a> in 2015. By using a unique hash for each class name, it prevented two developers from accidentally using the same name. It also provided the first link between <strong>JavaScript and CSS</strong>.</p><p>But this encapsulation came with its own problems — the unique class name is computed at build time, making it inaccessible and essentially a black box. While <em>CSS Modules</em> was designed as a set of transparent modules that could be interlinked, actual implementation was certainly lacking. This effectively locks us out of customization, especially for deeply nested components.</p><figure><img alt="CSS Modules transforming CSS" src="https://cdn-images-1.medium.com/max/1024/1*ZvOSUNDVBYtcG4_Az99Ipg.png" /><figcaption>Isolated and linked CSS made by CSS Modules</figcaption></figure><p>As a response to this black-boxing, <a href="https://styled-components.com/"><em>styled-components</em></a> emerged in 2016 (surprisingly, by the same team who created <em>CSS Modules</em>) and introduced a more dynamic approach to styling, which included overrides and theming. This marked the beginning of the <strong>CSS-in-JS</strong> era.<br>However, this approach came with its own set of issues, namely a <strong>drop in performance</strong> due to parsing and merging large CSS literals. This impact becomes apparent as a project grows, revealing the issue only when the scale is large and the technology deeply integrated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*48opOy5uCjXySzXPAvK_rg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*pI2is8vYuvASjD7iqJX84w.png" /><figcaption>Dynamic CSS generated by styled-components, using a babel plugin</figcaption></figure><p>If you wondered how other CSS-in-JS frameworks work, they are pretty similar — in runtime, and not very performant:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*iFjz5WMjmBS5RvI6AYSIeA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*arqDqsI3XOjhv92Rqc9KTQ.png" /><figcaption>Output <em>CSS-in-JS</em> with Emotion (left) and Stitches (right)</figcaption></figure><p>So for a while, I used a combination of<em> CSS Modules</em> and <em>SASS</em>, which worked decently despite the black-boxing issue. With the widespread adoption of CSS variables, I was even able to set up theming without using JavaScript.</p><p><a href="https://www.wix.com/">Wix</a> offered a potential solution to the extendability problem with <a href="https://stylable.io/">Stylable</a>. Stylable aimed to be the TypeScript of CSS, but it didn’t gain much traction, likely due to its complexity and some missing features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nYbqZEPPHTDfHZ6hQdgkKQ.png" /><figcaption>Styleable, a neat and static CSS language</figcaption></figure><h3>Goals for an Ideal CSS Framework</h3><p>Before diving into the potential solutions, let’s lay out the <strong>bare-minimum requirements</strong> for our ideal CSS framework:</p><ul><li><strong>Standard CSS adherence</strong>: It should stick to standard CSS as much as possible, both in behavior and output. Deviations will need a strong justification.</li><li><strong>Nesting syntax</strong> support.</li><li><strong>Zero runtime</strong>: Must be fully static out of the box.</li><li><strong>Composition and overrides</strong>: Necessary for flexible customization.</li></ul><p>Additionally, these are the <strong>nice-to-haves</strong>:</p><ul><li><strong>Option for Dynamic CSS</strong>: Useful for setting CSS variables or using user input.</li><li><strong>Some scripting capability</strong>: E.g., loops for writing more efficient CSS.</li><li><strong>Modern optimization techniques</strong>: Tree shaking, de-duping, etc., for lean, efficient CSS.</li></ul><h3><strong>A New Approach: JS-in-CSS</strong></h3><p>This series of events and technological shifts led me to envision a new kind of library — a <em>JS-in-CSS</em> library, or, <strong>Statically Generated CSS</strong> as it is more commonly known.<br>Instead of embedding CSS in JavaScript runtime, it would write CSS statically using JavaScript, giving developers full control while keeping good performance.</p><p>Here is what it would look like:</p><pre>// button.css.ts<br>import { classHash } from &quot;js-in-css&quot;;<br><br>export const buttonClass = classHash(&quot;button&quot;);<br><br>export default `<br>  .${buttonClass} {<br>  background: lightblue;<br>}`;</pre><p>At a glance, it may remind you of <em>styled-components</em>. However, the philosophy here is different. Instead of embedding CSS in JavaScript, we are using JavaScript to statically generate CSS — a subtle but significant difference. We can already do this with existing technology like <a href="https://webpack.js.org/loaders/val-loader/">val-loader</a>. You can then chain it with regular CSS tools, like <a href="https://github.com/webpack-contrib/sass-loader">sass-loader</a> and <a href="https://postcss.org/">PostCSS</a>.</p><figure><img alt="Build flow of CSS-in-JS — a *.css.ts file compiled down to .css and .js files" src="https://cdn-images-1.medium.com/max/1024/1*EvzWK-umUQmTw24-gRFCDg.png" /><figcaption>build-time CSS generator</figcaption></figure><p>Now, how to use this button class in our components? Same as <em>CSS Modules</em>:</p><pre>// button.tsx<br>import { buttonClass } from &quot;./button.css.ts&quot;;<br><br>export const Button = (props) =&gt; &lt;Button className={buttonClass} {…props} /&gt;;</pre><p>And how about overrides for nested components?</p><pre>// primary-button.css.ts<br>import { buttonClass } from &quot;./button.css.ts&quot;;<br><br>const primaryClass = classHash(&quot;primaryButton&quot;);<br><br>export default `.${buttonClass}.${primaryClass} {<br>  border: 2px solid black;<br>}`;</pre><p>This approach gives us all the encapsulation benefits of <em>CSS Modules </em>without the black-boxing, and all the scripting capabilities of <em>SASS</em> without having to learn a new language. With a bit of extension, we could also write dynamic functions that generate runtime styles.</p><h3><strong>(Glorious) Linaria</strong></h3><figure><img alt="official Linaria logo" src="https://cdn-images-1.medium.com/max/941/1*l3YNnKvNSIliXCSie3OL1A@2x.png" /></figure><p>Imagine my surprise when I found <a href="https://linaria.dev/"><em>Linaria</em></a>, a <em>JS-in-CSS</em> library introduced in 2018, embodying exactly this concept, with <strong>0 runtime</strong> code. It was a sweet discovery. Linaria lets you write CSS in a natural syntax and even supports caching!</p><p>Here is a sample of writing CSS with JavaScript using Linaria:</p><pre>import { css } from &#39;@linaria/core&#39;;<br>import { modularScale, hiDPI } from &#39;polished&#39;;<br>import fonts from &#39;./fonts&#39;;<br><br>// Write your styles in `css` tag<br>const header = css`<br>  text-transform: uppercase;<br>  font-family: ${fonts.heading};<br>  font-size: ${modularScale(2)};<br><br>  ${hiDPI(1.5)} {<br>    font-size: ${modularScale(2.5)};<br>  }<br>`;<br><br>// Then use it as a class name<br>&lt;h1 className={header}&gt;Hello world&lt;/h1&gt;;</pre><p>Of course, this is just a small example. They also have a syntax similar to <em>styled-components</em> for React and much more. You can learn more from the <a href="https://linaria.dev/">official site</a>, just remember to come back here and continue reading this article!</p><p>There are other libraries out there: <em>vanilla-extract</em>, <em>Astroturf</em>, <em>Treat</em>, and <em>Compiled CSS</em> (by Atlassian). These require you to write styles in camel case <em>objects</em>, unlike Linaria, which, in my opinion, captures the essence of <em>JS-in-CSS</em> by letting you write plain CSS, similar to <em>Styled Components</em>.</p><p>However, let’s proceed with caution. Linaria is impressive, but it would be prudent to see some benchmarks, real-world large-scale proof of concepts before crowning it as the winner. Adoption is slowly growing every month, with weekly downloads now reaching 300k. So, let’s explore together, experiment, and see if we can bring out the full potential of <em>JS-in-CSS</em> with <em>Linaria</em>.</p><h3>What’s missing?</h3><p>A <strong>component library</strong> (also known as a <em>design system</em>) is first on the list. We need a modular, customizable, default-ly themed, and extensive library to champion this new technology.</p><figure><img alt="Screenshot of a design system" src="https://cdn-images-1.medium.com/max/1024/1*C8ccKgR-_uKNXclEIDKAvw.png" /><figcaption>People are more willing to accept a technology if they have proper foundations</figcaption></figure><p>Secondly, we need a<strong> standalone transformer</strong> to enable the use of this tech outside of the ecosystem. We could build packages with <em>Linaria</em> and publish them as plain CSS, much like TypeScript.</p><p>Finally, we need support from next-gen bundlers. <em>esbuild</em> and <em>turbopack</em> are just around the corner, bringing substantial improvements to Developer Experience, and they need a plugin. And yes, we even need it in Go and Rust!</p><h3><strong>Conclusion</strong></h3><p>This exciting possibility of <em>Statically Generated CSS</em> presents a promising future for frontend development. If it delivers on its promises, it could solve long-standing issues with CSS and JavaScript integration while offering performance improvements and coding efficiency.</p><p>We might even come near the end of the <em>CSS-in-JS</em> war. The era in which every company created its own design system, and large corporations even engineered their own CSS solutions, may soon be coming to a close if one technology emerges on it, though it may take a few years.</p><p><strong>I encourage you to explore </strong><a href="https://linaria.dev/"><strong>Linaria</strong></a> and consider adopting or contributing to the technology. If you have a preference for another technology, please leave a comment and explain.</p><p>Lastly, Microsoft, if you’re reading this and aren’t too preoccupied with integrating Copilots everywhere, perhaps some of your TypeScript engineers could take a moment to check out this tech. 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fd9908a48ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Challenging AI to Write an Apple Watch 8 App to Help Quit Smoking]]></title>
            <link>https://medium.com/@urikutner/challenging-ai-to-write-an-apple-watch-8-app-to-help-quit-smoking-f3e681e5ac89?source=rss-a96e346f027------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3e681e5ac89</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[apple-watch]]></category>
            <dc:creator><![CDATA[Uri Kutner]]></dc:creator>
            <pubDate>Tue, 28 Feb 2023 09:33:24 GMT</pubDate>
            <atom:updated>2023-03-01T22:06:44.344Z</atom:updated>
            <content:encoded><![CDATA[<h3>Challenging ChatGPT to Write a Watch App to Help Quit Smoking</h3><h4>Can AI write program? Yes, but no more than 130 lines of code</h4><p>It’s evident that the world of programming is undergoing a significant change with the growing scope of AI. I imagined a future where a team of AI bots would work collaboratively to execute natural language instructions and iterate over bits of requirements and code until achieving the desired result. This team of bots would act as a <em>General Purpose Artificial Intelligence</em>, much like the pipeline of a CPU. In this scenario, a human engineer would set up and oversee the pipeline until we even get that automated. However, my expectations were proven wrong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ebHy4Safdd4i6No24KcoIw.png" /><figcaption>AI writing code, as painted by DALL-E, another AI</figcaption></figure><h3>Current limitations</h3><p>To demonstrate that current AI is not yet capable of coding by itself, I decided to challenge it to write a simple program:</p><blockquote><strong><em>[me]: </em></strong><em>I </em>want an apple watch 8 app to help users stop smoking. Every time the user finishes a pack, he would tell the app, and the app will start counting days before the user is allowed to buy another pack. The length of time between packs starts with a whole week without smoking, and then a week plus 2 days, then a week plus 4 days, etc, until reaching 21 days without smoking. Then the app will congratulate the user for finishing smoking, and instruct him/her never to smoke again.”</blockquote><blockquote><strong><em>[ChatGPT]: </em></strong>As an AI language model, I don’t have the ability to create apps, but I can provide you with guidance on how to develop an app for Apple Watch 8 to help you stop smoking. Here are some steps you can take:</blockquote><blockquote>Define the features and functionality of the app: Based on your requirements, the app should have the following features:</blockquote><blockquote>…</blockquote><p>As you can see, the model knows <em>how</em> to create the program, but making the whole thing in one go is <em>still</em> beyond it’s abilities.</p><h3>First attempt</h3><p>I simplified the process. Instead of making a whole app in one go, I tried making a smaller agile product, and pair program the bot, leading it each step of the way.</p><blockquote><strong><em>[me]: </em></strong>I want to make a simple apple watch app with flutter. could you help me?</blockquote><blockquote><strong><em>[ChatGPT]: </em></strong>Sure, I’d be happy to help you get started with making a simple Apple watch app using Flutter! Here’s a step-by-step guide to help you:</blockquote><blockquote>Install Flutter: The first step is to install Flutter on your system. You can follow the official guide to install Flutter by visiting <a href="https://flutter.dev/docs/get-started/install">https://flutter.dev/docs/get-started/install</a>.</blockquote><blockquote>Set up your development environment: Once Flutter is installed, you’ll need to set up your development environment. This includes installing Xcode on your Mac, which is required for developing iOS apps.</blockquote><blockquote>…</blockquote><p>The bot knew exactly what to do, as creating a new app is well documented. Following the instructions is pretty straightforward: installing flutter, failing, installing with brew, getting xcode, running a simulator. About an hour later, I managed to pass Flutter Doctor:</p><pre>Doctor summary (to see all details, run flutter doctor -v):<br>[✓] Flutter (Channel stable, 3.7.5, on macOS 13.2.1 22D68 darwin-arm64, locale en-IL)<br>[✗] Android toolchain - develop for Android devices<br> ✗ Unable to locate Android SDK.<br> Install Android Studio from: https://developer.android.com/studio/index.html<br> On first launch it will assist you in installing the Android SDK components.<br> (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for<br> detailed instructions).<br> If the Android SDK has been installed to a custom location, please use<br> `flutter config - android-sdk` to update to that location.<br>[✓] Xcode - develop for iOS and macOS (Xcode 14.2)<br>[✓] Chrome - develop for the web<br>[!] Android Studio (not installed)<br>[✓] VS Code (version 1.75.1)<br>[✓] Connected device (2 available)<br>[✓] HTTP Host Availability</pre><p>Next on the list, flutter create unsmoke_app. 3/5 done!<em> </em>😎<br>I added the missing watch device using XCode. ChatGPT was pretty clear, pointing me to the right menus with ease.</p><p>However, I encountered my first hurdle at this stage. Despite numerous troubleshooting attempts, I realized something that the bot had missed — it is <strong>impossible to create a watch app</strong> as <strong>Flutter does not yet support it</strong>. ChatGPT quickly confirmed this fact:</p><blockquote><strong><em>[me]: </em></strong>does flutter support apple watch natively?</blockquote><blockquote><strong><em>[ChatGPT]: </em></strong>As of my knowledge cutoff in September 2021, Flutter <em>did not have official support for Apple Watch natively.</em> Flutter was primarily designed for …</blockquote><p>Given that a watch app was out of reach, I opted to create a phone app with the help of the bot. Following its guidance, I was able to successfully create and run a basic app.</p><figure><img alt="ios app up and running" src="https://cdn-images-1.medium.com/max/1024/1*jjW4gQDB4QiEWF5WTkx5Kw.png" /><figcaption>Simple hello world app, as instructed by ChatGPT</figcaption></figure><p>Moving forward, I instructed the bot to write the start button, and it generated code based on my requirements. Taking small steps and iterating seemed to work well, and I was pleased with the quick results:</p><blockquote><em>[me]: </em>Great. I got that up and running, now I want it to show a big blue screen with a start button in the middle. pressing the button would show a success message<br>…</blockquote><blockquote><em>[me]: </em>when the user reaches success, can you write a reset button at the top right?<br><em>[me]: </em>don’t write the whole thing, just the relevant parts<br><em>[me]: </em>extract the user actions like onPressed to a function<br><em>[me]: </em>separate the app bar and the main body into two separate components<br><em>[me]: </em>attach styles to each element without inlining them<br>…</blockquote><figure><img alt="First attempt of the no smoke app, with just 1 feature" src="https://cdn-images-1.medium.com/max/1024/1*RnE-vDsQbr-4YspRJ5CcRA.png" /><figcaption>First attempt at the No Smoke app</figcaption></figure><p>After writing <strong>around 130 lines of code</strong>, the experiment hit a snag. The appBar became stuck behind the notch and the bot was unable to fix the issue. I attempted various solutions, including changing the wording of my question, starting a new conversation, and troubleshooting the problem. Unfortunately, the bot kept losing context, misplacing code, and making incorrect suggestions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rU-FgqoqAOAai5O8xQddug.png" /></figure><p>To be honest, I was surprised at how quickly the experiment failed with such a limited scope. It’s a relief to know that we don’t have to worry about a <a href="https://en.wikipedia.org/wiki/Instrumental_convergence#Paperclip_maximizer"><em>paperclip maximizer catastrophe</em></a> in the immediate future. <em>Whew!</em></p><h3>Second attempt</h3><p>Despite the initial failure, I didn’t give up! 💪<br>The next day, I approached the task more carefully, focusing only on the most important requests. This time, the bot performed more smoothly, getting me to 114 lines of code.</p><figure><img alt="The app working, counting down to zero" src="https://cdn-images-1.medium.com/max/1024/1*hjonkLDgrvswg-x0-ljXkA.gif" /><figcaption>114 lines of AI written code</figcaption></figure><p>At this point, I made the big request.</p><blockquote><strong><em>[me]: </em></strong>each time after reaching the target date, the next target will be 2 days later. After reaching a target of 21 days or more, and completing the duration, the app will congratulate the user on quitting cigarettes, and suggest to him never to smoke again.</blockquote><blockquote>Here is the current code:</blockquote><blockquote>import ‘dart:async’;<br>…</blockquote><blockquote><strong><em>[ChatGPT]: </em></strong>Great! To implement the new requirements, we need to make a few changes:</blockquote><blockquote>1. We need to keep track of the number of completed no-smoking periods. We can do this by storing a counter in SharedPreferences.</blockquote><blockquote>2. We need to update the target date each time the user reaches the target. We can calculate the new target date by adding 2 days to the current date.</blockquote><blockquote>3. We need to update the countdown text to show the correct number of 🚭 signs for the current period.</blockquote><blockquote>4. We need to add a check for when the user has completed 3 weeks or more of no smoking, and display a congratulatory message.</blockquote><blockquote>Here is the updated code:</blockquote><blockquote>…</blockquote><p>For a brief moment, it seemed like the AI had made a breakthrough. While slow, it was producing code. However, to my dismay, the code quickly spiraled into a fiasco. It was writing in the wrong places, forgetting crucial elements, and making an overall mess. At this point, I felt like I could have kept going, but in the end, it was actually simpler to write the code myself.</p><figure><img alt="A computer running many DOS terminals and rewriting itself" src="https://cdn-images-1.medium.com/max/600/1*pZXStLfPH2ZFjiVflyNnUA.gif" /><figcaption>No chance of computer rewriting their code and taking over any time soon</figcaption></figure><h3>What happened?</h3><p>I surpassed the mental capacity of ChatGPT, which is mainly determined by the size of <em>input</em> the AI can handle. Essentially, AI functions by using a graph of nodes, which each manipulate input in a small way before passing it along to the next node. Over time and with lots of data, engineers tweak the nodes to make sure the AI produces an output similar to the training set. It’s important to note that AI doesn’t actually “learn” per se, it’s more like it’s being trained to perform specific tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*g-P60z_CYRJZysMm4GjJdA.png" /><figcaption>AI “neural” graph with limited input.</figcaption></figure><p>However, this doesn’t necessarily mean that AI will be able to handle all tasks thrown its way, at least not yet. The size of input that an AI can take is tied to the number of nodes within its graph. Over the past few years, we’ve seen AI grow in terms of its capabilities, going from one sentence at a time, to carrying an entire conversation like ChatGPT, at least if it’s less than 130 lines.</p><p>While AI’s capacity is increasing, it’s important to understand that it’s not yet quite like humans who can extend their own capacity by writing, brainstorming, and breaking down ideas. Currently, the only way to <strong>increase the capacity of an AI is to increase the number of nodes</strong> within its graph, also known as the “model size.” This requires more data to train the model, otherwise it will overfit and not be able to handle new input. Growing the graph might not be so straight forward, and might have non-linear costs.</p><p>Despite these limitations, I believe that AI’s capacity will continue to grow in the future, similar to how computing power has grown according to Moore’s Law. However, it’s important to understand that even as AI gets better, it <strong>might not be as fast or effective as we initially anticipated</strong>.</p><h3>What’s ahead</h3><p>Looking ahead, the latest AI technology from 2022 may give rise to a new tool for coding called <strong>Natural Language Refactors</strong>. This tool would enable an AI to make small changes to your code, in real files, directly within your integrated development environment (IDE), which will be both feasible and appealing.</p><p>This could eventually lead to <strong>Programming in Natural Language</strong>, where the machine translates human language into computer binaries and vice versa. Additionally, this technology could be used for a variety of applications, such as generating tests, examples, and documentation, as well as for live code analysis, reviews for security, readability, performance, and ethics, and even guidance for merging code.</p><p>Given the rapid pace of innovation, it’s possible that Github co-pilot could announce these features as early as 2023.</p><p>To sum up, I believe that the field of code engineering will remain largely <strong>safe from automation for the next 5–10 years</strong>. We will need to create checks and balances for AIs first, before we can integrate them as code writing tools. Without such ethical considerations, bots could easily get stuck in dead ends, rendering them useless.</p><p>What about after 10 years, when General Artificial Intelligence is achieved? That’s when things could start to look very different indeed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3e681e5ac89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reusing JavaScript Tests]]></title>
            <link>https://medium.com/bitsrc/reusing-javascript-tests-483288d3f733?source=rss-a96e346f027------2</link>
            <guid isPermaLink="false">https://medium.com/p/483288d3f733</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Uri Kutner]]></dc:creator>
            <pubDate>Wed, 27 Nov 2019 20:37:47 GMT</pubDate>
            <atom:updated>2019-11-28T01:03:12.452Z</atom:updated>
            <content:encoded><![CDATA[<h4>Increasing test validity while decreasing costs</h4><figure><a href="https://bit.dev/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1eZJke_Le-0r02-xuR6bVA.jpeg" /></a></figure><p>Writing tests is hard. 😤<br>Why do we need them in the first place? 🤔</p><p>Code defines <em>a set of instructions </em>to perform a <em>specific operation.</em> Consider this function as performing the well-defined mathematical operation:<br><strong>y = a + b</strong>.<br>Assuming the developer understands the underlying principles, he can write this correct implementation in machine code:</p><pre>//seems about right</pre><pre>function Add(a,b) {<br> return a + b;<br>}</pre><p>However, noise from human error, system constraints, or other bugs may damage the code:</p><pre>function Add(a,b){<br> return a + ‘ ’ + b; //woops!<br>}</pre><p>This is where tests come in. ✨</p><p>Tests describe the operation in behavior-outcome language,<br>mirroring the code’s machine language.<br>Damaged code would be reflected as test failures:</p><pre>import Add;</pre><pre>test(‘add should return the sum of two numbers’, () =&gt; {<br>  expect(add(2,3)).toBe(5); //error! it is actually ‘2 3’!<br>});</pre><h3>Increase validity while decreasing costs</h3><p>Mathematically, “regular” code is a continuous function, while tests are discrete samples of the same operation. <strong>Writing and maintaining a sample size big enough to ensure correctness could be just as difficult as writing the ‘regular’ code itself.</strong> 😞</p><p>So why not reuse existing tests, as we do with our “regular” code? 😃</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O2hJdFBefhp3mJR-T4RYSg.png" /></figure><h3>Reusing tests</h3><p>I know, reusing tests is an awful experience.<br>Developing in existing endless interwoven code is hard enough, no matter how well-written it is.<br>If you ever dared to interweave tests, I bet you got a headache pretty quick.</p><p>But, I can imagine at least one use case where this would be applicable:</p><pre>interface IFileSystem {<br>  writeFile(path, content);<br>  unlink(path)<br>  …<br>}</pre><pre>//common file-system implementation:<br>class NodeFs implements IFileSystem {<br>  …<br>}</pre><p>Most tests written for NodeFS, could, with little adaptation, be written for IFileSystem! 😯</p><p>Another file system could have another implementation, and still, use the same tests!</p><pre>// memory-filesystem<br>//———————————————</pre><pre>// in memory file system for fast short and isolated uses.<br>class NodeFs implements IFileSystem {<br> …<br>}</pre><pre>//memory-filesystem.test<br>//———————————————<br>import FileSystemTests<br>import MemFs</pre><pre>FileSystemTests.validate(MemFs);</pre><h4>Can we do it today?</h4><p>Yes! 🥳<br><strong>The cost of code isolation is falling,</strong> and even tests worth the effort.</p><p>One of the most exciting tools in the domain of code isolation is <a href="https://bit.dev/"><strong>Bit</strong></a> (<a href="https://github.com/teambit/bit">Github</a>). Bit is a tool and platform that helps you isolate code. Bit also offers a quick and easy way to share your isolated components to a collection in <a href="https://bit.dev/">bit.dev</a>, so that others (and your future-self) may use and even collaborate on. Bit is usually used for UI components, as a way to gradually build a UI component library but, it can easily be used for Node/JS utility functions and tests.</p><figure><a href="https://bit.dev/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BaMDuNRZpZWpy4ZwPhYTbQ.gif" /></a><figcaption>Example: Shared components in bit.dev</figcaption></figure><p><a href="https://bit.dev/">Bit. Composable software.</a></p><ol><li>Write your test:</li></ol><pre>import expect from ’chai’; //you gotta get it somewhere<br>import { IBinaryOperation } from ’math-functions’;<br>import { toPairs } from ’combinatorics’;</pre><pre>function validateAssociativity&lt;T&gt;(<br>  operation: IBinaryOperation&lt;T&gt;,<br>  values: T[]) {</pre><pre>  toPairs(values).forEach((x, y) =&gt; {<br>      expect(binaryOperation(x, y))<br>    .toEqual(binaryOperation(y, x));<br>  }<br>}</pre><pre>export validateAssociativity;</pre><p>2. Isolate the test into an atomic component using <a href="https://bit.dev/">Bit</a>:</p><pre>§ bit add AssociativeTests.Ts —-id math/tests/associativity<br>§ bit add -c bit.envs/compilers/typescript<br>§ bit tag math/tests/associativity</pre><p>3. Push your component to your collection in <a href="https://bit.dev/">bit.dev</a>:<br>(learn how to <a href="https://docs.bit.dev/docs/quick-start">create your Bit collection here</a>)</p><pre>§ bit export collection.name math/tests/associativity</pre><p>3. Now we can easily reuse our shared reusable test component:</p><pre>import add from ’./add.js’;<br>import { validateAssociativity } from ’@bit/collection.name.math.tests.associativity’;</pre><pre>test(‘add associativity’, () =&gt; {</pre><pre>const sample = [1, 5, 3, 1000, 0.3, -17];<br>  // or maybe.. math/samples/realNumbers ..?</pre><pre>validateAssociativity(add, sample);</pre><pre>}</pre><p>Pretty neat! 🤯</p><p>Will pngSnapshot components be the next hot thing? 🔮<br>Could we have checklists like Accessibility support, FPS quota, and screen responsiveness?<br>What do you think? 😍</p><h3>Learn More</h3><ul><li><a href="https://blog.bitsrc.io/let-everyone-in-your-company-see-your-reusable-components-270cd3213fe9">Let Everyone In Your Company Share Your Reusable Components</a></li><li><a href="https://blog.bitsrc.io/meet-bits-atomic-component-cloud-521160de4f0c">Meet Bit’s Component Cloud</a></li><li><a href="https://blog.bitsrc.io/11-javascript-utility-libraries-you-should-know-in-2018-3646fb31ade">11 Javascript Utility Libraries you Should Know in 2019</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=483288d3f733" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bitsrc/reusing-javascript-tests-483288d3f733">Reusing JavaScript Tests</a> was originally published in <a href="https://medium.com/bitsrc">Bits and Pieces</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn the Vanilla and Flavouring Pattern]]></title>
            <link>https://medium.com/bitsrc/the-vanilla-and-flavouring-pattern-fcf07942a57a?source=rss-a96e346f027------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcf07942a57a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Uri Kutner]]></dc:creator>
            <pubDate>Wed, 13 Feb 2019 16:13:01 GMT</pubDate>
            <atom:updated>2019-05-26T10:22:51.233Z</atom:updated>
            <content:encoded><![CDATA[<h4>Can you write code that is both reusable and specific enough for a beautiful design?</h4><p>This pattern tries to tackle a difficult problem in coding: how do you make code that is generic and stable, but at the same time replaceable and specific?</p><h3>Reusable specific code</h3><p>In a top-down approach, one starts with a result in mind, and quickly iterate over the code until it produces the desired result. You may know this as <a href="https://blog.bitsrc.io/a-guide-to-test-driven-development-tdd-shorter-feedback-loop-faster-workflow-ce5bd6b247c4">Test Driven Development</a>, but it works the same with you as a tester.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*YMAkT-Z2YrB1fPqDStpOtQ.png" /><figcaption>A button from <a href="https://bit.dev/">Bit’s UI</a></figcaption></figure><p>Pretty straightforward. The button is a simple component with a border, border-radius and a color. You can even give it a small transformation so it would react when you click on it.<br>So far so good.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8aa3818b5a9a11318ef64ca068fc93d/href">https://medium.com/media/e8aa3818b5a9a11318ef64ca068fc93d/href</a></iframe><p>Unbeknownst to the button, in a different part of the code, another button is needed. One that is bolder, fuller, and more fitting to direct the user’s attention to whatever you want at the time.<br>It has a purple background, no border, and white text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/144/1*wybu3gABQA7O_Wq4nEqUjw.png" /></figure><p>How does one make a new button?<br><strong>Option 0: Create a new button from scratch</strong></p><p>Yes this is a thing. Developers reinvent the wheel on a daily basis. Some of my best friends are dead Dependency Injection frameworks that people just have to write for themselves.<br>Custom specific code is easy to tailor and fits most corners easily. It even simplifies your whole codebase by tackling a piece of existence all by itself.<br>Of course it also means that you would have to update it manually for every <em>single</em> bug in the buttonshpere. Good luck with that.</p><p><strong>Option 1: override using styles</strong></p><p>As our button receives a classname, we could easily override the styles we’d like, and get the result we wanted.<br>However, this method is flawed — the new button still receives all the base styles from the original button, so it will inherit its future changes as well. For example, when we make the original button bold, the new button would also get this style.<br>To keep the new button consistent, we would have to review it and override the new styles. This can be time consuming and even difficult with some styles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*Nbk_Upb87Edw7U2sJqjNyg.png" /></figure><p>This violates the Open Close Principle. The component is open for extensions, but it is defiantly not closed to modifications. Such violation to the Pure base class can sometimes be worse than you would expect:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*c9A0qadPrDKywJAh68hIcA.png" /><figcaption>yikes! I haven’t even edited this, it was like that when I found it</figcaption></figure><p><strong>Option 2: put a flag on it</strong></p><p>UI Components are, basically, functions. You could pass parameters, and make logic around it. This is the structure in JSX, but it could work just as well in other formats.</p><pre>&lt;Button <strong>invert={true}</strong> onClick={ () =&gt; this.handleCatGifs()}/&gt;</pre><p>It makes sense in the first glance, until you realize it violates the Inversion of Control Principle. You would be trapped in a maintenance hell really fast.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gdxMdfItkWNCmHYcmuxwMQ.png" /><figcaption>huh.. switch-case anyone?</figcaption></figure><p>And trust me, it is even worse if you have a bug that only effects some buttons and not others.</p><p>How, then, does one tackle this issue?</p><p><strong>Tip</strong>: Use <a href="https://bit.dev/"><strong>Bit </strong></a>to<strong> </strong>make your components reusable! Easily share them between apps, with your team, and use them to build new apps faster. Give it a try.</p><figure><a href="https://bit.dev/"><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Yhkh7jbS5Mx9uP96Y88pZg.gif" /></a><figcaption>React spinners with Bit: choose, play, reuse</figcaption></figure><p><a href="https://bit.dev/">Bit. Composable software.</a></p><h3>Enter the Vanilla and Flavouring pattern 🍨🍨🍦</h3><p>Create one ‘base class’ called Vanilla. This base houses all the generic functionality. You can put anything in there, as long as any logic and even styles must always apply, in all situation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8aa3818b5a9a11318ef64ca068fc93d/href">https://medium.com/media/e8aa3818b5a9a11318ef64ca068fc93d/href</a></iframe><p>Create a new decorating Flavor for each new instance of look. Flavors may not even depend directly on the Vanilla, just provide their styles.<br>Ideally, you should create a flavor to match each style in your style guide.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f637a612194e858684d9f586c7af1d25/href">https://medium.com/media/f637a612194e858684d9f586c7af1d25/href</a></iframe><p>Keep your Flavors as physically (or folderally) close to the original Vanilla base. When it changes, you would want to make sure they adapt perfectly.</p><p>When you want to change the look of a certain element, replace it with another Flavor. All looks <strong><em>must</em></strong> have their own flavor! Rouge styles are difficult to keep track of, and they indicate you are drifting away from your Style Guide.</p><p>When Flavours are no longer used, delete them! (…or keep them in an archive, if you get nostalgic). Ideally, when the Style Guide deprecates a theme, the code counterpart for this theme should be deprecated as well.</p><p>And that’s it. Vanilla keeps getting better, and new flavors come out every month. It’s a wonderful time to be a button!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/891f4b4cffab5bd4269b6cba01e033b8/href">https://medium.com/media/891f4b4cffab5bd4269b6cba01e033b8/href</a></iframe><h3>What did we gain?</h3><p>A well-established core responsible for the Fit and Function of the component.<br>A cheap decoration layer made out of many reusable variations, responsible for the Form of the component.</p><p>You could even add new behavior and animations to Vanilla later on!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G9xCV4J-BjXFR56Z9rDe0g.gif" /><figcaption>ever thought that onClick on return a Promise?</figcaption></figure><h3>In a wider lens…</h3><p>Could your code benefit for the Vanilla and Flavour pattern? Could you have already have been using it without a taste metaphor? Let me know what you think in the comments below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*u5onnkMCfBXd26l4KuA9yQ.jpeg" /></figure><h3>Relevant tips:</h3><ul><li>Never give vanilla any styles! especially sizes (margins, paddings, positioning), color (font, border, background, shadow), fonts, decorations.</li><li>Give a meaningful and specific name to your flavor. Focus on their purpose, and consider they would be replaced by very similar flavors, so don’t be too abstract.<br>At Bit, we prefix flavors by the current design system. It looks like Neon signs right now so we call them Neon buttons.</li><li>Be brave. Make a code fork of your Vanilla and start a new base class with new, exciting different functionality.</li><li>Compose styles together by passing flavored instances together. eg., a vanilla confirmation modal would use a vanilla button, but the NeonConfirmationModal would pass styles and NeonButton to its Vanilla.</li></ul><p>That’s all for now. Thanks for reading, and feel free to comment and ask anything! I’d be happy to chat :)</p><h3>Learn more</h3><ul><li><a href="https://blog.bitsrc.io/5-tools-for-faster-development-in-react-676f134050f2">5 Tools for Faster Development in React</a></li><li><a href="https://blog.bitsrc.io/11-javascript-animation-libraries-for-2018-9d7ac93a2c59">11 JavaScript Animation Libraries For 2019</a></li><li><a href="https://blog.bitsrc.io/how-to-easily-share-react-components-between-projects-3dd42149c09">How to Share React UI Components between Projects and Apps</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcf07942a57a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bitsrc/the-vanilla-and-flavouring-pattern-fcf07942a57a">Learn the Vanilla and Flavouring Pattern</a> was originally published in <a href="https://medium.com/bitsrc">Bits and Pieces</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bit's Component Playground now Visualizes Multiple Exports]]></title>
            <link>https://medium.com/bitsrc/bits-component-playground-now-visualizes-multiple-exports-15b00be5a097?source=rss-a96e346f027------2</link>
            <guid isPermaLink="false">https://medium.com/p/15b00be5a097</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[shared-components]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Uri Kutner]]></dc:creator>
            <pubDate>Thu, 19 Jul 2018 15:31:01 GMT</pubDate>
            <atom:updated>2019-04-01T11:36:35.809Z</atom:updated>
            <content:encoded><![CDATA[<h3>Bit’s Component Playground now Visualizes Multiple Exports</h3><h4><a href="https://bit.dev/">Bit’s</a> web platform now visualizes multiple exports for your component. It’s cool, and also useful. Here’s why.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*xMlVgsShSjceYhPX5XY_-Q.png" /><figcaption>Component with multiple exports visualized — see <a href="https://bit.dev/kutner/examples/examples/list">here</a></figcaption></figure><p><a href="https://bit.dev/"><strong>Bit</strong></a>’s platform turns JS components and modules into building blocks which can be easily shared, used and developed from any project.</p><p>Using Bit, you can quickly turn any piece of code into an API and share it cross-teams and cross-projects to speed your development.</p><p>As code sharing scales, so does the need to make the code you share more organized and discoverable. In March, we introduced the first version of Bit’s <a href="https://blog.bitsrc.io/introducing-the-live-react-component-playground-d8c281352ee7">playground</a>, a visualization tool which renders a live component preview.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*besXkX9bny5CjCIY4i4DHA.gif" /><figcaption>A React component <a href="https://bit.dev/bit/movie-app/components/hero">example</a> in Bit’s playground</figcaption></figure><p>In the past months many developers leveraged this playground to share components with their teams. Some shared great open source examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*N8Ft8jdzL4T8MVbTN2N6UA.png" /><figcaption>My favorite simple-yet-elegant Bit community example</figcaption></figure><p>However, up until now this playground only worked for <em>default exports</em>, so you would get an error when trying to run it on some more complicated use cases:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*T_-KFMBvNa2cKKc5zSv1RA.png" /><figcaption>the errors of <em>old ways</em></figcaption></figure><p>As of today, you now have access to all of the exports, and not just the default ones. This means you can now visualize a wider verity of use cases, and provide a better experience for sharing a useful component collection.</p><h3>Example</h3><p><a href="https://bit.dev/kutner/examples/examples/dual-export">Here is</a> a very simple component I made having a default export (Main) and an additional component (Secondary).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o60z54KlDRRe6ybGoYLOxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*k-hNIA3QMvZVfP1jOSlLDA.png" /><figcaption>Good thing emoticons work out of the box these days</figcaption></figure><p>As you can see, both exports are handles and Bit’s playground now presents both of them. As many components contain secondary components, this feature makes it much easier to provide visualization for these cases.</p><p>Greater visualization makes it easy to choose components with your own eyes, while also making it easier to learn how components look and behave.</p><h3><strong>Under the hood (how it works)</strong></h3><p>When a component is exported with Bit it’s already processed before reaching the browser. It starts as plain source code, and then compiled into a single UMD <em>bundle</em> using a compiler, such as our <a href="https://bit.dev/bit/envs/bundlers/webpack">webpack bundling compiler</a>.</p><p>When this bundle is run, it generates a plain object, with the component exports as properties of this object (you can see this in more details in <a href="http://bob.yexley.net/umd-javascript-that-runs-anywhere/">this article</a> about the UMD standard).</p><p>So, the live preview now scans this object, finding all the properties, and inject them into the rendering scope. Simple.</p><p>What about the <strong>default export</strong>? Well, it is available as the property “default” on the bundled result. However, “default” is a JS keyword and its awkward to use. So, in order to have a more natural experience, we rename it to be the <strong>component name</strong>, which is defined by the “@name” documentation (see more details in our <a href="https://docs.bit.dev/docs/rendering-components.html#many-exports-in-a-rendering-example">docs</a>).</p><p>All changes are backward compatible, so your existing components should work fine and you can leverage the upgraded playground without a worry.</p><h3>Into the (near) future</h3><p>In Bit’s near-future roadmap we have some very exciting features. An important part of this roadmap is greatly improving the discovery experience around the components: from the way they are organized and presented to the user’s ability to easily search and choose the best components.</p><p>The live playground, on which I’m personally working, is going to play a major part in this experience. Within a short while, all kinds of components and modules will be rendered and visualized without having to change a single thing in your code. You will be able to easily browse visualized collections, choose with your own eyes, and have a great experience doing so.</p><p>We welcome all ideas, suggestion and feedback- so feel free to let me know!</p><p>Cheers, Uri</p><p><a href="https://bit.dev/">Bit. Composable software.</a></p><h3>Learn more</h3><ul><li><a href="https://blog.bitsrc.io/introducing-the-live-react-component-playground-d8c281352ee7">Live React Component Playground with Bit</a></li><li><a href="https://blog.bitsrc.io/11-javascript-utility-libraries-you-should-know-in-2018-3646fb31ade">11 Javascript Utility Libraries you Should Know in 2019</a></li><li><a href="https://blog.bitsrc.io/simplify-complex-ui-by-implementing-the-atomic-design-in-react-with-bit-f4ad116ec8db">Atomic Design With React And Bit: Simplify a Complex UI</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15b00be5a097" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bitsrc/bits-component-playground-now-visualizes-multiple-exports-15b00be5a097">Bit&#39;s Component Playground now Visualizes Multiple Exports</a> was originally published in <a href="https://medium.com/bitsrc">Bits and Pieces</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Live React Component Playground with Bit]]></title>
            <link>https://medium.com/bitsrc/introducing-the-live-react-component-playground-d8c281352ee7?source=rss-a96e346f027------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8c281352ee7</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Uri Kutner]]></dc:creator>
            <pubDate>Thu, 29 Mar 2018 17:04:03 GMT</pubDate>
            <atom:updated>2019-03-31T07:22:20.995Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This is AN OLD and DEPRECATED post introducing Bit’s OLD (no longer used) playground. It’s kept for nostalgic purposes. Check out the </em><a href="https://bit.dev/components"><em>new playground here</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KkNqpdZ6qKvyrWCHKHJhDg.png" /><figcaption>Which movie to <a href="https://bit.dev/bit/movie-app/components/title-list">watch</a>? Zootopia!</figcaption></figure><p><a href="https://bit.dev/">Bit</a> is a tool build to turn your components into building blocks which can be easily shared and synced in different projects.</p><p>Part of Bit<a href="https://bit.dev/">’s</a> workflow is to make your components discoverable to <strong>find</strong> and <strong>choose </strong>from<strong>. </strong>But, how do you choose the right component for the job?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*besXkX9bny5CjCIY4i4DHA.gif" /><figcaption>React <a href="https://bit.dev/bit/movie-app/components/hero">Hero component</a> rendered live with Bit</figcaption></figure><p>Components could have thousands of stars, comments, even bug fixes, and still not fit your project. Maybe it has a rounded theme when you need squares? Maybe it doesn’t work with Promises and that’s a problem?</p><p>Personally, I think the best way to choose is through your own eyes. This is why I built an interactive playground where all the components you share with Bit are up and running in real time and can be played with on the web.</p><p>Creating an interactive version of code is made easy as <a href="https://bit.dev/">Bit</a> does most of the work <em>for you</em>. Basically, all you have to do is use Bit to share a React component, compile it as a UMD, add a usage example and see it live.</p><h3>How it works</h3><p>Rendering components on a webpage sound easy. After all, that’s the purpose of the code, right? In practice, code doesn’t run that well on its own. It gets a lot of support from frameworks, compilers, code servers and more.</p><p>To make it render like we want it to, we’re going to have to provide it with everything it needs and all the support it could get.</p><h4>Step 1: Compiling the code</h4><p>Even in the amazing world of just-in-time javascript, some compilation is required. For example, even popular libraries like React and Vue have their own syntax that browsers can’t chew on their own.</p><p>To make the code ready for the real world, we use a compiler based on <a href="https://webpack.js.org/">Webpack</a>. The compiler digests the code, and turns it into a <a href="https://github.com/umdjs/umd">UMD</a>. The great thing about this format is that it works in all environments, including the browser, Node.js, and your own project’s workspace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7BNqplonPYkjIAeyB3eYSg.png" /><figcaption>Compiling code to UMD</figcaption></figure><p>Bit also lets you implement your own compilers. Think you can write a better one? With Rollup, perhaps? Be our guest. Here is our <a href="https://bit.dev/bit/envs/bundlers/webpack">boilerplate</a> and you can also <a href="https://gitter.im/bit-src/Bit">get it touch</a> with any questions.</p><h4>Step 2: Dependencies</h4><p>To inject all the dependencies required by the code, we go through a slightly awkward stage called <em>re-bundling</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*-2k-Osv-GW2pjwiMRoZPLg.png" /><figcaption>Bit’s rebundler workflow</figcaption></figure><p>Rebundling takes the already compiled code, and compiles it again into a single file, this time with all its dependencies.</p><p>Unlike in the previous step, we now deal with an already pre-compiled standard code, which drastically reduces complexity. In the future, we aim to make all dependencies available as individual files, skipping this step entirely!</p><h4>Step 3: renderer</h4><p>In this step, the code is matched with its appropriate Renderer, and a usage example, provided by the owner of the component.</p><p>Following the <a href="https://en.wikipedia.org/wiki/Inversion_of_control">inversion of control</a> principle, the code cannot make decisions about how it will be used. Basically, it needs something to run it.</p><p>That’s why we created the <a href="https://docs.bit.dev/docs/rendering-components.html"><strong>Renderer</strong></a>, which is tasked with running the code.<br>The renderer is a regular Bit component on it’s own, meaning that we could easily replace it following the <a href="https://en.wikipedia.org/wiki/Open/closed_principle">Open Closed Principle</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*wmtwONJENqdNanZgUGOGvg.png" /><figcaption>Bit’s renderer workflow</figcaption></figure><h4>Step 4: running the code</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*N8Ft8jdzL4T8MVbTN2N6UA.png" /><figcaption>…<a href="https://bit.dev/gssfed/vital-ui-kit-react/packages/avatar">check it out</a></figcaption></figure><p>We now have pretty much everything we need.</p><p>To maintain security, all of the code is loaded and run inside a sandboxed iframe. Private code is fetched outside the iframe in a secure fashion.</p><p>To wire up all the pieces of code we use <a href="http://requirejs.org/">RequireJS</a> as our DI framework. You can play with the code <em>in real time</em>, using a Prism powered mini code editor.</p><h3>Do it yourself</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*n7r8D3d0wn62BtTTZdtNjA.gif" /><figcaption>React card component from Bit<a href="https://bit.dev/gssfed/vital-ui-kit-react/packages/card">’s community</a></figcaption></figure><p>To share your own components with a live preview and start playing with them online all you have to do is follow <a href="https://docs.bit.dev/tutorial/react-tutorial.html">this simple tutorial</a>.</p><p>Looking into the future, there are all kinds of interesting possibilities for this workflow, which I’m personally very proud of :).</p><p>Interactive preview is only the tip of the iceberg with what we could do with this technology. I’m certain that many teams could really benefit from real time code assembly: production debugging could be made much easier, error reporting and perf could be a side effect your code is not even aware of. The possibilities are limitless.</p><p>Feel free to <a href="https://bit.dev/">give it a try</a>, suggest feedback or create your own compilers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*C_gNgDDeyTO_SMXw5sIX5g.gif" /><figcaption>React Avatar component <a href="https://bit.dev/gssfed/vital-ui-kit-react/packages/avatar">from Bit’s community</a> by <a href="https://github.com/GSS-FED/vital-ui-kit">GSS-FED Vital UI Kit</a>.</figcaption></figure><h4>Learn more:</h4><ul><li><a href="https://blog.bitsrc.io/11-react-component-libraries-you-should-know-178eb1dd6aa4">11 React UI Component Libraries you Should Know in 2019</a></li><li><a href="https://blog.bitsrc.io/best-react-ui-component-libraries-for-2018-part-2-d231dcb04c0a">Best React UI Component Libraries And Frameworks part 2</a></li><li><a href="https://blog.bitsrc.io/9-tools-and-libraries-to-boost-your-react-component-workflow-6ff4b49511c2">9 React Libraries and Tools to Master your Component Workflow</a></li><li><a href="https://blog.bitsrc.io/11-vue-js-component-libraries-you-should-know-in-2018-3d35ad0ae37f">11 Vue UI Component Libraries You Should Know In 2019</a></li><li><a href="https://blog.bitsrc.io/how-to-easily-share-react-components-between-projects-3dd42149c09">How to Share React UI Components between Projects and Apps</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8c281352ee7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bitsrc/introducing-the-live-react-component-playground-d8c281352ee7">Live React Component Playground with Bit</a> was originally published in <a href="https://medium.com/bitsrc">Bits and Pieces</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>