<?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: John Cheng</title>
    <description>The latest articles on DEV Community by John Cheng (@johnnhoj).</description>
    <link>https://dev.to/johnnhoj</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%2F500686%2F417d842a-e577-4507-bf4e-5e09eacee824.jpeg</url>
      <title>DEV Community: John Cheng</title>
      <link>https://dev.to/johnnhoj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/johnnhoj"/>
    <language>en</language>
    <item>
      <title>Animate cards with zoom-in effect on picture</title>
      <dc:creator>John Cheng</dc:creator>
      <pubDate>Wed, 09 Nov 2022 04:02:32 +0000</pubDate>
      <link>https://dev.to/johnnhoj/animate-cards-with-zoom-in-effect-on-picture-3571</link>
      <guid>https://dev.to/johnnhoj/animate-cards-with-zoom-in-effect-on-picture-3571</guid>
      <description>&lt;p&gt;tldr; Had fun adding a zoom-in effect on card on hover&lt;/p&gt;

&lt;p&gt;Tailwind playground: &lt;a href="https://play.tailwindcss.com/CtxpncROJ9"&gt;https://play.tailwindcss.com/CtxpncROJ9&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Challenge
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Have the image "zoom-in" on hover&lt;/li&gt;
&lt;li&gt;Have the wrapper scale down on hover to intensify the zooming in effect&lt;/li&gt;
&lt;li&gt;(when adding text) Keep the text position in card to avoid too much movement&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How I did it
&lt;/h2&gt;

&lt;p&gt;It really all comes down to those classes: &lt;code&gt;duration-300 ease-linear hover:scale-[98%] hover:[&amp;amp;&amp;gt;img]:scale-110&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here, we set:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;transition duration with &lt;code&gt;duration-300&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;the transition timing function with &lt;code&gt;ease-linear&lt;/code&gt; and,&lt;/li&gt;
&lt;li&gt;the hover behavior with &lt;code&gt;hover:scale-[98%] hover:[&amp;amp;&amp;gt;img]:scale-110&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note: &lt;code&gt;[&amp;amp;&amp;gt;img]&lt;/code&gt; is an arbitrary value. It allowed me to target the child &lt;code&gt;img&lt;/code&gt; from the container and apply the scaling up for the zoom effect.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding text to the card
&lt;/h3&gt;

&lt;p&gt;One restriction here is, I didn't want to text to scale down with the whole card because too many things would be moving.&lt;/p&gt;

&lt;p&gt;To tackle that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I added a wrapper around &lt;code&gt;img&lt;/code&gt; that would scale down when the card (main container) is hovered with the mouse,&lt;/li&gt;
&lt;li&gt;the title is absolutely positioned relatively to the main container,&lt;/li&gt;
&lt;li&gt;the arbitrary values slightly change as now, we introduced an extra layer: &lt;code&gt;hover:[&amp;amp;&amp;gt;div]:scale-[98%] hover:[&amp;amp;&amp;gt;div&amp;gt;img]:scale-110&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Without text, we could target &lt;code&gt;img&lt;/code&gt; directly but now, we want the scale down to be applied on the image wrapper, thus &lt;code&gt;[&amp;amp;&amp;gt;div]&lt;/code&gt;, and the scale up on the image inside which results in &lt;code&gt;[&amp;amp;&amp;gt;div&amp;gt;img]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That's it! Thank you for reading and let me know in comments if it could be improved 👋&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>tutorial</category>
      <category>css</category>
    </item>
    <item>
      <title>Using overflow:scroll and flexbox to render a vertical list that takes all the available height based on a sibling element</title>
      <dc:creator>John Cheng</dc:creator>
      <pubDate>Fri, 28 Oct 2022 03:29:54 +0000</pubDate>
      <link>https://dev.to/johnnhoj/using-overflowscroll-and-flexbox-to-render-a-vertical-list-that-takes-all-the-available-height-based-on-a-sibling-element-g9b</link>
      <guid>https://dev.to/johnnhoj/using-overflowscroll-and-flexbox-to-render-a-vertical-list-that-takes-all-the-available-height-based-on-a-sibling-element-g9b</guid>
      <description>&lt;p&gt;tldr; Here is an implementation of a vertical scrollable list using flexbox that takes the available space set by a sibling element. Vanilla CSS and Tailwind versions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/clever-firefly-y97s87?file=/index.html"&gt;Code in Sandbox&lt;/a&gt; (&lt;em&gt;Contains Vanilla CSS version and Tailwind version&lt;/em&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  Use case
&lt;/h2&gt;

&lt;p&gt;We wanted to have a container with 2 columns where:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;the left-hand side had a growable textarea and,&lt;/li&gt;
&lt;li&gt;the right-hand side had a scrollable list on the y-axis that takes the full height&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Requirements
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;textarea&lt;/code&gt; can contain as much text as it wants&lt;/li&gt;
&lt;li&gt;The scrollable list should use the available height based on &lt;code&gt;textarea&lt;/code&gt; and display as many items as possible or &lt;code&gt;overflow:scroll&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Challenges
&lt;/h2&gt;

