Why is there a weird stretching animation when clicking on an item in my bookshelf UI using Framer Motion and Tailwind CSS in Next.js?

I’m working on a bookshelf UI in Next.js using Framer Motion for animations and Tailwind CSS for styling. Each book is an interactive li element with hover and click functionality. The problem I’m facing is that when I click on a book, there’s a weird “stretching” animation happening, and I can’t figure out why.

Behavior:

  1. When a book is hovered over, it slightly lifts (translate-y).
  2. When clicked, the selected book expands to show details.
  3. However, on clicking, the book appears to “stretch” or resize unexpectedly before settling into its final state.

Here is the current state of this issue: website

Code:

Here is the relevant code:

// Book.js
import { motion } from "framer-motion";
import Image from "next/image";
import { useState } from "react";

export default function Book({ data, isSelected, onSelect, isAnyHovered, onHover }) {
  const { title, author, route, year } = data;
  const [isHovered, setIsHovered] = useState(false);
  const [imageSize, setImageSize] = useState({ width: 0, height: 0 });

  const handleImageLoad = ({ target }) => {
    setImageSize({ width: target.naturalWidth / 4, height: target.naturalHeight / 4 });
  };

  const getImageClassName = () => {
    let className = "transition-all duration-800";

    if (isHovered) {
      className += " opacity-100 -translate-y-2";
    } else {
      className += " opacity-40 translate-y-0";
    }

    return className;
  };

  return (
    <motion.li
      initial={{ x: -50, opacity: 0 }}
      animate={{ x: 0, opacity: 1 }}
      exit={{ x: 50, opacity: 0 }}
      transition={{ duration: 0.4 }}
      layout
      className="relative flex gap-2 items-end"
    >
      <button onClick={() => onSelect(data)}>
        <Image
          alt={`Book spine of ${title}`}
          width={imageSize.width}
          height={imageSize.height}
          src={`/images/${route}`}
          onLoad={handleImageLoad}
          className={getImageClassName()}
          onMouseEnter={() => {
            setIsHovered(true);
            onHover(data);
          }}
          onMouseLeave={() => {
            setIsHovered(false);
            onHover(null);
          }}
        />
      </button>
      {isSelected && (
        <div className="pr-2">
          <h3 className="text-2xl font-bold">{title}</h3>
          <span>by {author}</span>
          <span>{year}</span>
        </div>
      )}
    </motion.li>
  );
}
// page.js
import { motion, AnimatePresence } from "framer-motion";
import { useState } from "react";
import Book from "./Book";

export default function Home() {
  const [books, setBooks] = useState([]);
  const [selectedBook, setSelectedBook] = useState(null);
  const [hoveredBook, setHoveredBook] = useState(null);

  const handleSelectBook = (book) => {
    setSelectedBook(selectedBook === book ? null : book);
  };

  return (
    <ul className="flex relative overflow-x-scroll">
      <AnimatePresence>
        {books.map((book) => (
          <Book
            key={book.id}
            data={book}
            isSelected={selectedBook === book}
            onSelect={handleSelectBook}
            isAnyHovered={hoveredBook !== null}
            onHover={setHoveredBook}
          />
        ))}
      </AnimatePresence>
    </ul>
  );
}

Observations:

  • The motion.li element uses layout from Framer Motion, which might be
    causing the stretching effect.
  • The Image component dynamically
    calculates its size with naturalWidth and naturalHeight. Could this
    recalculation be contributing to the issue?
  • Tailwind’s transition and
    transform classes (translate-y, transition-all, etc.) might be
    conflicting with Framer Motion’s layout.

What I’ve Tried:

  1. Removing layout from motion.li—but this breaks the animations.
  2. Disabling Tailwind transition-all classes—this did not fix the issue.
  3. Hardcoding the Image width and height instead of calculating them dynamically—this reduced, but did not eliminate, the stretching effect.

Question:

  • Why is this stretching animation happening when a book is clicked?
  • How can I prevent the weird resizing/stretching effect while keeping the animations for hover and select intact?

Any insights into how Tailwind CSS and Framer Motion might be interacting (or conflicting) here would be much appreciated. Let me know if additional context or code is needed!

remove keydown eventListener

I have the following eventListener:

window.addEventListener("keydown", function(e) {
    if(["Space","ArrowUp","ArrowDown"].indexOf(e.key) > -1) {
        e.preventDefault();
    }
}, false);

How can I romve it?

