<?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: Ananya Neogi</title>
    <description>The latest articles on DEV Community by Ananya Neogi (@ananyaneogi).</description>
    <link>https://dev.to/ananyaneogi</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%2F106991%2Fb487674a-45f7-4116-b695-a2607893e0ac.jpg</url>
      <title>DEV Community: Ananya Neogi</title>
      <link>https://dev.to/ananyaneogi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ananyaneogi"/>
    <language>en</language>
    <item>
      <title>Setting career goals</title>
      <dc:creator>Ananya Neogi</dc:creator>
      <pubDate>Tue, 05 Jan 2021 17:09:09 +0000</pubDate>
      <link>https://dev.to/ananyaneogi/setting-career-goals-1f5n</link>
      <guid>https://dev.to/ananyaneogi/setting-career-goals-1f5n</guid>
      <description>&lt;p&gt;When I ask people about their career goals, I mostly get answers like “I just go with the flow”. While this might work fine for some people but it generally doesn’t bode well in the long run. If you talk to successful people, you would quickly realize that most of them had been intentional with all their career-oriented decisions and those deliberate decisions have led to the place they are now.&lt;/p&gt;

&lt;p&gt;Intentionally crafting your career is essential. It is, however, easier said than done as we have myriad of options to choose from at our disposal. Also, it doesn’t help that we have so many distractions especially when every other day people are creating hype around some new technology or some new trend on Twitter. So that makes it more important to be intentional about the things we want to do in our career and not let ourselves fall into the trap of trends. Though I agree, sometimes, it pays off to jump on that hype train but make sure you are doing it for the right reasons and that you have done your research.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An aside thought:&lt;/strong&gt; I like to think of my career goals as an engineering problem for which I would carefully craft a solution that would help me achieve a particular outcome, similar to how I would do if it were an actual engineering problem. It might seem like an oversimplification because life doesn’t work that way, and there will be unknown bumps on the road, and we might even change course in the middle. But at its core, I think this analogy holds well. Thinking about my career goals in this sense allows me to be more analytical about my decisions!&lt;/p&gt;

&lt;p&gt;Coming back to the topic of setting intentional career goals – I have some questions you can ask yourself which will guide you to be intentional when setting your career goals for this year and beyond.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Do my values and work align with each other?
&lt;/h3&gt;

&lt;p&gt;Not a lot of people think about their values. But investing time and effort to think about what values matter the most to you and then aligning your career decisions to that will ensure you are on your best path forward. It will also ensure that the work you’re doing will truly make you feel fulfilled at the end of the day.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. How do you want to spend most of your workdays?
&lt;/h3&gt;

&lt;p&gt;I think this is the most important thing to consider because each day’s work will eventually make up your whole career. Intentionally selecting the kind of work to focus on each day means you are ultimately creating an intentional career path for yourself.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. A few years from now, how would you like to be introduced to someone else?
&lt;/h3&gt;

&lt;p&gt;Would you like to be called an author of a book or a paper? Maybe the creator of x? The first person to live on Mars? I’m joking about the last one, but the point is this can be a fun exercise and will help you dig deep into your dreams and aspirations.&lt;/p&gt;

&lt;p&gt;Now every time you have to make a career decision, you will have your answers as guiding principles. It is worth mentioning that the answers to these questions might change in a few years, but that’s OK because our goals can evolve as we evolve in our lives. Being true to yourself and what you want – however clichéd that might sound – will serve you well in the long run. Remember, we’re here for the marathon, not a sprint.&lt;/p&gt;

</description>
      <category>career</category>
    </item>
    <item>
      <title>How to be a good mentee</title>
      <dc:creator>Ananya Neogi</dc:creator>
      <pubDate>Mon, 17 Aug 2020 01:53:25 +0000</pubDate>
      <link>https://dev.to/ananyaneogi/how-to-be-a-good-mentee-3n52</link>
      <guid>https://dev.to/ananyaneogi/how-to-be-a-good-mentee-3n52</guid>
      <description>&lt;p&gt;I've found a lot of resources on being a good mentor but haven't found many on how to be a good mentee. Mentorship is a two-way street so its important for the mentee to give their 100% as its important for the mentor.&lt;/p&gt;

&lt;p&gt;Here's some advice, based on personal experience, on how to be a good mentee to get the most out of mentorship sessions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Take charge
&lt;/h2&gt;

&lt;p&gt;As a mentee, it is up to you to set the tone and expectations of your mentorship sessions. As an aside, I think it's important to mention here that a good mentor will let you take charge of your mentorship sessions! Be clear about your goals and expectations. Make sure to communicate what type of learning works best for you, for example, are you more comfortable with hands-on pair programming style sessions or you’re more comfortable with doing technical discussions together but then working on the problem later on your own. Whatever the method may be, the goal is to create the best learning environment for yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Come prepared
&lt;/h2&gt;

&lt;p&gt;During the mentorship session if you don’t have any predetermined tasks to work on then you can come prepared with some questions to ask your mentor or any topic to have a healthy discussion on. As a mentee, it’s up to you to absorb as much knowledge from your mentor.&lt;/p&gt;

&lt;h2&gt;
  
  
  It is ok to sound stupid
&lt;/h2&gt;

&lt;p&gt;Let go of your ego. Don’t be afraid to be the less smart person in the room. If you don’t understand a concept or even a word, ask for an explanation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ask good questions
&lt;/h2&gt;

&lt;p&gt;No question is a bad question so you should never be afraid to ask them. But I believe that an answer is as good as the question being asked, so be specific in your questions. &lt;br&gt;
For example, asking how does &lt;code&gt;useCallback&lt;/code&gt; hook work is an ok question but you can easily get a general answer if you read the react docs but instead, if you be specific and ask - "I know why we generally use &lt;code&gt;useCallback&lt;/code&gt; but in what scenarios will an &lt;code&gt;useCallback&lt;/code&gt; hook be most effective? Are there cases when you should avoid using it?"&lt;/p&gt;

&lt;p&gt;By asking specific questions you will get specific effective answers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the momentum going
&lt;/h2&gt;

&lt;p&gt;Do the work. There is no shortcut for this. If you are involved in a mentorship program/arrangement you have to take time out of your day to do the work.&lt;/p&gt;

&lt;p&gt;Do a weekly check-in with your mentor. Even if it’s not a full one-on-one mentorship session each week, at least keep your mentor up to date with your progress (positive or negative).&lt;br&gt;
A mentee has the power to keep a forward momentum of the mentorship.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ask for feedback
&lt;/h2&gt;

&lt;p&gt;Feedback is the most crucial part of the whole process. Ask for it. Ask for it often. And once you get some, act upon it. Ask clarifying questions if you don’t fully understand what the feedback is supposed to mean. Make sure to iron out exactly what action you need to take to improve upon based on the feedback. Remember that feedback without action is simply information.&lt;/p&gt;

