Is it possible in Headless WordPress development to consume the JS/CSS from the REST API?

I’m developing a headless WordPress website with Next.js and aiming to implement like/unlike features while displaying the count of likes.

My goal is to fully integrate this feature within WordPress and deliver it as a complete package to the Next.js application, encompassing styles and JavaScript. Next.js will solely handle the display to the user. I prefer not to create a REST endpoint in WordPress and build the UI in React; instead, I want WordPress to manage all aspects and return the styling/JavaScript code to React.

While this approach may seem contrary to the concept of Headless, is it feasible? If so, could you direct me to the necessary resources to accomplish it? Could the solution lie within Block Themes?

The resources on the internet for Headless WordPress are very basic and touch small things that’s why I asked, thanks.

Unexpected padding in div when using html2pdf

I’m trying to convert my html to pdf in react using html2pdf library but for some reason, its inserting padding on its own to the divs in the downloaded pdf.
But when I’m using the same code in vanilla javascript, its working perfectly fine.

Section with the issue

            <section
            className="relative w-full  bg-white"
            style={{ height: "236mm" }}
            >
            <div className=" flex w-full ">
                <div className=" w-full mx-5 ">
                <div className="  ">
                    <h1
                    className="titleq text-4xl tracking-widest whitespace-nowrap font-semibold mt-4 "
                    style={{ color: "#015E72" }}
                    >
                    Overview
                    </h1>
                    <p
                    className="  whitespace-nowrap font-semibold mt-2 mx-2 titlex"
                    style={{ fontSize: "medium" }}
                    >
                    {" "}
                    <span style={{ color: "#737373" }}>Itinerary for</span>{" "}
                    <span style={{ color: "#00B8C4" }}>5 Nights & 6 Days</span>{" "}
                    </p>
                    <div className=" flex gap-5 whitespace-nowrap text-xs mt-1 pb-3 mx-1 titlex">
                    <p>
                        {" "}
                        <span className=" font-semibold mx-1 ">Arrival:</span>
                        21/03/2024
                    </p>
                    <p>
                        <span className=" font-semibold mx-1 ">Departure:</span>
                        3/26/2024
                    </p>
                    </div>
                </div>
                <div className=" parent flex gap-5 border-t-2 border-b-2  titlex">
                    <div
                    className="w-20  items-center flex justify-center  "
                    style={{ backgroundColor: "#015E72" }}
                    >
                    <h3 className=" "> Day 1 </h3>
                    </div>
                    <div className="days flex flex-col space-y-2 py-3">
                    <div className="flex items-center gap-5">
                        <table className="w-full">
                        <tr className="space-x-8">
                            <td className="font-semibold">Sightseeing</td>
                            <td></td>
                            <td className="font-semibold">:</td>
                            <td></td>
                            <td className="">Srinagar</td>
                        </tr>

                        <tr className="space-x-8">
                            <td className="font-semibold">Hotel Stay At</td>
                            <td></td>
                            <td className="font-semibold">:</td>
                            <td></td>
                            <td className="">Home in Paradise</td>
                        </tr>
                        </table>
                    </div>
                    </div>
                </div>
                <div className=" parent flex gap-5 border-t-2 border-b-2  titlex">
                    <div
                    className="  w-20 text-center items-center flex justify-center  "
                    style={{ backgroundColor: "#D9F6FA" }}
                    >
                    <h3 className="   whitespace-nowrap  m-0 "> Day 2 </h3>
                    </div>
                    <div className="days flex flex-col space-y-2 py-3">
                    <div className="flex items-center gap-5">
                        <table className="w-full">
                        <tr className="space-x-8">
                            <td className="font-semibold">Sightseeing</td>
                            <td></td>
                            <td className="font-semibold">:</td>
                            <td></td>
                            <td className="">Sona,marg</td>
                        </tr>

                        <tr className="space-x-8">
                            <td className="font-semibold">Hotel Stay At</td>
                            <td></td>
                            <td className="font-semibold">:</td>
                            <td></td>
                            <td className="">Home in Paradise</td>
                        </tr>
                        </table>
                    </div>
                    </div>
                </div>
                <div className=" parent flex gap-5 border-t-2 border-b-2  titlex">
                    <div
                    className="  w-20 text-center items-center flex justify-center  "
                    style={{ backgroundColor: "#015E72" }}
                    >
                    <h3 className="   whitespace-nowrap  m-0 "> Day 3 </h3>
                    </div>
                    <div className="days flex flex-col space-y-2 py-3">
                    <div className="flex items-center gap-5">
                        <table className="w-full">
                        <tr className="space-x-8">
                            <td className="font-semibold">Sightseeing</td>
                            <td></td>
                            <td className="font-semibold">:</td>
                            <td></td>
                            <td className="">Doodhpathri </td>
                        </tr>

                        <tr className="space-x-8">
                            <td className="font-semibold">Hotel Stay At</td>
                            <td></td>
                            <td className="font-semibold">:</td>
                            <td></td>
                            <td className="">Home in Paradise</td>
                        </tr>
                        </table>
                    </div>
                    </div>
                </div>
                <div className=" parent flex gap-5 border-t-2 border-b-2  titlex">
                    <div
                    className="  w-20 text-center items-center flex justify-center  "
                    style={{ backgroundColor: "#D9F6FA" }}
                    >
                    <h3 className="   whitespace-nowrap  m-0 "> Day 4 </h3>
                    </div>
                    <div className="days flex flex-col space-y-2 py-3">
                    <div className="flex items-center gap-5">
                        <table className="w-full">
                        <tr className="space-x-8">
                            <td className="font-semibold">Sightseeing</td>
                            <td></td>
                            <td className="font-semibold">:</td>
                            <td></td>
                            <td className="">Gulmarg</td>
                        </tr>

                        <tr className="space-x-8">
                            <td className="font-semibold">Hotel Stay At</td>
                            <td></td>
                            <td className="font-semibold">:</td>
                            <td></td>
                            <td className="">Zahgeer Continental</td>
                        </tr>
                        </table>
                    </div>
                    </div>
                </div>
                <div className=" parent flex gap-5 border-t-2 border-b-2  titlex">
                    <div
                    className="  w-20 text-center items-center flex justify-center  "
                    style={{ backgroundColor: "#015E72" }}
                    >
                    <h3 className="   whitespace-nowrap  m-0 "> Day 5 </h3>
                    </div>
                    <div className="days flex flex-col space-y-2 py-3">
                    <div className="flex items-center gap-5">
                        <table className="w-full">
                        <tr className="space-x-8">
                            <td className="font-semibold">Sightseeing</td>
                            <td></td>
                            <td className="font-semibold">:</td>
                            <td></td>
                            <td className="">Pahalgam</td>
                        </tr>

                        <tr className="space-x-8">
                            <td className="font-semibold">Hotel Stay At</td>
                            <td></td>
                            <td className="font-semibold">:</td>
                            <td></td>
                            <td className="">Pahalgam Peaks</td>
                        </tr>
                        </table>
                    </div>
                    </div>
                </div>
                </div>
                <div className="   " style={{ width: "50%", height: "237mm" }}>
                <img
                    className="w-full h-full"
                    src=" https://tripdocks-images-bucket.s3.ap-south-1.amazonaws.com/Company/KAshmir%20DAsh%20%281%29.png?X-Amz-Expires=604800&response-content-type=image%2Fpng&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAR3BJ4BUYEYXQ5HPZ%2F20240213%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Date=20240213T151509Z&X-Amz-SignedHeaders=host&X-Amz-Signature=052c26dc33e359c5f3424f970873ebcced76cf7d4a8b181ca82c72405d747c74"
                    alt="  "
                    srcset="  "
                    style={{ objectFit: "cover", height: "220mm" }}
                />
                </div>

                <div className=" w-full absolute bottom-1">
                <div className="w-full flex">
                    <div className=" w-1/2 flex items-end ml-2">
                    <div className="">
                        <img
                        className="w-8 h-7"
                        src=" https://tripdocks-images-bucket.s3.ap-south-1.amazonaws.com/Company/Logo%20Crop_77a46fb1-ac8f-4856-a121-3054f3acbfed.png?X-Amz-Expires=604800&response-content-type=image%2Fpng&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAR3BJ4BUYEYXQ5HPZ%2F20240213%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Date=20240213T151509Z&X-Amz-SignedHeaders=host&X-Amz-Signature=3f19a9b10f257d7424045c439bd653ae52d9f0ddb0c3cfa8543517d83a6925c6"
                        crossorigin="anonymous"
                        alt=""
                        srcset=""
                        />
                    </div>
                    <div className=" relative">
                        <p
                        className="font-semibold absolute bottom-0 whitespace-nowrap"
                        style={{ color: "#015d72cf", fontSize: "x-small" }}
                        >
                        <div>
                            <p>6005646020</p>
                            <p>Kashmir Dash Holidays</p>
                        </div>
                        </p>
                    </div>
                    </div>

                    <div className=" w-1/2 flex justify-end items-end">
                    <div className="flex justify-center items-center">
                        <img
                        className="w-5 h-5 "
                        src="https://emecbucket.s3.ap-south-1.amazonaws.com/test-images/logob.png"
                        alt=""
                        crossorigin="anonymous"
                        srcset=""
                        />
                        <p
                        className="font-semibold text-xs mr-5"
                        style={{ color: "#015d72cf" }}
                        >
                        &nbsp;&nbsp;Powered by TripDocks
                        </p>
                    </div>
                    </div>
                </div>
                </div>
            </div>
            </section>

