<?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: yanir manor</title>
    <description>The latest articles on DEV Community by yanir manor (@manoryanir).</description>
    <link>https://dev.to/manoryanir</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%2F709047%2Fd18ad41b-51b9-4ec5-82c8-31f0eb1915b1.jpeg</url>
      <title>DEV Community: yanir manor</title>
      <link>https://dev.to/manoryanir</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/manoryanir"/>
    <language>en</language>
    <item>
      <title>Endpoint Confidence — Get It Fast With HURL</title>
      <dc:creator>yanir manor</dc:creator>
      <pubDate>Sun, 23 Jul 2023 13:46:06 +0000</pubDate>
      <link>https://dev.to/manoryanir/endpoint-confidence-get-it-fast-with-hurl-2b95</link>
      <guid>https://dev.to/manoryanir/endpoint-confidence-get-it-fast-with-hurl-2b95</guid>
      <description>&lt;p&gt;When making changes or refactoring code, it’s important to have confidence in the changes we make. One way to gain protection and confidence is through API testing.&lt;/p&gt;

&lt;p&gt;Although testing is essential, many developers do not enjoy writing tests due to the complexity and slowness of testing tools in the past. But what if there was a tool that made testing quicker and easier? That’s where Hurl comes in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Orange-OpenSource/hurl"&gt;Hurl&lt;/a&gt; is a command line tool that can run HTTP requests defined in a simple plain text format. It’s versatile and can be used for both fetching data and testing HTTP sessions.&lt;br&gt;
With Hurl, you can chain requests, capture values, and evaluate queries on headers and response bodies.&lt;br&gt;
Hurl makes it easy to work with HTML content, REST/SOAP/GraphQL APIs, or any other XML/JSON-based APIs.&lt;br&gt;
Hurl is an open source of Orange corporate.&lt;/p&gt;

&lt;p&gt;It’s a single binary that’s easy to install. Plus, it’s written in Rust, making it a lightweight and very fast.&lt;/p&gt;

&lt;p&gt;To use Hurl, simply create a text file with your requests and run it via terminal. You can see in the screenshot below how easy it is and what you’ll see on the terminal when you run it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jOxfQx6O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sk9atv4yzfun1cm3e4v7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jOxfQx6O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sk9atv4yzfun1cm3e4v7.png" alt="Image description" width="800" height="1089"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So why not give Hurl a try and see how it can help you gain confidence in your code and speed up your testing process? With its simple format, versatility, and ease of use, it just might become your go-to testing tool 🤝.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Framer-Motion Notification Challenge</title>
      <dc:creator>yanir manor</dc:creator>
      <pubDate>Tue, 25 Jan 2022 06:48:23 +0000</pubDate>
      <link>https://dev.to/manoryanir/framer-motion-notification-challenge-4idb</link>
      <guid>https://dev.to/manoryanir/framer-motion-notification-challenge-4idb</guid>
      <description>&lt;p&gt;I was inspired by Oleg Frolov's notification design and challenged myself to build it.&lt;/p&gt;

