<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Surya Shakti on Medium]]></title>
        <description><![CDATA[Stories by Surya Shakti on Medium]]></description>
        <link>https://medium.com/@suryashakti1999?source=rss-690cefdebc0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PIlR0s5xr2udV_MrKTYXFw.png</url>
            <title>Stories by Surya Shakti on Medium</title>
            <link>https://medium.com/@suryashakti1999?source=rss-690cefdebc0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 22:59:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@suryashakti1999/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ How I Made My Own Drag-and-Drop Kanban Board with React]]></title>
            <link>https://suryashakti1999.medium.com/how-i-made-my-own-drag-and-drop-kanban-board-with-react-718d12ef1fbf?source=rss-690cefdebc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/718d12ef1fbf</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Surya Shakti]]></dc:creator>
            <pubDate>Sat, 19 Jul 2025 06:46:28 GMT</pubDate>
            <atom:updated>2025-07-19T07:23:45.902Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever wanted to build your own <strong>Trello-style Kanban board</strong>?<br> You’re in the right place!</p><p>In this article, I’ll walk you through <strong>how I built a fully functional drag-and-drop Kanban board using React</strong>, including:</p><p>✅ Column and card structure<br> ✅ Drag-and-drop with react-beautiful-dnd<br> ✅ State management<br> ✅ Optional features: Add, Delete, Reorder, and Persist data</p><h3>🛠️ Tech Stack</h3><p>Here’s what I used:</p><ul><li><strong>React</strong> (Vite or Create React App)</li><li><strong>TypeScript</strong> (optional but recommended)</li><li><strong>TailwindCSS</strong> (for styling)</li><li><strong>react-beautiful-dnd</strong> (for drag and drop)</li></ul><h3>📦 Installation</h3><p>Create your project:</p><pre>npx create-react-app kanban-board --template typescript<br># or with Vite:<br>npm create vite@latest kanban-board -- --template react-ts<br>cd kanban-board<br>npm install</pre><p>Install dependencies:</p><pre>npm install react-beautiful-dnd<br>npm install -D tailwindcss postcss autoprefixer<br>npx tailwindcss init -p</pre><p>Add Tailwind to your CSS:</p><pre>/* src/index.css or src/main.css */<br>@tailwind base;<br>@tailwind components;<br>@tailwind utilities;</pre><p>Configure tailwind.config.js:</p><pre>content: [&quot;./index.html&quot;, &quot;./src/**/*.{js,ts,jsx,tsx}&quot;]</pre><h3>🧱 Folder Structure</h3><pre>src/<br>├── components/<br>│   ├── KanbanBoard.tsx<br>│   ├── Column.tsx<br>│   └── Card.tsx<br>├── data/<br>│   └── initialData.ts<br>├── types.ts<br>└── App.tsx</pre><h3>📄 Define Your Data Structure</h3><p>Create a types.ts file:</p><pre>export type CardType = {<br>  id: string;<br>  content: string;<br>};</pre><pre>export type ColumnType = {<br>  id: string;<br>  title: string;<br>  cards: CardType[];<br>};</pre><pre>export type BoardData = {<br>  [key: string]: ColumnType;<br>};</pre><p>Now, add sample data in data/initialData.ts:</p><pre>import { BoardData } from &#39;../types&#39;;</pre><pre>export const initialData: BoardData = {<br>  &#39;todo&#39;: {<br>    id: &#39;todo&#39;,<br>    title: &#39;To Do&#39;,<br>    cards: [<br>      { id: &#39;task-1&#39;, content: &#39;Write blog post&#39; },<br>      { id: &#39;task-2&#39;, content: &#39;Design UI&#39; },<br>    ],<br>  },<br>  &#39;inprogress&#39;: {<br>    id: &#39;inprogress&#39;,<br>    title: &#39;In Progress&#39;,<br>    cards: [<br>      { id: &#39;task-3&#39;, content: &#39;Build Kanban Board&#39; },<br>    ],<br>  },<br>  &#39;done&#39;: {<br>    id: &#39;done&#39;,<br>    title: &#39;Done&#39;,<br>    cards: [],<br>  },<br>};</pre><h3>🧠 The Core Logic — KanbanBoard</h3><p>Create KanbanBoard.tsx:</p><pre>import React, { useState } from &#39;react&#39;;<br>import { DragDropContext, DropResult } from &#39;react-beautiful-dnd&#39;;<br>import Column from &#39;./Column&#39;;<br>import { initialData } from &#39;../data/initialData&#39;;<br>import { BoardData } from &#39;../types&#39;;</pre><pre>const KanbanBoard = () =&gt; {<br>  const [boardData, setBoardData] = useState&lt;BoardData&gt;(initialData);</pre><pre>  const onDragEnd = (result: DropResult) =&gt; {<br>    const { destination, source, draggableId } = result;<br>    if (!destination) return;</pre><pre>    if (<br>      destination.droppableId === source.droppableId &amp;&amp;<br>      destination.index === source.index<br>    ) return;</pre><pre>    const start = boardData[source.droppableId];<br>    const finish = boardData[destination.droppableId];</pre><pre>    // Moving within same column<br>    if (start === finish) {<br>      const newCards = Array.from(start.cards);<br>      const [moved] = newCards.splice(source.index, 1);<br>      newCards.splice(destination.index, 0, moved);</pre><pre>      const updatedColumn = { ...start, cards: newCards };<br>      setBoardData({ ...boardData, [start.id]: updatedColumn });<br>    } else {<br>      const startCards = Array.from(start.cards);<br>      const [moved] = startCards.splice(source.index, 1);<br>      const finishCards = Array.from(finish.cards);<br>      finishCards.splice(destination.index, 0, moved);</pre><pre>      setBoardData({<br>        ...boardData,<br>        [start.id]: { ...start, cards: startCards },<br>        [finish.id]: { ...finish, cards: finishCards },<br>      });<br>    }<br>  };</pre><pre>  return (<br>    &lt;DragDropContext onDragEnd={onDragEnd}&gt;<br>      &lt;div className=&quot;flex space-x-4 p-4 overflow-auto&quot;&gt;<br>        {Object.values(boardData).map((column) =&gt; (<br>          &lt;Column key={column.id} column={column} /&gt;<br>        ))}<br>      &lt;/div&gt;<br>    &lt;/DragDropContext&gt;<br>  );<br>};</pre><pre>export default KanbanBoard;</pre><h3>📦 Column Component</h3><p>Create Column.tsx:</p><pre>import React from &#39;react&#39;;<br>import { Droppable } from &#39;react-beautiful-dnd&#39;;<br>import Card from &#39;./Card&#39;;<br>import { ColumnType } from &#39;../types&#39;;</pre><pre>const Column = ({ column }: { column: ColumnType }) =&gt; {<br>  return (<br>    &lt;div className=&quot;bg-gray-100 p-4 rounded w-64&quot;&gt;<br>      &lt;h2 className=&quot;text-lg font-semibold mb-4&quot;&gt;{column.title}&lt;/h2&gt;<br>      &lt;Droppable droppableId={column.id}&gt;<br>        {(provided) =&gt; (<br>          &lt;div<br>            className=&quot;space-y-2 min-h-[100px]&quot;<br>            {...provided.droppableProps}<br>            ref={provided.innerRef}<br>          &gt;<br>            {column.cards.map((card, index) =&gt; (<br>              &lt;Card key={card.id} card={card} index={index} /&gt;<br>            ))}<br>            {provided.placeholder}<br>          &lt;/div&gt;<br>        )}<br>      &lt;/Droppable&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><pre>export default Column;</pre><h3>🃏 Card Component</h3><p>Create Card.tsx:</p><pre>import React from &#39;react&#39;;<br>import { Draggable } from &#39;react-beautiful-dnd&#39;;<br>import { CardType } from &#39;../types&#39;;</pre><pre>const Card = ({ card, index }: { card: CardType; index: number }) =&gt; {<br>  return (<br>    &lt;Draggable draggableId={card.id} index={index}&gt;<br>      {(provided) =&gt; (<br>        &lt;div<br>          className=&quot;bg-white p-3 rounded shadow&quot;<br>          {...provided.draggableProps}<br>          {...provided.dragHandleProps}<br>          ref={provided.innerRef}<br>        &gt;<br>          {card.content}<br>        &lt;/div&gt;<br>      )}<br>    &lt;/Draggable&gt;<br>  );<br>};</pre><pre>export default Card;</pre><h3>📌 Using It in App.tsx</h3><pre>import React from &#39;react&#39;;<br>import KanbanBoard from &#39;./components/KanbanBoard&#39;;</pre><pre>const App = () =&gt; {<br>  return (<br>    &lt;div className=&quot;min-h-screen bg-gray-50&quot;&gt;<br>      &lt;h1 className=&quot;text-2xl font-bold text-center py-6&quot;&gt;Kanban Board&lt;/h1&gt;<br>      &lt;KanbanBoard /&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><pre>export default App;</pre><h3>🎯 Optional Add-ons</h3><h3>📝 Add New Cards or Columns</h3><p>You can add AddCardForm or AddColumnForm components to dynamically grow your board.</p><h3>🗃️ Persist Data</h3><p>Use localStorage or backend APIs (e.g. Firebase, Supabase) to persist the board state.</p><pre>useEffect(() =&gt; {<br>  const saved = localStorage.getItem(&quot;board&quot;);<br>  if (saved) setBoardData(JSON.parse(saved));<br>}, []);</pre><pre>useEffect(() =&gt; {<br>  localStorage.setItem(&quot;board&quot;, JSON.stringify(boardData));<br>}, [boardData]);</pre><h3>🧩 Add Filters / Tags</h3><p>Enhance UX by adding search, tags, or drag handles only on hover.</p><h3>🧠 Final Thoughts</h3><p>Building a drag-and-drop Kanban board is:</p><ul><li>A fun React challenge</li><li>A practical feature in many SaaS tools</li><li>A great way to learn react-beautiful-dnd</li></ul><p>You now have a solid, functional, and extensible Kanban board from scratch 🚀</p><h3>🙌 Let’s Connect</h3><ul><li>Like this article? Hit that clap button!</li><li>Want the GitHub repo? Just drop a comment or DM.</li><li>Follow for more frontend deep-dives and real-world guides.</li><li>Ever wanted to build your own <strong>Trello-style Kanban board</strong>?<br> You’re in the right place!</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=718d12ef1fbf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Building Your Own Component Library (And Why I Did It)]]></title>
            <link>https://suryashakti1999.medium.com/building-your-own-component-library-and-why-i-did-it-2ecc06db9330?source=rss-690cefdebc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ecc06db9330</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Surya Shakti]]></dc:creator>
            <pubDate>Sat, 19 Jul 2025 06:44:53 GMT</pubDate>
            <atom:updated>2025-07-19T07:23:08.794Z</atom:updated>
            <content:encoded><![CDATA[<p>As a frontend developer working extensively with <strong>React</strong> and <strong>Next.js</strong>, I’ve often faced one recurring problem:</p><blockquote><em>“I’ve written this exact component at least 4 times across different projects.”</em></blockquote><p>Whether it was a button, a modal, a dropdown, or even a toast — I was duplicating code, tweaking styles, and re-validating behaviors over and over.</p><p>Eventually, I decided to <strong>stop the cycle</strong> and build my own <strong>reusable component library</strong>.</p><p>In this post, I’ll walk you through:</p><ul><li>✅ Why I built it</li><li>🛠️ How I set it up</li><li>📦 How I use it across multiple projects</li><li>🚀 How it improved my speed, consistency, and sanity</li></ul><h3>🤔 Why Build Your Own Component Library?</h3><p>There are plenty of UI libraries out there — <strong>MUI</strong>, <strong>Chakra UI</strong>, <strong>ShadCN</strong>, <strong>Tailwind UI</strong>, etc. — so why build your own?</p><p>Here are the exact reasons I did:</p><h3>1. Consistency Across Projects</h3><p>I work on multiple client and side projects. Having a shared component system helps maintain design consistency and <strong>reduces time spent on UI decisions</strong>.</p><h3>2. Custom Requirements</h3><p>Most libraries are great — but often too opinionated. I needed full control over styles, animation, accessibility, and logic (especially with Tailwind).</p><h3>3. Avoiding Repetition</h3><p>I was tired of copy-pasting components across projects and refactoring minor changes every time.</p><h3>4. Speed</h3><p>Having my own pre-built Button, Input, Form, Modal, etc. drastically cuts down my dev time.</p><h3>5. It’s a Great Learning Experience</h3><p>You get deep insights into accessibility (ARIA), responsiveness, reusable APIs, and scalable architecture.</p><h3>🏗️ The Tech Stack I Used</h3><ul><li><strong>React</strong> (with TypeScript)</li><li><strong>TailwindCSS</strong> (for utility-first styling)</li><li><strong>Vite</strong> (for fast builds + dev experience)</li><li><strong>Storybook</strong> (to develop &amp; test components in isolation)</li><li><strong>NPM / GitHub Packages</strong> (to share privately or publicly)</li></ul><p>Other useful tools:</p><ul><li><strong>Rollup</strong> (for bundling)</li><li><strong>Ladle</strong> (alternative to Storybook)</li><li><strong>Turborepo</strong> (for mono-repo setup)</li></ul><h3>📁 Folder Structure</h3><pre>my-component-library/<br>├── src/<br>│   ├── components/<br>│   │   ├── Button/<br>│   │   │   ├── Button.tsx<br>│   │   │   ├── Button.stories.tsx<br>│   │   │   └── index.ts<br>│   │   ├── Modal/<br>│   │   └── Input/<br>│   ├── utils/<br>│   └── index.ts<br>├── tailwind.config.js<br>├── package.json<br>└── tsconfig.json</pre><h3>🔨 Sample Component: Button</h3><p>Here’s an example of a reusable Button component:</p><pre>import React from &#39;react&#39;;<br>import clsx from &#39;clsx&#39;;</pre><pre>interface ButtonProps extends React.ButtonHTMLAttributes&lt;HTMLButtonElement&gt; {<br>  variant?: &#39;primary&#39; | &#39;secondary&#39; | &#39;outline&#39;;<br>}</pre><pre>const Button: React.FC&lt;ButtonProps&gt; = ({<br>  children,<br>  variant = &#39;primary&#39;,<br>  className,<br>  ...rest<br>}) =&gt; {<br>  const base = &#39;px-4 py-2 rounded text-white font-medium&#39;;<br>  const variants = {<br>    primary: &#39;bg-blue-600 hover:bg-blue-700&#39;,<br>    secondary: &#39;bg-gray-600 hover:bg-gray-700&#39;,<br>    outline: &#39;border border-gray-500 text-gray-700 bg-transparent&#39;,<br>  };</pre><pre>  return (<br>    &lt;button<br>      className={clsx(base, variants[variant], className)}<br>      {...rest}<br>    &gt;<br>      {children}<br>    &lt;/button&gt;<br>  );<br>};</pre><pre>export default Button;</pre><p>Use it like this:</p><pre>&lt;Button variant=&quot;primary&quot;&gt;Submit&lt;/Button&gt;</pre><h3>🔁 Publishing to NPM (Optional)</h3><p>To use this across multiple projects:</p><ol><li>Create a scoped package (e.g., @yourname/ui)</li><li>Add a build script using Vite/Rollup</li><li>Publish to NPM or GitHub Package Registry</li></ol><p>In your app:</p><pre>npm install @yourname/ui</pre><p>Then import:</p><pre>import { Button } from &#39;@yourname/ui&#39;;</pre><h3>📚 Using Storybook</h3><p>Each component can be documented in its own Storybook file:</p><pre>import React from &#39;react&#39;;<br>import { Button } from &#39;./Button&#39;;</pre><pre>export default {<br>  title: &#39;Components/Button&#39;,<br>  component: Button,<br>};</pre><pre>export const Primary = () =&gt; &lt;Button variant=&quot;primary&quot;&gt;Primary&lt;/Button&gt;;<br>export const Secondary = () =&gt; &lt;Button variant=&quot;secondary&quot;&gt;Secondary&lt;/Button&gt;;</pre><p>Start Storybook with:</p><pre>npm run storybook</pre><h3>🧩 Bonus: Design Tokens + Theming</h3><p>Once your library scales:</p><ul><li>Use <strong>design tokens</strong> for spacing, colors, typography</li><li>Add <strong>light/dark mode</strong> support</li><li>Sync tokens with <strong>Figma</strong> for design-dev consistency</li></ul><h3>🚀 How My Component Library Changed Everything</h3><p>After building my own UI library:</p><ul><li>I shipped UIs <strong>3× faster</strong></li><li>Maintained <strong>consistent design</strong></li><li>Reduced <strong>tech debt</strong></li><li>Improved <strong>collaboration with designers</strong></li><li>Deepened my understanding of scalable UI systems</li></ul><h3>🧠 Final Thoughts</h3><p>You don’t need to be a big team or startup to build your own UI library.</p><p>Even a small, well-maintained set of reusable components can:</p><ul><li>Increase your development speed</li><li>Improve UX consistency</li><li>Make you a more efficient and confident frontend engineer</li></ul><p>It’s not about reinventing the wheel — it’s about <strong>owning the wheel</strong> you use daily.</p><h3>👋 Let’s Connect</h3><p>Got questions? Want the boilerplate repo? Curious how to publish yours to NPM?</p><p>Drop a comment or DM me on <a href="https://www.linkedin.com/in/suryashakti/">LinkedIn</a> — happy to help!</p><h3>✨ If you found this useful:</h3><ul><li>❤️ Leave a clap</li><li>💬 Share your experience</li><li>🔁 Bookmark for later</li></ul><p>Happy building! 🧑‍💻💪</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ecc06db9330" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[️ Inside a Production-Grade React Folder Structure (With Real Examples)]]></title>
            <link>https://suryashakti1999.medium.com/%EF%B8%8F-inside-a-production-grade-react-folder-structure-with-real-examples-53c2ec265a5e?source=rss-690cefdebc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/53c2ec265a5e</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Surya Shakti]]></dc:creator>
            <pubDate>Fri, 18 Jul 2025 19:26:18 GMT</pubDate>
            <atom:updated>2025-07-19T07:17:58.010Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Best folder structure in reactjs" src="https://cdn-images-1.medium.com/max/1024/1*G-q_NPZQzvnbddrnlhzsWQ.jpeg" /><figcaption>best folder structure in react</figcaption></figure><p><em>Why structure matters and how to architect your React apps for scalability</em></p><blockquote><em>“If your folder structure feels chaotic, your codebase probably is too.”</em></blockquote><p>Whether you’re a solo developer or working in a team, having a <strong>clean and scalable folder structure</strong> is non-negotiable for long-term success. In my early projects, I used to dump everything into a components folder, and it worked — until it didn’t. As the codebase grew, <strong>everything became harder to manage</strong>: onboarding new developers, reusing components, debugging, testing.</p><p>After building multiple React apps (both client and freelance), here’s my take on a <strong>production-ready folder structure</strong> that balances simplicity with scalability.</p><h3>🚀 Why Folder Structure Matters</h3><p>A good folder structure helps:</p><ul><li><strong>Onboard new devs faster</strong> ✅</li><li><strong>Separate concerns</strong> (UI, logic, state, data) ✅</li><li><strong>Encourage reusability</strong> ✅</li><li><strong>Improve testing &amp; maintainability</strong> ✅</li></ul><h3>📁 Recommended Folder Structure</h3><p>Here’s a real-world structure I use for React (or Next.js) projects:</p><pre>src/<br>├── assets/            # Images, fonts, static files<br>├── components/        # Reusable UI components<br>│   ├── ui/            # Atomic base components (Button, Input)<br>│   └── shared/        # Shared higher-order components<br>├── features/          # Feature-specific modules (by domain)<br>│   └── auth/<br>│       ├── components/<br>│       ├── hooks/<br>│       ├── services/<br>│       └── AuthPage.tsx<br>├── hooks/             # Global reusable custom hooks<br>├── lib/               # Utilities, API clients, helpers<br>├── pages/             # Routes (if using Next.js or React Router)<br>├── store/             # Zustand / Redux / Context files<br>├── styles/            # Global styles, Tailwind config<br>├── types/             # Global TypeScript types &amp; interfaces<br>├── constants/         # App-wide enums, config values<br>├── layouts/           # Page/layout wrappers<br>├── tests/             # Global testing utilities/mocks<br>└── App.tsx / index.tsx</pre><p>Let’s break it down 👇</p><h3>🔍 Folder-by-Folder Explanation</h3><h3>1. components/</h3><p>This houses <strong>reusable UI components</strong> that are not tied to any single feature.</p><ul><li>components/ui: Atomic components like Button, Input, Modal, etc.</li><li>components/shared: Higher-level components like Navbar, Sidebar, ThemeToggle.</li></ul><p><strong>💡 Tip</strong>: Keep your components small and focused. Composition &gt; inheritance.</p><h3>2. features/</h3><p>Inspired by the <a href="https://feature-sliced.design/">feature-sliced design</a>, this keeps related code together by <strong>feature</strong>, not by type.</p><p>Example:</p><pre>features/auth/<br>├── components/<br>├── hooks/<br>├── services/<br>└── AuthPage.tsx</pre><p>This keeps your app modular and <strong>easy to refactor</strong> when a feature changes or scales.</p><h3>3. hooks/</h3><p>Global reusable <strong>custom hooks</strong> that work across features.<br> Examples:</p><ul><li>useDebounce.ts</li><li>useOnClickOutside.ts</li><li>useLocalStorage.ts</li></ul><h3>4. lib/</h3><p>Your shared <strong>utility functions</strong>, API clients, interceptors, date formatters, etc.</p><p>Examples:</p><ul><li>axiosClient.ts</li><li>formatDate.ts</li><li>parseJWT.ts</li></ul><h3>5. store/</h3><p>Your <strong>global state management layer</strong>.<br> Can be:</p><ul><li>Redux (with slices &amp; middleware)</li><li>Zustand stores</li><li>React Context</li></ul><p>Keep each store isolated and organized by domain.</p><h3>6. types/</h3><p>TypeScript interfaces, enums, and types used across the app.</p><p>Examples:</p><ul><li>User.ts</li><li>ApiResponse.ts</li><li>Theme.ts</li></ul><p><strong>💡 Tip</strong>: Group these per domain if your app gets big (types/auth/User.ts).</p><h3>7. constants/</h3><p>App-wide constant values, enums, and config objects.</p><p>Examples:</p><ul><li>ROUTES.ts</li><li>THEMES.ts</li><li>API_ENDPOINTS.ts</li></ul><h3>8. layouts/</h3><p>Your <strong>page-level layout wrappers</strong> — authenticated layout, dashboard layout, public layout, etc.</p><p>Helps enforce consistent structure across views.</p><h3>9. styles/</h3><p>Global styles, Tailwind config, theme tokens, variables, etc.</p><h3>10. pages/ (if using Next.js or React Router)</h3><p>If you’re in a Next.js app, use file-based routing inside /pages or /app.</p><h3>🧪 Testing Setup (Bonus)</h3><p>I recommend a separate tests/ folder for:</p><ul><li>Mocks &amp; test utils</li><li>Unit tests</li><li>Component tests</li></ul><p>For larger projects, colocating tests next to components (.test.tsx) is also a good idea.</p><h3>📦 Real Example Structure (From One of My Projects)</h3><pre>src/<br>├── components/<br>│   └── ui/<br>│       ├── Button.tsx<br>│       └── Input.tsx<br>├── features/<br>│   └── dashboard/<br>│       ├── components/<br>│       ├── DashboardPage.tsx<br>│       └── dashboard.store.ts<br>├── hooks/<br>│   └── useDarkMode.ts<br>├── lib/<br>│   └── axiosClient.ts<br>├── store/<br>│   └── auth.store.ts<br>├── styles/<br>│   └── globals.css<br>├── types/<br>│   └── User.ts<br>├── constants/<br>│   └── ROUTES.ts<br>├── pages/<br>│   └── index.tsx<br>└── App.tsx</pre><h3>🧠 Final Thoughts</h3><p>There’s <strong>no one-size-fits-all</strong> folder structure, but having a strong foundation helps your team and future-you.</p><p>Start small, but <strong>organize with scale in mind</strong>. A well-structured project can survive:</p><ul><li>Multiple contributors</li><li>Frequent refactors</li><li>New features and pivoting</li></ul><h3>🔗 Bonus</h3><p>Want a boilerplate of this structure?<br> I’ll soon open-source a minimal starter template using this exact architecture — follow me on <a href="https://www.linkedin.com/in/suryashakti/">LinkedIn</a> or <a href="https://github.com/SuryaShakti">GitHub</a> to get it when it’s live.</p><p><strong>👏 Over to You:</strong><br> How do you structure your React or Next.js apps? Drop your thoughts or folder tips in the comments — I’d love to learn from you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53c2ec265a5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Build a Complete Website with Docusaurus (Landing Page + Docs + Blog)]]></title>
            <link>https://suryashakti1999.medium.com/build-a-complete-website-with-docusaurus-landing-page-docs-blog-8a8b051a7da9?source=rss-690cefdebc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a8b051a7da9</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Surya Shakti]]></dc:creator>
            <pubDate>Sat, 22 Oct 2022 15:40:46 GMT</pubDate>
            <atom:updated>2025-07-19T07:24:51.609Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you looking to build a modern product website that includes a <strong>landing page</strong>, <strong>documentation</strong>, and a <strong>developer blog</strong> — all without reinventing the wheel?<br>Enter <a href="https://docusaurus.io/"><strong>Docusaurus</strong></a> — a powerful static site generator maintained by Facebook that’s perfect for <strong>developer-centric websites</strong>.</p><p>In this guide, you’ll learn how to <strong>build and customize</strong> an end-to-end website using Docusaurus — including:</p><ul><li>✅ Landing pages</li><li>📘 Docs with versioning</li><li>✍️ A built-in blog</li><li>🧩 Custom React pages</li><li>🧭 Navbar, footer &amp; layout control</li></ul><h3>🛠️ Step 1: Installing Docusaurus</h3><p>Start by setting up a fresh Docusaurus project with the official CLI:</p><pre>npx create-docusaurus@latest my-website classic<br>cd my-website<br>npm install</pre><p>This will scaffold a fully working starter project using the <strong>classic template</strong>, which comes with:</p><ul><li>Blog support</li><li>Docs engine</li><li>Custom pages</li><li>Pre-configured React layout</li></ul><h3>▶️ Step 2: Running the Development Server</h3><p>To see your new site in action, run:</p><pre>npm run start</pre><p>Now visit <a href="http://localhost:3000/">http://localhost:3000</a> — you’ll see your new Docusaurus-powered site with a simple homepage, docs sidebar, and blog section.</p><h3>🗂️ Docusaurus Project Structure Explained</h3><p>Here’s a quick breakdown of the folders you’ll find in your project:</p><pre>my-website/<br>├── blog/         # Markdown blog posts<br>├── docs/         # Markdown documentation pages<br>├── src/          # React pages, styles, custom components<br>│   └── pages/    # Landing page &amp; other routes<br>├── static/       # Public assets like images, logos<br>└── docusaurus.config.js  # Main config file</pre><p>🔹 blog/<br>Each .md file here is a blog post. You can include metadata like title, date, tags, and more using frontmatter.</p><p>🔹 docs/<br>The heart of your documentation. Supports sidebar navigation, search, and versioning out of the box.</p><p>🔹 src/pages/<br>This is where your custom pages live. Want to create a /pricing or /about page? Just drop a React component here.</p><p>🔹 static/<br>Static files here (e.g. logo.png) are available at the root level on your site. Think of it like public/ in Next.js or Vite.</p><h3>🏠 Customizing the Homepage</h3><p>The default homepage lives at:</p><pre>src/pages/index.js</pre><p>It’s a standard React component — customize it like you would any React page:</p><pre>export default function Home() {<br>  return (<br>    &lt;main&gt;<br>      &lt;h1&gt;Welcome to My Product&lt;/h1&gt;<br>      &lt;p&gt;This is your landing page. Customize freely!&lt;/p&gt;<br>    &lt;/main&gt;<br>  );<br>}</pre><p>Want to add hero sections, feature cards, or animations? Go wild — it’s just React under the hood.</p><h3>🧭 Customizing the Navbar</h3><p>The navbar is configured in docusaurus.config.js inside the themeConfig object:</p><pre>themeConfig: {<br>  navbar: {<br>    title: &#39;MySite&#39;,<br>    logo: {<br>      alt: &#39;Site Logo&#39;,<br>      src: &#39;img/logo.svg&#39;,<br>    },<br>    items: [<br>      { to: &#39;/docs/intro&#39;, label: &#39;Docs&#39;, position: &#39;left&#39; },<br>      { to: &#39;/blog&#39;, label: &#39;Blog&#39;, position: &#39;left&#39; },<br>      { href: &#39;https://github.com/myrepo&#39;, label: &#39;GitHub&#39;, position: &#39;right&#39; },<br>    ],<br>  },<br>}</pre><p>You can:</p><ul><li>Add links to internal pages or external sites</li><li>Position items on left/right</li><li>Use a custom logo and title</li></ul><h3>🦶 Customizing the Footer</h3><p>Also in themeConfig, you can define the footer with sections and links:</p><pre>footer: {<br>  style: &#39;dark&#39;,<br>  links: [<br>    {<br>      title: &#39;Docs&#39;,<br>      items: [{ label: &#39;Getting Started&#39;, to: &#39;/docs/intro&#39; }],<br>    },<br>    {<br>      title: &#39;Community&#39;,<br>      items: [<br>        { label: &#39;Discord&#39;, href: &#39;https://discordapp.com&#39; },<br>        { label: &#39;Twitter&#39;, href: &#39;https://twitter.com&#39; },<br>      ],<br>    },<br>  ],<br>  copyright: `Copyright © ${new Date().getFullYear()} My Company.`,<br>}</pre><h3>📄 Creating a New Page</h3><p>To create a new custom page (e.g., /about), just add a new file to src/pages:</p><pre>touch src/pages/about.js</pre><p>Add a simple React component:</p><pre>export default function About() {<br>  return &lt;h1&gt;About Us&lt;/h1&gt;;<br>}</pre><p>Visit /about in the browser and it just works. No routing setup needed.</p><h3>🧪 Bonus: Add Analytics, Search, Versioning, and More</h3><p>Docusaurus supports:</p><ul><li>Full-text search (via Algolia or local)</li><li>Google Analytics or Plausible</li><li>Docs versioning</li><li>Multi-language support</li><li>Custom themes and plugins</li></ul><p>It’s insanely extensible for real-world SaaS/product teams.</p><h3>✅ Conclusion</h3><p>You just learned how to:</p><ul><li>Set up a complete product website using Docusaurus</li><li>Customize landing pages, blog, docs, and layouts</li><li>Create new routes using simple React components</li><li>Tweak your navbar, footer, and site structure</li></ul><p>With Docusaurus, you don’t need a full-blown CMS or custom framework to build a <strong>clean, fast, SEO-friendly website</strong> for your product or dev tools.</p><h3>🧠 Want More Like This?</h3><p>Follow me for posts on:</p><ul><li>React &amp; Next.js best practices</li><li>Full-stack web dev workflows</li><li>Building dev-focused SaaS tools</li></ul><p>Feel free to connect or drop questions in the comments 👇</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a8b051a7da9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Array methods in JavaScript. array.map(), array.filter(), array.push(), array.shift() and much more]]></title>
            <link>https://suryashakti1999.medium.com/array-methods-in-javascript-f3dd73d670ed?source=rss-690cefdebc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3dd73d670ed</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Surya Shakti]]></dc:creator>
            <pubDate>Fri, 04 Jun 2021 06:12:43 GMT</pubDate>
            <atom:updated>2021-06-04T06:12:43.040Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RYW_0bknC-FtRqM5" /><figcaption>Photo by <a href="https://unsplash.com/@florianolv?utm_source=medium&amp;utm_medium=referral">Florian Olivo</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>An array in JavaScript is a data structure, which can hold one or more values at a time. Unlike most languages where array is a reference to the multiple variables, in JavaScript array is a single variable that stores multiple elements.</p><p>Array methods are nothing but JavaScript built-in functions which can be applied on the array. Array has many methods to perform different operations and to make things a lot more easier.</p><h3>Array Methods</h3><ol><li>array.push()</li><li>array.pop()</li><li>array.shift()</li><li>array.unshift()</li><li>array.map()</li><li>array.filter()</li><li>array.sort()</li><li>array.concat()</li><li>array.every()</li><li>array.some()</li><li>array.includes()</li><li>array.join()</li><li>array.find()</li><li>array.findIndex()</li><li>array.indexOf()</li><li>array.reverse()</li></ol><h3>array.push()</h3><p>The push()method adds one or more elements to the end of the array. It returns the new length of the array.</p><pre>const array = [1,2,3,4];</pre><pre>array.push(5,6,7); // returns 7 (new length)</pre><pre>console.log(array);</pre><p>output :-</p><pre>[1, 2, 3, 4, 5, 6, 7]</pre><h3>array.pop()</h3><p>The pop() method extracts the last element from the array and returns that element.</p><pre>// ---------example 1---------</pre><pre>const array2 = [1,2,3];</pre><pre>const lastElement = array2.pop();</pre><pre>console.log(lastElement);</pre><pre>// ---------example 2---------</pre><pre>const array3 = [&#39;a&#39;,&#39;b&#39;,&#39;c&#39;];</pre><pre>const lastElement2 = array3.pop();</pre><pre>console.log(lastElement2);</pre><p>Output :-</p><pre>3<br>c</pre><h3>array.shift()</h3><p>The shift() method extracts the first element of the array the returns the element.</p><pre>const array4 = [&#39;surya&#39;, &#39;auro&#39;, &#39;soumya&#39;];</pre><pre>const firstElement = array4.shift();</pre><pre>console.log(firstElement);</pre><p>Output :-</p><pre>surya</pre><h3>array.unshift()</h3><p>The unshift() method adds element to the beginning of the array and returns the new length of the array.</p><pre>const array5 = [1,2,3,4];<br>array5.unshift(0); // returns 5 (new length)<br>console.log(array5);</pre><p>Output :-</p><pre>[0,1,2,3,4]</pre><h3>array.map()</h3><p>The map() method calls a function for each element of the array and returns the array of results.</p><pre>const array7 = [1,2,3,4,5,6,7,8];</pre><pre>const mappedArray = array7.map((<em>each</em>) =&gt; <em>each</em> = <em>each</em>+1);</pre><pre>console.log(mappedArray);</pre><p>Output :-</p><pre>[2, 3, 4, 5, 6, 7, 8, 9]</pre><h3>array.filter()</h3><p>The filter() method creates a new array filled with all the array elements that pass the specified condition.</p><pre>//-----------Example 1------------</pre><pre>const array8 = [&#39;a&#39;,&#39;b&#39;,&#39;c&#39;,&#39;d&#39;,&#39;c&#39;,&#39;e&#39;,&#39;c&#39;];</pre><pre>const filteredArray = array8.filter((<em>each</em>) =&gt; <em>each</em> === &#39;c&#39;);</pre><pre>console.log(&#39;Example 1 --&gt;&#39;,filteredArray);</pre><pre>//-----------Example 2------------</pre><pre>const array9 = [&#39;a&#39;,&#39;b&#39;,&#39;c&#39;,&#39;d&#39;,&#39;c&#39;,&#39;e&#39;,&#39;c&#39;];</pre><pre>const filteredArray2 = array9.filter((<em>each</em>) =&gt; <em>each</em> !== &#39;c&#39;);</pre><pre>console.log(&#39;Example 2 --&gt;&#39;,filteredArray2);</pre><p>Output :-</p><pre>Example 1 --&gt; [&quot;c&quot;, &quot;c&quot;, &quot;c&quot;]<br>Example 2--&gt; [&quot;a&quot;, &quot;b&quot;, &quot;d&quot;, &quot;e&quot;]</pre><h3>array.sort()</h3><p>The sort() method sorts values as strings. The default order of sorting the array is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code units values.</p><pre>const array10 = [&#39;mango&#39;, &#39;apple&#39;, &#39;kiwi&#39;,&#39;orange&#39;];</pre><pre>console.log(array10.sort());</pre><p>As sort() method sorts array according to the UTF-16 values and not according to the mathematical values it does not go right with numbers. Hence we have to pass a comparing function in the sort() method that will have two arguments and should return positive number or negative number or zero. If ‘a’ and ‘b’ are the two arguments of the comparing function then if the comparing function returns positive number then ‘b’ will come first, if the comparing function returns negative number then ‘a’ will come first, if the comparing function returns 0 then nothing will change.</p><pre>const array11 = [235,12,265,65,99,1000];</pre><pre>const ascending = array11.sort((<em>a</em>, <em>b</em>) =&gt; <em>a</em>-<em>b</em>);</pre><pre>console.log(&#39;ascending --&gt; &#39;,ascending);</pre><pre>const descending = array11.sort((<em>a</em>, <em>b</em>) =&gt; <em>b</em>-<em>a</em>);</pre><pre>console.log(&#39;descending --&gt; &#39;,descending);</pre><p>Output :-</p><pre>[&quot;apple&quot;, &quot;kiwi&quot;, &quot;mango&quot;, &quot;orange&quot;]<br>ascending --&gt; [12, 65, 99, 235, 265, 1000]<br>descending --&gt; [1000, 265, 235, 99, 65, 12]</pre><h3>array.concat()</h3><p>The concat() method merges two or more arrays and creates a new array without changing the old existing arrays.</p><pre>const array12 = [1,2,3,4,5];</pre><pre>const array13 = [12,5,6767,43,2];</pre><pre>console.log(array12.concat(array13));</pre><p>Output :-</p><pre>[1, 2, 3, 4, 5, 12, 5, 6767, 43, 2]</pre><h3>array.every()</h3><p>The every() method returns true or false based on the fact that every element of the array passes the provided condition or not.</p><pre>const array14 = [5,10,15,20,25];</pre><pre>console.log(array14.every(<em>each</em> =&gt; <em>each</em>%5 === 0));</pre><pre>console.log(array14.every(<em>each</em> =&gt; <em>each</em>%2 === 0));</pre><p>Output :-</p><pre>true<br>false</pre><h3>array.some()</h3><p>The some() method returns true or false based on the fact that at least one element of the array passes the provided condition or not.</p><pre>const array15 = [5,10,15,20,25];</pre><pre>console.log(array15.some(<em>each</em> =&gt; <em>each</em>%7 === 0));</pre><pre>console.log(array15.some(<em>each</em> =&gt; <em>each</em>%2 === 0));</pre><p>Output :-</p><pre>false<br>true</pre><h3>array.includes()</h3><p>The includes() method determines whether the given array contains the specified element. It returns true if an array contains the element, otherwise false.</p><pre>const array16 = [1,2,3,4,5];</pre><pre>console.log(array16.includes(5))</pre><pre>console.log(array16.includes(8))</pre><p>Output :-</p><pre>true<br>false</pre><h3>array.join()</h3><p>The join() method concatenates every element of the array with a specified separator and returns that concatenated string.</p><pre>const array17 = [&#39;I&#39;, &#39;am&#39;, &#39;a&#39;, &#39;frontend&#39;, &#39;software&#39;, &#39;developer.&#39;];</pre><pre>console.log(array17.join(&#39; &#39;));</pre><p>Output :-</p><pre>I am a frontend software developer.</pre><h3>array.find()</h3><p>The find() method returns the value of the first element in the array that passes the given condition.</p><pre>const array18 = [1,23,45,25,5,77,147];</pre><pre>console.log(array18.find(<em>item</em> =&gt; <em>item</em>%5 === 0))</pre><p>Output :-</p><pre>45</pre><h3>array.findIndex()</h3><p>The findIndex() method returns the index of the first element in the array that passes the specified condition.</p><pre>const array19 = [1,23,45,25,5,77,147];</pre><pre>console.log(array19.findIndex(<em>item</em> =&gt; <em>item</em>%5 === 0));</pre><p>Output :-</p><pre>2</pre><h3>array.indexOf()</h3><p>The indexOf() method returns the position of the specified item in an array.</p><pre>const array20 = [1,23,45,25,5,77,147];</pre><pre>console.log(array20.indexOf(77));</pre><p>Output :-</p><pre>5</pre><h3>array.reverse()</h3><p>The reverse() method reverses the array.</p><pre>const array21 = [1,23,45,25,5,77,147];</pre><pre>console.log(array21.reverse());</pre><p>Output :-</p><pre>[147, 77, 5, 25, 45, 23, 1]</pre><ul><li><a href="https://suryashakti1999.medium.com/to-do-list-app-using-javascript-for-absolute-beginners-13ea9e38a033">Building To-Do List App Using vanilla JavaScript For Absolute Beginners</a></li><li><a href="https://suryashakti1999.medium.com/string-and-number-methods-in-javascript-f4967d705c86">String And Number methods in JavaScript.</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3dd73d670ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[String And Number methods in JavaScript.]]></title>
            <link>https://suryashakti1999.medium.com/string-and-number-methods-in-javascript-f4967d705c86?source=rss-690cefdebc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4967d705c86</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Surya Shakti]]></dc:creator>
            <pubDate>Sat, 08 May 2021 10:22:28 GMT</pubDate>
            <atom:updated>2021-05-08T12:18:33.595Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yiaJepGvRRX9ZSAJR-mj_g.jpeg" /></figure><p><strong>Strings</strong> — Any character written inside quotes is considered as a <strong>string</strong> in JavaScript. If there is nothing inside the quotes then also it is considered as a string. We Can use single or double quotes. We can also use quotes inside a string but they should not match the quotes which are surrounding the string.</p><h3>String methods</h3><ol><li>length()</li><li>charAt()</li><li>indexOf()</li><li>lastIndexOf()</li><li>toUperCase()</li><li>toLowercase()</li><li>concat()</li><li>trim()</li><li>slice()</li><li>replace()</li><li>split()</li><li>substring()</li></ol><h4>1. The length() Method</h4><p>The length()method returns the length of the string.</p><pre>const string = &quot;This is a string.&quot;;</pre><pre>const strLength = string.length;</pre><pre>console.log(`The length of the string is ${strLength}.`);</pre><p>output : -</p><pre>The length of the string is 17</pre><h4>2. The charAt() Method</h4><p>The charAt()method returns the character at specified index which is passed as a parameter in charAt().</p><pre>const string = &quot;This is a string.&quot;;</pre><pre>console.log(string.charAt(5));</pre><p>output :-</p><pre>i</pre><h4>3. The indexOf() Method</h4><p>The indexOf()method returns the index of first occurrence of specified string which is passed as a parameter in indexOf().</p><pre>const string = &quot;This is a string.&quot;;</pre><pre>console.log(string.indexOf(&quot;is&quot;));</pre><p>output :-</p><pre>2</pre><h4>4. The lastIndexOf() Method</h4><p>The lastIndexOf()method returns the index of last occurrence of specified string which is passed as a parameter in indexOf().</p><pre>const string = &quot;This is a string.&quot;;</pre><pre>console.log(string.lastIndexOf(&quot;is&quot;));</pre><p>output :-</p><pre>5</pre><h4>5. The toUppercase() Method</h4><p>The toUppercase()method converts the string to uppercase</p><pre>const str3 = &quot;This is a String&quot;;</pre><pre>const str3Up = str3.toUpperCase();</pre><pre>console.log(str3Up);</pre><p>output :-</p><pre>THIS IS A STRING</pre><h4>6. The toLowercase() Method</h4><p>The toLowercase()method converts the string to uppercase</p><pre>const str4 = &quot;THIS IS A STRING&quot;;</pre><pre>const str4Up = str4.toLowerCase();</pre><pre>console.log(str4Up);</pre><p>output :-</p><pre>this is a string</pre><h4>7. The Concat() Method</h4><p>The concat()method merges two or more string into one</p><pre>const str1 = &quot;This is string 1.&quot;;</pre><pre>const str2 = &quot;This is String 2.&quot;;</pre><pre>const concatenatedString = str1.concat(&quot; &quot;, str2);</pre><pre>console.log(concatenatedString);</pre><p>output :-</p><pre>This is string 1. This is String 2.</pre><h4>8. The trim() Method</h4><p>The trim()method removes all the whitespaces from both starting and ending of the string.</p><pre>const stringToTrim = &quot;   string to       trim          &quot;;</pre><pre>const trimmedString = stringToTrim.trim();</pre><pre>console.log(trimmedString);</pre><p>output : -</p><pre>string to       trim</pre><h4>9. The slice() Method</h4><p>the slice()method returns a part or slice of the given input string. The method takes 2 parameters: the starting index, and the ending index.</p><pre>const slice = &quot;2020-11-11t08:29:06Tz&quot;;</pre><pre>const sliced = slice.slice(0,10)</pre><pre>console.log(sliced);</pre><p>output :-</p><pre>2020-11-11</pre><h4>10. The replace() Method</h4><p>The replace()method replaces a specified value with another value in a string.</p><pre>const strToReplace = &quot;this is a string&quot;;</pre><pre>console.log(strToReplace.replace(&quot;string&quot;, &quot;replaced string&quot;));</pre><p>output :-</p><pre>this is a replaced string</pre><h4>11. The split() Method</h4><p>The split() method converts a string into an array</p><pre>const strToSplit = &quot;this is a string&quot;;</pre><pre>const splittedStr = strToSplit.split(&#39; &#39;);</pre><pre>console.log(splittedStr);</pre><p>output :-</p><pre>[&quot;this&quot;, &quot;is&quot;, &quot;a&quot;, &quot;string&quot;]</pre><h4>12. The substring() Method</h4><p>The substring() method returns the part of the string between the start and end indexes which are passed as parameters in substring() method.</p><pre>const string5 = &quot;this is a string.&quot;;</pre><pre>console.log(string5.substring(4,10));</pre><p>output :-</p><pre>is a</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-GsXPsK4fYJ4VRb3iIWww.jpeg" /></figure><p><strong>Numbers</strong> — In JavaScript there is only one type of number. It can be written with or without decimals.</p><h3>Numbers methods</h3><ol><li>toString()</li><li>toExponential()</li><li>toFixed()</li><li>valueOf()</li><li>Number()</li><li>parseInt()</li><li>parseFloat()</li></ol><h4>1. The toString() method</h4><p>The toString() method converts the number to string.</p><pre>const num = 43516;</pre><pre>const numToString = num.toString();</pre><pre>console.log(numToString);</pre><p>output :-</p><pre>43516</pre><h4>2. The toExponential() method</h4><p>The toExponential() method converts a number to its exponential form.</p><p>Parameters :- it accepts a single parameter and it specifies the number of digits after the decimal.</p><pre>const num2 = 43516;</pre><pre>const numToExponential = num2.toExponential(2);</pre><pre>console.log(numToExponential);</pre><p>output :-</p><pre>4.35e+4</pre><h4>3. The toFixed() method</h4><p>The toFixed() method formats a number using fixed-point notation.</p><p>parameter :- it accepts a single parameter and it specifies the number of digits after the decimal.</p><pre>const num3 = 4.3516;</pre><pre>const numToFixed = num3.toFixed(2);</pre><pre>console.log(numToFixed);</pre><p>output :-</p><pre>4.35</pre><p>4. The valueOf() method</p><p>The valueOf() method in JavaScript is used to return the primitive value of a number.</p><pre>const num4 = 4.3516;</pre><pre>const numValue = num4.valueOf();</pre><pre>console.log(numValue);</pre><p>output :-</p><pre>4.3516</pre><h4>5. The Number() method</h4><p>The Number() is used to convert the variables into numbers.</p><pre>const str = &quot;23561&quot;;</pre><pre>const strToNum = Number(str);</pre><pre>console.log(strToNum);</pre><p>output :-</p><pre>23561</pre><h4>6. The parseInt() method</h4><p>The parseInt() method converts the string to whole number.</p><pre>const strr = &quot;23.561&quot;;</pre><pre>const str2ToNum = parseInt(strr);</pre><pre>console.log(str2ToNum);</pre><p>output :-</p><pre>23</pre><h4>7. The parseFloat() method</h4><p>The parseFloat() method converts the string to floating point number.</p><pre>const strr = &quot;23.561&quot;;</pre><pre>const str2ToNum = parseFloat(strr);</pre><pre>console.log(str2ToNum);</pre><p>output :-</p><pre>23.561</pre><p><a href="https://medium.com/@suryashakti1999/to-do-list-app-using-javascript-for-absolute-beginners-13ea9e38a033">Building To-Do List App Using vanilla JavaScript For Absolute Beginners</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4967d705c86" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building To-Do List App Using vanilla JavaScript For Absolute Beginners]]></title>
            <link>https://suryashakti1999.medium.com/to-do-list-app-using-javascript-for-absolute-beginners-13ea9e38a033?source=rss-690cefdebc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/13ea9e38a033</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Surya Shakti]]></dc:creator>
            <pubDate>Fri, 31 Jul 2020 10:03:51 GMT</pubDate>
            <atom:updated>2021-06-05T03:31:19.800Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building To-Do List App Using Vanilla JavaScript For Absolute Beginners</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q9ytuylJQXMP-FaxjQyA1Q.jpeg" /><figcaption><strong>Preview of our To-Do app</strong></figcaption></figure><p>The best way to learn something is by doing. In this tutorial, we will be building a To-Do List app using pure JavaScript. If you are a beginner and tired of studying from boring theoretical tutorials then you are in a right place because here we will practically build this To-Do app from scratch. Don’t worry I have explained each and every step to develop our To-do app.</p><p>In this app, we will be able to add new tasks to be done, delete tasks, mark tasks after completion, we will have a drop-down menu to filter our tasks on basis of completed or incomplete tasks.</p><p>So without any further delay let’s get started with the coding.</p><p>We have to create a folder and we have to create three files there:</p><ol><li><strong>index.html</strong></li><li><strong>styles.css</strong></li><li><strong>main.js</strong></li></ol><h3><strong>HTML file for our app</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbb6af71e970a06ca01e400e15d1ff8a/href">https://medium.com/media/fbb6af71e970a06ca01e400e15d1ff8a/href</a></iframe><p>As this tutorial mainly focuses on teaching JavaScript concepts, I assume that you must be familiar with the HTML syntax and easily understand above code but still we will discuss briefly about what’s happening in this html file.</p><p>In body tag of our file we have three main section: <strong>1. Heading 2. Form 3.Task Container </strong>and at last we are just linking our <strong>JavaScript</strong> file.</p><p>Heading section as you already guessed contains title of our app.</p><p>In form section, we have an input element to enter a new task, a button to display that task below, a dropdown which filters our tasks on basis of completed or incomplete tasks.</p><p>In task container section we have all our tasks which are added to our page dynamically when user adds a task through JavaScript.</p><h3>CSS file for styling</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65ea02e97973c42564a694ea3a4b7997/href">https://medium.com/media/65ea02e97973c42564a694ea3a4b7997/href</a></iframe><p>This is my styling for our To-Do List app which you can easily understand by just reading once as I have also added comments specifying the role of the code. You can also come up with your own styling. And please send the link of your styling in comment section. I would love to see all of your creative styling.</p><h3>JavaScript file for functionality</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/638eec9f15b2ad2a85b9e1d34ab8fcad/href">https://medium.com/media/638eec9f15b2ad2a85b9e1d34ab8fcad/href</a></iframe><p>Here comes the exciting part for which you guys are reading this. The JavaScript file is responsible for all the functionality of our app.</p><h4>1. Storing Elements in constants</h4><p>First let’s store html elements which we will use in different functionalities.</p><pre><em>//selectors</em></pre><pre>const todoInput = document.querySelector(&#39;.todo_input&#39;);</pre><pre>const todoButton = document.querySelector(&#39;.todo_button&#39;);</pre><pre>const todoList = document.querySelector(&#39;.todo_list&#39;);</pre><pre>const filterOption = document.querySelector(&#39;.filter_todo&#39;);</pre><p>Here, with the help of <strong>document.querySelector()</strong> method we are storing html elements with specific class to their respective constants. Now constants <strong>todoInput</strong>, <strong>todoButton</strong>, <strong>todoList</strong>, <strong>filterOption </strong>contains html elements.</p><h4><strong>2. Adding Event Listeners to elements</strong></h4><p>Now we will add click event listeners to our Buttons and Dropdown Filter.</p><pre><em>//event listeners</em></pre><pre>todoButton.addEventListener(&quot;click&quot;, addTodo)</pre><pre>todoList.addEventListener(&quot;click&quot;, deleteCheck)</pre><pre>filterOption.addEventListener(&quot;click&quot;, filterTodo)</pre><p>The addEventListener() method attaches an event handler to the specified element. Now when we will click ‘+’ button element in our input then addTodo function will execute. When we will click any task which is added in task container of our app then deleteCheck function will execute. When we will click select element (dropdown) in our app then filterTodo function will execute</p><h4>3. Adding a Task with check button and delete button</h4><pre>function addTodo(event) {</pre><pre>event.preventDefault();</pre><pre><em>//todo DIV</em></pre><pre>const todoDiv = document.createElement(&#39;div&#39;);</pre><pre>todoDiv.classList.add(&#39;todo&#39;);</pre><pre><em>//todo LI</em></pre><pre>const newTodo = document.createElement(&#39;li&#39;);</pre><pre>newTodo.innerText = todoInput.value;</pre><pre>newTodo.classList.add(&#39;todo_item&#39;);</pre><pre>todoDiv.appendChild(newTodo);</pre><pre>if(todoInput.value === &quot;&quot;){</pre><pre>return null;</pre><pre>}</pre><pre><em>//check mark BUTTON</em></pre><pre>const completedButton = document.createElement(&#39;button&#39;);</pre><pre>completedButton.innerHTML = &#39;&lt;i class=&quot;fas fa-check&quot;&gt;&lt;/i&gt;&#39;;</pre><pre>completedButton.classList.add(&#39;complete_btn&#39;)</pre><pre>todoDiv.appendChild(completedButton);</pre><pre><em>//delete BUTTON</em></pre><pre>const deleteButton = document.createElement(&#39;button&#39;);</pre><pre>deleteButton.innerHTML = &#39;&lt;i class=&quot;fas fa-trash&quot;&gt;&lt;/i&gt;&#39;;</pre><pre>deleteButton.classList.add(&#39;delete_btn&#39;)</pre><pre>todoDiv.appendChild(deleteButton);</pre><pre><em>//Append to Actual LIST</em></pre><pre>todoList.appendChild(todoDiv);</pre><pre><em>//Clear todo input VALUE</em></pre><pre>todoInput.value = &quot;&quot;</pre><pre>}</pre><p>This addTodo function will execute when the add button on input will be clicked. This function is responsible for adding a task, adding check button and adding delete button.</p><p>Firstly, we are calling <strong>event.preventDefault()</strong> method which cancels the event if it is cancelable. In our case as our add button is of submit type, when we click on this our page gets submitted and get refreshed and that’s something we don’t want in our application that is where event.preventDefault() method comes into play method prevent it from submitting the form.</p><p>Then with the help of <strong>document.createElement()</strong> method we are creating a html <em>&lt;div&gt; </em>element which will contain the task, check and delete button. Next we are creating html <em>&lt;li&gt; </em>which is our actual task which we are getting from <strong>todoInput.value</strong> which just takes whatever user types in input field and stores it in this <em>&lt;li&gt; </em>element. In the similar way we are creating both check and delete buttons. At last we are checking if our input field is not empty which means there is some task written there and if so, we are append our <em>&lt;li&gt;</em> (list) and both buttons in the <em>&lt;div&gt; </em>element we just created.</p><h4>4. Deleting and checking the task accordingly</h4><pre><em>//DELETE &amp; CHECK</em></pre><pre>function deleteCheck(e) {</pre><pre>const item = e.target;</pre><pre><em>//DELETE ITEM</em></pre><pre>if (item.classList[0] === &quot;delete_btn&quot;) {</pre><pre>const todo = item.parentElement;</pre><pre><em>//ANIMATION TRANSITION</em></pre><pre>todo.classList.add(&quot;fall&quot;)</pre><pre>todo.addEventListener(&#39;transitionend&#39;, function () {</pre><pre>todo.remove()</pre><pre>})</pre><pre>}</pre><pre><em>//COMPLETE ITEM</em></pre><pre>if (item.classList[0] === &quot;complete_btn&quot;) {</pre><pre>const todo = item.parentElement;</pre><pre>todo.classList.toggle(&quot;completedItem&quot;)</pre><pre>}</pre><pre>}</pre><p>As we have added an event listener on our todoList <em>&lt;div&gt;</em>,<em> </em>whenever we will click on check or delete button this function will execute. However on clicking the task itself in the <em>&lt;div&gt;</em> also execute this function but as we are handling the situation when either of any button is clicked so clicking the task will not do anything.</p><p>In this function we are getting the target element using <strong>e.target</strong>. Then we are checking if the target element is delete button or check button. If it is delete button(delete_btn) then we are simply getting its parent element with <strong>.parentElement </strong>property and deleting it with the help of <strong>.remove()</strong> method after the transition is completed which is added by adding ‘<em>fall’ class </em>to the whole <em>&lt;div&gt;. </em>If we clcik on check button (complete_btn) then we are just toggling a class to the parent element that is <em>&lt;div&gt; </em>itself which will apply some styling to the task to confirm that this task is completed.</p><h4>5. Filtering the tasks according to the selected option</h4><pre><em>//FILTERING THE TASKS ACCORDING THE OPTION</em></pre><pre>function filterTodo(e) {</pre><pre>const todos = todoList.childNodes;</pre><pre>for(let i = 1; i&lt;todos.length; i++ ){</pre><pre>switch (e.target.value) {</pre><pre>case &quot;all&quot;:</pre><pre>todos[i].style.display = &quot;flex&quot;;</pre><pre>break;</pre><pre>case &quot;completed&quot;:</pre><pre>if (todos[i].classList.contains(&#39;completedItem&#39;)) {</pre><pre>todos[i].style.display = &quot;flex&quot;;</pre><pre>} else {</pre><pre>todos[i].style.display = &quot;none&quot;;</pre><pre>}</pre><pre>break;</pre><pre>case &quot;uncompleted&quot;:</pre><pre>if (!todos[i].classList.contains(&#39;completedItem&#39;)) {</pre><pre>todos[i].style.display = &quot;flex&quot;;</pre><pre>} else {</pre><pre>todos[i].style.display = &quot;none&quot;;</pre><pre>}</pre><pre>break;</pre><pre>}</pre><pre>}</pre><pre>}</pre><p>When we click one of the options of dropdown then this filterTodo function will execute. This function is responsible for filtering the tasks on the basis of all tasks, completed and uncompleted tasks. In constant<strong> todos </strong>we are storing all the todo tasks. Then using for loop we are iterating over them . In the loop we are checking which option is clicked from the dropdown and just filtering the elements by implementing the display style to the todos.</p><p>For example:- If you clicked completed option of the dropdown then it will check which todos have class of <strong>completed_item </strong>and add a style of flex to it otherwise it will add style of display none to it.</p><pre>todos[i].style.display = &quot;flex&quot;;</pre><pre>} else {</pre><pre>todos[i].style.display = &quot;none&quot;;</pre><pre>}</pre><p>Other options filter the todos by the same method.</p><p>Now our application is working great without any problem.</p><p>That is all for today. I hope this was helpful for guys. I will be posting my ideas on various topics and we will build many cool apps together.</p><p>Good Day, Good Coding…</p><blockquote>String And Number methods in JavaScript</blockquote><p><a href="https://suryashakti1999.medium.com/string-and-number-methods-in-javascript-f4967d705c86">String And Number methods in JavaScript.</a></p><blockquote>Array methods in JavaScript</blockquote><p><a href="https://suryashakti1999.medium.com/array-methods-in-javascript-f3dd73d670ed">Array methods in JavaScript. array.map(), array.filter(), array.push(), array.shift() and much more</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13ea9e38a033" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>