Download PDF code

   const options = {
  filename: "Package Trial.pdf",

  html2canvas: { scale: 1.5, useCORS: true },
  jsPDF: {
    format: [236, 229], // Custom page size (height x width) in millimeters
    orientation: "portrait",
  },
  margin: [0, -2.2, -3, 0], // Adjust margins as needed
  pagebreak: { mode: "avoid-all" }, // Add page break between sections
};

html2pdf().set(options).from(printableRef.current).save();

Actual Page
This is the Actual Page written

PDF Image

This is the pdf I get after downloading

Appwrite + React: Blog app: Failed to construct ‘URL’: Invalid URL

I am using appwrite with react and I am having a problem logging in or signing up users.

When a users click the button he should see the home page, edit post and add post routes.
But I’m getting an error in Failed to construct ‘URL’: Invalid URL

Here is the error message:
console message

Below is the code for my appwrite.auth.js file:

import conf from "../conf/conf.js"
import { Client, Account, ID } from "appwrite";

export class AuthService {
    client = new Client();
    account;

    constructor() {
        this.client
        .setEndpoint(conf.appwriteUrl)
        .setProject(conf.appwriteProjectId)
        this.account = new Account(this.client)
    }

    async createAccount({email, password, name}){
        try {
            const userAccount = await this.account.create(ID.unique(), email, password, name)
            if (userAccount) {
                return this.login({email, password})
            } else {
                return userAccount
            }
        } catch (error) {
            throw error
        }
    }

