Where is the default style on button, input, etc. in create-next-app?

I just created a default create-next-app application.

I added some simple elements in the app/page.tsx , like <button>click</button> and an <input type="text" placeholder="name" />. However these elements are displayed without any style at all; you can’t understand that it’s a button, on the screen, neither the input box.
Why is this happening? Should I install anything else on top?

I see the global.css file imports @import "tailwindcss"; and this impacts the <button> and <input>. So it is Tailwind that overides the HTML components and they don’t have style at all.

Is the solution to read the Tailwind documentation for every component that I need to use and add styles or is there another approach?

Overlapping SVG animations cause jumps

If an <animate> animation begins while another one is running, the animated attribute jumps to some weird intermediate value (and animates from there). How is that value computed?

And the speed of the animation becomes weird and then becomes normal again midway.

Click for example “Go left” (optionally wait for the animation to finish), “Go right” (don’t wait for this one to finish), “Go left”:

<svg>
  <circle cx="10" cy="10" r="5" />
  <circle cx="60" cy="10" r="5" />
  <circle cx="110" cy="10" r="5" />
  <circle cx="60" cy="10" r="5" fill="orange">
    <animate id="go-right" attributeName="cx" to="110" dur="2s" begin="indefinite" fill="freeze" additive="replace" accumulate="none" />
    <animate id="go-left" attributeName="cx" to="10" dur="2s" begin="indefinite" fill="freeze" additive="replace" accumulate="none" />
  </circle>
</svg>

<script>
  goLeft = document.getElementById('go-left');
  goRight = document.getElementById('go-right');
</script>

<button onclick="goLeft.beginElement()">Go left</button>
<button onclick="goRight.beginElement()">Go right</button>

Spec Section 12.4.3 The animation sandwich model says

A non-additive animation simply overrides the result of all lower sandwich layers.

Spec Section 12.4.5 The animation effect function F(t,u) says

Higher priority animations that are not additive will override all earlier (lower priority) animations, and simply set the attribute value.

And I explicitly set these animations to be neither additive nor cumulative.

So why do the animations influence each other? Specifically, how is the value computed?

Adding calls to endElement() makes the values even weirder.

How to use a sprite sheet in A-Frame?

How do I make the texture for a simple box/cube in a-frame a sprite sheet, like, a 6 image sprite sheet, as if it was for a single cube in Minecraft or something, i know if you put an image in for the src attribute it makes all 6 sides that image, but i would like to make each* side have a different texture.
and also, if i add an img tag to an assets tag, which in a-frame

