<?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: Aiaru / 아야루</title>
    <description>The latest articles on DEV Community by Aiaru / 아야루 (@anapimolodec).</description>
    <link>https://dev.to/anapimolodec</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%2F697816%2F68611dce-8844-4dde-9f50-09e22ee77f26.jpg</url>
      <title>DEV Community: Aiaru / 아야루</title>
      <link>https://dev.to/anapimolodec</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anapimolodec"/>
    <language>en</language>
    <item>
      <title>Resolving Environment Preset Loading Error in React Three Fiber</title>
      <dc:creator>Aiaru / 아야루</dc:creator>
      <pubDate>Wed, 27 Nov 2024 02:39:07 +0000</pubDate>
      <link>https://dev.to/anapimolodec/resolving-environment-preset-loading-error-in-react-three-fiber-5elc</link>
      <guid>https://dev.to/anapimolodec/resolving-environment-preset-loading-error-in-react-three-fiber-5elc</guid>
      <description>&lt;p&gt;Recently I got this error on a project using Three Fiber Js which was working perfectly fine before.&lt;/p&gt;




&lt;p&gt;After reading these discussions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/77057501/could-not-load-potsdamer-platz-1k-hdr-failed-to-fetch" rel="noopener noreferrer"&gt;stackoverflow/questions/77057501&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pmndrs/drei/issues/1492" rel="noopener noreferrer"&gt;github/issues/1492&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The problem is occurring because it cannot find the &lt;code&gt;preset&lt;/code&gt; used in the &lt;code&gt;&amp;lt;Environment&amp;gt;&lt;/code&gt; component.&lt;/p&gt;