&lt;p&gt;Oleg design - &lt;br&gt;
&lt;a href="https://dribbble.com/shots/2585157-Notification"&gt;Notification design by Oleg Frolov's&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/framer-motion-messages-br8oh"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;For the CSS design, I chose to take tailwind CSS.&lt;br&gt;
First, we need to create a box with SVG of message notification icon.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Cet4GvcK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rkp03afffo4nuk65ikb1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Cet4GvcK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rkp03afffo4nuk65ikb1.png" alt="Image description" width="310" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;now let's start adding some animation.&lt;br&gt;
let us build the 3 dots animation.&lt;br&gt;
for that, we will need a container with 3 spans for each dot.&lt;br&gt;
for animation state, we will use variants.&lt;br&gt;
for example, the container animation has 2 states "begin"&lt;br&gt;
and "end". &lt;br&gt;
each one will have its own animation attributes.&lt;br&gt;
for the dots, the animation change will be from y 0 percent to 100 percent.&lt;br&gt;
after defining the variation we can use it in initial and animate. &lt;br&gt;
also, you can define what the transition is going to look like.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_N0nMOlL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7jet9ww6si2wea2wxoqs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_N0nMOlL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7jet9ww6si2wea2wxoqs.png" alt="Image description" width="312" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;for the message text animation, we need an interval.&lt;br&gt;
how can we control to start the animation on each tick?&lt;br&gt;
for that, we need to import for framer useAnimation.&lt;br&gt;
then we can define the animation that we want to acquire&lt;br&gt;
and we just pass it into the useAnimation reference.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GpmRUgay--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgm9xe7tesu40oc8ibgc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GpmRUgay--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgm9xe7tesu40oc8ibgc.png" alt="Image description" width="306" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;you can see the full code in codesandbox.&lt;/p&gt;

</description>
      <category>react</category>
      <category>animation</category>
      <category>framer</category>
      <category>tailwindcss</category>
    </item>
    <item>
      <title>Counter - Framer Motion</title>
      <dc:creator>yanir manor</dc:creator>
      <pubDate>Mon, 17 Jan 2022 11:15:45 +0000</pubDate>
      <link>https://dev.to/manoryanir/counter-framer-motion-7ga</link>
      <guid>https://dev.to/manoryanir/counter-framer-motion-7ga</guid>
      <description>&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/react-tailwind-starter-forked-7hmb6"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;I have been enjoying Framer Motion's animation library.&lt;br&gt;
Framer Motion is beautiful and easy to use out of the box.&lt;br&gt;
I was inspired by Ehsan Rahimi's counter design as I took on the challenge of developing it with framer motion.&lt;/p&gt;

&lt;p&gt;Dribbble:&lt;br&gt;
&lt;a href="https://dribbble.com/shots/16434514-Tally-Counter-Micro-Interaction"&gt;Tally Counter Micro-Interaction by Ehsan Rahimi on Dribbble&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I used tailwind css for styling, react icons for icons, and animation framer for animation.&lt;br&gt;
For state, interaction will manage using a simple use state. &lt;br&gt;
We will have a number for the count and a boolean for showing the clear icon action.&lt;br&gt;
Let's dive into the drag gesture. &lt;br&gt;
The drag gesture follows the rules of the pan gesture but applies pointer movement to the x and/or y axis of the component.&lt;br&gt;
dragConstraints  - constraints on drag area.&lt;br&gt;
drag and on drag end events listener.&lt;br&gt;
Look at the code for the full vision. &lt;/p&gt;

&lt;p&gt;Link for framer documentation:&lt;br&gt;
&lt;a href="https://www.framer.com/docs/gestures/#drag"&gt;Gestures | Framer for Developers&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Framer motion - simple menu animation</title>
      <dc:creator>yanir manor</dc:creator>
      <pubDate>Fri, 14 Jan 2022 09:32:27 +0000</pubDate>
      <link>https://dev.to/manoryanir/framer-motion-simple-menu-animation-31ap</link>
      <guid>https://dev.to/manoryanir/framer-motion-simple-menu-animation-31ap</guid>
      <description>&lt;p&gt;Let's see how to create a simple menu animation.&lt;br&gt;
For the style, we will use tailwindcss.&lt;/p&gt;

&lt;p&gt;we will have a container that contains the flex layout and background color. &lt;br&gt;
For animate layout change across multi-component, we will need to use &lt;strong&gt;AnimateSharedLayout&lt;/strong&gt;.&lt;br&gt;
inside we have a wrapper that will control the on-click selection and have a nice animation opacity effect.&lt;br&gt;
inside will contain text and a condition on when an item is selected then framer motion layout animation will give is power for a nice underline animation,&lt;/p&gt;