    async login({email, password}){
        try {
            return await this.account.createEmailSession(email, password)
        } catch (error) {
            throw error
        }
    }

    async getCurrentUser(){
        try {
            return await this.account.get()
        } catch (error) {
            console.log("Appwrite service :: getCurrentUser() :: ", error)
        }
        return null
    }

    async logout(){
        try {
            await this.account.deleteSessions()
        } catch (error) {
            console.log("Appwrite service :: logout() :: ", error);
        }
    }
}

const authService = new AuthService()

export default authService

Below is my appwrite/config.js file for reference:

import conf from "../conf/conf";
import { Client, Databases, Storage, Query, ID } from "appwrite";


export class Service {
    client = new Client()
    databases;
    bucket;

    constructor(){
        this.client
        .setEndpoint(conf.appwriteUrl)
        .setProject(conf.appwriteProjectId)
        this.databases = new Databases(this.client)
        this.bucket = new Storage(this.client)
    }

    async getPost(slug) {
        try {
            return await this.databases.getDocument(conf.appwriteDatabaseId, conf.appwriteCollectionId, slug)
        } catch (error) {
            console.log("Appwrite service :: getPost() :: ", error)
            return false
        }
    }

    async getPosts(queries = [Query.equal("status", "active")]) {
        try {
            return await this.databases.listDocuments(conf.appwriteDatabaseId, conf.appwriteCollectionId, queries)
        } catch (error) {
            console.log("Appwrite service :: getPosts() :: ", error)
            return false
        }
    }

    async createPost({title, slug, content, featuredImage, status, userId}) {
        try {
            return await this.databases.createDocument(conf.appwriteDatabaseId, conf.appwriteCollectionId, slug, {title, content, featuredImage, status, userId})
        } catch (error) {
            console.log("Appwrite service :: createPost() :: ", error)
            return false
        }
    }

    async updatePost(slug, {title, content, featuredImage, status}) {
        try {
            return await this.databases.updateDocument(conf.appwriteDatabaseId, conf.appwriteCollectionId, slug, {title, content, featuredImage, status})
        } catch (error) {
            console.log("Appwrite service :: updatePost() :: ", error)
            return false;
        }
    }

    async deletePost(slug) {
        try {
            await this.databases.deleteDocument(conf.appwriteDatabaseId, conf.appwriteCollectionId, slug)
            return true;
        } catch (error) {
            console.log("Appwrite service :: deletePost() :: ", error)
            return false;
        }
    }

    // storage service

    async uploadFile(file) {
        try {
            return await this.bucket.createFile(conf.appwriteBucketId, ID.unique(), file) // if error use uploadFile()
        } catch (error) {
            console.log("Appwrite service :: uploadFile() :: ", error)
            return false
        }
    }

    async deleteFile(fileId) {
        try {
            return await this.bucket.deleteFile(conf.appwriteBucketId, fileId)
        } catch (error) {
            console.log("Appwrite service :: deleteFile() :: ", error)
            return false
        }
    }

    getFilePreview(fileId) {
        return this.bucket.getFilePreview(conf.appwriteBucketId, fileId).href
    }
}

const service = new Service()
export default service;

Is there a way to fix this? It seems doesn’t seem to recognize the new construct URL.

I have been following Hitesh Chowdary’s YouTube Tutorial.

https://www.youtube.com/watch?v=zWF7O7aHQW4

Kevin to use it though it to my final koi fish feel join loo

Hugs koi you kiss for though like girl looks so I’ll looks coffee kiss call like Sarah nip like after muja added by

This kiss for or if looks to join deep please see low so in for his ho this so I’ll be house in sweet fle for your so this time I do it chill hugs so it will it eat too this up I’ll in the hell go the went in unit ree we have to it enough looking eating definitely ji this during so so what double his high mail in so in so I’ll see her ex knees we live give looks jobs deal this wife police full day was warm Saturday March Jai Hind do me so I alone so main meal is in one into his ho not sure

How to make Slider move automatically?

Please help me make my slider move automatically. Everything works well, the only thing missing is to make the slider move automatically. The code below is a template of my work. Please help make the photos move automatically for around 3 to 5 seconds per photo. I have tried different ways to make the slider automatically move but it makes the photos lose its responsiveness and position.

index.html


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>LANDING PAGE</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css">
    <link rel="stylesheet" href="style.css">