&lt;p&gt;If the feedback made you feel uncomfortable, make sure to communicate that clearly with your mentor. Feedback is supposed to build you up, not tear you down.&lt;/p&gt;




&lt;p&gt;On closing notes, mentorship is a really great way to level up and learn from other's experiences. You can have a mentor in any way or capacity. It can be a formal time-boxed arrangement or it can be an informal arrangement with someone you respect or it can even be a life-long thing, whatever that may be make sure you respect yours and your mentors time. Do the work and absorb as much knowledge as you can!&lt;/p&gt;

</description>
      <category>career</category>
    </item>
    <item>
      <title>2019 Year In Review</title>
      <dc:creator>Ananya Neogi</dc:creator>
      <pubDate>Thu, 02 Jan 2020 06:45:47 +0000</pubDate>
      <link>https://dev.to/ananyaneogi/2019-year-in-review-ehh</link>
      <guid>https://dev.to/ananyaneogi/2019-year-in-review-ehh</guid>
      <description>&lt;p&gt;2019 was the best year of my professional life thus far and I'm so grateful for that. There were so many &lt;em&gt;pinch-myself&lt;/em&gt; moments and I'm still in awe of how so many things turned out to be.&lt;/p&gt;

&lt;p&gt;Two of my biggest achievements this year were tackling imposter syndrome and overcoming my anxiety about being in public spaces.&lt;br&gt;
I put in a lot of effort and learned a lot in my field which helped me overcome some serious case of imposter syndrome! I know it is something that never fully goes away, that it comes and goes but I did tackle that well this year 💪&lt;/p&gt;

&lt;p&gt;One of the goals I set for 2019 was to be active in the developer community and I'm so happy I did it as much as I could. In the past, I was never able to go to meetups/events due to my anxiety and I always used to turn down such opportunities but this year I went head first and attended as many meetups/events/conferences as I could. And let me tell you that was the best decision ever! &lt;/p&gt;

&lt;h2&gt;
  
  
  Writing
&lt;/h2&gt;

&lt;p&gt;The biggest thing that influenced my year was me writing on &lt;a href="//dev.to/ananyaneogi"&gt;dev.to&lt;/a&gt;. It opened up many opportunities for me and I came across so many amazing people because of it. My posts on dev has more than 300k views! &lt;em&gt;What!&lt;/em&gt; 🤯&lt;br&gt;
It makes my day whenever I read a comment or an email or a twitter DM saying they're thankful they learned something from my blog.&lt;/p&gt;

&lt;p&gt;I'm so grateful for this community 💜. Kudos to the entire DEV team for building such an amazing platform! &lt;/p&gt;

&lt;p&gt;I also received my first paid writing gig this year! I never imagined when I started writing at the start of this year that this could even happen.&lt;/p&gt;

&lt;p&gt;To be honest I didn't write as many posts as I would have liked to but I will continue to write as much as I can going forward.&lt;/p&gt;

&lt;h2&gt;
  
  
  Career
&lt;/h2&gt;

&lt;p&gt;This year was full of learning. I deep-dived into JavaScript, learned a lot about Accessibility, really understood how React works and polished my skills in CSS. I worked on some small projects purely for learning purposes (check out github).&lt;br&gt;
I did start work on one or two side projects but did not finish any of it, will continue to work on those in 2020. Or maybe I'll start a few new ones, I'm not sure 😅&lt;/p&gt;

&lt;p&gt;I also finished Hacktoberfest! Looking forward to contribute more towards OSS. &lt;/p&gt;

&lt;p&gt;I spoke at my first ever major conference at &lt;a href="https://www.reactindia.io/conferences/2019"&gt;ReactIndia&lt;/a&gt;. It was an amazing experience and I feel so honoured that I got to share the stage with such amazing people of the tech community.&lt;/p&gt;

&lt;h2&gt;
  
  
  Life
&lt;/h2&gt;

&lt;p&gt;I don't really write about my personal life but here's a brief overview in the grand scheme of things -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I started bullet journaling this year and it has been a game-changer for me. I will continue this in the future.&lt;/li&gt;
&lt;li&gt;Travelled solo halfway across the world!&lt;/li&gt;
&lt;li&gt;Travelled to a few more places with friends, the best one was the trip to McLeod Ganj. Have you been there? You should.&lt;/li&gt;
&lt;li&gt;Made some good new friends.&lt;/li&gt;
&lt;li&gt;Did rock climbing, rappelling and zip-lining for the first time.&lt;/li&gt;
&lt;li&gt;Did not read as many books as I wanted to.&lt;/li&gt;
&lt;li&gt;Started to re-learn French.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Onwards 2020
&lt;/h2&gt;

&lt;p&gt;I'll be moving to a new place (details to be disclosed soon 😊) This will be a big change and will shake things up a lot so I've not set any goals that are set in stone. I've left room for a lot of experimentation and I'll adapt as things happen.&lt;/p&gt;

&lt;p&gt;But I do have goals that I wish to see through-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I want to continue writing about all the things I'm learning&lt;/li&gt;
&lt;li&gt;I want to speak at more events and the focus will be on small local events&lt;/li&gt;
&lt;li&gt;I want to read at least 14 books&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy new year folks! 🎉 Looking forward to 2020! &lt;br&gt;
Share your year in review and 2020 goals with me &lt;a href="https://twitter.com/_ananyaneogi"&gt;@_ananyaneogi&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;I also want to mention that success doesn't always mean visible success! It's ok if you didn't tick off your 2019 goals checklist or you don't have a long list of "achievements" for the year. Sometimes life gets in the way and things happen so be kind to yourself. 💜 &lt;strong&gt;Tangible achievements are not always the true measure of success!&lt;/strong&gt; Celebrate your wins no matter how small because small wins accumulate and become big one day. Get ready to take on life in the new year even stronger 💪&lt;/p&gt;




</description>
      <category>yearinreview</category>
    </item>
    <item>
      <title>Demystifying Modern Frontend Jargon</title>
      <dc:creator>Ananya Neogi</dc:creator>
      <pubDate>Thu, 10 Oct 2019 18:13:52 +0000</pubDate>
      <link>https://dev.to/ananyaneogi/demystifying-modern-frontend-jargon-1agf</link>
      <guid>https://dev.to/ananyaneogi/demystifying-modern-frontend-jargon-1agf</guid>
      <description>&lt;p&gt;The world of frontend programming is full of confusing jargons and we see a lot these terms getting thrown around. This is my small attempt to break down some of these terms or concepts into simpler terms with very limited to no code examples.&lt;/p&gt;

&lt;h1&gt;
  
  
  1. Pure function
&lt;/h1&gt;