&lt;p&gt;full code &amp;amp; example - &lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/react-tailwind-starter-forked-tirmr"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>react</category>
      <category>framermotion</category>
      <category>animation</category>
      <category>tailwindcss</category>
    </item>
    <item>
      <title>Switch Button Magic By Framer Motion</title>
      <dc:creator>yanir manor</dc:creator>
      <pubDate>Wed, 12 Jan 2022 12:48:28 +0000</pubDate>
      <link>https://dev.to/manoryanir/switch-button-magic-by-framer-motion-1g62</link>
      <guid>https://dev.to/manoryanir/switch-button-magic-by-framer-motion-1g62</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq5mx5fmcjlui2eaqi0vp.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%2Fq5mx5fmcjlui2eaqi0vp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How to create an animated switch button in React?&lt;br&gt;
First, we install tailwindcss for this job&lt;br&gt;
There will be two elements in the switch button: a container and a bull.&lt;/p&gt;

&lt;p&gt;container&lt;br&gt;
&lt;code&gt;cursor-pointer    w-16 h-10 flex items-center bg-gray-300 rounded-full p-1&lt;/code&gt;&lt;br&gt;
bull&lt;br&gt;
&lt;code&gt;bg-white w-8 h-8 rounded-full shadow-md&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It's that easy to have a static switch button.&lt;br&gt;
now we need to add click behavior.&lt;br&gt;
lets create a simple use state hook to toggle active state. &lt;br&gt;
&lt;code&gt;const [isSelected, setSelected] = useState(false)&lt;/code&gt;&lt;br&gt;
on container we will add click handler&lt;br&gt;
&lt;code&gt;onClick={() =&amp;gt; setSelected(!isSelected)}&lt;/code&gt;&lt;br&gt;
and interactive css&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;${isSelected ? 'bg-red-500 justify-end' : 'justify-start'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Take it for a test. &lt;br&gt;
its working but something is missing.&lt;br&gt;
Yes, animation, are you ready for the magic 🪄?&lt;br&gt;
Change the bull div to be motion div.&lt;br&gt;
Add the magic layout property.&lt;br&gt;
ta dam 🎉🎉🎉 you have a nice switch button.&lt;/p&gt;

&lt;p&gt;you can see and play with the code - run in terminal - npm run build &amp;amp;&amp;amp; npm run preview.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/vite-react-tailwindcss-l5tpiw?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>react</category>
      <category>animation</category>
      <category>framer</category>
      <category>tailwindcss</category>
    </item>
    <item>
      <title>vitest + mocks = 💪 superpower</title>
      <dc:creator>yanir manor</dc:creator>
      <pubDate>Tue, 04 Jan 2022 12:45:10 +0000</pubDate>
      <link>https://dev.to/manoryanir/vitest-mocks-superpower-1ldd</link>
      <guid>https://dev.to/manoryanir/vitest-mocks-superpower-1ldd</guid>
      <description>&lt;p&gt;Previously, we discovered how powerful vitest can be when used with vite.&lt;br&gt;
Using mocks gives us the flexibility to simulate, develop, test, and refine use cases quickly and easily. &lt;br&gt;
For mocking behavior in development and API integration I will use MSW.&lt;br&gt;
For simple function business logic, I will demonstrate vitest mocking function.&lt;/p&gt;

&lt;p&gt;Full code - &lt;a href="https://github.com/yanirmanor/vite-test-vitest"&gt;https://github.com/yanirmanor/vite-test-vitest&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For a simple function mock you will use&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;vi.fn()&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;then you have all kinds of functions that you can use and control the mock. The most popular I think is mockReturnValue for mocking the return value or mockImplementation for mocking the function implementation.&lt;/p&gt;

&lt;p&gt;examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  vi.fn().mockReturnValue(23)
  expect(mockFnOverrideValue()).toBe(23) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mockFnGetSum = 
  vi.fn().mockImplementation(sum =&amp;gt; sum * 3.14)
  const total = mockFnGetSum(100)
  expect(total).toBe(314) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nice. now I will show how you can use MSW for development and testing.&lt;br&gt;
First install msw -&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pnpm install msw --save-dev&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;then run&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pnpx  msw init public/ --save&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;In development - I created a vite .env variables VITE_MOCKING and set it to be true.&lt;br&gt;
in the app.jsx I added an if statement, then you need to create and handlers a set of request mock.&lt;br&gt;
you need to set the handlers array inside setupWorker and make it start.&lt;br&gt;
you can open the network tab inside the chrome devtools &lt;br&gt;
and look for the service worker in the response header.&lt;br&gt;
also, you will see in devtools console - [MSW] Mocking enabled&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (import.meta.env.VITE_MOCKING === true) {
  const handlers = [
    rest.get('https://randomuser.me/api/', (req, res, ctx) =&amp;gt; {
      return res(
        ctx.delay(1000),
        ctx.status(202, 'Mocked status'),
        ctx.json({
          results: [
            {
              name: {
                first: 'John',
                last: 'Doe'
              }
            }
          ]
        })
      )
    })
  ]

  const worker = setupWorker(...handlers)
  worker.start()
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have almost done.&lt;br&gt;
this technique is similar for testing.&lt;br&gt;
instead of using serviceWorker we will replace it with setupServer&lt;br&gt;
and start this node server to run by listen() before all tests&lt;br&gt;
, after all, we call close and finally on after each test we will reset&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const server = setupServer(...restHandlers)

// Start server before all tests
beforeAll(() =&amp;gt; server.listen({ onUnhandledRequest: 'error' }))

//  Close server after all tests
afterAll(() =&amp;gt; server.close())

// Reset handlers after each test `important for test isolation`
afterEach(() =&amp;gt; server.resetHandlers())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this approach, your tests will be cleaner and more readable, and your software will be developed more quickly.&lt;br&gt;
Enjoy 😎&lt;/p&gt;

</description>
      <category>vite</category>
      <category>vitest</category>
      <category>testing</category>
      <category>react</category>
    </item>
    <item>
      <title>Vite - found the missing part</title>
      <dc:creator>yanir manor</dc:creator>
      <pubDate>Tue, 21 Dec 2021 07:26:53 +0000</pubDate>
      <link>https://dev.to/manoryanir/vite-found-the-missing-part-41pe</link>
      <guid>https://dev.to/manoryanir/vite-found-the-missing-part-41pe</guid>
      <description>&lt;p&gt;Vite is a build tool that aims to provide a faster and leaner development experience for modern web projects.&lt;br&gt;
The meaning of vite comes to the French word for "quick" 🇫🇷.&lt;br&gt;
I love 😍 vite but something was missing 😕. how to run tests?&lt;br&gt;
Yesterday vitest was open source 🍾. &lt;br&gt;
Vitest is a blazing fast new unit test framework powered by Vite.&lt;br&gt;
Given Jest's massive adoption, Vitest provides a compatible API that allows you to replace Jest in most projects. &lt;br&gt;
Vitest includes the most common features required when setting up your unit tests (mocking, snapshots, coverage). &lt;br&gt;
Vitest cares a lot about performance and uses Worker threads to run as much as possible in parallel.&lt;/p&gt;

&lt;p&gt;Lets take vitest for a ride 🏎.&lt;/p&gt;

&lt;p&gt;First we create new vite project&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pnpm create vite&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;lets add vitest&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pnpm i -D vitest&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;in src directory we will add a test file App.test.js&lt;br&gt;
we will add a simple test to check its works&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('basic', () =&amp;gt; {
    expect('JOHN'.toLowerCase()).to.equal('john')
  })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in package json we will add 2 scripts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"test": "vitest",
"coverage": "vitest --coverage"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;lets run&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;npm run test&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 and we check step one.&lt;/p&gt;

&lt;p&gt;How can we test react component?&lt;br&gt;
We can use react-test-renderer or testing-library/react.&lt;br&gt;
I prefer testing-library.&lt;br&gt;
For that please install&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pnpm i -D @testing-library/react&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;and happy-dom or jsdom.&lt;br&gt;
We need to rename the test file from js to jsx.&lt;br&gt;
We need to edit vite.config.js and add&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test: {
    environment: "happy-dom", // or 'jsdom', 'node'
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now let's create simple react component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function SimpleText () {
  return &amp;lt;h1&amp;gt;Hello World&amp;lt;/h1&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('basic react with testing library', () =&amp;gt; {
    const { getByText } = render(&amp;lt;SimpleText /&amp;gt;)
    expect(getByText('Hello World')).toBeTruthy()
  })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That all. it's working.&lt;/p&gt;

&lt;p&gt;In conclusion, I'm very happy about vetest.&lt;br&gt;
It feels like the missing piece was found.&lt;br&gt;
For more information&lt;br&gt;
&lt;a href="https://vitejs.dev/"&gt;Home | Vite&lt;/a&gt;&lt;br&gt;
&lt;a href="https://vitest.dev/"&gt;Home | Vitest&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/yanirmanor/vite-test-vitest"&gt;Example | vite test via vitest&lt;/a&gt;&lt;br&gt;
Enjoy 🥃.&lt;/p&gt;

</description>
      <category>vite</category>
      <category>react</category>
      <category>testing</category>
      <category>jest</category>
    </item>
    <item>
      <title>Monorepo with Turborepo</title>
      <dc:creator>yanir manor</dc:creator>
      <pubDate>Mon, 20 Dec 2021 12:38:53 +0000</pubDate>
      <link>https://dev.to/manoryanir/monorepo-with-turborepo-enp</link>
      <guid>https://dev.to/manoryanir/monorepo-with-turborepo-enp</guid>
      <description>&lt;p&gt;I will show you how you can use monorepo Turborepo with pnpm for a high-performance build system in your local and continuous integration builds.&lt;/p&gt;

&lt;p&gt;First, we need to create the root directory.&lt;br&gt;
then we will generate npm package json by -&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pnpm init -y&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;now we need to create pnpm-workspace.yaml file.&lt;br&gt;
pnpm-workspace.yaml defines the root of the workspace and enables you to include / exclude directories from the workspace.&lt;br&gt;
In our example, we will have 2 projects first is a remix application and the other lib via vite.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;packages:
  - application
  - lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now we can add Turborepo&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pnpm i -Dw turbo&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;The -w flag is for workspace (or --workspace-root)&lt;br&gt;
Also, we need to install pnpm in the root.&lt;br&gt;
we need to add turbo section in the root package json file.&lt;br&gt;
This is the definition of the pipeline. &lt;br&gt;
you can set caching and how tasks are related according to npm package scripts like build lint test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"turbo": {
    "pipeline": {
      "dev": {
        "cache": false
      },
      "build": {
        "dependsOn": [
          "^build"
        ],
        "outputs": [
          "build/**",
          "dist/**"
        ]
      }
    }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, we can add the npm script for monorepo.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
    "dev": "turbo run dev",
    "build": "turbo run build"
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this setup, we will create two folders.&lt;br&gt;
application and lib.&lt;br&gt;
run&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pnpx init vite@latest&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 set folder to be lib.&lt;br&gt;
run&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pnpx create-remix@latest&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 set folder to be application. &lt;br&gt;
then go to the root folder and run&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pnpm i -r&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 will install node_modules for both projects.&lt;/p&gt;

&lt;p&gt;we can use vite to create a library that we can use inside the remix application.&lt;br&gt;
inside&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;vite.config.js&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 we will add this section.&lt;br&gt;
For more information please read Building for Production Library mode | Vite (vitejs.dev)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;build: {
    lib: {
      entry: "./src/index.js",
      formats: ["cjs", "es"],
      fileName: (format) =&amp;gt; `index.${format}.js`,
    },
    rollupOptions: {
      external: ["react", "react-dom"],
    },
  },
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can create a simple component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fczbo8d199bq38yagtbk9.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%2Fczbo8d199bq38yagtbk9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then create an index.js file in the src folder.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;export { default as Card } from "./components/Card"&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;inside the package json of the vite lib, we need to add&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  "main": "./dist/index.cjs.js",
  "module": "./dist/index.esm.js",
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally we need to build it by running&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pnpm run build&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;For using this component inside the Remix app.&lt;br&gt;
go to package json of remix and add this line inside the dependencies property&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;"lib": "workspace:*"&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
.&lt;br&gt;
Then go to the root of the monorepo and&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pnpm i&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvj9rxxudwpfbuxc5yo43.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%2Fvj9rxxudwpfbuxc5yo43.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For running all the applications in the monorepo side by side&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pnpm run dev&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdwupibx1zmc9vtnpyx0e.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%2Fdwupibx1zmc9vtnpyx0e.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It all works with caching and monorepo.&lt;br&gt;
You will be able to publish your application quickly and smartly with high speed.&lt;br&gt;
Link to github: &lt;br&gt;
&lt;a href="https://github.com/yanirmanor/mono-turbo-example" rel="noopener noreferrer"&gt;https://github.com/yanirmanor/mono-turbo-example&lt;/a&gt;&lt;/p&gt;

</description>
      <category>monorepo</category>
      <category>turborepo</category>
      <category>pnpm</category>
      <category>react</category>
    </item>
    <item>
      <title>PNPM install smart</title>
      <dc:creator>yanir manor</dc:creator>
      <pubDate>Tue, 14 Dec 2021 18:19:59 +0000</pubDate>
      <link>https://dev.to/manoryanir/pnpm-install-smart-2cnn</link>
      <guid>https://dev.to/manoryanir/pnpm-install-smart-2cnn</guid>
      <description>&lt;p&gt;Let's think about installing and node module.&lt;br&gt;
Installation takes some time, and you will find some shared packages on a local computer in many projects. &lt;br&gt;
Consider the cost of storage and processing for the CI docker virtual machine.&lt;br&gt;
So how can we get some speed and efficiency?&lt;/p&gt;

&lt;p&gt;pnpm for the rescue. pnpm is a fast, disk space-efficient package manager.&lt;br&gt;
pnpm will be stored in a content-addressable store.&lt;/p&gt;

&lt;p&gt;In the video below you can see the comparison between npm and pnpm&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/4w4WWJ7YG4Q"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;What pnpm gives:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If you depend on different versions of the dependency, only the files that differ are added to the store. For instance, if it has 100 files, and a new version has a change in only one of those files, pnpm update will only add 1 new file to the store, instead of cloning the entire dependency just for the singular change.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All the files are saved in a single place on the disk. When packages are installed, their files are hard-linked from that single place, consuming no additional disk space. This allows you to share dependencies of the same version across projects.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As a result, you save a lot of space on your disk proportional to the number of projects and dependencies, and you have a lot faster installations!&lt;/p&gt;

&lt;p&gt;Also, pnpm has some features. You can create a workspace to unite multiple projects inside a single repository.&lt;/p&gt;

&lt;p&gt;Next, I will write with the combination using pnpm with turborepo.&lt;/p&gt;

</description>
      <category>yarn</category>
      <category>pnpm</category>
      <category>npm</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Control CSS using x-state state machines</title>
      <dc:creator>yanir manor</dc:creator>
      <pubDate>Sun, 21 Nov 2021 07:02:40 +0000</pubDate>
      <link>https://dev.to/manoryanir/control-css-using-x-state-state-machines-5c6h</link>
      <guid>https://dev.to/manoryanir/control-css-using-x-state-state-machines-5c6h</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Do you ever think about adding a CSS condition to control a CSS behavior? &lt;br&gt;
It will be hard and will include a lot of if statements most of the time.&lt;br&gt;
Here is how you can control your styling through an x-state state machine.&lt;/p&gt;
&lt;h2&gt;
  
  
  Coding
&lt;/h2&gt;

&lt;p&gt;First installing&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install xstate @xstate/react&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Let's build the machine. We'll design three possible states: idle, loading, and success. &lt;br&gt;
To simulate, I added an automatic transition (this is the after with time in JSON).&lt;br&gt;
Now that we have finished the machine, let's integrate it with the react code.&lt;br&gt;
We will create a new data attribute called data-state.&lt;br&gt;
This data attribute will contain the current state.&lt;br&gt;
We are almost done, let's add CSS behavior.&lt;br&gt;
you need to create CSS selector like this&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.btn[data-state='loading']&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Congratulations we done.&lt;br&gt;
The full code - &lt;br&gt;
&lt;a href="https://stackblitz.com/edit/vitejs-vite-wjcxwo?file=src/App.jsx"&gt;https://stackblitz.com/edit/vitejs-vite-wjcxwo?file=src/App.jsx&lt;/a&gt;&lt;br&gt;
please run this line in terminal&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm run dev&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I like this approach.&lt;br&gt;
I can design the state's behavior using x-state, then control it via CSS selector and assign the relevant attributes.&lt;br&gt;
I think it gives a lot of power and simplicity to your styling ecosystem. &lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>css</category>
      <category>xstate</category>
    </item>
    <item>
      <title>Control Locales In NextJS</title>
      <dc:creator>yanir manor</dc:creator>
      <pubDate>Mon, 15 Nov 2021 08:59:14 +0000</pubDate>
      <link>https://dev.to/manoryanir/control-locales-in-nextjs-4dmo</link>
      <guid>https://dev.to/manoryanir/control-locales-in-nextjs-4dmo</guid>
      <description>&lt;p&gt;In today's world supporting translation for multi-languages is very important. &lt;br&gt;
So how can we do it with Nextjs? &lt;br&gt;
Nextjs is built by page, which means controlling different locales through routing. &lt;br&gt;
First, you need to install the package&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install next-translate&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Then create a file i18n.json in the file you can control what languages you have, what is the default language, what file will load in a specific page or it will be global, and many more options.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "locales": ["en", "fr"],
  "defaultLocale": "en",
  "pages": {
    "*": ["global"],
    "/info": ["info"]
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you are done go to next.config and add it to the module&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const nextTranslate = require("next-translate");

module.exports = {
  reactStrictMode: true,
  ...nextTranslate(),
};

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

&lt;/div&gt;



&lt;p&gt;Great, we have completed the configuration 🤙.&lt;/p&gt;

&lt;p&gt;Now create a locales folder in it, and add language and related files to each folder (you can see in the github project).&lt;br&gt;
In each file, create an object with a key value.&lt;br&gt;
Finally, go to the next page and use a translation like this to control it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import useTranslation from "next-translate/useTranslation";

export default function Info() {
  let { t } = useTranslation();
  return (
      &amp;lt;h1&amp;gt;{t("info:love")}&amp;lt;/h1&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in the URL you can see the change by adding/fr/ for French otherwise it will be English.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Surprisingly I find localization very simple to use with this package.&lt;br&gt;
Link: &lt;a href="https://github.com/yanirmanor/next-locales"&gt;https://github.com/yanirmanor/next-locales&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>NEXTJS 12 - Server component</title>
      <dc:creator>yanir manor</dc:creator>
      <pubDate>Mon, 08 Nov 2021 10:15:19 +0000</pubDate>
      <link>https://dev.to/manoryanir/next-12-server-component-3bc5</link>
      <guid>https://dev.to/manoryanir/next-12-server-component-3bc5</guid>
      <description>&lt;p&gt;Next 12 was released last October.&lt;br&gt;
The first thing that catches my eyes and gets me curious is SWC the new rust compiler that will give faster refresh and build.&lt;br&gt;
Compilation using Rust needs to be 17x faster than Babel.&lt;br&gt;
Also, the server component looks promising.&lt;br&gt;
Let's take the new version for a ride 🚴🏼‍♂️.&lt;br&gt;
Link: &lt;a href="https://github.com/yanirmanor/next12-server-components"&gt;https://github.com/yanirmanor/next12-server-components&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lets create new next js 12 application&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx create-next-app@latest&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Then change to configuration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// next.config.js
module.exports = {
  swcMinify: true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That it. Now you can enjoy the power of SWC.&lt;/p&gt;

&lt;p&gt;Let's add Tailwindcss for nice and fast CSS power.&lt;br&gt;
We will use Tailwindcss with JIT mode.&lt;/p&gt;
&lt;h4&gt;
  
  
  Here are the advantages that JIT offers:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Lightning-fast build times&lt;/li&gt;
&lt;li&gt;Every variant is enabled out of the box&lt;/li&gt;
&lt;li&gt;Generate arbitrary styles without writing custom CSS (top[-10px])&lt;/li&gt;
&lt;li&gt;Identical CSS in development and production&lt;/li&gt;
&lt;li&gt;Better browser performance in development&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;First, we will need to install and init.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -D tailwindcss@latest postcss@latest autoprefixer@latest @tailwindcss/jit
npx tailwindcss init -p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we need to add mode JIT.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// tailwind.config.js
module.exports = {
 mode: "jit",
 purge: ["./src/**/*.{js,jsx,ts,tsx}"],
 darkMode: false, // or 'media' or 'class'
 theme: {
  extend: {},
 },
 variants: {
  extend: {},
 },
 plugins: [],
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And import to the global css file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//global.css
@tailwind base;
@tailwind components;
@tailwind utilities;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And for hot refreshing add this to .env file&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;TAILWIND_MODE=watch&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;That's it and you are ready to use Tailwind&lt;br&gt;
For more information and examples you can check in&lt;br&gt;
&lt;a href="https://tailwindcss.com/"&gt;https://tailwindcss.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, we will take a look at react server component.&lt;br&gt;
First, we need to upgrade for the alpha version of react 18.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install react@alpha react-dom@alpha&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;We need to add this 2 flag in the config file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// next.config.js
module.exports = {
  experimental: {
    concurrentFeatures: true,
    serverComponents: true
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if you already have customized pages/_document component, you need to remove the getInitialProps static method and the getServerSideProps export if there’s any, otherwise, it won't work with server components. &lt;/p&gt;

&lt;p&gt;To run a component on the server, append .server.js to the end of the filename. For example ./pages/demo.server.js is a Server Component.&lt;br&gt;
For client components, add .client.js. For example, ./components/info.client.js.&lt;br&gt;
You can then import other server or client components from any server component.&lt;/p&gt;

&lt;p&gt;The server components will always be server-side rendered and streamed to the client, and will not be included by the client runtime. &lt;br&gt;
You will need to wrap the server component with Suspense.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I love the new compiler, this is a good staff for nextjs for the development user experience. &lt;br&gt;
for the server component, I don't feel it's ready its have some bugs.&lt;br&gt;
I found some issues with using the fetch from the new react-fetch npm module.&lt;br&gt;
It's also is very hard to find information and examples.&lt;br&gt;
What I love and why I think it will rock - &lt;br&gt;
Direct option running SQL from the server component&lt;br&gt;
No client-server waterfall of API calls&lt;br&gt;
more secure.&lt;br&gt;
I love the flexibility that it gives, but I think a developer will need to think about when and what will be on the server and what is good to stay on the client. still, it was fun.&lt;/p&gt;

</description>
      <category>react</category>
      <category>nextjs</category>
      <category>tutorial</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