</head>
<body>

    <header>
        <a href="#" class="brand">SAMPLE</a>
        <div class="menu-btn">
            <div class="navigation">
                <div class="navigation-items">
                    <a href="#">SAMPLE</a>
                    <a href="#">SAMPLE</a>
                    <a href="#">SAMPLE</a> 
                    <a href="#">SAMPLE</a>
                    <a href="#">SAMPLE</a>
                </div>
            </div>
        </div>
    </header>

    <section class="home">

        <img decoding="async" class="img-slide active" src="1.jpg" ></img>
        <img decoding="async" class="img-slide" src="2.jpg" ></img>
        <img decoding="async" class="img-slide" src="3.jpg" ></img>
        <img decoding="async" class="img-slide" src="4.jpg" ></img>
        <img decoding="async" class="img-slide" src="5.jpg" ></img>
        <img decoding="async" class="img-slide" src="6.jpg" ></img>
        <div class="content active">
          <div class="wrapper">
            <h1>SAMPLE<br> </h1> <span1>SAMPLE TEXT</span1> <br><br>
        <!--   <p>text</p> --> 
          <a href="#">Visit</a>
          </div>
        </div>
        <div class="content">
          <h1>SAMPLE<br> </h1> <span>SAMPLE</span> <br><br>
        <!--  <p>text</p> --> 
          <a href="#">Visit</a>
        </div>
        <div class="content">
          <h1>try<br> </h1> <span>SAMPLE</span> <br><br>
        <!--  <p>try</p> --> 
          <a href="#">Visit</a>
        </div>
        <div class="content">
          <h1>help<br> </h1> <span1>SAMPLE TEXT</span1> <br><br>
        <!--  <p>help</p> --> 
          <a href="#">Visit</a>
        </div>
        <div class="content">
          <h1>SAMPLE<br> </h1>  <span1>SAMPLE TEXT</span1> <br><br>
        <!--  <p>sample</p> -->
          <a href="#">Visit</a>
        </div>
        <div class="content">
          <h1>SAMPLE<br>  </h1>  <span1>SAMPLE TEXT</span1> <br><br>
        <!--  <p>sample</p> -->
          <a href="#">Visit </a>
        </div>
        <div class="media-icons">
            <a href="#"><i class="fab fa-facebook-f"></i></a>
            <a href="#"><i class="fab fa-instagram"></i></a>
            <a href="#"><i class="fab fa-youtube"></i></a>
        </div>
        <div class="slider-navigation">
            <div class="nav-btn active"></div>
            <div class="nav-btn"></div>
            <div class="nav-btn"></div>
            <div class="nav-btn"></div>
            <div class="nav-btn"></div>
            <div class="nav-btn"></div>

        </div>
    </section> <script src="main.js" defer data-deferred="1"></script> </body>
</html>




-----------------------------
Style.css

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700;800;900&display=swap');

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Poppins", sans-serif;
}



header{
    z-index: 999;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 200px;
    transition: 0.5s ease;
}

header .brand{
    color: #fff;
    font-size: 1.5rem;
    font-weight: 900;
    text-transform: uppercase;
    text-decoration: none;
    opacity: 0;
    
}

header .brand:hover{
    color: #14723d
}

header .navigation{
    position: relative;
}

header .navigation .navigation-items a{
    position: relative;
    color: #fff;
    font-size: 1.5em;
    font-weight: 900;
    text-decoration: none;
    margin-left: 30px;
    transition: 0.3s ease;
   
}

header .navigation .navigation-items a:before{
    content: '';
    position: absolute;
    background: #fff;
    font-weight: 900;
    width: 0;
    height: 3px;
    bottom: 0;
    left: 0;
    transition: 0.3s ease;
}

header .navigation .navigation-items a:hover:before{
    width: 100%;
    background: #14723d;
    font-weight: 900;
}

section{
    padding: 100px 200px;
}

.home {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    flex-direction: column;
    background: #14723d
}