The following code has 3 cubes:

  • The front one is just a single image that is repeated,
  • The one on the left is a 1×6 sprite sheet, inputted for the src, but it is still just a stretched version of the image repeated, instead of have each bit on 1 side,
  • And on the right is that same sprite sheet but in a cross shape, which also didn’t work.
    None of them do what I want, which is to display a different image on each side of the cube using a sprite sheet, (and also maybe different polygons like pyramids and rectangular prisms…) 3;

    <html>
      <head>
        <script src="https://aframe.io/releases/1.7.1/aframe.min.js"></script>
      </head>
      <body>
        <a-scene>
          <a-assets>
          </a-assets>
    
          <a-box
            src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAAf9JREFUeF7t3EEKwzAQxdDx/Q/t0isIBBOj7udD9Fqy65mZOw987n3iMeYEsuvbGMguj34hyzwCCUQq0EtdCktnA6HlpLtApLB0NhBaTroLRApLZwOh5aS7QKSwdDYQWk66C0QKS2cDoeWku0CksHQ2EFpOugtECktnA6HlpLtApLB0NhBaTroLRApLZwOh5aS7QKSwdDYQWk66C0QKS2cDoeWku0CksHQ2EFpOugtECktnA6HlpLtApLB0NhBaTroLRApLZwOh5aS7QKSwdDYQWk66C0QKS2cDoeWku0CksHQ2EFpOugtECktnA6HlpLtApLB0NhBaTroLRApLZwOh5aS7QKSwdDYQWk66ewbkPvIk5/z/+uv7nxPILsRAdnlMIIE4BXqHOF3xaiA4nXMYiNMVrwaC0zmHgThd8WogOJ1zGIjTFa8GgtM5h4E4XfFqIDidcxiI0xWvBoLTOYeBOF3xaiA4nXMYiNMVrwaC0zmHgThd8WogOJ1zGIjTFa8GgtM5h4E4XfFqIDidcxiI0xWvBoLTOYeBOF3xaiA4nXMYiNMVrwaC0zmHgThd8WogOJ1zGIjTFa8GgtM5h4E4XfFqIDidcxiI0xWvBoLTOYeBOF3xaiA4nXMYiNMVrwaC0zmHgThd8WogOJ1zGIjTFa8GgtM5h4E4XfHqKyA/1xGPeqikrOsAAAAASUVORK5CYII="
            position="0 0 -5"
            rotation="0 45 0"
            scale="2 2 2">
          </a-box>
    
          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CCtHgoSIwHQWJAFKQFhCAtHgoS40GQGBAFaQEhSIuHgsR4ECQGREFaQAjS4qEgMR4EiQFRkBYQgrR4KEiMB0FiQBSkBYQgLR4KEuNBkBgQBWkBIUiLh4LEeBAkBkRBWkAI0uKhIDEeBIkBUZAWEIK0eChIjMdbBPkPUYRwmbmkSu0AAAAASUVORK5CYII=
    "
            position="-5 0 0"
            rotation="0 45 0"
            scale="2 2 2">
          </a-box>
    
          <a-box
            src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAADICAYAAAAKhRhlAAAAAXNSR0IArs4c6QAABnBJREFUeF7tncFuWzkQBO3//2gvBGTvXSJmMGhUzvMos7pVZILI+v3p+fNXspXfhn1UbOJfEBbrUCMt1qEw/v0oFZlUbEJj+e6YJOBROEkXrq2xILCF8YpMKjbhUbhQd/gSFgsCWxivyKRiExproe7wJSwWBLYwXpFJxSY01kLd4UtYLAhsYbwik4pNaKyFusOXsFgQ2MJ4RSYVm9BYC3WHL2GxILCF8YpMKjahsRbqDl/CYkFgC+MVmVRsQmMt1B2+hMWCwBbGKzKp2ITGWqg7fAmLBYEtjFdkUrEJjbVQd/gSFgsCWxivyKRiExproe7wJWqK9ff3V/Fhit/f34pMKjbxeTNZLKiU4XGLNQyYLq+xKLHheY01DBgur7EgsOlxjTVNGK6vsSCw4XGNNQyYLq+xKLHheY01DBgur7EgsOlxjTVNGK6vsSCw4XGNNQyYLq+xKLHheY01DBgur7EgsOlxjTVNGK6vsSCw4XGNNQyYLq+xKLHheY01DBgur7EgsOlxjTVNGK6vsSCw4XGNNQyYLq+xKLHheY01DBgur7EgsOlxjTVNGK6vsSCw4XGNNQyYLq+xKLHheY01DBgur7EgsOnxJmONf9Cz5LOkPxufJd1gtbGPj7EsVqihjUAsVhjGZ2wDFvhxvh61WDk6jZWz8igkrDwKc1oaC7CyWADWwi+C2bg2bLxBPArzXnkUElYaK6e18U7XWHke/q3wGKuNN4hHIQh9IxCNBQLZgAV+nK9HLVaOTmP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Vw7JYOSuNBVhZLABLY+WwLFbOSmMBVhYLwNJYOSyLlbPSWICVxQKwNFYOy2LlrDQWYFVTrI0vG1/6gvmKTCo28XkjWSygk4VRiwUga6wclsXKWX0+8wemvx5deZGvf7rwwYpNeBSGaS+OWSwAW2PlsCxWzsqjkLACs6dH/VvhrXg0FsjDozCHZbFyVh6FhBWYPT3qUXgrHo0F8vAozGFZrJyVRyFhBWZPj3oU3opHY4E8PApzWBYrZ+VRSFiB2dOjHoW34tFYIA+PwhyWxcpZeRQSVmD29KhH4a14NBbIw6Mwh2WxclYehYQVmD096lF4Kx6NBfLwKMxhWayclUchYPUfGUwgxLGETOoAAAAASUVORK5CYII=
    "
            position="5 0 0"
            rotation="0 45 0"
            scale="2 2 2">
          </a-box>
    
          <a-sky color="#222"></a-sky>
        </a-scene>
      </body>
    </html>
    
    <!-- you can use wasd or arrow keys to move around BTW!.:3 -->