Enterprise Architect: Adding an label to a Legend in (in javascript)

I was inspired by Enterprise Architect scripting with java – add CustomProperty

I have no issues adding the legend to be added to the diagram but they entries to the legend aren’t added. Any ideas why this my not work are welcome. (version 15.2.1554)

function addLegendEntries( legendGUID, arr=[{ 'BackgroundColor': -1, 'Stereotype' : 'Stereotype'}] ){
    let description = ""
    let customPropertyIndex = 0;
    arr.forEach( ({BackgroundColor, Stereotype}) => {
        description += "@PROP=@NAME="+Stereotype+"@ENDNAME;@TYPE=LEGEND_OBJECTSTYLE@ENDTYPE;@VALU=#Back_Ground_Color#="+BackgroundColor+";#Pen_Color#=16777215;#Pen_Size#=1;#Legend_Type#=LEGEND_OBJECTSTYLE;@ENDVALU;@PRMT="+customPropertyIndex++ +"@ENDPRMT;@ENDPROP;"
    })
        description += "@PROP=@NAME=Legend@ENDNAME;@TYPE=LEGEND_STYLE_SETTINGS@ENDTYPE;@VALU=@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;"
    const sqlInsertStmt="INSERT INTO t_xref "
            + "(" 
                + "Client,"
                + "XrefID,"
                + "Type,"
                + "Name,"
                + "Visibility,"
                + "`Partition`,"
                + "Supplier,"
                + "Description"
            + ") "
            + " VALUES ("
                +"'"+legendGUID+ "',"
                + "'{"+  generateGUID() +"}',"
                + "'element property',"
                + "'CustomProperties',"
                + "'Public',"
                + "'0',"
                + "'&lt;none&gt;',"
                + "'"+description+"'"
            + ");"
            
            out( sqlInsertStmt )
    out( Repository.SQLQuery( sqlInsertStmt ) )
}

function addLegend(diagramID, arr=[{ 'BackgroundColor': -1, 'Stereotype' : 'Stereotype'}])
{
    Repository.EnsureOutputVisible( "Script" );    
    Repository.ClearOutput("Script");
    var pkg as EA.Package; 
    pkg = Repository.GetTreeSelectedPackage();   
    elements = pkg.Elements;
    var legend = elements.AddNew('Diagram Legend', 'Text');
    legend.Subtype = 76;    
    legend.Update();
    var diagram as EA.Diagram;
    diagram = Repository.GetDiagramByID(diagramID);
    Session.Output(diagram.Name);
    diagramObjects = diagram.DiagramObjects;

    diagramObject = diagramObjects.AddNew("l=100; r=100; t=100; b=500;", "");
    addLegendEntries( legend.ElementGUID , arr )
    diagramObject.ElementID = legend.ElementID;
    diagramObject.Update();
    diagram.Update()    
}
    Repository.EnsureOutputVisible( "Script" );
    Repository.ClearOutput("Script"); 
    const diagram = Repository.GetDiagramByGuid("{4FA59731-72DF-402c-AF60-1C3381BC2052}");       // Get the current diagram
    out(diagram.DiagramID)
    addLegend(diagram.DiagramID, collectColorsInDiagram(diagram)) 
    Repository.ReloadDiagram(diagram.DiagramID)
    out("Done")