.home:before{
    z-index: 777;
    content: '';
    position: absolute;
    background: rgba(251, 3, 3, 0.034);
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.home .content{
    z-index: 888;
    color: white;
    font-weight: bold;
    width: 70%;
    margin-top: 50px;
    display: none;
}


/*
.home .content .wrapper
{
    
    width: 300px;
    height: 200px;
    max-width: 100%;
    top: 30%;
    color:white;
    position:fixed;
    background-color: rgb(0,0,0);
    background-color: rgba(0,0,0, 0.4);
      
}

*/
.home .content.active{
    display: block;
}

.home .content h1{
    font-size: 6em;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 5px;
    line-height: 75px;
    margin-bottom: 40px;
    text-shadow: 7px 7px /*#14723d */ black;
}


.home .content span{
    font-size: 20px;
    font-weight: 400;
    
}
.home .content span1{
    font-size: 20px;
    font-weight: 400;
    opacity: 0;
    
}

.home .content p{
    margin-bottom: 65px;
}

.home .content a{
    background: #fff;
    padding: 15px 25px;
    color: #14723d;
    font-size: 1.1em;
    font-weight: 500;
    text-decoration: none;
    border-radius: 2px;
    justify-content: center;
    text-align: center;

    
  
}

.home .content a:hover{
    background: #14723d;
    color: #fff;
}

.home .media-icons{
    z-index: 888;
    position: fixed;
    right: 30px;
    display: flex;
    flex-direction: column;
    transition: 0.5s ease;
}

.home .media-icons a{
    color: #fff;
    font-size: 1.6em;
    transition: 0.3s ease;
}

.home .media-icons a:not(:last-child){
    margin-bottom: 20px;
}

.home .media-icons a:hover{
    transform: scale(1.3);
    color: #14723d
}

.home img{
    z-index: 000;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.slider-navigation{
    z-index: 888;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: translateY(135px);
    margin-bottom: 12px;
}

.slider-navigation .nav-btn{
    width: 25px;
    height: 25px;
    background: #fff;
    font-weight: bold;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 2px rgba(255, 255, 255, 0.5);
    transition: 0.3s ease;
}

.slider-navigation .nav-btn.active{
    background: #14723d;
}

.slider-navigation .nav-btn:not(:last-child){
    margin-right: 20px;
}

.slider-navigation .nav-btn:hover{
    transform: scale(1.2);
}

.img-slide{
    position: absolute;
    width: 100%;
    clip-path: circle(0% at 0 50%);
}

.img-slide.active{
    clip-path: circle(150% at 0 50%);
    transition: 2s ease;
    transition-property: clip-path;
}

@media (max-width: 1040px){
    header{
        padding: 12px 20px;
    }
    section{
        padding: 100px 20px;
    }
    .home .media-icons{
        right: 15px;
    }
    header .navigation{
        display: none;
    }
    header .navigation.active{
        position: fixed;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        background: rgba(1, 1, 1, 0.5);
    }

    header .navigation .navigation-items a{
        color: #222;
        font-size: 1.2em;
        margin: 20px;
    }
    header .navigation .navigation-items a:before{
        background: #222;
        height: 5px;
    }
    header .navigation .navigation-items{
        background: #fff;
        width: 600px;
        max-width: 600px;
        margin: 20px;
        padding: 40px;
        display: flex;
        flex-direction: column;
        align-items: center;
        border-radius: 5px;
        box-shadow: 0 5px 25px rgb(1 1 1 / 20%);
    }
    .menu-btn{
        background: url(menu.png)no-repeat;
        background-size: 30px;
        background-position: center;
        width: 40px;
        height: 40px;
        cursor: pointer;
        transition: 0.3s ease;
    }
    .menu-btn.active{
        z-index: 999;
        background: url(close.png)no-repeat;
        background-size: 25px;
        background-position: center;
        transition: 0.3s ease;
    }
}

@media (max-width: 560px){
    .home .content h1{
        font-size: 2em;
        line-height: 60px;
    }
}

@media (max-width: 560px){
    .home .content a{
        background: white;
        padding: 7px 15px;
        color: #14723d;
        font-size: 1.1em;
        font-weight: 500;
        text-decoration: none;
        border-radius: 2px;
        justify-content: center;
        text-align: center;
    }
}

----------------------------
main.js




const menuBtn = document.querySelector(".menu-btn");
const navigation = document.querySelector(".navigation");

menuBtn.addEventListener("click", () => {
    menuBtn.classList.toggle("active");
    navigation.classList.toggle("active");
});

const btns = document.querySelectorAll(".nav-btn");
const slides = document.querySelectorAll(".img-slide");
const contents = document.querySelectorAll(".content");

var sliderNav = function(manual){
    btns.forEach((btn) => {
        btn.classList.remove("active");
    });

    slides.forEach((slide) => {
        slide.classList.remove("active");
    });

    contents.forEach((content) => {
        content.classList.remove("active");
    });

    btns[manual].classList.add("active");
    slides[manual].classList.add("active");
    contents[manual].classList.add("active");
}

    btns.forEach((btn, i) => {
        btn.addEventListener("click", () => {
            sliderNav(i)
        });
    });


Please help and thank you for your time.

How can I handle the dot in a decimal input when I want to format the string using the toLocaleString() function? [closed]

I have a numeric input. I want to use toLocaleString() to format it based on the current locale. Usually it means adding thousand separators.

There is a simple pitfall here though. The toLocaleString should not be called on strings. It should be called on numbers. You can check it here:

    const temp = '123456'
    console.log(temp.toLocaleString())

And compare it to:

const temp = '123456'
const numericValue = +temp
console.log(numericValue.toLocaleString())

The problem I have encountered is that when user wants to enter a decimal number, as soon as he enters the dot, the +value syntax drops the dot for converting it into a decimal.

What should I do?

Update: (more explanation)

I have added an event handler for key-down event to an input. The point is that the e.target.value is in string. When user wants to write 123456.78, as soon as he gets to the dot (123456.) now I have 123456. as a string. I want to use toLocaleString for this. If I change it to number using +e.target.value, or parseInt(e.target.value) or parseFloat(e.target.value) I will get 123456 as a number. I will lose the dot sign. If I don’t convert it into a number, then the toLocaleString won’t put thousand separators into it. I’m stuck at this point.

Resizing NextJS CV Component within a Parent Component without Shrink Effect

I’m currently working on a NextJS project and facing a challenge with resizing a CV preview section. In my application, I have a parent component representing the CV preview section, and within it, there’s a child component for the CV itself.

I want to implement a feature where I can resize the CV component without causing a shrink effect meaning the whole cv is resized-down , similar to what is demonstrated in this video: https://imgur.com/a/3K7HsUS.

I have set a fixed width and height for the CV component to avoid formatting issues, and I’m hesitant to use max-width due to potential complications.

Could someone guide me on achieving this resizing functionality within NextJS? Any help would be greatly appreciated.

Tried adjusting CV component dimensions with CSS, but encountered a shrink effect that messes with the cv content on shrinking browser.I want to achieve dynamic resizing without shrinking

Trouble Placing Negative Numbers in the Negative Area of Scatter Plot Graph

I am encountering difficulties while attempting to plot negative numbers in the negative area of a scatter plot graph using Plotly. Despite my efforts to adjust the y-axis scaling and coordinates, the negative values consistently appear in the positive area of the graph

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Scatter Plot</title>
    <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
    <div id="scatterplot"></div>
    <script>
        function plotGraph(data) {
            // Create an array to hold traces for each row of coordinates
            const traces = [];
            
            // Define marker shapes cycle
            const markerShapes = ['circle', 'square', 'diamond', 'cross', 'x', 'triangle-up', 'triangle-down', 'triangle-left', 'triangle-right', 'pentagon'];
            
            let markerIndex = 0; // Start with the first shape
            let dataCounter = 0; // Counter to track data points
            
            // Iterate over each entry in the data
            data.forEach((entry, index) => {
                // Extract x and y values from the entry
                const coordinates = entry.data.map(coord => [parseFloat(coord[0]), parseFloat(coord[1]), parseFloat(coord[2].split('e')[1])]); // Splitting the exponent
                
                // Generate x values as the index of the points within the row
                const xValues = Array.from(Array(coordinates.length).keys()).map(x => x + Math.random() * 0.5 - 0.25); // Apply jitter
                
                // Adjust y-values for negative numbers
                const adjustedYValues = coordinates.map(coord => {
                    const value = parseFloat(coord[1]) * Math.pow(10, coord[2]);
                    return coord[0] === '-' ? -value : value;
                });
                
                // Create a trace for the current entry
                const trace = {
                    x: xValues,
                    y: adjustedYValues,
                    mode: 'markers',
                    type: 'scatter',
                    name: `Occurrences: ${entry.occurrences}`,
                    marker: {
                        symbol: markerShapes[Math.floor(dataCounter / 10) % markerShapes.length], // Change marker shape every 10 data points
                        size: 10 // Adjust the size of the marker symbols
                    }
                };
                
                // Increment the counter
                dataCounter += adjustedYValues.length;
                
                // Add the trace to the traces array
                traces.push(trace);
            });
            
            // Define layout options
            const layout = {
                title: 'Scatter Plot',
                xaxis: {
                    title: 'Index within the Row'
                },
                yaxis: {
                    title: 'Coordinate Value'
                },
                height: 800, // Set the height to 800 pixels
                width: 1200 // Set the width to 1200 pixels
            };
            
            // Plot the graph
            Plotly.newPlot('scatterplot', traces, layout);
        }
        
        // Fetch data and plot the graph
        fetch('/data')
            .then(response => response.json())
            .then(data => {
                plotGraph(data);
            })
            .catch(error => console.error('Error fetching data:', error));
    </script>
</body>
</html>

here is the graph.json

[
  {
    "data": [
      [
        "1",
        "1",
        "e-04"
      ],
      [
        "1",
        "1",
        "e-05"
      ],
      [
        "1",
        "1",
        "e-06"
      ],
      [
        "1",
        "1",
        "e-07"
      ],
      [
        "-1",
        "1",
        "e-04"
      ],
      [
        "-1",
        "1",
        "e-05"
      ],
      [
        "-1",
        "1",
        "e-06"
      ]
    ],
    "occurrences": 2
  }
]

and the server.js

the graph maps the data by the first digit and the exponent #

const fs = require('fs');
const express = require('express');
const app = express();
const port = 3000;

// Serve static files from the public folder
app.use(express.static('public'));

// Read data from the JSON file
const rawData = fs.readFileSync('graph.json');
let data = JSON.parse(rawData);

// Route to serve the JSON data
app.get('/data', (req, res) => {
    res.json(data);
});

// Route to serve filtered data based on occurrence number
app.get('/filtered-data/:occurrence', (req, res) => {
    const occurrence = parseInt(req.params.occurrence);
    const filteredData = data.filter(entry => entry.occurrences === occurrence);
    res.json(filteredData);
});

// Start the server
app.listen(port, () => {
    console.log(`Server is running on port ${port}`);
});

I have tried various approaches, including adjusting the data format and layout settings, but have not been successful. Any guidance or suggestions on how to properly position negative numbers in the negative area of the scatter plot graph would be greatly appreciated. Thank you

Valid route path is displaying both valid path component and non existing path component

When i hit locathost:3000/faq or any other valid routes React is displaying both valid routes content and NotFound(basically 404 custom page) component at the bottom of page. I want to display NotFound component content only if I hit invalid route
Ex: localhost:3000/not-existing-url

const routes = [
  {
    path: '/',
    component: HomePage,
    is_private: false,
  },
  {
    path: '/faq',
    component: RedirectFaqToSupport,
    is_private: false,
  },
  {
    path: '/about-us',
    component: About,
    is_private: false,
  },
  {
    path: '/contact-us',
    component: Contact,
    is_private: false,
  },
 {
    component: NotFound,
    is_private: false,
    path: '*'
  },
]

Here is my App.js component code.

class App extends Component {
  constructor() {
    super()
    this.state = {
      redirectToReferrer: false, // may not need this anymore
    }
  }

  render() {
    const { isMobile } = this.props

    const renderLoader = () => (
      <Columns.Column size={12}>
        <div className="has-text-centered" style={{ marginTop: '15%' }}>
          <i className="fas fa-3x fa-cog fa-spin"></i>
        </div>
      </Columns.Column>
    )

    return (
      <Suspense fallback={renderLoader()}>
        <BrowserRouter>
          <Provider>
            <ScrollToTop />
            <Subscribe to={[AppContainer]}>
              {(auth) => {
                return (
                  <>
                    <Header
                      isAuth={auth.state.isAuth}
                      modalViewType={auth.state.modalViewType}
                      unreadMessageCount={auth.state.unreadMessageCount}
                      auth={auth}
                    />
                    <ErrorBoundary>
                      <div className="page-master-container">
                        <Switch>
                          <BuildRoutes
                            isMobile={isMobile}
                            isAuth={auth.state.isAuth}
                            auth={auth}
                          />
                        </Switch>
                      </div>
                    </ErrorBoundary>
                    <Footer isAuth={auth.state.isAuth} />
                  </>
                )
              }}
            </Subscribe>
          </Provider>
        </BrowserRouter>
      </Suspense>
    )
  }
}

Here is BuidRoutes component code

const PrivateRoute = ({ component: Component, ...rest }) => (
  <Route
    {...rest}
    render={(props) =>
      rest.isAuth === true ? (
        <Component {...props} {...rest} />
      ) : (
        <Redirect
          to={{
            pathname: '/login',
            state: { from: props.location },
          }}
        />
      )
    }
  />
)

export const BuildRoutes = ({ isMobile, isAuth, auth }) => {
  const location = useLocation()

  useEffect(() => {
    const queryParams = QueryString.parse(location.search)
    setFeatureFlag(queryParams)
  }, [location])

  return (
    <>
      {routes.map(
        ({ path, component: Component, is_private, is_mother }, key) =>
          !is_private ? (
           
              <Route
                exact={is_mother ? false : true}
                path={path}
                key={key}
                render={(props) => (
                  <Component
                    {...props}
                    isMobile={isMobile}
                    isAuth={isAuth}
                    auth={auth}
                  />
                )}
              />
           
          ) : (
            
              <PrivateRoute
              isAuth={isAuth}
              isMobile={isMobile}
              auth={auth}
              exact={is_mother ? false : true}
              path={path}
              key={key}
              component={Component}
            />
    
            
          )
      )}
      <Route
        exact
        path="/brand/:brandName"
        render={(props) => {
          const { brandName } = props.match.params
          if (bikeBrands.includes(brandName)) {
            return <Redirect to={`/brand/${brandName}-rental`} />
          }
          return <BrandLandingPage brandName={brandName} />
        }}
      />
    </>
  )
}

Note: Also I tried below method but it didn’t help. Still displays NotFound component along with valid routes component

export const BuildRoutes = ({ isMobile, isAuth, auth }) => {
  const location = useLocation()

  useEffect(() => {
    const queryParams = QueryString.parse(location.search)
    setFeatureFlag(queryParams)
  }, [location])

  return (
    <>
      {routes.map(
        ({ path, component: Component, is_private, is_mother }, key) =>
          !is_private ? (
            <Route
              exact={is_mother ? false : true}
              path={path}
              key={key}
              render={(props) => (
                <Component
                  {...props}
                  isMobile={isMobile}
                  isAuth={isAuth}
                  auth={auth}
                />
              )}
            />
          ) : (
            <PrivateRoute
              isAuth={isAuth}
              isMobile={isMobile}
              auth={auth}
              exact={is_mother ? false : true}
              path={path}
              key={key}
              component={Component}
            />
          )
      )}
      <Route
        component={NotFound}
      />
      <Route
        exact
        path="/brand/:brandName"
        render={(props) => {
          const { brandName } = props.match.params
          if (bikeBrands.includes(brandName)) {
            return <Redirect to={`/brand/${brandName}-rental`} />
          }
          return <BrandLandingPage brandName={brandName} />
        }}
      />
    </>
  )
}

I am using “react-router-dom”: “^5.2.0”,

why type error not coming when it is not match?

I am using typescript in my demo project. My I am facing one issue I am not getting type error

interface v1 extends checkBoxBaseParams {
  disableCheckBoxIfInvalid: false;
  rowsStatus?: Array<{ shouldDisableRow: boolean }>;
}

interface v2 extends checkBoxBaseParams {
  disableCheckBoxIfInvalid: true;
  rowsStatus: Array<{ shouldDisableRow: boolean }>;
}

In above code I am trying to do if “disableCheckBoxIfInvalid” is true I want to make rowsStatus field required.
if disableCheckBoxIfInvalid is false I want to make rowsStatus field optional.

I am not getting this ERROR why ?

export type CheckBoxParamsType = v1 | v2 | v4;

const vari1: CheckBoxParamsType = {
  selectedRows: [],
  setSelectedRows: (selectedRows: selectedRowData[]) => {},
  isMasterCheckBoxSelected: false,
  setMasterCheckBox: (isMasterCheckBoxSelected: boolean) => {},
  disableCheckBoxIfInvalid: true,
};

disableCheckBoxIfInvalid –> true why not getting
here is my code

export interface selectedRowData {
  rowData: any;
  tableIndex: number;
}

interface checkBoxBaseParams {
  selectedRows: selectedRowData[];
  setSelectedRows: (selectedRows: selectedRowData[]) => void;
  isMasterCheckBoxSelected: boolean;
  setMasterCheckBox: (isMasterCheckBoxSelected: boolean) => void;
}

interface v4 extends checkBoxBaseParams {
  selectAcrossPageEnabled?: false;
}
interface v1 extends checkBoxBaseParams {
  disableCheckBoxIfInvalid: false;
  rowsStatus?: Array<{ shouldDisableRow: boolean }>;
}

interface v2 extends checkBoxBaseParams {
  disableCheckBoxIfInvalid: true;
  rowsStatus: Array<{ shouldDisableRow: boolean }>;
}


export type CheckBoxParamsType = v1 | v2 | v4;

const vari1: CheckBoxParamsType = {
  selectedRows: [],
  setSelectedRows: (selectedRows: selectedRowData[]) => {},
  isMasterCheckBoxSelected: false,
  setMasterCheckBox: (isMasterCheckBoxSelected: boolean) => {},
  disableCheckBoxIfInvalid: true,
};

code link
https://www.typescriptlang.org/play?ssl=36&ssc=1&pln=1&pc=1#code/KYDwDg9gTgLgBASwHY2FAZgQwMbDgZ2ABthtUATAJQgHcARTGTOAbwFgAoOOKWhpgFxxMSAJ4BuTtyYAjEgEkk5UEKQBXALYy0kjgF9OnZKgw482ABakA1gCEIIW5kIAFTFEwb8rKQWKkKahp8IUISMmAqPkZMAG0AXV1uQhgAZX8IqOChAAowgMigkL9wwOimBIBKOABeAD44ADcIBHIkxHwAWWcTAGErbDsHdNLIoRkICBIRdpTu-D6BoZBchC6etH6bexARgvJxyemkavqmlrbOAw4jFDQsXCaAFjhQVCVvS22HJ1d3T287C4JQCAEFsLx8Pg3ABzYAAUSQmDkkQA-EIsERCLprsZ7mYmgBGV4gd7kT5LHa-YBuDxeHzA8hrZEkLaDHbydCKRqYIitDG87G+XjBVJMGBqfDouCgqAeUQAHhYBAsEDURHIdGZKKChymwBEcD0dRxhg4eNMj0aACYSWSKd9HM4af96UDuEz8CzgGzlpzubz+XAYFA1MB2iL8GLGJKhLL5UqVWqNVqvTraHrjkaTVczZxQJBYMHRGA8L6drSAQAVEt4GpEuAAHyatubjSeuk42AgSAWTXcCEJQnLDkrXhrpdqDOSGTK2TgCQANL4UntMkVcvl17Rilu5-w4vFTg0WHpl8C1vNFo61xQBVjgOeZzAr5tKQ5VusFm+b7OxnAJn1ERj1YM9fE9b0RxAf0kB5PkDmDUNHyuXQgA

Compile OpenBLAS using emscripten

I’m trying to compile OpenBLAS for WebAssembly.
I have a wasm/matrix.c file and OpenBLAS-0.3.26-x64-64 folder which I downloaded from github.

// wasm/matMul.c

#include "../OpenBLAS/include/cblas.h"
#include "emscripten.h"
#include <stdlib.h>

int result[2];
EMSCRIPTEN_KEEPALIVE        
void matMul(double *m1, double *m2, int m, int n, int k)
{
    size_t size = m * k * sizeof(double);
    double *m3 = (double *)malloc(size);
    cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, k, n, 1.0, m1, n, m2, k, 0, m3, k);
    result[0] = (int)m3;
    result[1] = size;
}

I tried emcc -IOpenBLAS/include -LOpenBLAS/lib wasm/matMul.c -o matrix.js, but it gaved the following error:

 C:msys64tmpemscripten_temp_zbcdvpw2matMul_0.o: undefined symbol: cblas_dgemm

Getting error while deploying a blockchain voting system project through reactjs and using emailjs for otp verificaton

I was deploying a project on voting system in blockchain with react and it contain otp feature through emailjs but I am facing error. Can someone please help me..??Console errorWhen I click on send OTP this occurs. I am new to react. Anyone help is appreciated.

The otp is also not received at my end so I am also sharing emailjs template. Please advice what should I change in template. Email js Template