Kevin Powell - Community

KPC

Kevin Powell - Community

A friendly place for developers to meet other devs, ask questions, get help, and just have a good time 🙂.

Join

front-end

resources

back-end

ui-ux

os-and-tools

Astro - how to pass data from the server- to the client-side JavaScript

I'm sorry for not providing any code but I have doubts on whether my code would be even relevant in light of my question. Also, I have no idea which part of the code could be helpful, so, when asked for, I'll provide the requested part of the code, probably using some playground. I'm coding a relatively simple website, using Astro, and I seem to have an issue with passing data between the server- and client-side JavaScript. The thing is, I'm fetching some data inside the server-side JavaScript (Front Matter) and need those inside my client-side JavaScript, to simply filter them....
No description

Curve in the end for the last navigation link

SUMMARY: I have an idea to add a small curve to each link at the bottom, but I'm facing an issue with the last one. I added a background image to the body tag, and this is where the problem arises. PROBLEM: Green section that should be transparent. However, when I add transparency, the curved effect disappears (due to the negative margin-left). TRIED: I attempted to use a border-left, but it didn't work....
No description

What is the most "Semantic" way of adding svg's inside button elements?

Like this ```html <button class="btn__nav hamburger" value="<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1' stroke-linecap='round' stroke-linejoin='round' class='feather feather-menu'><line x1='3' y1='12' x2='21' y2='12'></line><line x1='3' y1='6' x2='21' y2='6'></line><line x1='3' y1='18' x2='21' y2='18'></line></svg>"> Menu...

Weather App

I'm building a simple weather app project. Current, I'm using open-meteo.com's API for weather data. One of the parameters I'm using is weather interpretation codes. The variable documentation is attached (see picture) My question is, what's the best method at converting code into description? I know there's multiple ways, such as if/else if, case, sets, etc. (I'm assuming using Key / Value) What would you recommend? Thanks....
No description

Continuous text change depicting encryption/security using code

I want to achieve an effect like this using code. Will start from random and finish at a specific sentence like "Security @ Apple" (without the background effect)
No description

Problem with a basic responsive container, which needs a min-height even when empty

https://codepen.io/OrzCode/pen/mdKjpYb I have a #content div in the middle section of this Codepen, which holds the content. This #content div is supposed to be 80% height of its parent (the middle cyan/teal section) when empty/to begin with, and should grow to scale to content size. I can't get it to both: (1) grow with content without overflowing (which is what is currently happening in this codepen), and also (2) have a minimum size even when empty. eg when the #content div is empty, it should still be 80% height/width of the parent box. The #content div disappears entirely if I add code to make the middle section grow based on content....

Icon inside Button

I've made a button component which I than used somewhere else. I placed fontawesome 6 icon <i></i> inside it and it's well aliged with the text in the button. As it was little bit bigger I changed the font-size of it. Now the icon is not vertically aligned. I tried using svg which works fine and it's alignment is not affected by the font-size of the button. Why is that. Picture and codepen link are given. CODE PEN: font-size on line 37. https://codepen.io/Arslan-Akbar/pen/oNJMNqY...
No description

Struggling with the new view transitions API

Hi! I am exploring the View transitions API. I have a simple demo with just a box that changes background-color and width on click. Since I see some things I don't understand (the height also changes during animation) I wanted to try to debug/replay it in the browser dev tools. EDIT: I kinda solved it, but I am struggling with the API itself. Please jump down to the latest reply I open the Animations drawer, I click the box, I record the animation, I see it right there. But I cannot figure out how to "replay it". When I click play, change speed, or draw manually, nothing happens in the main browser window. I don't understand. What do I have to do to actually see the animation being replayed....
No description

IntersectionObserver [JS]

Hello, I'm attempting to use IntersectionObserver() in JS to create a lazy loading effect. My code at the moment is the basic setup. Where I'm stuck at the moment is trying to figure out how to detect the child of the element being observed. Basically, I want to check if .cards is observed and if true, console.log which card is within the intersection. Thanks 👍 ...

Button positioning

Pls how do I make this buttons stay on the same position regardless of how the paragraphs words wrap? I've googled & chatgtp how to do it and the answers see don't work, probably because Google doesn't understand my question precisely...
No description

NextJS,

I have a Next.js application where I've replaced React with Preact. In the profiler, I notice that the rendering time for the Portal, specifically for the 'next-route-announcer,' ranges from 1.5 to 3 seconds. I'm trying to identify the root cause of this delay. What areas should I investigate to pinpoint the issue?
No description

dynamic size with only clamp, min and max

I have a div, I want its width to be 50% as long as 95vw is not possible. If 95vw is possible, I want 95vw to be the width. Can I express this logic with clamp, min and max?

Instead of the background color "light blue" , I want to turn it light green for right and red

Red for wrong. I am using the document.body.style but its not working for some reason. Is there any other way I can get this done?
No description

responsive mobile button isnt working

im currently following a tutorial on how to create a responsive navbar put im struggling as i cant make the mobile button to work i use no libs on my site here is all my code needed...

JavaScript question

So apparently the correct answers is 3. I don’t get why there are 3 loops before the code stops. In the 3rd loop i = 2 and x = 3. Shouldn’t there be 1 more loop since i < 3 . I get why x = 3 what I don’t get is my the loops stops there at i = 2 and x = 3 . i still smaller than 3
No description

Code Pen to Local system?

Hi All! I have moved Kevin's Code Pen https://codepen.io/kevinpowell/pen/BavVLra to my local system and every thing works except for the animation. Other than copy, paste, and linking the css and js to the HTML file is there something else I need to do to get this to work? Thank you....

How do i link my HTML to JS?

Im a beginner so its my first time ever doing this.

Question on CSS Cascade algorithm

I was learning about css cascade algorithm and when trying it out in browser i saw a weird behaviour. for any css property - an user agent stylesheet is specified as !important cannot be overriden by author style sheet. which is true and correct. take this example : ...
No description

Code doesn't run on vscode

https://codepen.io/Ned-Michael/pen/eYbKONr Hello, the code works perfectly on Codepen, anytime I try to run it on vs studio my CSS file doesn't show up on the web page, meanwhile, I've linked successfully on my HTML file....