Here’s the SQL statement that is generated:

    INSERT INTO t_xref 
        (Client,XrefID,Type,Name,Visibility,Partition,Supplier,Description)  
    VALUES 
        ('{9CCF46B8-D221-41b1-B1B9-EF7072547F74}','{cb940358-f76f-9fdd-dfca-d4537143e394}','element property','CustomProperties','Public','0','&lt;none&gt;',
'@PROP=@NAME=ArchiMate_Grouping@ENDNAME;@TYPE=LEGEND_OBJECTSTYLE@ENDTYPE;@VALU=#Back_Ground_Color#=13458026;#Pen_Color#=16777215;#Pen_Size#=1;#Legend_Type#=LEGEND_OBJECTSTYLE;@ENDVALU;@PRMT=0@ENDPRMT;@ENDPROP;@PROP=@NAME=ArchiMate_Capability@ENDNAME;@TYPE=LEGEND_OBJECTSTYLE@ENDTYPE;@VALU=#Back_Ground_Color#=15528442;#Pen_Color#=16777215;#Pen_Size#=1;#Legend_Type#=LEGEND_OBJECTSTYLE;@ENDVALU;@PRMT=1@ENDPRMT;@ENDPROP;@PROP=@NAME=ArchiMate_Capability@ENDNAME;@TYPE=LEGEND_OBJECTSTYLE@ENDTYPE;@VALU=#Back_Ground_Color#=16777184;#Pen_Color#=16777215;#Pen_Size#=1;#Legend_Type#=LEGEND_OBJECTSTYLE;@ENDVALU;@PRMT=2@ENDPRMT;@ENDPROP;@PROP=@NAME=ArchiMate_Capability@ENDNAME;@TYPE=LEGEND_OBJECTSTYLE@ENDTYPE;@VALU=#Back_Ground_Color#=16443110;#Pen_Color#=16777215;#Pen_Size#=1;#Legend_Type#=LEGEND_OBJECTSTYLE;@ENDVALU;@PRMT=3@ENDPRMT;@ENDPROP;@PROP=@NAME=ArchiMate_Grouping@ENDNAME;@TYPE=LEGEND_OBJECTSTYLE@ENDTYPE;@VALU=#Back_Ground_Color#=13434880;#Pen_Color#=16777215;#Pen_Size#=1;#Legend_Type#=LEGEND_OBJECTSTYLE;@ENDVALU;@PRMT=4@ENDPRMT;@ENDPROP;@PROP=@NAME=@ENDNAME;@TYPE=LEGEND_OBJECTSTYLE@ENDTYPE;@VALU=#Back_Ground_Color#=-1;#Pen_Color#=16777215;#Pen_Size#=1;#Legend_Type#=LEGEND_OBJECTSTYLE;@ENDVALU;@PRMT=5@ENDPRMT;@ENDPROP;@PROP=@NAME=Legend@ENDNAME;@TYPE=LEGEND_STYLE_SETTINGS@ENDTYPE;@VALU=@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;');

The sql statement appears that it isn’t working and there is nothing in DBError.txt

Regex, valid string has comma seperating words

I am trying to figure out how to use Regex in looking for a comma. I have a form where A usser will submit information seperated by a comma and I need to verify there is not a comma at the end, or mult comma together, etc.

I tried this, ^(w+)(,s*w+)*$, however it did not work because it failed when I added more than 1 word within a , bracket.

Invalid: hello,,,,,,

Invalid: hello, world, , how, are, you

Invalid: hello, world,

Valid: Hello, World

Valid: Hello, World, how are you, doing, today

Valid: .5 cups, 1.5 cups

Updating Data in a simple Chart.JS chart

I know this has been asked before many times but I am curious to see what I’m doing wrong with this simple Chart.JS chart and adding data to it.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Our First Line Chart</title>
</head>
<body>
  <div style="width: 900px; height: 400px;">
    <canvas id="myChart"></canvas>
  </div>
    
  <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  <script>
    const ctx = document.getElementById('myChart');
    
    new Chart(ctx, {
      type: 'line',
       data: {
          labels: ['12AM', '1AM', '2AM', '3AM', '4AM', '5AM'],
          datasets: [{
            label: 'Temperature',
            data: [43, 46, 55, 65, 56, 44],
            borderWidth: 1
          }]
        },
        options: {
          scales: {
            y: {
              beginAtZero: true
            }
          }
        }
      });
      function addData(chart, label, newData) {
        chart.data.labels.push(label);
        chart.data.datasets.forEach((dataset) => {
        dataset.data.push(newData);
       });

      chart.update();
      };
    addData(myChart, '6AM', 32);
    </script> 
</body>
</html>

It shows the chart just fine, but the chart does not update to add the new data that I’m trying to add with the addData function.

Enable vertical move in lightweight charts

I create a lightweight chart with candlestick data. If I left click and keep pressed on the chart I can move the candles on the horizontal axis, but not vertically on the y axis. The candles are kind of stuck on the current price scale.
If I rescale the y axis manually using click and hold the left mouse button on the y axis and move to rescale, I’m able to move the chart freely in both axis.

I tried using

                    handleScroll: {
                        vertTouchDrag: true,
                    },

or

                    handleScale: {
                        priceAxisPressedMouseMove: true,
                        timeAxisPressedMouseMove: true,
                    },

or

                    rightPriceScale: {
                         mode: LightweightCharts.PriceScaleMode.Normal, // Enable normal scaling mode
                    },
                    handleScale: {
                         axisPressedMouseMove: {
                             time: true,
                             price: true,
                         },
                    },
                    handleScroll: {
                         mouseWheel: true, // Enable scrolling with the mouse wheel
                         pressedMouseMove: true, // Allow dragging with the mouse
                    },

