<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mitya Kuznetsov</title>
    <description>The latest articles on DEV Community by Mitya Kuznetsov (@frontendj).</description>
    <link>https://dev.to/frontendj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F453311%2Fa944b3ca-6c99-41a8-9586-01dc25ddf141.jpg</url>
      <title>DEV Community: Mitya Kuznetsov</title>
      <link>https://dev.to/frontendj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/frontendj"/>
    <language>en</language>
    <item>
      <title>Fun front end</title>
      <dc:creator>Mitya Kuznetsov</dc:creator>
      <pubDate>Fri, 19 Mar 2021 17:16:02 +0000</pubDate>
      <link>https://dev.to/frontendj/fun-front-end-kl5</link>
      <guid>https://dev.to/frontendj/fun-front-end-kl5</guid>
      <description>&lt;p&gt;The front of the front end is powerful and these days developers can do things that couldn’t be imagined a couple of years ago. Or could be? I remember times when CSS was very limited but one way or another a lot could be achieved. And I have a feeling that in reality imagination is the limitation part, not the technology. And having fun is an integral part of the process.&lt;/p&gt;

&lt;p&gt;While browsing through different articles sometimes I meet those that I would call ‘crazy’. Those where developers try something just because it’s fun. Technologies behind a development preview flag, something specific to a browser, something that can be achieved easily with a different approach, something that people do just because they can.&lt;/p&gt;

&lt;p&gt;And here I gathered some of these tricks for you. Some of the approaches are actually quite useful for specific requests, some are just fooling around. But all of them are really simple, cool and fun (and thus somehow impressive for me). I hope you’ll like them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Animation URLs with javascript and emojis
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://matthewrayfield.com/articles/animating-urls-with-javascript-and-emojis/" rel="noopener noreferrer"&gt;https://matthewrayfield.com/articles/animating-urls-with-javascript-and-emojis/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9lvvsb95k7vcvet85lmr.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9lvvsb95k7vcvet85lmr.gif" alt="Example of an animated url"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With javascript, we can change a page URL, and the part after # can be changed actually without redirecting anywhere. So placing ASCII symbols there or emojis we can draw funny animations. Pretty cool for a home project but I also can imagine it on a more serious project&lt;/p&gt;

&lt;h2&gt;
  
  
  Split emoji text effect with CSS
&lt;/h2&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/mandymichael/embed/mWXGZp?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This one is fun. Overflow: hidden, some clip-path and we can cut emojis, combine particles, create crazy combinations. Pure joy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzlgbbjpfcsbcklvfxe9h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzlgbbjpfcsbcklvfxe9h.png" alt="Emoji combinations - MacOS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unfortunately emoji change from platform to platform, but compared to Windows, the results aren't terrible.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2yct0k8w0gdoif0s1h5m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2yct0k8w0gdoif0s1h5m.png" alt="Emoji combinations - Windows"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The talking favicon in 256 bytes
&lt;/h2&gt;