&lt;p&gt;A function is called pure when its return value is determined only by its own arguments. When given the same argument, the result will always be the same.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;twice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we pass &lt;code&gt;4&lt;/code&gt; to this function, it will always return &lt;code&gt;8&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Key points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pure functions provide &lt;em&gt;&lt;a href="https://en.wikipedia.org/wiki/Referential_transparency"&gt;referential transparency&lt;/a&gt;&lt;/em&gt;. This means that when a pure function is invoked it can be replaced by its own result. We can replace &lt;code&gt;twice(4)&lt;/code&gt; by &lt;code&gt;8&lt;/code&gt; without affecting our outcome.&lt;/li&gt;
&lt;li&gt;Pure functions cannot reference variables from their outer scope. If any function is doing so then its not a pure function.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NOT a pure function&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// can be mutated from anywhere else&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;impureTwice&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Pure functions cannot call impure functions.&lt;/li&gt;
&lt;li&gt;Pure functions do not produce side effects (see below).&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  2. Impure function
&lt;/h1&gt;

&lt;p&gt;An impure function mutates state outside its scope. Any function that has side effects is impure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// can be mutated from anywhere else&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// alerts and dialogs also cause side effect&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;showAlert&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;oh hey! this is a side effect!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Beware! might seem like a pure function, but its not&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getRandomRange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;max&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;max&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  3. Side effect
&lt;/h1&gt;

&lt;blockquote&gt;An operation, function or expression is said to have a side effect if it modifies some state variable value outside its local environment.&lt;/blockquote&gt;

&lt;p&gt;When a function or expression modifies state outside its own context, the result is a side effect. For example, manipulating the DOM, making an API call, modifying database, creating alerts and dialogs, etc.&lt;/p&gt;




&lt;h1&gt;
  
  
  4. Stateful vs Stateless
&lt;/h1&gt;

&lt;p&gt;Stateful programs or components store data in memory about the current state. They can modify the state and access its history as well.&lt;/p&gt;

&lt;p&gt;Stateless programs or components depend only on their arguments and do not access or even need knowledge about anything outside their scope. They do not reference any information from earlier in their execution. &lt;strong&gt;Pure functions are stateless.&lt;/strong&gt; Its the statelessness that enables referential transparency in pure functions.&lt;/p&gt;




&lt;h1&gt;
  
  
  5. Imperative vs Declarative Paradigms
&lt;/h1&gt;

&lt;p&gt;JavaScript can support both programming paradigms.&lt;br&gt;
Imperative code gives instructions informing the computer &lt;strong&gt;how&lt;/strong&gt; to achieve a desired result, such as &lt;code&gt;for&lt;/code&gt; loop.&lt;br&gt;
Declarative code tells the computer &lt;strong&gt;what&lt;/strong&gt; you want to achieve rather than how, and the computer takes care of how to achieve the end result, such as &lt;code&gt;Array.map&lt;/code&gt;.&lt;/p&gt;


&lt;h1&gt;
  
  
  6. Reactive Programming &amp;amp; Observables
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Reactive programming&lt;/strong&gt; is the idea that you can create entire program just by defining the different streams and the operations that are performed on those streams.&lt;br&gt;
&lt;em&gt;Streams&lt;/em&gt; are nothing but sequence of values over time.&lt;/p&gt;

&lt;blockquote&gt;
Here's an analogy: Think about reactive programming as plumbing. We decide which pipes we need in our application, we decide how those pipes are connected together and then we turn on the water and sit back.
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Observables&lt;/strong&gt; are a blueprint for how we want to create streams, subscribe to them, react to new emitted values, and combine streams together to build new ones. JavaScript observables are an implementation of the observer pattern.&lt;/p&gt;

&lt;p&gt;There are two types of observables -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Cold observables:&lt;/em&gt; They begin pushing only when we subscribe to it. If we subscribe again, it will start over.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Hot observables:&lt;/em&gt; They will always push even if we're not specifically reacting to them with a subscription.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://rxmarbles.com/"&gt;RxMarbles&lt;/a&gt; is a great resource to visualize all how the operations happen.&lt;/p&gt;


&lt;h1&gt;
  
  
  7. Tree shaking
&lt;/h1&gt;

&lt;p&gt;Tree shaking is a term used in reference to JavaScript module bundling. It refers to the static analysis of all imported code and exclusion of anything that isn't used.&lt;br&gt;
The concept behind tree shaking is &lt;em&gt;live code inclusion&lt;/em&gt;. This means that we include the parts that are needed to begin with, as opposed to removing the parts that are not needed at the later stage.&lt;/p&gt;