&lt;p&gt;When using flexbox with &lt;code&gt;overflow:scroll&lt;/code&gt; and rendered the list of items directly, it would increase the height instead of displaying as many as possible given the height from the left-hand side.&lt;/p&gt;




&lt;h2&gt;
  
  
  Our solution for the scrollable list
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;We have a &lt;code&gt;flex&lt;/code&gt; wrapper that has the &lt;code&gt;overflow: scroll;&lt;/code&gt; property, let's call it &lt;em&gt;container&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We added an additional wrapper container around the overflowing list of items with a &lt;code&gt;max-height: 0;&lt;/code&gt;, let's call it &lt;em&gt;list-container&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We rendered the list of items&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If we had rendered the items in &lt;em&gt;container&lt;/em&gt; directly, they would have increased its height and not respect the height provided by &lt;code&gt;textarea&lt;/code&gt; on the left-hand side.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;list-container&lt;/em&gt; do not increase the height of &lt;em&gt;container&lt;/em&gt; thanks to &lt;code&gt;max-height:0;&lt;/code&gt; and as we do not define the overflow behaviour, it defaults to visible. However, as we set &lt;code&gt;overflow:scroll&lt;/code&gt; at the &lt;em&gt;container&lt;/em&gt; level, we still benefit from the scrolling we wanted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final note
&lt;/h2&gt;




&lt;p&gt;I hope you found the post interesting. If you have implemented a similar solution in a more elegant way, please let me know in comments 🙌 This is what &lt;strong&gt;we&lt;/strong&gt; came up with and it's probably not perfect!&lt;/p&gt;

&lt;p&gt;Take care everyone 👋&lt;/p&gt;

</description>
      <category>css</category>
      <category>tailwindcss</category>
      <category>tutorial</category>
      <category>overflowscroll</category>
    </item>
    <item>
      <title>How I handle my notes with symbolic links</title>
      <dc:creator>John Cheng</dc:creator>
      <pubDate>Sun, 21 Feb 2021 17:37:14 +0000</pubDate>
      <link>https://dev.to/futurice/how-i-handle-my-notes-with-symbolic-links-594j</link>
      <guid>https://dev.to/futurice/how-i-handle-my-notes-with-symbolic-links-594j</guid>
      <description>&lt;h1&gt;
  
  
  Background
&lt;/h1&gt;

&lt;p&gt;Handling notes has always been tricky for me. Should I use an app or have markdowns in a folder?&lt;/p&gt;

&lt;p&gt;Lately, I decided to only use markdowns and have them centralised in a folder called &lt;code&gt;notes&lt;/code&gt; while making them accessible in the relevant projects via symbolic links.&lt;/p&gt;

&lt;p&gt;Objectives:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Access only project specific notes in VSCode (or any IDE)&lt;/li&gt;
&lt;li&gt;Keep a folder containing all of my notes&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  How-To
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~
|-- .gitignore_global
|-- Documents/
    |-- notes/
        |-- project_foo/
    |-- project_foo/
        |-- .notes/ (ignore from version control)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Instructions
&lt;/h2&gt;

&lt;p&gt;The first step is to have the version control ignore the notes in each projects. For example, I decided to have my notes in a &lt;code&gt;.notes&lt;/code&gt; folder under each project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create a global gitignore
touch ~/.gitignore_global

# Add the folder that will contain the notes in each project
echo .notes &amp;gt;&amp;gt; ~/.gitignore_global

# Add the global gitignore to the git configurations
git config --global core.excludesfile ~/.gitignore_global
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's create the folder that will contain all the notes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create the folder where all the notes will be centralised
mkdir ~/Documents/notes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, let's say we have a project called &lt;code&gt;project_foo&lt;/code&gt;. We can now create the folder that will contain the notes and link it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create the folder where the project specific notes will be found
mkdir ~/Documents/notes/project_foo

# Link the project specific notes folder into the project
ln -s ~/Documents/notes/project_foo ~/Documents/project_foo/.notes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Folder &lt;code&gt;notes&lt;/code&gt; contains &lt;strong&gt;all&lt;/strong&gt; the notes&lt;/li&gt;
&lt;li&gt;Each project has a &lt;code&gt;.notes&lt;/code&gt; folder with &lt;strong&gt;only related notes&lt;/strong&gt; and ignored by version control&lt;/li&gt;
&lt;li&gt;All the notes are synced between the &lt;code&gt;notes&lt;/code&gt; folder and the &lt;code&gt;.notes&lt;/code&gt; one in each project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks to this architecture, I am now able to access my project's notes in my IDE directly and avoid using another app for that. To add to that, because they are synced in the &lt;code&gt;notes&lt;/code&gt; folder, I still have the possibility to open all my notes at once if needed.&lt;/p&gt;

&lt;h1&gt;
  
  
  Final words
&lt;/h1&gt;

&lt;p&gt;Thank you for reading my &lt;strong&gt;first ever blog post&lt;/strong&gt; and I hope it helps some of you :)&lt;/p&gt;

&lt;p&gt;Let me know your thoughts and/or improvements!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://unsplash.com/@dtravisphd?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Photo by David Travis&lt;/a&gt;&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>notes</category>
      <category>markdown</category>
      <category>git</category>
    </item>
  </channel>
</rss>