but none worked. But I think some don’t work because of outdated settings. I’m using latest 4.2.2.
Anyone knows, how to allow moving the chart freely from the beginning?

A very simple example for testing is like this

var chart = LightweightCharts.createChart(document.body, {
width: 400, height: 300,
                    handleScroll: {
                        vertTouchDrag: true,
                    },
});
var lineSeries = chart.addCandlestickSeries();
lineSeries.setData([
    { time: '2019-04-11',open: 80.01, close: 82, high: 83, low: 79 },
]);
chart.timeScale().fitContent();

(See https://jsfiddle.net/g5qeLa7h/)

Grid Items not Centering

I am building a React component with a grid layout, and I’m having trouble centering the entire grid within its container. I am using Flexbox for the layout, but the grid items aren’t centering properly.

Here’s the setup:

1. I have a container that should center its children both horizontally and vertically.
2. Inside the container, I am rendering three cards that should be displayed in a responsive grid.

Here is my code:

import React from 'react';
import Section from './Section';
import ClipPath from './ClipPath';
import Arrow from './Arrow';
import BluetoothScannerIllustration from './Svg';

const About = () => {
  return (
    <Section crosses>
      <div className="container mx-auto max-w-6xl px-4">
  {/* Heading */}
  <h1 className="gradientText lg:text-6xl text-center text-5xl font-[500] text-white font-inter">
    We've Noticed A{' '}
    <span className="bg-gradient-to-r from-rose-400 to-red-500 bg-clip-text text-transparent">
      Major
    </span>{' '}
    Problem.
  </h1>
  <p className="text-n-4 font-inter text-xl sm:text-lg md:text-xl lg:text-xl text-center max-w-2xl mx-auto mt-5">
    Transportation hubs are overcrowded,
    <br className="block lg:hidden" />
    <span className="hidden lg:inline-block">‎ making people late and frustrated.</span> It's time for a smarter
    solution.
  </p>

  <div className="flex -mt-10 justify-center">
    <BluetoothScannerIllustration />
  </div>

  <div className="mt-12 max-w-6xl !mx-auto flex justify-center">
    <div className="grid grid-cols-1 items-center md:grid-cols-2 lg:grid-cols-3 gap-6 mx-auto justify-center">   
      <div
        className="relative items-center p-0.5 bg-no-repeat bg-[length:100%_100%] md:max-w-[24rem] w-full"
        style={{
          backgroundImage: `url('data:image/svg+xml;utf8,${encodeURIComponent(`
            <svg preserveAspectRatio="none" width="384" height="366" viewBox="0 0 384 366" fill="none" xmlns="http://www.w3.org/2000/svg">
              <path vector-effect="non-scaling-stroke" d="M32 1H319.453C328.037 1 336.238 4.5601 342.1 10.832L374.648 45.6545C380.015 51.3966 383 58.9629 383 66.8225V334C383 351.121 369.121 365 352 365H32C14.8792 365 1 351.121 1 334V32C1 14.8792 14.8792 1 32 1Z" stroke="white" stroke-opacity="0.15" stroke-width="2"/>
              <path vector-effect="non-scaling-stroke" d="M32 1H319.453C328.037 1 336.238 4.5601 342.1 10.832L374.648 45.6545C380.015 51.3966 383 58.9629 383 66.8225V334C383 351.121 369.121 365 352 365H32C14.8792 365 1 351.121 1 334V32C1 14.8792 14.8792 1 32 1Z" stroke="url(#paint0_linear_333_9188)" stroke-opacity="0.85" stroke-width="2"/>
              <defs>
                <linearGradient id="paint0_linear_333_9188" x1="192" y1="0" x2="192" y2="366" gradientUnits="userSpaceOnUse">
                  <stop stop-color="#33CEFF"/>
                  <stop offset="0.562842" stop-color="#D633FF" stop-opacity="0"/>
                </linearGradient>
              </defs>
            </svg>
          `)}')`,
        }}
      >
        <div className="relative z-2 font-inter flex flex-col min-h-[22rem] p-[2.4rem]">
          <h5 className="text-2xl text-white mb-5">The Problem</h5>
          <p className="mb-6 text-n-3">
            Overcrowded transit areas, combined with inadequate infrastructure and poor planning, result in persistent delays that affect daily commuters and logistics.
          </p>
          <div className="flex items-center mt-auto">
            <a
              target="_blank"
              rel="noopener noreferrer"
              href="https://psychcentral.com/adhd/why-are-people-with-adhd-always-late"
              className="ml-auto font-code text-xs font-bold text-n-1 uppercase tracking-wider"
            >
              Explore more
            </a>
            <Arrow />
          </div>
        </div>
        <ClipPath />
      </div>

      {/* Solution Card */}
      <div
        className="relative p-0.5 bg-no-repeat bg-[length:100%_100%] md:max-w-[24rem] w-full"
        style={{
          backgroundImage: `url('data:image/svg+xml;utf8,${encodeURIComponent(`
            <svg preserveAspectRatio="none" width="384" height="366" viewBox="0 0 384 366" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path vector-effect="non-scaling-stroke" d="M32 1H319.453C328.037 1 336.238 4.5601 342.1 10.832L374.648 45.6545C380.015 51.3966 383 58.9629 383 66.8225V334C383 351.121 369.121 365 352 365H32C14.8792 365 1 351.121 1 334V32C1 14.8792 14.8792 1 32 1Z" stroke="white" stroke-opacity="0.15" stroke-width="2"/>
                <path vector-effect="non-scaling-stroke" d="M32 1H319.453C328.037 1 336.238 4.5601 342.1 10.832L374.648 45.6545C380.015 51.3966 383 58.9629 383 66.8225V334C383 351.121 369.121 365 352 365H32C14.8792 365 1 351.121 1 334V32C1 14.8792 14.8792 1 32 1Z" stroke="url(#paint0_linear_333_9188)" stroke-opacity="0.85" stroke-width="2"/>
                <defs>
                <linearGradient id="paint0_linear_333_9188" x1="192" y1="0" x2="192" y2="366" gradientUnits="userSpaceOnUse">
                    <stop stop-color="#33CEFF"/>
                    <stop offset="0.562842" stop-color="#D633FF" stop-opacity="0"/>
                </linearGradient>
                </defs>
            </svg>
          `)}')`,
        }}
      >
        <div className="relative z-2 font-inter flex flex-col min-h-[22rem] p-[2.4rem]">
          <h5 className="text-2xl text-white mb-5">The Solution</h5>
          <p className="mb-6 text-n-3">
            By using advanced analytics and IoT-enabled devices, we can optimize the flow of people and goods, reducing congestion and delays.
          </p>
          <div className="flex items-center mt-auto">
            <a
              target="_blank"
              rel="noopener noreferrer"
              href="https://example.com/solution"
              className="ml-auto font-code text-xs font-bold text-n-1 uppercase tracking-wider"
            >
              Learn More
            </a>
            <Arrow />
          </div>
        </div>
        <ClipPath />
      </div>

      {/* Impact Card */}
      <div
        className="relative p-0.5 bg-no-repeat bg-[length:100%_100%] md:col-span-2 w-full"
        style={{
          backgroundImage: `url('data:image/svg+xml;utf8,${encodeURIComponent(`
            <svg preserveAspectRatio="none" width="384" height="366" viewBox="0 0 384 366" fill="none" xmlns="http://www.w3.org/2000/svg">
              <path vector-effect="non-scaling-stroke" d="M32 1H319.453C328.037 1 336.238 4.5601 342.1 10.832L374.648 45.6545C380.015 51.3966 383 58.9629 383 66.8225V334C383 351.121 369.121 365 352 365H32C14.8792 365 1 351.121 1 334V32C1 14.8792 14.8792 1 32 1Z" stroke="white" stroke-opacity="0.15" stroke-width="2"/>
              <path vector-effect="non-scaling-stroke" d="M32 1H319.453C328.037 1 336.238 4.5601 342.1 10.832L374.648 45.6545C380.015 51.3966 383 58.9629 383 66.8225V334C383 351.121 369.121 365 352 365H32C14.8792 365 1 351.121 1 334V32C1 14.8792 14.8792 1 32 1Z" stroke="url(#paint0_linear_333_9188)" stroke-opacity="0.85" stroke-width="2"/>
              <defs>
                <linearGradient id="paint0_linear_333_9188" x1="192" y1="0" x2="192" y2="366" gradientUnits="userSpaceOnUse">
                  <stop stop-color="#33CEFF"/>
                  <stop offset="0.562842" stop-color="#D633FF" stop-opacity="0"/>
                </linearGradient>
              </defs>
            </svg>
          `)}')`,
        }}
      >
        <div className="relative z-2 font-inter flex flex-col min-h-[22rem] p-[2.4rem]">
          <h5 className="text-2xl text-white mb-5">The Impact</h5>
          <p className="mb-6 text-n-3">
            Enhanced transportation efficiency can lead to reduced emissions, improved commuter satisfaction, and economic growth.
          </p>
          <div className="flex items-center mt-auto">
            <a
              target="_blank"
              rel="noopener noreferrer"
              href="https://example.com/impact"
              className="ml-auto font-code text-xs font-bold text-n-1 uppercase tracking-wider"
            >
              Discover Impact
            </a>
            <Arrow />
          </div>
        </div>
        <ClipPath />
      </div>
    </div>
  </div>
</div>

    </Section>
  );
};

export default About;

Here is how it currently looks like:https://ibb.co/hFScmDX

Thank you!

Does the Angular resource API support adding an initial value for the resource?

Suppose we first check whether a resource is not loading like this:

    @if (!countriesResource.isLoading()) {
      <ul>
        @for (
          country of countriesResource.value(); 
          track country.name.official
        ) {
          <li>{{ country.name.official }}</li>
        }
      </ul>

If the resource is not loading, however has not initiated a request yet, is there a way to provide an initial value so that countriesResource.value() resolves to an initial value?

What do i need to focus on as a developer upcoming

I wanna know about if learning framework should be priority over languages .What key when becoming a self taught developer

For me my learning curve is getting greater so experiencing hard times i know a must but what am learning is not about perfection but getting the right concept and making a new solvable challenge

Putting HTML as part of string in JSON?

Wondering if there’s any way of doing this? I think I could do it if I use dangerouslySetInnerHTML but ideally I’d just call this within my p tag.

This is my Json

  "login": [
    {
      "title": "Hello!",
      "blurb": "This is a secret direct link to enable login without a username and password. If you're having trouble accessing my portfolio via this link, please <a href="mailto: [email protected]" className={`${styles.link}`}>contact me.</a>"
    }
  ]

And then in my js file (nextJS) I’d just do this

<p className={`${styles.body} fadeIn`}>{cms.blurb}</p>

Any way of doing this? Something I can change in my json file?

Responsive navbar click

I try to get my navbar responsive. Follow this tut on w3schools. If I copy and paste it is working, but I want it to be mobile first (media queries) and there is my problem.

The switch from mobile to tablet/desktop works. But there is something wrong with the click function and css.

window.onload=function() {

  const x = document.getElementById("myTopnav");
  const burger = document.getElementById("burger");

  burger.addEventListener("click", () => {

    if (x.className === "topnav") {
      x.className += " responsive";
    } else {
      x.className = "topnav";
    }
    
  });

};
.topnav {
  overflow: hidden;
  background-color: #333;
}

.topnav a {
  float: right;
  display: none;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 24px;
}

.topnav a:hover {
  background-color: #ddd;
  color: black;
}

.topnav a.active {
  background-color: #04AA6D;
  color: white;
  display: block;
  float: left;

}

.topnav .icon {
  display: block;
}


/*  X-Small devices (portrait phones, less than 576px)
    No media query for `xs` since this is the default in Bootstrap
*/
/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
}

@media (min-width: 576px) {
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
  .topnav a:not(:first-child) {display: block;}
  .topnav a.icon {
    float: right;
    display: none;
  }
}

@media (min-width: 768px) {
  .topnav.responsive {position: relative;}
  .topnav.responsive .icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  .topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {}

/* X-Large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {}

/* XX-Large devices (larger desktops, 1400px and up) */
@media (min-width: 1400px) {}
<nav>
    <!-- Top Navigation Menu -->
    <div class="topnav" id="myTopnav">
      <a href="#home" class="active">Brand</a>
      <a href="#news">News</a>
      <a href="#contact">Contact</a>
      <a href="#about">About</a>
      <a href="#" id="burger" class="icon">
        <svg width="35px" height="35px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M3.46447 20.5355C4.92893 22 7.28595 22 12 22C16.714 22 19.0711 22 20.5355 20.5355C22 19.0711 22 16.714 22 12C22 7.28595 22 4.92893 20.5355 3.46447C19.0711 2 16.714 2 12 2C7.28595 2 4.92893 2 3.46447 3.46447C2 4.92893 2 7.28595 2 12C2 16.714 2 19.0711 3.46447 20.5355ZM18.75 16C18.75 16.4142 18.4142 16.75 18 16.75H6C5.58579 16.75 5.25 16.4142 5.25 16C5.25 15.5858 5.58579 15.25 6 15.25H18C18.4142 15.25 18.75 15.5858 18.75 16ZM18 12.75C18.4142 12.75 18.75 12.4142 18.75 12C18.75 11.5858 18.4142 11.25 18 11.25H6C5.58579 11.25 5.25 11.5858 5.25 12C5.25 12.4142 5.58579 12.75 6 12.75H18ZM18.75 8C18.75 8.41421 18.4142 8.75 18 8.75H6C5.58579 8.75 5.25 8.41421 5.25 8C5.25 7.58579 5.58579 7.25 6 7.25H18C18.4142 7.25 18.75 7.58579 18.75 8Z" fill="#fff"></path> </g></svg>
      </a>
    </div>
</nav>  

Hope, someone can help me.

How can I dynamically load Webpack 5 split chunks on demand?

I’m using Webpack 5’s splitChunks to optimize my bundles and load them on demand. Here’s the general setup in my Webpack configuration:

optimization: {
  splitChunks: {
    chunks: 'all',
    minChunks: 2,
    cacheGroups: {
      main: {
        test: /src/(utils|services|actions/framework|reducers/framework|pages/index.js)/,
        name: 'main',
        priority: 3,
        enforce: true,
        reuseExistingChunk: true
      },
      secondBundle: {
        test: /src/(components/(Homepage|Search|ProductPage|Category)|viewModel/(homepage)|pages/(Homepage|Search|ProductPage|Category))/,
        name: 'secondBundle',
        chunks: 'all',
        priority: 2,
        enforce: true,
        reuseExistingChunk: true
      },
      thirdBundle: {
        test: /src/components/.*/,
        name: 'thirdBundle',
        priority: 1,
        enforce: true,
        reuseExistingChunk: true
      }
    }
  },
}

What I’m Trying to Achieve:

Initial Load: I want to load the main and secondBundle on the landing page. These bundles should contain everything necessary to render the page fully.
Post-Load: After the initial page load, I want to load the thirdBundle dynamically, only when the user navigates to /home.

The Problem:
Even though I’ve verified through Webpack Analyzer that the required files for the /home route are already included in the first two bundles (main and secondBundle), the page doesn’t fully load when navigating to /home.
I expect that after the initial page load, the third bundle (thirdBundle) should load asynchronously and complete the page, but it doesn’t seem to be happening as expected.

What I’ve Tried:

I’ve confirmed that the chunks for /home are present in the initial bundles via Webpack Analyzer.
I’ve attempted to load the third bundle programmatically after the page load, but it doesn’t seem to be completing the page render.

Questions:
Why is the page not fully loading, even though the required files for /home are part of the first two bundles?
Is there a specific Webpack configuration or method I’m missing to ensure that the third bundle loads after the initial page load, without blocking the page’s render?

Additional Info:

The Webpack configuration seems to be properly splitting the chunks, and I’m using chunks: ‘all’ to ensure all potential code is included.
I also have an enforce: true flag set on all cache groups to make sure the chunks are being created correctly.

Could there be an issue with how Webpack is processing the chunks, or am I missing something, a configuration maybe regarding how bundles are loaded dynamically after the initial load?

I appreciate any help or suggestions on how to fix this issue!

replace hard coded ip address with something else in docker compose on linux

I’m using linux and trying to set up a docker compose app on raspberry pi. Below is my compose.yaml file. How do I configure this so that I don’t have to hard code the ip address in the yaml file?

    services:
        client:
            build: client/.
            ports:
                - "5173:5173"
            networks:
                - backend
            environment:
                - VITE_HOST=192.168.0.147 ## <-- bad!
            extra_hosts:
                - "host.docker.internal:host-gateway"
        server:
            build: express/.
            ports:
                - "8008:8008"
            networks:
                - backend
            extra_hosts:
                - "host.docker.internal:host-gateway"
            environment:
                - HOST=locaalhost
                - HOST_IP=host.docker.internal
            volumes:
                - /home:/home

    volumes:
        home:

    networks:
        backend:

Below is a code snippet that shows how the VITE_HOST env line is used in the client. It is used to connect to the ‘server’. The client is a vite/vue project. The server saves info from the client to the underlying operating system.

    const host =  import.meta.env.VITE_HOST;
    const url = `http://${host}:8008/users`;

    const response = await fetch(url , {
                method: "GET",
                headers: {
                    "Access-Control-Allow-Origin": "*",
                    "Access-Control-Allow-Methods": "GET, OPTIONS, PUT, POST",
                    "Access-Control-Allow-Headers": "X-Requested-With",
                    "Content-Type": "text/plain"
                }
            });
    ...

For some reason host.docker.internal doesn’t do anything on my pi or my desktop (my desktop is linux). How can I make this work?? Thanks.

How to use Form-IO in swift iOS app using Javascript in WKWebView

I want to integrate Form-IO in iOS App WkWebView. I used JavaScript to show the ui in web view. but I’m not able to see web view in screen. I tried in delegate method too but failed to load the web view.

I added webpagePreferences.allowsContentJavaScript = true to enable the Javascript still no webpage loaded in simulator.

I printed web view’s frame as well. it’s printing based on device I chose. I don’t know what wrong I’m doing here. Please correct the wrong here.

class ViewController: UIViewController, WKUIDelegate, UIScrollViewDelegate {
   
   
   var webView: WKWebView!
   
   
   override func viewDidLoad() {
       super.viewDidLoad()
       
       let config = WKWebViewConfiguration()
       
       let webpagePreferences = WKWebpagePreferences()
       webpagePreferences.allowsContentJavaScript = true
       config.defaultWebpagePreferences = webpagePreferences
       
       let contentController = WKUserContentController()
       contentController.add(self, name: "log")
       config.userContentController = contentController
       
       webView = WKWebView(frame: self.view.bounds, configuration: config)
       self.view.addSubview(webView)
       webView.frame = self.view.bounds
       webView.navigationDelegate = self
       
               
       let htmlContent = """
               <!DOCTYPE html>
               <html lang="en">
               <head>
                   <meta charset="UTF-8">
                   <meta name="viewport" content="width=device-width, initial-scale=1.0">
                   <title>Form.io</title>
                   <script src="https://cdn.form.io/formio.js"></script>
               </head>
               <body>
                   <div id="formio"></div>
                   <script type="text/javascript">
                       window.onload = function() {
                           window.webkit.messageHandlers.log.postMessage('Before form render');                   
                           Formio.createForm(document.getElementById('formio'), {
                             components: [
                               {
                                 type: 'textfield',
                                 key: 'firstName',
                                 label: 'First Name',
                                 placeholder: 'Enter your first name.',
                                 input: true
                               },
                               {
                                 type: 'textfield',
                                 key: 'lastName',
                                 label: 'Last Name',
                                 placeholder: 'Enter your last name',
                                 input: true
                               },
                               {
                                 type: 'button',
                                 action: 'submit',
                                 label: 'Submit',
                                 theme: 'primary'
                               }
                             ]
                           }
               );
                       };
                   </script>
               </body>
               </html>
               """
       
       print("Before loading the HTML content")
       webView.loadHTMLString(htmlContent, baseURL: nil)
       print("After loading the HTML content")
   }

}

// WKWebView delegate method to catch console logs
extension ViewController: WKScriptMessageHandler {
   func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
       if let messageBody = message.body as? String {
           print("JavaScript log: (messageBody)")
       }
   }
}

// WK navigation Delegate
extension ViewController: WKNavigationDelegate {
   func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
       print("delegate called....")
       let stringValue = """
                   <script type="text/javascript">
                       window.onload = function() {
                           window.webkit.messageHandlers.log.postMessage('Before form render');
                           Formio.createForm(document.getElementById('formio'), {
                                                         components: [
                                                           {
                                                             type: 'textfield',
                                                             key: 'firstName',
                                                             label: 'First Name',
                                                             placeholder: 'Enter your first name.',
                                                             input: true
                                                           },
                                                           {
                                                             type: 'textfield',
                                                             key: 'lastName',
                                                             label: 'Last Name',
                                                             placeholder: 'Enter your last name',
                                                             input: true
                                                           },
                                                           {
                                                             type: 'button',
                                                             action: 'submit',
                                                             label: 'Submit',
                                                             theme: 'primary'
                                                           }
                                                         ]
                                                       }.then(function(form) {
                               window.webkit.messageHandlers.log.postMessage('Form rendered');
                           }).catch(function(err) {
                               window.webkit.messageHandlers.log.postMessage('Error loading form: ' + err);
                           });
                       };
                   </script>
"""
       webView.evaluateJavaScript(stringValue)
   }
}