&lt;p&gt;It seems like there are two solutions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Update Three Fiber JS to version 9.70.4 or above&lt;br&gt;
&lt;code&gt;npm install @react-three/drei@^9.70.4&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For a more resilient approach, store the environment map locally:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Identify the HDR file name from the error message (e.g., &lt;code&gt;'dikhololo_night_1k.hdr'&lt;/code&gt; for &lt;code&gt;preset='night'&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Download the HDR file from &lt;a href="https://polyhaven.com/a/dikhololo_night" rel="noopener noreferrer"&gt;free resources website&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Place the file in your project's public directory at /&lt;code&gt;public/hdri/&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Update your Environment component to reference the local file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Environment files="/hdri/your_file.hdr"&amp;gt;
...
&amp;lt;/Environment&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.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%2F1rd4hlpecyoko70k93by.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F1rd4hlpecyoko70k93by.png" alt="folder structure" width="674" height="156"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This local file approach prevents future loading issues and gives you more control over the environment map used in your scene.&lt;/p&gt;




&lt;p&gt;You can check the source code here: &lt;a href="https://github.com/anapimolodec/mazmun/blob/main/src/components/custom_canvas.js" rel="noopener noreferrer"&gt;code file&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Hope it helped anyone!&lt;/p&gt;

</description>
      <category>threejs</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Convert SVG into a 3D figure using React Three.js Fiber</title>
      <dc:creator>Aiaru / 아야루</dc:creator>
      <pubDate>Wed, 02 Oct 2024 10:38:17 +0000</pubDate>
      <link>https://dev.to/anapimolodec/convert-svg-into-a-3d-figure-using-react-threejs-fiber-33hc</link>
      <guid>https://dev.to/anapimolodec/convert-svg-into-a-3d-figure-using-react-threejs-fiber-33hc</guid>
      <description>&lt;p&gt;In this post, I will show you how to create a custom 3D figure using Three.js and integrate it into a React.js website.&lt;br&gt;
Source code: &lt;a href="https://github.com/anapimolodec/svg-to-3d" rel="noopener noreferrer"&gt;github&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Get an SVG of the Figure
&lt;/h2&gt;

&lt;p&gt;The first step is to create or download an SVG (Scalable Vector Graphics) of the shape you want to turn into a 3D object. For this example, I will create a 3D figure based on a traditional red Kazakh ornament. I downloaded the image and converted it into an SVG. You can easily convert any image into SVG format using free tools like &lt;a href="https://picsvg.com/" rel="noopener noreferrer"&gt;online converters&lt;/a&gt;. &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%2Fmhsq8p6ejwcnmu9mq2oc.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%2Fmhsq8p6ejwcnmu9mq2oc.png" alt="converting image"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Install Dependencies
&lt;/h2&gt;

&lt;p&gt;Before we begin, ensure you have created a &lt;a href="https://create-react-app.dev/docs/getting-started" rel="noopener noreferrer"&gt;React app&lt;/a&gt; and placed the downloaded SVG file in the &lt;code&gt;/public&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;We will be using &lt;a href="https://r3f.docs.pmnd.rs/getting-started/introduction" rel="noopener noreferrer"&gt;Three.js Fiber&lt;/a&gt;, a React renderer for Three.js. It’s simple to use, especially if you're already familiar with Three.js.&lt;/p&gt;

&lt;p&gt;Install the necessary packages with the following command:&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 three @react-three/fiber @react-three/drei
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Create the 3D Figure
&lt;/h2&gt;

&lt;p&gt;We’ll use the &lt;code&gt;useLoader&lt;/code&gt; hook to load the SVG file (&lt;code&gt;/oyu.svg&lt;/code&gt;). The SVGLoader parses the SVG and returns data that we can use to generate 3D shapes. The SVG paths are then converted into shapes, and using &lt;code&gt;flatMap&lt;/code&gt;, we get a flat array of all shapes. Finally, by adding depth, the shape is extruded into a 3D figure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// /src/components/Figure.js file
import React from "react";
import { useLoader } from "@react-three/fiber";
import * as THREE from "three";
import { SVGLoader } from "three/examples/jsm/loaders/SVGLoader";

const Figure = () =&amp;gt; {
  const svgData = useLoader(SVGLoader, "/oyu.svg");

  const shapes = svgData.paths.flatMap((path) =&amp;gt; path.toShapes(true));

  const geometry = new THREE.ExtrudeGeometry(shapes, {
    depth: 10,
  });
  geometry.center();

  return (
    &amp;lt;mesh geometry={geometry} scale={0.07}&amp;gt;
      &amp;lt;meshPhongMaterial attach="material" color="red" /&amp;gt;
    &amp;lt;/mesh&amp;gt;
  );
};

export default Figure;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Play with &lt;code&gt;scale&lt;/code&gt; and find the appropriate value for your figure. I used &lt;code&gt;0.07&lt;/code&gt; because the figure was too big as an example.&lt;/p&gt;

&lt;p&gt;Now we have the 3D figure, but we need a canvas to display it and some lighting to visualize it.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Create a canvas
&lt;/h2&gt;

&lt;p&gt;Create a component called &lt;code&gt;CustomCanvas&lt;/code&gt; where we will place the 3D figure. The canvas will include ambient and directional lights to illuminate the figure. Additionally, I’ve added &lt;code&gt;OrbitControls&lt;/code&gt; to enable rotating and zooming around the 3D figure. Lights were chosen as an example, you can play with values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Canvas camera={{ position: [0, 0, 20] }}&amp;gt;
    &amp;lt;OrbitControls enableZoom={true} enablePan={true} /&amp;gt;
    &amp;lt;ambientLight intensity={0.5} /&amp;gt;
    &amp;lt;directionalLight position={[10, 10, 5]} intensity={1} /&amp;gt;
    &amp;lt;Figure position={[0, 0, 0]} /&amp;gt;
  &amp;lt;/Canvas&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since we're loading the SVG, it's a good idea to wrap the canvas in Suspense, allowing users to see a loading message while the figure is being prepared. Here's the updated canvas:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// /src/components/Canvas.js file
import { Canvas } from "@react-three/fiber";
import { OrbitControls, Text } from "@react-three/drei";
import Figure from "./Figure";
import { Suspense } from "react";

const Loading = () =&amp;gt; {
  return (
    &amp;lt;Text&amp;gt;
      Loading...
    &amp;lt;/Text&amp;gt;
  );
};

const Scene = () =&amp;gt; (
  &amp;lt;&amp;gt;
    &amp;lt;OrbitControls enableZoom={true} enablePan={true} /&amp;gt;
    &amp;lt;ambientLight intensity={0.5} /&amp;gt;
    &amp;lt;directionalLight position={[10, 10, 5]} intensity={1} /&amp;gt;
    &amp;lt;Figure position={[0, 0, 0]} /&amp;gt;
  &amp;lt;/&amp;gt;
);

export const CustomCanvas = () =&amp;gt; (
  &amp;lt;Canvas camera={{ position: [0, 0, 20] }}&amp;gt;
    &amp;lt;Suspense fallback={&amp;lt;Loading /&amp;gt;}&amp;gt;
      &amp;lt;Scene /&amp;gt;
    &amp;lt;/Suspense&amp;gt;
  &amp;lt;/Canvas&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Integrate the Canvas into Your App
&lt;/h2&gt;

&lt;p&gt;Now, let's include the &lt;code&gt;CustomCanvas&lt;/code&gt; in your main &lt;code&gt;App.js&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "./App.css";
import { CustomCanvas } from "./components/Canvas";

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;div className="main"&amp;gt;
        &amp;lt;CustomCanvas /&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, add some basic styling for your canvas in &lt;code&gt;App.css&lt;/code&gt; to ensure it takes up the full screen.&lt;br&gt;
&lt;/p&gt;

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

.main {
  height: 100vh;
  width: 100vw;
  overflow: hidden; //adjust for your needs
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After completing the above steps, your 3D figure should be displayed, and it will look something like this:&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%2Fr3po8qx43cxhlb37saf7.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%2Fr3po8qx43cxhlb37saf7.png" alt="result"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Feel free to play with depth and customize the material as you wish! Hope it was helpful~&lt;/p&gt;

&lt;p&gt;The source code can be found &lt;a href="https://github.com/anapimolodec/svg-to-3d" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>threejs</category>
      <category>webgl</category>
      <category>frontend</category>
      <category>react</category>
    </item>
    <item>
      <title>Connecting Tailwind CSS, NextJS, and Storybook</title>
      <dc:creator>Aiaru / 아야루</dc:creator>
      <pubDate>Thu, 29 Jun 2023 07:14:51 +0000</pubDate>
      <link>https://dev.to/anapimolodec/connecting-tailwind-css-nextjs-and-storybook-2fe9</link>
      <guid>https://dev.to/anapimolodec/connecting-tailwind-css-nextjs-and-storybook-2fe9</guid>
      <description>&lt;p&gt;Short summary of how to connect &lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;NextJS&lt;/a&gt;, &lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;TailwindCSS&lt;/a&gt; and &lt;a href="https://storybook.js.org/" rel="noopener noreferrer"&gt;Storybook&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The connection is showed by making a simple button.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1: Create NextJS app
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;npx create-next-app --typescript&lt;/code&gt;&lt;br&gt;
If you need detailed steps of creating NextJS app, please check its documentation &lt;a href="https://nextjs.org/learn/basics/create-nextjs-app/setup" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 2: Make a button
&lt;/h4&gt;

&lt;p&gt;You can edit the &lt;code&gt;src/pages/index.tsx&lt;/code&gt; file for the purpose of testing. We will create a simple button, which can change its background color when clicked. Color is generated randomly, and updated using &lt;code&gt;state&lt;/code&gt; in React. Thus, add &lt;code&gt;import {useState} from 'react'&lt;/code&gt; at the top of the file and edit the &lt;code&gt;Home&lt;/code&gt; function as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function Home() {
  const [ccolor, setCcolor] = useState&amp;lt;string&amp;gt;("");

  function changeColor() {
    const randomColor = Math.floor(Math.random()*16777215).toString(16);
    setCcolor(randomColor);
  }

  return (
        &amp;lt;div&amp;gt;
          &amp;lt;p&amp;gt; get a random color &amp;amp;#128071;&amp;lt;/p&amp;gt;
          &amp;lt;button onClick={changeColor} style ={{backgroundColor: "#" + `${ccolor}`}}&amp;gt; 👏 &amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can check the result by running the app (&lt;code&gt;npm run dev&lt;/code&gt;). Button background color changes when clicked.&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%2Fsq8yf0spt9hvz1xysonn.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%2Fsq8yf0spt9hvz1xysonn.png" alt="Simple button" width="310" height="106"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 3: Install Tailwind CSS
&lt;/h4&gt;

&lt;p&gt;Now we can add Tailwind CSS by following its &lt;a href="https://tailwindcss.com/docs/guides/nextjs" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;. &lt;br&gt;
In the created app folder, install Tailwind CSS.&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 postcss autoprefixer
npx tailwindcss init -p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;According to your current folder structure, modify the content pathways in the &lt;code&gt;tailwind.config.js&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  content: [
    "./src/**/*.{js,ts,jsx,tsx,mdx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add Tailwind CSS directives to the top of your &lt;code&gt;styles/global.css&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Try running the app to check if everything is working without errors.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 4: Add Tailwind CSS to the button
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { use, useState } from "react";


export default function Home() {
  const [ccolor, setCcolor] = useState&amp;lt;string&amp;gt;("");

  function changeColor() {
    const randomColor = Math.floor(Math.random()*16777215).toString(16);
    setCcolor(randomColor);
  }

  return (
    &amp;lt;div className="flex flex-col justify-center items-center 
                                        w-screen h-screen bg-gray-300"&amp;gt;
      &amp;lt;p className="font-mono text-xl text-center"&amp;gt; get a random color &amp;lt;/p&amp;gt;
        &amp;lt;button className = "rounded-full text-5xl m-4 p-8 shadow-xl" onClick={changeColor} style ={{backgroundColor: "#" + `${ccolor}`}}&amp;gt; 👏 &amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above changes the background color of the page, changes the text properties and makes the button round and shadowed. &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%2F5lj3kzsuffm9lkntnr3w.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%2F5lj3kzsuffm9lkntnr3w.png" alt="Button with Tailwind" width="750" height="526"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Up to this point, you connected NextJS with Tailwind CSS.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 5: Install Storybook
&lt;/h4&gt;

&lt;p&gt;In the same folder, install Storybook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx storybook@latest init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And try running it to check if it is working properly: &lt;code&gt;npm run storybook&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Modify &lt;code&gt;.storybook/main.js&lt;/code&gt; as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import type { StorybookConfig } from "@storybook/nextjs";
const config: StorybookConfig = {
  stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
  **staticDirs: ['../public'],**
  addons: [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/addon-interactions",
    **"@storybook/addon-postcss",**
  ],
  framework: {
    name: "@storybook/nextjs",
    options: {},
  },
  docs: {
    autodocs: "tag",
  },
};
export default config;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Edit &lt;code&gt;.storybook/preview.js&lt;/code&gt; by adding this line at the top of the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import '../src/styles/globals.css';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now as the folder structure changed, we should edit the content path for &lt;code&gt;tailwind.config.js&lt;/code&gt; file as well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;content: [
    "./src/stories/**/*.{js,ts,jsx,tsx,mdx}",
],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 6: Create story for the button
&lt;/h4&gt;

&lt;p&gt;We want to create a button component, which will have 2 templates: default button and round button. The component has 3 arguments to play with: border radius, background color, and the emoji of the button. &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%2Fvh58lal4h20tfr42faqk.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%2Fvh58lal4h20tfr42faqk.png" alt="arguments" width="800" height="322"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following the Storybook’s &lt;a href="https://storybook.js.org/docs/react/writing-stories/introduction" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;, added our button in &lt;code&gt;Button.tsx&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {useState} from 'react';
import './button.css';

interface ButtonProps {
  radius?: number; //border radius
  backgroundColor?: string; //background color
  emoji: 'clap' | 'heart' | 'star'; //emoji on the button
}
const emojiStyles = {
  clap: "👏",
  heart: "💔",
  star: "🌟",
};

export const Button = ({
  radius = 50,
  backgroundColor,
  emoji = 'clap'
}: ButtonProps) =&amp;gt; {
//here comes our button
  const [ccolor, setCcolor] = useState&amp;lt;string&amp;gt;("");

  const ButtonClass = "text-5xl m-4 p-8 shadow-xl bg-gray-400 ";
  return (
    &amp;lt;button 
      className = {ButtonClass}
      style = {{backgroundColor, borderRadius: radius}}
      &amp;gt;
      {emojiStyles[emoji]}
    &amp;lt;/button&amp;gt;
  );
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, we create its story in &lt;code&gt;Button.stories.ts&lt;/code&gt; as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { StoryObj, Meta } from '@storybook/react';
import { Button } from './Button';

const meta: Meta&amp;lt;typeof Button&amp;gt; = {
  title: 'Example/Button',
  component: Button,
};

export default meta;

//create a “template” of how args map to rendering (from SB)
type Template = StoryObj&amp;lt;typeof Button&amp;gt;;

//created two variations of the button
export const Default:  Template = {
  args :{
    radius: 50,
    backgroundColor: '#ff8b8b',
    emoji: 'clap'
  },
};


export const Circle: Template = {
  args: {
    radius: 100,
    backgroundColor: 'blue',
    emoji: 'clap'
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fj6c4n34yyz0h15xny2dp.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%2Fj6c4n34yyz0h15xny2dp.png" alt="Image description" width="800" height="755"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this simple tutorial we used NextJS with TailwindCSS by utilizing Storybook. The example is very simple and can be further developed. Please feel free to check GitHub repository with this project &lt;a href="https://github.com/anapimolodec/simple-button" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading up to this point ✨&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>tailwindcss</category>
      <category>storybook</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to make tags in Overleaf</title>
      <dc:creator>Aiaru / 아야루</dc:creator>
      <pubDate>Wed, 28 Jun 2023 05:39:02 +0000</pubDate>
      <link>https://dev.to/anapimolodec/how-to-make-tags-in-overleaf-33pd</link>
      <guid>https://dev.to/anapimolodec/how-to-make-tags-in-overleaf-33pd</guid>
      <description>&lt;p&gt;Recently, I have been updating my resume and decided to add technical skills as tags to increase readability. By the end of this post, you will learn how to draw tag-looking boxes around text in Overleaf, as shown in the picture below.&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%2F66q3p1mwv0h45svxpa69.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%2F66q3p1mwv0h45svxpa69.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1: Import required packages.
&lt;/h4&gt;

&lt;p&gt;In order to create colorful boxes, we will use the &lt;code&gt;tcolorbox&lt;/code&gt; package. If you want to know more about this package, you can check the reference &lt;a href="https://ctan.org/pkg/tcolorbox?lang=en" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Import the package in the beginning of your document as follows: &lt;/p&gt;

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

\usepackage{tcolorbox}
\begin{document} ...


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

&lt;/div&gt;
&lt;h4&gt;
  
  
  Step 2: Define the colorbox for your document
&lt;/h4&gt;

&lt;p&gt;To keep all "tags" consistent throughout the document and avoid defining them every time, you can set the dimensions as well as the color for your colorbox at the beginning of your document:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

\usepackage{tcolorbox}
\tcbset{on line, boxsep=1pt, left=0pt,right=3pt,top=0pt,bottom=0pt,colframe=red, colback=red}
\begin{document} ...


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

&lt;/div&gt;

&lt;p&gt;If we break down this line: &lt;br&gt;
&lt;code&gt;on line&lt;/code&gt; keeps your colorboxes inline with the rest of the text;&lt;br&gt;
&lt;code&gt;left&lt;/code&gt;,&lt;code&gt;right&lt;/code&gt;,&lt;code&gt;top&lt;/code&gt;, &lt;code&gt;bottom&lt;/code&gt; are inner margins set to each side of the box;&lt;br&gt;
&lt;code&gt;boxsep&lt;/code&gt; adds an inner margin to all sides;&lt;br&gt;
&lt;code&gt;colframe&lt;/code&gt; defines the color of the box border;&lt;br&gt;
&lt;code&gt;colback&lt;/code&gt; defines the color of the box background;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 3: Use the color box inside your text.
&lt;/h4&gt;

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

Created interfaces using \tcbox{Figma}.


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

&lt;/div&gt;

&lt;p&gt;The result would be as follows because it has a red border as well as a red background, and an additional 3px margin on the right:&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%2Fxl1dzznsy8xfnukbe8v8.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%2Fxl1dzznsy8xfnukbe8v8.png" alt="one red tag"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 4: Add custom colors for tags.
&lt;/h4&gt;

&lt;p&gt;To add a personal touch to your document, you can add custom colors and use them in your boxes. To do so, add a custom color at the beginning of your document:&lt;/p&gt;

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

\definecolor{babyblue}{rgb}{0.82, 0.96, 0.936} 
\usepackage{tcolorbox}
\tcbset{on line, boxsep=1pt, left=0pt,right=3pt,top=0pt,bottom=0pt,colframe=babyblue, colback=babyblue}
\begin{document} ...


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

&lt;/div&gt;

&lt;p&gt;In the example above, I added a color called &lt;em&gt;babyblue&lt;/em&gt; using the unit RGB color system and replaced the &lt;code&gt;colframe&lt;/code&gt; and &lt;code&gt;colback&lt;/code&gt; colors with it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 5: Add specific tags
&lt;/h4&gt;

&lt;p&gt;If you want to highlight a specific colorbox by defining colors or other properties only for that instance, you can do so by adding properties inline. For example, if you want to color a specific box with a different color, you can use the following:&lt;br&gt;
&lt;code&gt;I can use \tcbox{HTML} and \tcbox[colframe=green, colback=green]{CSS}.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Result: &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%2Fltm62jpzumm1oozm975t.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%2Fltm62jpzumm1oozm975t.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By repeating the same process, you can define various tags with different custom colors:&lt;/p&gt;

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

\textbf{Skills}\\
\tcbox{Tag1} \tcbox{Tag2} \tcbox[colframe=almond, colback=almond]{Language1} 
\tcbox[colframe=almond, colback=almond]{Language2} \tcbox[colframe=yellow, colback=yellow]{Technology1}
\tcbox[colframe=yellow, colback=yellow]{Technology2}


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

&lt;/div&gt;

&lt;p&gt;Result: &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%2Fj6yn8c3fmsam3ysiba5c.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%2Fj6yn8c3fmsam3ysiba5c.png" alt="Result"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this will be useful for your project ~.~&lt;/p&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://tex.stackexchange.com/questions/222152/how-to-define-an-inner-margin-for-a-tcolorbox" rel="noopener noreferrer"&gt;How to define an inner margin for a tcolorbox?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.overleaf.com/latex/examples/drawing-coloured-boxes-using-tcolorbox/pvknncpjyfbp" rel="noopener noreferrer"&gt;Drawing coloured boxes using tcolorbox&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>overleaf</category>
      <category>latex</category>
      <category>resume</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