&lt;p&gt;So, as you already might hear, almost all the browsers now support SVG favicons. A brilliant developer Lea Verou showed a really easy way to create a favicon from an emoji (if you're too lazy to create a special one).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/LeaVerou/status/1241619866475474946" rel="noopener noreferrer"&gt;https://twitter.com/LeaVerou/status/1241619866475474946&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The second fun fact about the technique is that we don't need a separate file - we can just write&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link rel="icon" href="data:image/svg+xml,&amp;lt;svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'&amp;gt;&amp;lt;text y='.9em' font-size='90'&amp;gt;💩&amp;lt;/text&amp;gt;&amp;lt;/svg&amp;gt;"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And with a short piece of javascript, the favicon gets an animated emoji 😎&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body onload="setInterval(_=&amp;gt;i.href=`data:image/svg+xml,&amp;lt;svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'&amp;gt;&amp;lt;text y='14'&amp;gt;${[...'😮😀😁😐😑😬'][++x%6]}&amp;lt;/text&amp;gt;&amp;lt;/svg&amp;gt;`,x=9)"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://twitter.com/aemkei/status/1242211870448259072" rel="noopener noreferrer"&gt;https://twitter.com/aemkei/status/1242211870448259072&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhpn2jzcbbh93m8bj9xbu.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhpn2jzcbbh93m8bj9xbu.gif" alt="Example of animated emoji favicon"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bonus&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These cute animations reminded me of something very old. Very old, very useless but so cool. This library (&lt;a href="http://lab.ejci.net/favico.js/)%C2%A0" rel="noopener noreferrer"&gt;http://lab.ejci.net/favico.js/) &lt;/a&gt; allows you to play video within a favicon (yay, one step to Doom) o_O. How crazy is that?&lt;/p&gt;

&lt;h2&gt;
  
  
  JS in CSS
&lt;/h2&gt;

&lt;p&gt;We already had JS in CSS once (remember filters functions in IE?) but here we’re talking about something else. The idea is simple — storing JS string in CSS native variables, we can execute them and thus understand in which file we’re currently. This, for example, gives us the possibility to save something in local storage to be able to interact with CSS again using the saved information. Or something else crazy :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://juwain.dev/posts/js-in-css-2/" rel="noopener noreferrer"&gt;https://juwain.dev/posts/js-in-css-2/&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjuwain.dev%2Fimages%2F1-qw8twl9pzsea27abgzueqq.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjuwain.dev%2Fimages%2F1-qw8twl9pzsea27abgzueqq.gif" alt="Example of defining and using JS strings in CSS - from juwain.dev"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Credits: juwain.dev&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Using CSS without HTML
&lt;/h2&gt;

&lt;p&gt;The craziest techniques. I guess it’s more about knowing the principles of browsers work, which is definitely an important skill in our profession. But also having pure, not ready for production fun🙂&lt;/p&gt;

&lt;p&gt;&lt;a href="https://css-tricks.com/using-css-without-html/" rel="noopener noreferrer"&gt;https://css-tricks.com/using-css-without-html/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Apparently, some browsers understand a special HTTP Header Link, in which we can pass CSS code without an actual CSS file. And CSS already can contain everything, including meaningful text content in pseudo-elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi0.wp.com%2Fcss-tricks.com%2Fwp-content%2Fuploads%2F2010%2F12%2Fwebsitewithouthtml.jpg%3Fw%3D570%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi0.wp.com%2Fcss-tricks.com%2Fwp-content%2Fuploads%2F2010%2F12%2Fwebsitewithouthtml.jpg%3Fw%3D570%26ssl%3D1" alt="Example of a meaningful page without HTML and CSS - from css-tricks.com"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Credits: csstricks.com&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And here there is a nice example of what can be done in CSS without a line of HTML. Everything is easy, I just keep forgetting that a lot of stuff can be put directly into CSS notation.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ainalem/embed/oNxXRgW?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;If you know some similar examples of fun, please share. After all what else for we need Fridays ;)&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
    </item>
    <item>
      <title>Blocks' random alignment with CSS</title>
      <dc:creator>Mitya Kuznetsov</dc:creator>
      <pubDate>Fri, 21 Aug 2020 14:41:50 +0000</pubDate>
      <link>https://dev.to/frontendj/blocks-random-alignment-with-css-1634</link>
      <guid>https://dev.to/frontendj/blocks-random-alignment-with-css-1634</guid>
      <description>&lt;p&gt;Recently I had a nice CSS challenge - easy at first sight, but as usual, it happens, a bit tricky. &lt;/p&gt;

&lt;p&gt;I needed to create a simple component in which several text blocks (let's call them tags) are displayed at random order. Something like that.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/frontendj/embed/KKzzorz?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The initial markup was simple, and the result was quite boring. Considering that actually all the blocks weren't related to each other, there was a feeling, that they needed some dynamic, and I wanted to move them randomly in different directions. And here lied the challenge. I didn't know widths of blocks (cause inner text was random), I didn't know the width of the parent (cause markup was responsive), plus some blocks took 100% of the parent's width, so I couldn't move them at all.&lt;/p&gt;

&lt;p&gt;Ideally, I wanted to calculate somehow the random length of a shift for every text block.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.item {
    left: random(0, [parentWidth] - [itemWidth])
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;SCSS has a built-in function for randomizing, but we can't mix there absolute and relative dimensions, and anyway, the result would be static. So it seemed that nothing could be solved in that direction.&lt;/p&gt;

&lt;p&gt;I could try to generate just a random number within some reasonable range and try to shift the text blocks with its help. But in this case, I would have to adjust the maximum width for the blocks, otherwise, they will go beyond the boundaries of the parent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@for $i from 1 through 4 {
  .item:nth-child(#{$i}) {
    $random: random(30) - 15; // getting a shift between -15px and 15px
    margin-left: $random + px;
    max-width: calc(100% - #{2 * abs($random)}px);
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/frontendj/embed/PoNNRLr?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Anyway, I tried and it seemed to work. But for long text blocks, some of the inner data were trimmed, because I had to compensate their shift with decreasing their width. In such cases, I'd like to just leave blocks without shifting. Luckily some flexbox magic came to help.&lt;/p&gt;

&lt;p&gt;If we add blocks of random width before and after each tag, they will push and pull, and therefore balance the tag randomly. Also, they will shrink to zero width if the text block is too wide.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.item {
  display: flex;

  &amp;amp;::before,
  &amp;amp;::after {
    content: '';
    flex: 1 1 auto;
    background: red;
    max-width: 40%;
  }

  &amp;amp;::after {
    background: green;
  }
}

@for $i from 1 through 4 {
  .item:nth-child(#{$i}) {
    &amp;amp;::before {
      flex-grow: random(5);
    }

    &amp;amp;::after {
      flex-grow: random(5);
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It works! Long tags displace balancers, and short tags are randomly aligned.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/frontendj/embed/oNxxdgQ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;I could stop here, but still I would like to make the text blocks appear with a random shift every time the block is redrawn, and not just when the CSS is recompiled. So a little bit of javascript would be fine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[...document.getElementsByClassName('item')].forEach((item) =&amp;gt; {
  item.style.setProperty('--puller-grow', Math.random() * 5);
  item.style.setProperty('--pusher-grow', Math.random() * 5);
});
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/frontendj/embed/JjXXvRm?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Now everything is fine. Blocks are randomly arranged, stay within the parent's bounds, and make the most of the available space to display their content.&lt;/p&gt;

&lt;p&gt;I stopped here, cause the font that I used, didn't give me the possibility to add some real dynamic to the blocks and let them slowly slide back and forth. But I was surprised, that it actually can be done with changing flex-basis property. The result isn't spectacular though.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/frontendj/embed/WNwoxgL?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