&lt;h1&gt;
  
  
  8. Compilation: JIT vs AOT
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Just-In-time (JIT)&lt;/strong&gt; compilation is the process of translating code written in a programming language to machine code at runtime (during a program or application's execution). At runtime, certain dynamic information is available, such as type identification. A JIT compiler monitors to detect functions or loops of code that are run multiple times. These pieces of code are then compiled. If they're quite commonly executed, JIT will optimize them and also store the optimized, compiled code for execution. Browsers use JIT compilation to run JavaScript. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ahead-Of-Time (AOT)&lt;/strong&gt; compilation is the process of translating code written in a programming language to machine code before execution (as opposed to at runtime). Doing so reduces runtime overhead and compiles all files together rather than separately.&lt;/p&gt;

&lt;p&gt;Some benefits of AOT:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Better security because evaluation is already done.&lt;/li&gt;
&lt;li&gt;Templates and styles are inlined with JS so fewer asynchronous calls.&lt;/li&gt;
&lt;li&gt;Small download size, because the compiler need not to be download as the app is precompiled.&lt;/li&gt;
&lt;li&gt;AOT also enables tree shaking.&lt;/li&gt;
&lt;/ul&gt;


&lt;h1&gt;
  
  
  9. Reducer
&lt;/h1&gt;

&lt;p&gt;If you've used Redux or functional programming, chances are you might already know this very well. But if we put aside that, what does a reducer mean itself? In simple terms, a reducer provides instructions for combining things. &lt;br&gt;
Typically a reducer function takes an accumulator, which is the on-going result of our combinations as we move along and the list of things that we wish to combine.&lt;br&gt;
Here's a (not very practical 😂) example of making cookie-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;flour&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;butter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sugar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;eggs&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;// result ➡️ ["cookie dough"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We &lt;em&gt;combined&lt;/em&gt; our list of ingredients to our desired result! 🍪 &lt;br&gt;
Here, &lt;code&gt;mix&lt;/code&gt; is our accumulator containing the on-going result of our combination so far. So, if we add something else to our list of ingredients our accumulator will change.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;flour&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;butter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sugar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;eggs&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;chocolate chip&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;// result ➡️ ["chocolate chip cookie dough"]&lt;/span&gt;
&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;flour&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;butter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sugar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;eggs&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blueberry&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;// result ➡️ ["blueberry cookie dough"]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we can see, we have &lt;strong&gt;reduced&lt;/strong&gt; our ingredients into a fully formed cookie dough!&lt;/p&gt;

&lt;h1&gt;
  
  
  10. Thunk
&lt;/h1&gt;

&lt;p&gt;In computer programming, a thunk is just another word for a function. But this is a special name for a function that’s returned by another function and it takes no arguments.&lt;br&gt;
Thunks are used to delay or defer a computation until its result is needed, or to insert operations at the beginning or end of the other computations. Then when that thunk is invoked, it performs a potentially expensive computation and/or causes some side effect to occur.&lt;/p&gt;

&lt;p&gt;For example -&lt;br&gt;
Suppose you wish to do some mathematical operations on numbers. Now, creating a thunk would mean not to do the computations directly, but instead create a function with no arguments that will calculate it when the actual value is needed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// this is a thunk because it defers work for later&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// it can be named, or anonymous&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;thunk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// we can store the returned function to a variable&lt;/span&gt;
&lt;span class="c1"&gt;// OR use it directly like ➡️ add(1,2)()&lt;/span&gt;

&lt;span class="c1"&gt;// we can pass the thunk to different places&lt;/span&gt;
&lt;span class="nx"&gt;checkIfEven&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;thunk&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// we can use it in other calculations&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;twice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;thunk&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;thunk()&lt;/code&gt; will return &lt;code&gt;3&lt;/code&gt; wherever used unless we change its value by calling &lt;code&gt;add&lt;/code&gt; again with different arguments.&lt;/p&gt;




&lt;p&gt;This was just my naive approach to explain things but if you have a better explanation for any of these, please comment below, I would love to know 🙂&lt;br&gt;
Also, If you know of any such frontend related jargons let me know, I might do a part 2!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>HTML can do that?</title>
      <dc:creator>Ananya Neogi</dc:creator>
      <pubDate>Tue, 25 Jun 2019 21:38:30 +0000</pubDate>
      <link>https://dev.to/ananyaneogi/html-can-do-that-c0n</link>
      <guid>https://dev.to/ananyaneogi/html-can-do-that-c0n</guid>
      <description>&lt;p&gt;After witnessing some &lt;a href="https://dev.to/ananyaneogi/css-can-do-that-18g7"&gt;awesome things CSS can do&lt;/a&gt;, it's time for HTML to come in the same spotlight!&lt;/p&gt;

&lt;p&gt;It's amazing that you can do so much with &lt;em&gt;just&lt;/em&gt; HTML.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Dropdown with searchable text
&lt;/h2&gt;

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




&lt;h2&gt;
  
  
  2. Dialog box
&lt;/h2&gt;

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




&lt;h2&gt;
  
  
  3. Measuring progress
&lt;/h2&gt;

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

&lt;p&gt;Styling this is not an easy task, I agree! But there's always some workaround and it's nicely explained here - &lt;a href="https://css-tricks.com/html5-progress-element/"&gt;How to style progress element&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Expand/collapse details
&lt;/h2&gt;

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




&lt;h2&gt;
  
  
  5. Show correct mobile keypad based on input type
&lt;/h2&gt;

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




&lt;h2&gt;
  
  
  6. Add a simple colour picker
&lt;/h2&gt;

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




&lt;h2&gt;
  
  
  7. Highlight text
&lt;/h2&gt;

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




&lt;h2&gt;
  
  
  8. Create a direct phone number link
&lt;/h2&gt;

&lt;p&gt;Similar to email link with &lt;code&gt;mailto&lt;/code&gt; we can also create a direct phone number link.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"tel:+917272727272"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;+91-7272727272&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  9. Show deletion and insertion of text
&lt;/h2&gt;

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




&lt;h2&gt;
  
  
  10. Edit page contents
&lt;/h2&gt;

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

&lt;p&gt;Wish to make your own browser editor? You can do that too - &lt;a href="https://www.simonewebdesign.it/how-to-make-browser-editor-with-html5-contenteditable/"&gt;How to make browser editor with html.&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; Not all browsers have implemented these elements and attributes. But we can still use these today with progressive enhancements! 🙂&lt;/p&gt;

&lt;p&gt;HTML is the foundation of any webpage, it's only wise to pay real good attention to it. Semantic markup not only helps in SEO but also helps in &lt;a href="https://dev.to/ananyaneogi/accessible-and-expressive-html-semantics-43h1"&gt;accessibility&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you've come across any such cool thing HTML is capable of, please mention below 😀&lt;/p&gt;




&lt;p&gt;In other news, I made a silly project : &lt;a href="https://hp-ipsum.netlify.com"&gt;https://hp-ipsum.netlify.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow me on twitter &lt;a href="https://twitter.com/_ananyaneogi"&gt;@_ananyaneogi&lt;/a&gt; to get more tidbits 😊&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>html</category>
    </item>
    <item>
      <title>What are your favourite non-tech related podcasts?</title>
      <dc:creator>Ananya Neogi</dc:creator>
      <pubDate>Sat, 15 Jun 2019 12:43:45 +0000</pubDate>
      <link>https://dev.to/ananyaneogi/what-are-your-favourite-non-tech-related-podcasts-1j6m</link>
      <guid>https://dev.to/ananyaneogi/what-are-your-favourite-non-tech-related-podcasts-1j6m</guid>
      <description>&lt;p&gt;Tell me your favourite non-tech related podcasts.&lt;br&gt;
I'll start with mine -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.wnycstudios.org/shows/radiolab"&gt;Radiolab&lt;/a&gt; &lt;em&gt;This is my most favourite one!&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://99percentinvisible.org/"&gt;99% Invisible&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npr.org/programs/invisibilia/"&gt;Invisibilia&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npr.org/series/423302056/hidden-brain"&gt;Hidden Brain&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gimletmedia.com/shows/science-vs"&gt;Science Vs.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All though I listen to many more sporadically, but these are the ones I try to keep up with.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>podcast</category>
    </item>
    <item>
      <title>Subgrids are here! (Almost)</title>
      <dc:creator>Ananya Neogi</dc:creator>
      <pubDate>Mon, 10 Jun 2019 20:43:30 +0000</pubDate>
      <link>https://dev.to/ananyaneogi/subgrids-are-here-almost-49eg</link>
      <guid>https://dev.to/ananyaneogi/subgrids-are-here-almost-49eg</guid>
      <description>&lt;p&gt;Support for subgrid (part of CSS Grid Level 2 specification) has landed on Firefox Nightly! Even though this is not yet getting shipped in any browser, but we can test it in the Nightly version. After trying it out for couple of hours I'm really excited to think about all the possibilities in layouts this will bring, once this gets shipped widely.&lt;/p&gt;

&lt;p&gt;To start experimenting with it you’ll need to enable the feature first on Nightly-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;code&gt;about:config&lt;/code&gt; in the browser&lt;/li&gt;
&lt;li&gt;Search for subgrid&lt;/li&gt;
&lt;li&gt;Toggle &lt;code&gt;layout.css.grid-template-subgrid-value.enabled&lt;/code&gt; and set &lt;code&gt;subgrid&lt;/code&gt; to true.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mxQTHplb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/od1ya45jd63hjqqgs8d4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mxQTHplb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/od1ya45jd63hjqqgs8d4.png" alt="" width="880" height="550"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  What are subgrids ?
&lt;/h1&gt;

&lt;blockquote&gt;A grid container that is itself a grid item can defer the definition of its rows and columns to its parent grid container, making it a subgrid. In this case, the grid items of the subgrid participate in sizing the grid of the parent grid container, allowing the contents of both grids to align.&lt;/blockquote&gt;

&lt;p&gt;This might sound a little confusing. Let us walk through an example. &lt;br&gt;
Here we have a &lt;code&gt;grid-wrapper&lt;/code&gt; inside which we have 3 direct child elements &lt;code&gt;elem1&lt;/code&gt;, &lt;code&gt;elem2&lt;/code&gt;,&lt;code&gt;elem3&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"grid-wrapper"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"elem elem1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Element 1&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"elem elem2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Element 2&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"elem elem3"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Element 4&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Element 4 paragraph 1&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Element 4 paragraph 2&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we position these on grid.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.grid-wrapper&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="na"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2fr&lt;/span&gt; &lt;span class="m"&gt;1fr&lt;/span&gt; &lt;span class="m"&gt;4fr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="na"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;30px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.elem1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;grid-column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;grid-row&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.elem2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;grid-column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;grid-row&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.elem3&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;grid-column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="m"&gt;-1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;grid-row&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;We notice that all the immediate children of &lt;code&gt;grid-wrapper&lt;/code&gt; are nicely placed on the grid, but not the inner children of &lt;code&gt;.elem3&lt;/code&gt;.&lt;br&gt;
What if now we want the &lt;code&gt;p&lt;/code&gt; elements to follow the same tracking size as it's parent as well because we don't want to explicitly position them. This is where &lt;code&gt;subgrid&lt;/code&gt; comes in.&lt;/p&gt;

&lt;p&gt;Replace the exsiting &lt;code&gt;.elem3&lt;/code&gt; with the following and see it in action.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.elem3&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;grid-column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="m"&gt;-1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;grid-row&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="na"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;subgrid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;In short, &lt;code&gt;subgrid&lt;/code&gt; is a new value for the &lt;code&gt;grid-template-columns&lt;/code&gt; and &lt;code&gt;grid-template-rows&lt;/code&gt; properties. This instructs the &lt;code&gt;grid-template-columns&lt;/code&gt;/ &lt;code&gt;grid-template-rows&lt;/code&gt;property to use the tracks defined on the parent as the track sizing and number used by the inner grid without explicitly stating.&lt;/p&gt;

&lt;p&gt;This is just a basic example. We can create complex and interesting layouts very easily with the combination of grid and subgrid.&lt;/p&gt;

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

&lt;h1&gt;
  
  
  References
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/TR/css-grid-2/"&gt;W3C Spec&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Subgrid"&gt;MDN docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Excellent talk by Rachel Andrew at CSSconf EU 2019: &lt;a href="https://www.youtube.com/watch?v=vxOj7CaWiPU"&gt;Hello Subgrid!&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>webdev</category>
      <category>css</category>
    </item>
    <item>
      <title>Are you a conference speaker? Share your experience!</title>
      <dc:creator>Ananya Neogi</dc:creator>
      <pubDate>Mon, 27 May 2019 17:48:23 +0000</pubDate>
      <link>https://dev.to/ananyaneogi/are-you-a-conference-speaker-share-your-experience-547p</link>
      <guid>https://dev.to/ananyaneogi/are-you-a-conference-speaker-share-your-experience-547p</guid>
      <description>&lt;p&gt;If you're a conference speaker, share your experience so far! &lt;br&gt;
Some insights on the following would be great for people who wish to start speaking at conferences - &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How did you get started? &lt;/li&gt;
&lt;li&gt;Tips for writing CFPs?&lt;/li&gt;
&lt;li&gt;Things to keep in mind while preparing for the talk?&lt;/li&gt;
&lt;li&gt;Share any links to resources that you've come across or you have written yourself on the topic of public speaking.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
      <category>techtalks</category>
    </item>
    <item>
      <title>CSS can do that?</title>
      <dc:creator>Ananya Neogi</dc:creator>
      <pubDate>Fri, 17 May 2019 21:42:09 +0000</pubDate>
      <link>https://dev.to/ananyaneogi/css-can-do-that-18g7</link>
      <guid>https://dev.to/ananyaneogi/css-can-do-that-18g7</guid>
      <description>&lt;p&gt;A list of amazing things that CSS can do! &lt;/p&gt;

&lt;p&gt;&lt;em&gt;EDIT: Some of these properties won't work in some browsers because of support. We can check for browser support using &lt;code&gt;@supports&lt;/code&gt; and add fallback styles accordingly. Please use Chrome to view the examples 🙂&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. &lt;code&gt;box-decoration-break&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This CSS property specifies how an element's fragments should be rendered when broken across multiple lines, columns, or pages.&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/ananyaneogi/embed/GeRoRO?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  2. &lt;code&gt;attr()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;We can retrieve values of the selected element in CSS by using &lt;code&gt;attr()&lt;/code&gt;. This method could be really helpful with accessibility purposes.&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/ananyaneogi/embed/gEpeda?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  3. &lt;code&gt;backface-visibility&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This CSS property sets whether the back face of an element is visible when turned towards the user. Thinking of a card flip UI?&lt;/p&gt;

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




&lt;h2&gt;
  
  
  4. &lt;code&gt;conic-gradient&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Gradients are a wonderful thing. You might've used to style backgrounds with linear gradients but do you know we can use pure css to create pie charts with the help of &lt;code&gt;conic-gradient&lt;/code&gt;!&lt;/p&gt;

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

&lt;p&gt;To better understand how &lt;code&gt;conic-gradients&lt;/code&gt;, reference the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/conic-gradient"&gt;MDN docs on it&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  5. &lt;code&gt;filter&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Who needs photoshop filter effects when you have CSS filters. 🙃&lt;br&gt;
Filter functions applies graphical changes to the appearance of an input image. The effects we can achieve are as follows - &lt;code&gt;blur&lt;/code&gt;, &lt;code&gt;brightness&lt;/code&gt;, &lt;code&gt;contrast&lt;/code&gt;, &lt;code&gt;grayscale&lt;/code&gt;, &lt;code&gt;hue-rotate&lt;/code&gt;, &lt;code&gt;opacity&lt;/code&gt;, &lt;code&gt;invert&lt;/code&gt;, &lt;code&gt;sepia&lt;/code&gt;, &lt;code&gt;saturate&lt;/code&gt;, &lt;code&gt;drop-shadow&lt;/code&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;drop-shadow&lt;/code&gt; filter is pretty amazing. It lets you apply drop shadow to the input image. &lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/ananyaneogi/embed/PvmbeR?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  6. &lt;code&gt;mix-blend-mode&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This CSS property sets how an element's content should blend with the content of the element's background or its parent.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ananyaneogi/embed/rgwNLx?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;br&gt;
Amazing things can be achieved by mixing blend modes and filters with images and text. Learn more on &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode"&gt;MDN Docs.&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  7. &lt;code&gt;first-letter&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;One of my favourite things in books and magazines are the beautiful drop-caps. We can create drop with &lt;code&gt;first-letter&lt;/code&gt; pseudo-element.&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/ananyaneogi/embed/oRWBBE?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  8. &lt;code&gt;shape-outside&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This CSS property provides a way to customise wrapping adjacent inline content around complex objects rather than simple rectangular boxes.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/ananyaneogi/embed/ZNKepv?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;em&gt;Open the example in a different tab and try changing the width of the window and notice how the text wraps around the image.&lt;/em&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  9. &lt;code&gt;writing-mode&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This CSS property sets whether the lines of text are laid out horizontally or vertically. We can have these values-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;horizontal-tb&lt;/code&gt; - Content flows horizontally from left to right, vertically from top to bottom.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;vertical-lr&lt;/code&gt; - Content flows horizontally from left to right, vertically from top to bottom.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;vertical-rl&lt;/code&gt; - Content flows horizontally from right to left, vertically from top to bottom.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Checkout this &lt;a href="https://ananyaneogi.github.io/css-experiments/quote.html"&gt;this example&lt;/a&gt; to see it in action.&lt;/p&gt;


&lt;h2&gt;
  
  
  10. Adding gradient to text
&lt;/h2&gt;

&lt;p&gt;This is achieved with the combination of &lt;code&gt;-webkit-background-clip: text&lt;/code&gt; and &lt;code&gt;-webkit-text-fill-color: transparent&lt;/code&gt; CSS properties.&lt;/p&gt;

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




&lt;h2&gt;
  
  
  11. Smooth scroll snap
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;scroll-snap-type&lt;/code&gt; CSS property sets how snap points are applied on the scroll container.&lt;/p&gt;

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

&lt;p&gt;This example shows vertical(&lt;code&gt;y&lt;/code&gt;) scroll with value &lt;code&gt;mandatory&lt;/code&gt;. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-type"&gt;MDN docs&lt;/a&gt; does a great job on explaining how to use other values such as &lt;code&gt;proximity&lt;/code&gt; and horizontal scroll(&lt;code&gt;x&lt;/code&gt;).&lt;/p&gt;




&lt;p&gt;These are just a few great things CSS can do. Possibilities are endless! 🥳&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
    </item>
    <item>
      <title>Create A Dark/Light Mode Switch with CSS Variables</title>
      <dc:creator>Ananya Neogi</dc:creator>
      <pubDate>Wed, 10 Apr 2019 20:27:44 +0000</pubDate>
      <link>https://dev.to/ananyaneogi/create-a-dark-light-mode-switch-with-css-variables-34l8</link>
      <guid>https://dev.to/ananyaneogi/create-a-dark-light-mode-switch-with-css-variables-34l8</guid>
      <description>&lt;p&gt;Giving your users a way to customise the interface to their preference is a huge win for user experience. Here we are going to provide the user with a simple switch to toggle between dark mode and light mode and we will also try to remember their preference for future visits.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let's begin!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you don't have a website of your own to which you wish to add this functionality, use this demo website to follow along.&lt;/p&gt;

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

&lt;h1&gt;
  
  
  Adding the CSS
&lt;/h1&gt;

&lt;p&gt;We will be adding CSS custom properties also known as CSS variables, which we can reference and modify throughout the document. If you wish to read more about custom properties you can &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties" rel="noopener noreferrer"&gt;read on MDN.&lt;/a&gt; &lt;br&gt;
Here's the tldr; version - &lt;/p&gt;

&lt;blockquote&gt;Custom properties (sometimes referred to as CSS variables or cascading variables) are entities defined by CSS authors that contain specific values to be reused throughout a document. They are set using custom property notation (e.g., --main-color: black;) and are accessed using the var() function (e.g., color: var(--main-color);) &lt;/blockquote&gt;

&lt;p&gt;First, we'll add our light or default mode css variables to the &lt;code&gt;:root&lt;/code&gt; pseudo class. It matches with the root element in your document tree, generally the &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; tag. We will use &lt;code&gt;:root&lt;/code&gt; because we want to avail the variables globally.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;

&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;--primary-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#302AE6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="na"&gt;--secondary-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#536390&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="na"&gt;--font-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#424242&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="na"&gt;--bg-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="na"&gt;--heading-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#292922&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Second, we'll add our dark mode css variables.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;

&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;data-theme&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"dark"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;--primary-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#9A97F3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="na"&gt;--secondary-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#818cab&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="na"&gt;--font-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#e1e1ff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="na"&gt;--bg-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#161625&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="na"&gt;--heading-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#818cab&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;What is &lt;code&gt;[data-theme="dark"]&lt;/code&gt;? This means we are referencing a &lt;code&gt;data&lt;/code&gt; attribute called &lt;code&gt;data-theme&lt;/code&gt; with a value "dark". We will find the use of it in a while.&lt;/p&gt;

&lt;p&gt;Then, we can reference these variables in our stylesheets like so-&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;

&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;bg-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;font-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="cm"&gt;/*other styles*/&lt;/span&gt;
    &lt;span class="nc"&gt;.....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;secondary-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="cm"&gt;/*other styles*/&lt;/span&gt;
    &lt;span class="nc"&gt;.....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;primary-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="cm"&gt;/*other styles*/&lt;/span&gt;
    &lt;span class="nc"&gt;.....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;







&lt;h1&gt;
  
  
  Adding the HTML "toggle switch markup"
&lt;/h1&gt;

&lt;p&gt;This is essentially just a checkbox, however we will add some additional markup to style like a toggle switch. I referenced the styles from &lt;a href="https://codepen.io/AllThingsSmitty/pen/MmxxOz/" rel="noopener noreferrer"&gt;this codepen.&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"theme-switch-wrapper"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"theme-switch"&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"slider round"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;em&amp;gt;&lt;/span&gt;Enable Dark Mode!&lt;span class="nt"&gt;&amp;lt;/em&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;

&lt;span class="cm"&gt;/*Simple css to style it like a toggle switch*/&lt;/span&gt;
&lt;span class="nc"&gt;.theme-switch-wrapper&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nt"&gt;em&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;margin-left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.theme-switch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inline-block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;34px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;60px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.theme-switch&lt;/span&gt; &lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;display&lt;/span&gt;&lt;span class="nd"&gt;:none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.slider&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#ccc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;.4s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.slider&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;4px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;26px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;4px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;.4s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;26px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="nd"&gt;:checked&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nc"&gt;.slider&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#66bb6a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="nd"&gt;:checked&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nc"&gt;.slider&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;translateX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;26px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.slider.round&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;34px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.slider.round&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;







&lt;h1&gt;
  
  
  Adding the JavaScript
&lt;/h1&gt;

&lt;p&gt;The final part is to add the bit of JavaScript to tie it all together.&lt;br&gt;
We have 3 tasks in hand-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add event handlers to handle accordingly the check/uncheck event of toggle-switch&lt;/li&gt;
&lt;li&gt;Store the user preference for future visits&lt;/li&gt;
&lt;li&gt;Check for saved user preference, if any, on load of the website&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Adding the event handlers
&lt;/h4&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;


&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;toggleSwitch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.theme-switch input[type="checkbox"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;switchTheme&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data-theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data-theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;    
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;toggleSwitch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;change&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;switchTheme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Remember, the &lt;code&gt;data-theme&lt;/code&gt; attribute we referenced in CSS above, this is where it's getting added to our root element.&lt;/p&gt;




&lt;h4&gt;
  
  
  Store the user preference for future visits
&lt;/h4&gt;

&lt;p&gt;We will use browser's localStorage to store the user preference.&lt;br&gt;
Let's modify our &lt;code&gt;switchTheme&lt;/code&gt; function -&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;switchTheme&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data-theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//add this&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data-theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//add this&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;    
&lt;span class="p"&gt;}&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h4&gt;
  
  
  Check for saved user preference, if any, on load of the website
&lt;/h4&gt;

&lt;p&gt;We will check if the theme preference is saved, if yes then we will, accordingly-&lt;br&gt;
    - set our &lt;code&gt;data-theme&lt;/code&gt; attribute&lt;br&gt;
    - check/uncheck our toggle-switch checkbox&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;


&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currentTheme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentTheme&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data-theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;currentTheme&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentTheme&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;toggleSwitch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That's it! Check out the full demo below.&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/ananyaneogi/embed/zXZyMP?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;br&gt;
I recently added this to &lt;a href="https://ananyaneogi.com" rel="noopener noreferrer"&gt;my website&lt;/a&gt;, so check that out as well, &lt;em&gt;maybe!&lt;/em&gt;&lt;/p&gt;







&lt;p&gt;&lt;strong&gt;Pro-Tip: How to decide on the color scheme?&lt;/strong&gt;&lt;br&gt;
My suggestion is to stay in the same spectrum of your primary or brand color and generate a palette out of it. Use the darkest shade from the palette as the background color and the lighter shades as font colors when in dark mode. I used &lt;a href="https://javisperez.github.io/tailwindcolorshades/#/" rel="noopener noreferrer"&gt;this color shades generator&lt;/a&gt; for generating my color palette.&lt;br&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%2Flbp3qqs9ybhgcevcwbor.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%2Flbp3qqs9ybhgcevcwbor.png"&gt;&lt;/a&gt;&lt;br&gt;
Even if you don't end up using the exact colors generated, it is still a good place to start. Even I ended up fine tuning the colors I ultimately used.&lt;/p&gt;




&lt;h1&gt;
  
  
  Resources
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://medium.freecodecamp.org/learn-css-variables-in-5-minutes-80cf63b4025d" rel="noopener noreferrer"&gt;Learn CSS Variables in 5 minutes
&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Nevertheless, Ananya Coded</title>
      <dc:creator>Ananya Neogi</dc:creator>
      <pubDate>Tue, 05 Mar 2019 19:19:07 +0000</pubDate>
      <link>https://dev.to/ananyaneogi/nevertheless-ananya-coded--55en</link>
      <guid>https://dev.to/ananyaneogi/nevertheless-ananya-coded--55en</guid>
      <description>&lt;p&gt;Let's take a trip down the road, back in the early '00s when I was just a school girl. My parents really invested in my education, sent me to a top school in my city, gave me all the privileges of a good education. Not coming from a wealthy family, this meant a lot. This meant that my parents sacrificed a LOT for this privilege of education. Things were different for girls back then in India. People from society, even some relatives advised and taunted my parents that they were &lt;em&gt;wasting&lt;/em&gt; so much money educating a &lt;em&gt;girl&lt;/em&gt;, because according to them,  girls were just meant to be married off when they come of age and should only be limited to household work and were not meant for getting a higher education. I remember I was in tears when I overheard this conversation!&lt;br&gt;
But, my parents did not budge, they never discriminated solely because I was a girl, they kept educating me from a good school to a good university, even though they had to sacrifice so much during this whole journey. I am so so grateful to have such wonderful and amazing parents. ❤️&lt;/p&gt;

&lt;h2&gt;
  
  
  So, why #shecoded you ask?
&lt;/h2&gt;

&lt;p&gt;She coded for her parents, to honour all the sacrifices her parents made for her. She coded for a dream that ignited her heart as a kid. She coded to prove all those people wrong who doubted her. She coded to give her parents all the &lt;em&gt;luxuries&lt;/em&gt; that they once sacrificed for her sake. She coded to make her parents proud who bought her, her first computer even though they couldn't afford it. Most importantly, she coded for that little girl, who cried thinking it was a curse to be born a girl. She coded to prove to her that she was and will always be enough to do anything she sets her heart to do!&lt;/p&gt;

&lt;h2&gt;
  
  
  I hope to see my community...
&lt;/h2&gt;

&lt;p&gt;It breaks my heart that things still might be the same for many girls and they might not have had the same privileges that I got. Many women don't even consider a career in tech because somewhere while growing up someone said to them that they are not enough! I hope to see my community fight for women in tech. I hope to see my tech community be more accepting, kind and respectful. I hope to see my tech community take actions against people who are disrespectful and hostile against fellow humans.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advice for #womenintech
&lt;/h2&gt;

&lt;p&gt;It can be very difficult at times, it might even seem hopeless but don't give up! We need you in this field. We need you to continue fighting for equal rights for our younger generations of women to come. You are not alone in this fight! Keep learning and growing. 🤗&lt;/p&gt;

&lt;p&gt;Last but not least I want to give a shoutout to some of my favourite women/people in tech, who have unknowingly helped me throughout and continue to inspire me everyday. &lt;a href="https://twitter.com/aprilwensel"&gt;@aprilwensel&lt;/a&gt; &lt;a href="https://twitter.com/sarah_edo"&gt;@sarah_edo&lt;/a&gt; &lt;a href="https://twitter.com/SaraSoueidan"&gt;@SaraSoueidan&lt;/a&gt; &lt;a href="https://twitter.com/NikkitaFTW"&gt;@NikkitaFTW&lt;/a&gt; &lt;a href="https://twitter.com/jensimmons"&gt;@jensimmons&lt;/a&gt; &lt;a href="https://twitter.com/Una"&gt;@Una&lt;/a&gt; &lt;a href="https://twitter.com/LeaVerou"&gt;@LeaVerou&lt;/a&gt; &lt;a href="https://twitter.com/jina"&gt;@jina&lt;/a&gt; &lt;a href="https://twitter.com/manjula_dube"&gt;@manjula_dube&lt;/a&gt; &lt;a href="https://twitter.com/kvlly"&gt;@kvlly&lt;/a&gt; &lt;a href="https://twitter.com/venikunche"&gt;@venikunche&lt;/a&gt; &lt;a href="https://twitter.com/vaidehijoshi"&gt;@vaidehijoshi&lt;/a&gt; &lt;a href="https://twitter.com/AnjanaVakil"&gt;@AnjanaVakil&lt;/a&gt; &lt;a href="https://twitter.com/MinaMarkham"&gt;@MinaMarkham&lt;/a&gt; &lt;a href="https://twitter.com/b0rk"&gt;@b0rk&lt;/a&gt; &lt;a href="https://twitter.com/rachelandrew"&gt;@rachelandrew&lt;/a&gt; &lt;a href="https://twitter.com/ladyleet"&gt;@ladyleet&lt;/a&gt; ...The list is endless to be honest. &lt;/p&gt;

</description>
      <category>wecoded</category>
      <category>womenintech</category>
    </item>
    <item>
      <title>Useful CSS Media Query Features</title>
      <dc:creator>Ananya Neogi</dc:creator>
      <pubDate>Tue, 12 Feb 2019 20:15:38 +0000</pubDate>
      <link>https://dev.to/ananyaneogi/useful-css-media-query-features-o7f</link>
      <guid>https://dev.to/ananyaneogi/useful-css-media-query-features-o7f</guid>
      <description>&lt;p&gt;A typical media query consists of a &lt;strong&gt;media type&lt;/strong&gt; (screen, print, speech, etc) and one or more expressions, involving &lt;strong&gt;media features&lt;/strong&gt;, which resolve to either true or false. &lt;br&gt;
The result of the query is true if the media type specified in the media query matches the type of device the document is being displayed on and all expressions in the media query are true. The corresponding styles are applied, when the media query result is true.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; If no media type is specified the default is &lt;code&gt;all&lt;/code&gt; type, i.e the corresponding styles will be applicable for all devices.&lt;/p&gt;
&lt;h2&gt;
  
  
  Media features
&lt;/h2&gt;

&lt;p&gt;Media features describe specific characteristics of the user agent and the device the document is being displayed on. These are optional.&lt;/p&gt;

&lt;p&gt;Here are a few useful media features that I've come across-&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Aspect Ratio
&lt;/h3&gt;

&lt;p&gt;Aspect ratio is the width to height ratio of the viewport.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* Exact aspect ratio */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;aspect-ratio&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Minimum aspect ratio */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-aspect-ratio&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;16&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nc"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Maximum aspect ratio */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-aspect-ratio&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's a practical example using aspect ratio -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="m"&gt;9&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="m"&gt;100vw&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-aspect-ratio&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;16&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="m"&gt;16&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://jsfiddle.net/ananyaneogi/x70wy25b/4/"&gt;Check out the working demo&lt;/a&gt;. Increase/decrease the height of the window to see it in effect.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Orientation
&lt;/h3&gt;

&lt;p&gt;There are two orientation values-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;portrait&lt;/code&gt;: The viewport is in a portrait orientation, i.e., the height is greater than or equal to the width.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;landscape&lt;/code&gt;: The viewport is in a landscape orientation, i.e., the width is greater than the height.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orientation&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;landscape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cm"&gt;/* landscape styles */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orientation&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;portrait&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cm"&gt;/* portrait styles */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This media feature helps in responsive design. We can use it with other media features such as width and height.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="nf"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-height&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;640px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orientation&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;portrait&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="nc"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3. &lt;code&gt;display-mode&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The display-mode is used to test the display mode of an application. There are 4 types according to the &lt;a href="https://w3c.github.io/manifest/#the-display-mode-media-feature"&gt;spec.&lt;/a&gt; It is a part of Web App Manifest specification.&lt;br&gt;
The feature query will apply irrespective of whether a web app manifest is present or not.&lt;/p&gt;

&lt;p&gt;Check out this article for a practical usage of this- &lt;a href="https://developers.google.com/web/fundamentals/native-hardware/fullscreen/"&gt;Making Fullscreen Experiences&lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  4. &lt;code&gt;hover&lt;/code&gt;, &lt;code&gt;any-hover&lt;/code&gt; and &lt;code&gt;any-pointer&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;hover&lt;/code&gt;: The hover CSS media feature can be used to test whether the user's primary input mechanism can hover over elements.&lt;/p&gt;

&lt;p&gt;I've found it useful to use this feature to avoid cases in which touch devices emulate &lt;em&gt;hover&lt;/em&gt; states on long tap of &lt;em&gt;hoverable&lt;/em&gt; elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hover&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hover&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;any-hover&lt;/code&gt;: This checks whether any available input can hover over elements.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;any-pointer&lt;/code&gt;: This checks whether the user has any pointing device (mouse, stylus), if so then how accurate it is.&lt;br&gt;
Accuracy is measured with - &lt;code&gt;fine&lt;/code&gt;, &lt;code&gt;coarse&lt;/code&gt;, &lt;code&gt;none&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A really great article on this topic -&lt;br&gt;
&lt;a href="https://css-tricks.com/touch-devices-not-judged-size/"&gt;Touch Devices Should Not Be Judged By Their Size&lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  5. Width and Height
&lt;/h3&gt;

&lt;p&gt;These two are very commonly used media features and are an essential part of responsive web.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* Exact width */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;360px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Maximum width */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-width&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;768px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nc"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Minimum width */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;992px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Exact height */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;360px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Minimum height */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-height&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;640px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Maximum height */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-height&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;768px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* All the values can also be in rem, em, vw, vh */&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  6. &lt;code&gt;prefers-color-scheme&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This has been introduced in media queries level 5. It will be useful when it is fully implemented!&lt;br&gt;
This is used to detect if the user has requested their system to use a light or dark color theme. Previously I wrote about &lt;a href="https://dev.to/ananyaneogi/enabling-dark-mode-on-websites-based-on-surrounding-light--3jel"&gt;enabling dark mode on websites using surrounding light&lt;/a&gt;, this can be an add on to that if the ambient light API is not available.&lt;/p&gt;

&lt;p&gt;Check out other features introduced in &lt;a href="https://drafts.csswg.org/mediaqueries-5/"&gt;media queries level 5.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; As pointed out &lt;a href="https://dev.to/equinusocio/comment/8lkb"&gt;here&lt;/a&gt;, according to &lt;a href="https://caniuse.com/#search=prefers-color-scheme"&gt;caniuse&lt;/a&gt;, it is available in the technology preview version of safari.&lt;/p&gt;




&lt;p&gt;These are few of the useful media features that I've found. There are others as well such as &lt;code&gt;resolution&lt;/code&gt;, &lt;code&gt;update&lt;/code&gt;, etc. Full list can be found on &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media"&gt;MDN.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you've come across any other lesser known media features and it's use cases, let me know!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
    </item>
  </channel>
</rss>