How to reverse SVG animations with JS in HTML

I am creating a website to simulate lever frames for railways that currently use them. To simulate the levers I decided to use SVGs which seems to be working relatively well. However, I am currently running into the issue not being able to reverse the animations so reset the levers to their original state.

The animation worked fine (other than the text moving too far down) with both keyPoints="0; 1" and keyPoints="1; 0" while using beginElement()` to trigger the animation, but as I have it set up right now there is no animation at all.

How can I get the animation to play in reverse so the levers can move either direction? Is there a better way than reversing the keyPoints?

//defined in a json file
leverframe = {
  "1": {
    "id": "HJ1",
    "type": "d"
  },
  "2": {
    "id": "HJ2",
    "type": "s"
  },
  "3": {
    "id": "HJ3",
    "type": "s"
  },
  "4": {
    "id": "HJ4",
    "type": "es"
  }
}

// box.html
const leverlist = new Map()

for (const lever of Object.keys(leverframe)) {
  const leverimg = document.createElementNS("http://www.w3.org/2000/svg", "svg")
  levers.appendChild(leverimg)
  leverimg.outerHTML = '<svg xmlns="http://www.w3.org/2000/svg" id="' + lever + '" viewBox="0 0 35 300" width="35px" height="300px"><image href="https://cdn.glitch.global/35ec23e6-47cb-4d5f-87eb-598ad1888739/' + leverframe[lever].type + '.png?v=1749249192147" height="329" y="-0.579" style="transform-box: fill-box; transform-origin: 50% 50%;"><title>image</title><animateTransform id="' + lever + 'pull1" type="scale" additive="sum" attributeName="transform" values="1 1;1 0.9" begin="indefinite" dur="2s" fill="freeze" keyTimes="0; 1" keyPoints="0; 1"></animateTransform><animateMotion id="' + lever + 'pull2" path="M 0 0 L 0 34.352" calcMode="linear" begin="pull1.begin" dur="2s" fill="freeze" keyTimes="0; 1" keyPoints="0; 1"></animateMotion></image><text style="white-space: pre; fill: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 10px; text-anchor: middle;" x="12.5" y="117.5" id="object-0"><title>text</title>' + lever + '<animateMotion id="' + lever + 'pull3" path="M 0 0 L 0 43.512" calcMode="linear" begin="pull1.begin" dur="2s" fill="freeze" keyTimes="0; 1" keyPoints="0; 1"></animateMotion></text></svg>'

  leversvg = document.getElementById(lever)
  leverlist.set(lever, false)

  leversvg.onclick = function() {
    leverlist.set(lever, !leverlist.get(lever))

    if (leverlist.get(lever)) {
      console.log("doing animation")
      console.log(document.getElementById(lever + "pull1"))
      document.getElementById(lever + 'pull1').setAttribute("keyPoints", "0; 1")
      document.getElementById(lever + 'pull2').setAttribute("keyPoints", "0; 1")
      document.getElementById(lever + 'pull3').setAttribute("keyPoints", "0; 1")
      document.getElementById(lever + 'pull1').beginElement();
      console.log("done animation")
    } else {
      console.log("doing animation")
      console.log(document.getElementById(lever + "pull1"))
      document.getElementById(lever + 'pull1').setAttribute("keyPoints", "1; 0")
      document.getElementById(lever + 'pull2').setAttribute("keyPoints", "1; 0")
      document.getElementById(lever + 'pull3').setAttribute("keyPoints", "1; 0")
      document.getElementById(lever + 'pull1').beginElement();
      console.log("done animation")
    }
  }
}
<div id="levers" alt="Box Levers" style="max-width: 90vw; overflow-y: auto; white-space: nowrap;"></div>

Node modules not getting install in user mode linux

so i recently switched to linux and i have a Next JS project on github, I’m able to clone to the project but to work on it i have to install node modules. The problem is whenever i run “npm i” command it takes around 15 mins tops to just throw me an error that I don’t have permission to download it.

So i tried installing it via “sudo npm i” but I am getting same error. I tried using NVM too but no success in that either.

I even tried changing the ownership to my hard_disk but still same thing. Also one more thing, whenever i login into my system, i always has to mount my hard_disk again and again everytime can you guys please help me 🙂

what’s the best medication for prolong cough?

Meet the leading Prolong cough Pain Management pharmacy at Uslinctusstore. Experience tailored solutions for a life free from discomfort. Choose expertise, choose relief. Your well-being is our priority.#buyhitechpromethazinehydrochloride #buywockhardtpromethazine. Secure your order before it runs out! Limited stocks- Buy now!

Contact our online pharmacy now; +1(945)266-6325 | 19452666325

https://uslinctusstore.com/product/wockhardt-promethazine/

https://uslinctusstore.com/

[email protected]

modal does not block body from scrolling

  useEffect(() => {
    if (modal_ref.current) {
        modal_ref.current.showModal();
    } else {
        modal_ref.current.close();
    }
  }, [foc]);

when my <dialogue /> component is rendered and covers the entire viewpoint, the above useEffect fires, but body beneath still scrolls. There is no position: fixed, in the dialogue either.

How to ensure that the blocks scrolling of all components beneath?

My Node Js server is running slower when there is no client input

I have been working on a game using javascript canvas and Node JS as a personal project, and noticed some odd server behaviour so I made a minimal server and client to test it and I noticed something very odd. For example if I set the tick rate of the server to be 100 ticks per second (this also happens with other tick rates) and then run the server with this as the main loop:

let tickCounter = 0; 
let lastPrint = Date.now();

function gameLoop() { 
    tickCounter++; 
    const now = Date.now(); 
    if (now - lastPrint >= 1000) { 
        console.log(Ticks per second: ${tickCounter}); 
        lastPrint = now; tickCounter = 0; 
    }
    setTimeout(gameLoop, TICK_INTERVAL)
} 
gameLoop();

The server will output 65 ticks per second (which should be 100). However, when I run my client with the following code

var mouse = { X: canvas.width / 2, Y: canvas.height / 2, }

window.addEventListener('mousemove', e => {
    mouse.X = e.clientX;
    mouse.Y = e.clientY;
    
    console.log(mouse.X, mouse.Y)
    
    socket.emit("rotate", { "angle": Math.atan2(mouse.X - canvas.width / 2, mouse.Y - canvas.height / 2) + Math.PI })
});

And then move my mouse, inexplicably the tick speed goes up to 100 (what it is supposed to be) on the server. This tick speed change is causing a lot of problems with my actual project. Just to clarify I am using Windows and also express js to make the server.

I have already tried using different tick speeds (the same thing will happen with all of them), I have tried using setInterval instead, I have tried increasing the task priority in task manager of node.exe, all to no avail. The only thing that does work is to just constantly send useless data from the client to the server, but that is not a sustainable solution and will cause unnecessary strain to the server later on in the project.

Edit: It is definitely a problem with Windows, because I sent the code to a friend who uses linux and he did not have the same problem.

pinch and zoom react native skia and react gesture handler

I am using react native skias library and I am trying to do matrix calculations to create a pannable and zoomable skia canvas (like figma or google maps). Here is my implementation so far

function MyCanvas({
  imageView,
  canvasWidth,
  canvasHeight,
}: {
  imageView: Element[];
  canvasWidth: number;
  canvasHeight: number;
}) {
  const translateX = useSharedValue(0);
  const translateY = useSharedValue(0);
  const scale = useSharedValue(1);
  const savedScale = useSharedValue(1);
  const focalX = useSharedValue(0);
  const focalY = useSharedValue(0);

  const matrix = useSharedValue(Matrix4());

  const context = useSharedValue({ x: 0, y: 0 });

  const panGesture = Gesture.Pan()
    .onStart(() => {
      context.value = { x: translateX.value, y: translateY.value };
    })
    .onUpdate((event) => {
      translateX.value = event.translationX + context.value.x;
      translateY.value = event.translationY + context.value.y;
    });

  const pinchGesture = Gesture.Pinch()
    .onUpdate((event) => {
      scale.value = event.scale * savedScale.value;
      focalX.value = event.focalX;
      focalY.value = event.focalY;
    })
    .onEnd(() => {
      savedScale.value = scale.value;
      console.log(matrix.value);
    });

  const computedMatrix = useDerivedValue(() => {
    return processTransform3d([
      // 1. Apply current global panning
      { translateX: translateX.value },
      { translateY: translateY.value },

      // 2. Translate to pivot point (focal point for zoom)
      { translateX: focalX.value },
      { translateY: focalY.value },

      // 3. Apply scaling
      { scale: scale.value },

      // 4. Translate back from pivot point
      { translateX: -focalX.value },
      { translateY: -focalY.value },
    ]);
  }, [scale, translateX, translateY, focalX, focalY]);

  useDerivedValue(() => {
    // console.log(computedMatrix.value);
    // This effect updates the Skia Matrix4 instance directly.
    matrix.value = computedMatrix.value;
  });

  const composedGesture = Gesture.Simultaneous(panGesture, pinchGesture);

  return (
    <GestureDetector gesture={composedGesture}>
      <View className="bg-gray-950 flex-1 overflow-visible">
        <Canvas style={{ flex: 1 }}>
          <Group matrix={computedMatrix}>{imageView}</Group>
        </Canvas>
      </View>
    </GestureDetector>
  );
}

This pans (translates) fine but whenever I try pinch to zoom in continues to zoom in on the origin (0,0) and not the focal point of the pinch gesture. Any suggestions?

How to create multiple SVGs in for loops [duplicate]

I am attempting to make a website that simulates lever frames from certain railways, and I was wondering how to create animated / unique images for each lever. I did some research and I am still not sure that an SVG is even the way to go here, but it seemed the best way in my very limited opinion. I want each lever to have its own unique number, but I didnt want to create 100+ levers of each type with numbers. When the lever is pulled I would like the lever to “pull” or “push” (I will simulate this by somehow shrinking and expanding the height of the lever)

I previously was simulating the levers with a button that just transformed down by its own height, so most of the infrastructure is there already, I just need help setting up the SVGs

This is my code so far (literally not much to it) and already I am getting probably the obvious error of leverimg.createElement is not a function

for (const lever of Object.keys(leverframe)) {
        const leverimg = document.createElement("svg")
        image = leverimg.createElement("img")
        text = leverimg.createElement("text")
        
        image.src = "path/to/img"
        text.innerHTML = lever
}

and here is an image for reference to the lever. The number goes on the white plate just under the handle

How can I create the SVG with js (again if I even should be using the SVG at all) so I can have the lever and the text overlapping and animated

Error when running next build in nextjs monorepo turborepo

I have a turborepo with 2 NextJS projects in it.

When I run next build I get this error:

[TypeError: Cannot read properties of null (reading 'useContext')]
Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of null (reading 'useContext')
    at exports.useContext (/Users/user/dev/repos/repo-root/node_modules/styled-jsx/node_modules/react/cjs/react.production.js:488:33)

Package.json of app A

{
  "name": "docs",
  "version": "0.1.0",
  "type": "module",
  "private": true,
  "scripts": {
    "dev": "next dev --turbopack -p 3001",
    "build": "next build",
    "start": "next start",
    "lint": "next lint --max-warnings 0",
    "check-types": "tsc --noEmit"
  },
  "dependencies": {
    "next": "^15.2.1",
    "react": "^19.1.0",
    "react-dom": "^19.1.0"
  },
  "devDependencies": {
    "@types/node": "^22.13.10",
    "@types/react": "19.0.0",
    "@types/react-dom": "19.0.0",
    "eslint": "^9.22.0",
    "typescript": "5.8.2"
  }
}

Package.json of app B

{
  "name": "app",
  "version": "0.1.0",
  "type": "module",
  "private": true,
  "scripts": {
    "dev": "next dev --turbopack -p 3002",
    "build": "next build",
    "start": "next start",
    "lint": "next lint --max-warnings 0",
    "check-types": "tsc --noEmit"
  },
  "dependencies": {
    "next": "^15.2.1",
    "react": "19.0.0",
    "react-dom": "19.0.0"
  },
  "devDependencies": {
    "@types/node": "^22.13.10",
    "@types/react": "19.0.0",
    "@types/react-dom": "19.0.0",
    "eslint": "^9.22.0",
    "typescript": "5.8.2"
  }
}

I tried creating a custom 404 and/or error pages without any success.

Can an inappropriate callback be passed to waitFor?

I was going over Road to React (the book by Robin Wieruch), and I encountered a confusing piece of code. The code is on the Testing chapter, page 227:


describe('App', () => { 
    it('succeeds fetching data', 
        async () => { const promise = Promise.resolve({ data: { hits: stories,},
    });

    axios.get.mockImplementationOnce(() => promise);
    
    render(<App />); 
    
    expect(screen.queryByText(/Loading/)).toBeInTheDocument();
    
    await waitFor(async () => await promise);
 
    expect(screen.queryByText(/Loading/)).toBeNull();
    });
});

This is the useEffect code:


React.useEffect(() => { 
    handleFetchStories();
}, [url);

This is handleFetchStories and storiesReducer:


// handleFetchStories 

const handleFetchStories = React.useCallback(async () => {
    dispatchStories({ type: 'STORIES_FETCH_INIT' });
    const result = await axios.get(url);
    dispatchStories({ type: 'STORIES_FETCH_SUCCESS',
    payload: result.data.hits,
    });

    try { 
    const result = await axios.get(url);
    dispatchStories({ type: 'STORIES_FETCH_SUCCESS',
    payload: result.data.hits,});
    } 
    catch { 
    dispatchStories({ type: 'STORIES_FETCH_FAILURE' });
}
}, [url]);


// StoriesReducer
const storiesReducer = (state, action) => { 
switch (action.type) { 
case 'STORIES_FETCH_INIT':
return { ...state,
isLoading: true,
isError: false,
};
case 'STORIES_FETCH_SUCCESS':
return { ...state,
isLoading: false,
isError: false,
data: action.payload,
};
case 'STORIES_FETCH_FAILURE':
return { ...state,
isLoading: false,
isError: true,
};
case 'REMOVE_STORY':
return { ...state,
data: state.data.filter( (story) => action.payload.objectID !== story.objectID ),
};
default:
throw new Error();
}
};

My problem is with this line:

await waitFor (async () => await promise)

I understand waitFor's behaviour, but it seems like this code is redundant, given that the promise is already resolved. However, the code works. In addition, the callback has nothing to do with a DOM update, so I suspect that this is an inappropriate use of waitFor.

Can’t Change Font Awesome Icon On Click

In my password field I have an eye icon that is supposed to change to the slashed eye on click and show password elements. But when I click it, it does nothing. What needs to be changed in my code?? Excuse the ChatGPT word vomit. I have confirmed that nothing in my CSS seems to be overriding any changes

HTML:

<!-- ============================
       B) SIGN UP MODAL
       ============================ -->
  <div class="modal-overlay" id="signupModal" style="display: none;">
    <div class="modal-box">
      <h2>SIGN UP</h2>
      <form id="signupForm">
        <input
          type="text"
          id="signupFirstName"
          placeholder="First Name"
          required
        />
        <input
          type="text"
          id="signupLastName"
          placeholder="Last Name"
          required
        />
        <input
          type="text"
          id="signupUsername"
          placeholder="Username"
          required
        />

        <!-- Password Field (Signup) -->
        <div class="input-with-icon">
          <input
            type="password"
            id="signupPassword"
            placeholder="Password"
            required
          />
          <i
            class="fa-regular fa-eye toggle-password"
            data-target="signupPassword"
          ></i>
        </div>

        <!-- Confirm Password Field (Signup) -->
        <div class="input-with-icon">
          <input
            type="password"
            id="signupConfirmPassword"
            placeholder="Confirm Password"
            required
          />
          <i
            class="fa-regular fa-eye toggle-password"
            data-target="signupConfirmPassword"
          ></i>
        </div>

        <div id="signupError" class="error-box" style="display: none;">
          <!-- Error text will appear here -->
        </div>

        <button class="submit-btn" type="submit">SUBMIT</button>
      </form>
    </div>
    <!-- /.modal-box for signup -->
  </div>
  <!-- /#signupModal -->

JS:

document.addEventListener('DOMContentLoaded', () => {
  
  // Toggle password visibility
  document.querySelectorAll('.toggle-password').forEach(icon => {
    icon.addEventListener('click', () => {
        console.log('Eye icon clicked, toggling!');
      const targetId = icon.getAttribute('data-target');
      const input = document.getElementById(targetId);
      if (!input) return;

      const isHidden = input.type === 'password';
      input.type = isHidden ? 'text' : 'password';

      // Toggle icon class
      icon.classList.toggle('fa-eye');
      icon.classList.toggle('fa-eye-slash');
    });
  });

Wagtail – How can I use a custom StructBlock with programmatically assignable default values?

I have created a StreamField for some of the site’s settings. This StreamField contains a collection of a custom StructBlock, named FacetBlock. FacetBlock contains a BooleanBlock, a CharBlock, an IntegerBlock and a ChoiceBlock. Now I need to make the CharBlock translatable, which means the admin will be able to enter one text for each language available on the site.

The way I was thinking of doing this is by using another custom StructBlock, this time called TranslatableTextBlock. It would contain a ChoiceBlock, a CharBlock and some hidden input to store the complete value. Using javascript, the admin would select a language, enter the text for that language and then move on to the next language. I’m not sure yet how that would be saved the database, but I’m not even able to get that far.

Right now, I can have either the fields show up with no default value or I get a javascript error (TypeError: e is null) in vendor.js, which triggers the same error in comments.js. Here is the code I have so far. I have omitted the FacetBlock definition, because it works perfectly when reverting TranslatableTextBlock to a CharBlock.

Python code:

class TranslatableTextBlock(StructBlock):
    def __init__(self, default_text:str = None, default_language:str = None, local_blocks = None, search_index = True, **kwargs):
        local_blocks = [
            (
                "language",
                ChoiceBlock(
                    choices=LANGUAGES,
                    default=default_language if default_language else None,
                    help_text=_("Select the language for this text")
                )
            ),
            (
                "text",
                CharBlock(
                    default=default_text if default_text else None,
                    help_text=_("Enter your text in the selected language"),
                )
            )
        ]
        super().__init__(local_blocks, search_index, **kwargs)

    class Meta:
        form_classname = "struct-block translatable-text-block"
        form_template = 'blocks/translatable_text_block_admin.html'
        icon = 'doc-full'
        label = _('Translated text')
        template = 'blocks/translatable_text_block.html'


class TranslatableTextBlockAdapter(StructBlockAdapter):
    js_constructor = "website.blocks.TranslatableTextBlock"

    @cached_property
    def media(self):
        structblock_media = super().media
        return Media(
            js=structblock_media._js + ["website/js/translatable_text_block.js"],
            css=structblock_media._css
        )

register(TranslatableTextBlockAdapter(), TranslatableTextBlock)

The admin template (translatable_text_block_admin.html):

{% load wagtailadmin_tags  %}

<div class="{{ classname }}">
{% if help_text %}
    <span>
        <div class="help">
            {% icon name="help" classname="default" %}
            {{ help_text }}
        </div>
    </span>
{% endif %}
    {% for child in children %}
    {{ child }}
    <div class="w-field" data-field data-contentpath="{{ child.block.name }}">
        {% if child.block.label %}
        <label class="w-field__label" {% if child.id_for_label %}for="{{ child.id_for_label }}"{% endif %}>{{ child.block.label }}{% if child.block.required %}<span class="w-required-mark">*</span>{% endif %}</label>
        {% endif %}
        {{ child.render_form }}
    </div>
    {% endfor %}
</div>

Javascript code (translatable_text_block.js):

if (typeof TranslatableTextBlockDefinition === "undefined") {
    class TranslatableTextBlockDefinition extends window.wagtailStreamField.blocks.StructBlockDefinition {
        render(placeholder, prefix, initialState, initialError) {
            const block = super.render(placeholder, prefix, initialState, initialError);    // The error happens on this line.
            // Some custom modifications would happen here.
            return block;
        }
    }

    window.telepath.register("website.blocks.TranslatableTextBlock", TranslatableTextBlockDefinition);
}

The javascript error:

TypeError: e is null
vendor.js:2:191488
Uncaught TypeError: e is null
comments.js:1:47007

Is anyone familiar with nested StructBlock for Streamfields in admin settings? Or maybe I’m going at this the wrong way and there is an easier solution? I welcome frame challenges 🙂

Using D3 worked example, get page 404 error with my csv file

I have taken the worked example from D3 for multiple plots on one graph, and having downloaded the csv file, it worked:-

<!-- Code from d3-graph-gallery.com -->
<!DOCTYPE html>
<meta charset="utf-8">

<!-- Load d3.js -->
<script src="https://d3js.org/d3.v4.js"></script>

<!-- Create a div where the graph will take place -->
<div id="my_dataviz"></div>


<script>

// set the dimensions and margins of the graph
var margin = {top: 10, right: 30, bottom: 30, left: 60},
    width = 460 - margin.left - margin.right,
    height = 400 - margin.top - margin.bottom;

// append the svg object to the body of the page
var svg = d3.select("#my_dataviz")
  .append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom)
  .append("g")
    .attr("transform",
          "translate(" + margin.left + "," + margin.top + ")");

//Read the data
d3.csv("data/Org.csv", function(data) {

  // group the data: I want to draw one line per group
  var sumstat = d3.nest() // nest function allows to group the calculation per level of a factor
    .key(function(d) { return d.name;})
    .entries(data);

  // Add X axis --> it is a date format
  var x = d3.scaleLinear()
    .domain(d3.extent(data, function(d) { return d.year; }))
    .range([ 0, width ]);
  svg.append("g")
    .attr("transform", "translate(0," + height + ")")
    .call(d3.axisBottom(x).ticks(5));

  // Add Y axis
  var y = d3.scaleLinear()
    .domain([0, d3.max(data, function(d) { return +d.n; })])
    .range([ height, 0 ]);
  svg.append("g")
    .call(d3.axisLeft(y));

  // color palette
  var res = sumstat.map(function(d){ return d.key }) // list of group names
  var color = d3.scaleOrdinal()
    .domain(res)
    .range(['#e41a1c','#377eb8','#4daf4a','#984ea3','#ff7f00','#ffff33','#a65628','#f781bf','#999999'])

  // Draw the line
  svg.selectAll(".line")
      .data(sumstat)
      .enter()
      .append("path")
        .attr("fill", "none")
        .attr("stroke", function(d){ return color(d.key) })
        .attr("stroke-width", 1.5)
        .attr("d", function(d){
          return d3.line()
            .x(function(d) { return x(d.year); })
            .y(function(d) { return y(+d.n); })
            (d.values)
        })

})

</script>

I changed the location of the csv file, to be local, which would allow my adaptations to be tested, and it worked.

I then modified the code, so it used my CSV file, which looks (with more entries) as follows:-

Time,TimeB,TimeC, Place, Data1, Data2, Data3
2025-03-10,2025-03-10,1, Place1,20.0625,19.76305,47996
2025-03-10,2025-03-10,2, Place2,20.1875,19.88156,49357
2025-03-10,2025-03-10,3, Place3,20.4375,19.98456,50589

I have changed the code to reflect that the column headings are different, and only tried to plot Data1, but I have tried changing the “year” heading to “Time” (which was a string) or TimeB (a date/Time value) or TimeC which is just a number.

However, for every attempt, I receive a Page 404 error.

I am running d3 v4, on an Apache server on a local machine; and I have used Firefox and Chromium on an Ubuntu machine, with identical results.

I cannot see why minor changes to a worked example (on my system) results in it breaking!

Any guidance would be most appreciated.