Where did I mess up the html

Hello IM trying to do another FEM Challenge and just ready with the html Live : https://roelofwobben.github.io/browser-extenstion/ But it looks to me I messed up the html somewhere because some text appears way to the bottom. Did I mess up the html or is there something more wrong ? @ἔρως @vince
2466 Replies
vince
vince7mo ago
I don't see any css here?
vince
vince7mo ago
No description
vince
vince7mo ago
(ignore the highlighted line)
roelof
roelofOP7mo ago
that is correct. That is the next step if the html is allright
vince
vince7mo ago
I don't know what it's supposed to look like but it says you can remove the text at the bottom if you plan on imported it dynamically it's placed at the bottom so it appears at the bottom
roelof
roelofOP7mo ago
oke, I will take a look and as from tomorrow add the css I think it will be a lot of css 😦 First I want to make it work with a fixed text
vince
vince7mo ago
sounds like fun!
roelof
roelofOP7mo ago
we see the next coming days First I have to make the light theme work and then the changes for the dark theme some 13 colors in both so a lot to find out but we get there some day @vince but the html look well to you ?
vince
vince7mo ago
I don't know enough about the program to tell I can critique once you have something more
roelof
roelofOP7mo ago
oke then time to write a lot of css with a lot of colors Will costs me a few days I think and I hope I can use that pen from Kevin as example how I can make this work @vince how long would you do with this challenge ?
vince
vince7mo ago
How long should it take you? Doesn't matter, you're learning and you're doing it as a hobby. Have fun with it
roelof
roelofOP7mo ago
No idea how long it takes me cannot look into the future how many energy I have on a day but I think 1 week for the light and one week for the dark modus
vince
vince7mo ago
If you set up the light mode right it should just be a matter of making the switching functionality for the dark mode So like for example if you have a body background color:
body {
background-color: var(--background-color);
}
body {
background-color: var(--background-color);
}
Just use css props and you can toggle the value depending on if they're on light or dark moded
roelof
roelofOP7mo ago
yep, that is the same "trick" as Kevin did here https://codepen.io/kevinpowell/pen/EMdjOV
Kevin
CodePen
darkmode
...
roelof
roelofOP7mo ago
From tomorrow I will try to write the css I hope I can make it work. Afraid that this is more then I can chew and need a positve thing in my life not another failed thing
vince
vince7mo ago
Don't look at it as a failure look at it as a learning experience You're doing it for fun no need to put pressure on it
roelof
roelofOP7mo ago
I know but I m a person who like to do things very good And less feels like failure
ἔρως
ἔρως7mo ago
it shouldn't
vince
vince7mo ago
You can't do things very good without doing things very bad You should see some of my old stuff from years ago And I'm sure 5 years from now I'll be like 'why did I do it this way' when looking at my current stuff
bfmv
bfmv7mo ago
wow i just moved on from this project few hours ago
roelof
roelofOP7mo ago
and i just begin and alreadys stuck @vince can you help me figure out why the filter-container is on the same height as the header Now the header does not take the whole width and the logo is not on the right of the div Live page : https://roelofwobben.github.io/browser-extenstion/ IM now busy with the mobile The desktop I will do after the mobile is ready
vince
vince7mo ago
You have it in a flex container 😄
roelof
roelofOP7mo ago
No description
vince
vince7mo ago
No description
vince
vince7mo ago
And everything is in the header
roelof
roelofOP7mo ago
oke I did it in a flex so I can use space-between between the two items which must be in the header
vince
vince7mo ago
Then you want them on the same line?
roelof
roelofOP7mo ago
the both icons , yep, I want them on the same line I take a break Now things are really messed up @vince updated my repo @vince if and when you have time . can you help me with 2 things First the header does not want to be centered Second how do I get rid of the border on the moon icon ?
vince
vince7mo ago
Put in some work and let me know when you're really stuck, it wouldn't be any benefit if I showed you the code right when you don't know how to do something
roelof
roelofOP7mo ago
I dd put some work in it And tried every "trick" I know
vince
vince7mo ago
Have you tried googling it? 'How to remove button border css'
roelof
roelofOP7mo ago
yep, for the border I did
vince
vince7mo ago
What did you find? Did it work?
roelof
roelofOP7mo ago
I tried :
border: none
border: none
and
border-color: var(--<color>)
border-color: var(--<color>)
where <color> is the color I need chips, I see my errror I did it on the svg not on the button 😦
vince
vince7mo ago
Var(--color) is a custom property, that wouldn't work Ahh classic haha
roelof
roelofOP7mo ago
oke now I hope I can find out why the header is not centered think I solved it also now a break till tomorrow and I hope your are happy with the css so far @vince
vince
vince7mo ago
I dont have enough bandwidth to review the code unfortunately but if it works its good enough haha
roelof
roelofOP7mo ago
it looks like it working but I think I use already too much css
bfmv
bfmv7mo ago
have u finished it
roelof
roelofOP7mo ago
nope, I still have to do the cards thing @bfmv this is how far I am https://roelofwobben.github.io/browser-extenstion/
bfmv
bfmv7mo ago
oh nice
roelof
roelofOP7mo ago
@ἔρως @vince Can one of your two help me figure out why the devlens icon is getting bigger when I do :

width: 70%

width: 70%
Live : https://roelofwobben.github.io/browser-extenstion/
ἔρως
ἔρως7mo ago
because that's how images work the image, by default, will be resized proportionally
roelof
roelofOP7mo ago
oke but I expect when I do 70% the image will be smaller not bigger
ἔρως
ἔρως7mo ago
there is a bug somewhere 🤔
roelof
roelofOP7mo ago
yep and I cannot see where
ἔρως
ἔρως7mo ago
me neither
roelof
roelofOP7mo ago
Then I hope vince sees it
ἔρως
ἔρως7mo ago
on the first .extension you have a .content-extension the other ones don't have that <div>
ἔρως
ἔρως7mo ago
removing it makes everything look the same
No description
ἔρως
ἔρως7mo ago
adding to the others makes them behave like the first
No description
ἔρως
ἔρως7mo ago
the difference is the display: flex that that .content-extension has
roelof
roelofOP7mo ago
I know I have to rewritten the rest. Want to have first one ready @ἔρως @vince can be be a good solution to make the height and width in px instead of in % ? Or is then the image not responsive anymore ?
ἔρως
ἔρως7mo ago
you can set a width or height
roelof
roelofOP7mo ago
I know but for responsive images I think I can better use % then px ?
ἔρως
ἔρως7mo ago
you can use px
roelof
roelofOP7mo ago
oke, with px I can solve it This look better
roelof
roelofOP7mo ago
No description
roelof
roelofOP7mo ago
next : to make the remove button pretty and add a switch
vince
vince7mo ago
I use px all the time beginner trap that you shouldn't use them
roelof
roelofOP7mo ago
@vince oke Kevins says that for margins and so you can better use em And for fonts better em HRU @vince
ἔρως
ἔρως7mo ago
for fonts, usually, it's better to use rem the problem with em is that it uses the font-size of the parent that means that the font-size may end up being completely different than expected
vince
vince7mo ago
Yea use a mix of everything really, just need to understand how the different units work
ἔρως
ἔρως7mo ago
exactly you can use rem for sizes, but you will be surprised
roelof
roelofOP7mo ago
oke, the light theme is done What do you experts think of it Live version : https://roelofwobben.github.io/browser-extenstion/ @ἔρως @vince
vince
vince7mo ago
sorry i am doing a ton of overtime recently and don't have bandwidth to really look at this 😦
roelof
roelofOP7mo ago
oke, no problem
ἔρως
ἔρως7mo ago
the channel for reviews is #showcase
roelof
roelofOP7mo ago
I know but the challenge is not complete
ἔρως
ἔρως7mo ago
you have a bug: 2 of the cards have > showing
roelof
roelofOP7mo ago
both solved @ἔρως I m more curious if the css has not to many things
ἔρως
ἔρως7mo ago
it seems fine to me
roelof
roelofOP7mo ago
Thanks then now time for the dark theme 🙂 but not today anymore
vince
vince7mo ago
What's the mobile design look like in the figma / image they gave you?
No description
vince
vince7mo ago
Spacing / font sizes / padding all look a bit off imo
roelof
roelofOP7mo ago
GitHub
browser-extenstion/design/mobile-design-light.jpg at main · Roelof...
Contribute to RoelofWobben/browser-extenstion development by creating an account on GitHub.
roelof
roelofOP7mo ago
otherwise here a image
No description
vince
vince7mo ago
ah okay it's a bit different compared to the design
roelof
roelofOP7mo ago
oops. then I have to change some things I wanted to be as close as possible I know a toggle switch is missing and I wanted to add them as soon as possible if you have other things , just write here and I try to change them
vince
vince7mo ago
The buttons and italicized text
roelof
roelofOP7mo ago
Can you be more specific what is wrong there ?
vince
vince7mo ago
The buttons are too large and the original design doesn't use the italicized text
roelof
roelofOP7mo ago
oke, then I have to find out how big the buttons must be
vince
vince7mo ago
Look at the design and then replicate that. It's probably because your padding is too large and you need more border radius on them
roelof
roelofOP7mo ago
I know , the design does not say explicit how big things must be So I have to eye-ball things like padding and width
vince
vince7mo ago
Yup that's how it'll be in real work too unless your designer is really good
roelof
roelofOP7mo ago
and this time eyeballing is diffcul t because on Windows image viewer I cannot know when the picture is on 100%
vince
vince7mo ago
Yea its definitely harder when you only have an image to reference. If you wanna keep doing frontend mentor I think if you pay for their subscription they give you figma files which would make it easier
roelof
roelofOP7mo ago
yep, and paying for me is not a option
vince
vince7mo ago
Do you have venmo? I can send you the cost of a month's subscription
roelof
roelofOP7mo ago
I do not and no-one have to pay for me
vince
vince7mo ago
Okay no worries
roelof
roelofOP7mo ago
Then I rather quit FE work
vince
vince7mo ago
Why?
roelof
roelofOP7mo ago
I rather quit then someone pay for my hobby
vince
vince7mo ago
It's not that serious man I was just trying to do something nice 😂
roelof
roelofOP7mo ago
oke no problem
roelof
roelofOP7mo ago
@vince is this better ?
No description
vince
vince7mo ago
Text is too close to the right and font is still italicized Also your font size is set in px not rem And you have a width in px remove the width
roelof
roelofOP7mo ago
you mean the width of the remove button. I did that because otherwise the text will be outside the button and with the text also the button text ??
vince
vince7mo ago
yyea the font being italicized is for the italicized text and the rest of it is about the button
roelof
roelofOP7mo ago
Can you help me to make the button good ? and I do not see why the text is italicized aha, I see it I choose the wrong font in my font-definition If I did it right, the text should be good now font-sizes are now in rem Can you still help me to make the buttons right ?
vince
vince7mo ago
I already gave you my suggestions above
vince
vince7mo ago
No description
vince
vince7mo ago
If you remove the set width that should get rid of the 'text is too close to the right' issue Then you probably just need to mess with the padding a little bit to get the size closer to the design
roelof
roelofOP7mo ago
Those I already solved it all except the font is too close to the right
roelof
roelofOP7mo ago
I have to think how to solve this problem :
No description
roelof
roelofOP7mo ago
the button takes now the whole div 😦
vince
vince7mo ago
Try max-width: fit-content
roelof
roelofOP7mo ago
That looks a lot better now I have to decrease the font-size so it will look the same as the picture hmm, this looks more then the picture but I find the button now very small nope, this looks not the same
roelof
roelofOP7mo ago
No description
roelof
roelofOP7mo ago
Have to think what my next step then will be or are you now totally happy ? @vince
vince
vince7mo ago
Looks good enough, there's still things I would change but I don't have time to go over them Good job
roelof
roelofOP7mo ago
thanks
ἔρως
ἔρως7mo ago
the text is different - the color is more muted on the original design the spacing under the title is too small, compared to the design
roelof
roelofOP7mo ago
What do you mean with muted : a lighther grey ?
ἔρως
ἔρως7mo ago
yes, but on your version it is blue
roelof
roelofOP7mo ago
blue ?? I never used blue anywhere if I look it looks like the weight needs to be lower
ἔρως
ἔρως7mo ago
this looks like blue text to me
No description
ἔρως
ἔρως7mo ago
dark blue
roelof
roelofOP7mo ago
oke according to the data I got it is this color: hsl(227, 75%, 14%); now I see it on a bigger image I can image that you say it is blue Then i have to choose between those :
--font-color: hsl(227, 75%, 14%);
--neutral800: hsl(226, 25%, 17%);
--neutral700: hsl(225, 23%, 24%);
--neutral600: hsl(226, 11%, 37%);
--font-color: hsl(227, 75%, 14%);
--neutral800: hsl(226, 25%, 17%);
--neutral700: hsl(225, 23%, 24%);
--neutral600: hsl(226, 11%, 37%);
ἔρως
ἔρως7mo ago
that is dark blue - #09153e probably the 600 onr one
roelof
roelofOP7mo ago
oke, I will change it now
roelof
roelofOP7mo ago
this better :
No description
ἔρως
ἔρως7mo ago
the best way to get the color is this way: - open the image in paint - zoom to the max, on the color you want - use the color picker tool - click on an area of uniform color - click on the custom color thingy - copy the values from there the title and the logo were correct just the text that wasnt
roelof
roelofOP7mo ago
oke, then it uses two colors for the text I can change that
ἔρως
ἔρως7mo ago
the title has the dark blue the text under it has that neutral 600
roelof
roelofOP7mo ago
oke then I have to make a variable for heading-font-color and font-color
ἔρως
ἔρως7mo ago
no, just one for the text
roelof
roelofOP7mo ago
this better :
No description
ἔρως
ἔρως7mo ago
the color of the "remove" button is incorrect it is the same dark blue as everything else but you have it as the same color as the text under the title
vince
vince7mo ago
font-weigght too
ἔρως
ἔρως7mo ago
and the spacing under the tifle title
vince
vince7mo ago
yup and some more spacing between the button and text
No description
vince
vince7mo ago
id add just a tad bit more
ἔρως
ἔρως7mo ago
the title is also too big you need to reduce it by about 2px
roelof
roelofOP7mo ago
you mean the Extensions one or the name of the extension ?
ἔρως
ἔρως7mo ago
the name of the extension if you compare with the design, the title goes a bit under the beginning of the symbol in your version, it reaches under the line, on the first extension
vince
vince7mo ago
Also box shadow on the card as well (and maybe a slight gray border? I can't tell from the screenshot)
roelof
roelofOP7mo ago
This better :
No description
vince
vince7mo ago
It does look a lot better yea, title still too large though
ἔρως
ἔρως7mo ago
and needs more font-width weight so, try removing 2 more pixels and revert to the previous font-weight
roelof
roelofOP7mo ago
next try
No description
roelof
roelofOP7mo ago
I now remember why I left FE work this little things costs a lot of time to get right
ἔρως
ἔρως7mo ago
the remove button is still wrong
vince
vince7mo ago
it's why a lot of people don't like it, lots of back and forth with clients lol
ἔρως
ἔρως7mo ago
the color needs to be the same as the title
roelof
roelofOP7mo ago
oke moment
ἔρως
ἔρως7mo ago
it's a huge list of tiny details. if you miss one and you have 300 different things, you are screwed you need to check one by one
roelof
roelofOP7mo ago
oke, button is changed
ἔρως
ἔρως7mo ago
now, the switch is missing
roelof
roelofOP7mo ago
I know that is the next thing I would add when this is "perfect" I know custom switches are also a pain in the ass
ἔρως
ἔρως7mo ago
not at all you will see can you show the result you have, and send the image of what you need to implement?
roelof
roelofOP7mo ago
and I have to adapt the html to make it work it is on the same line as the button
ἔρως
ἔρως7mo ago
is the button in a div?
roelof
roelofOP7mo ago
at this moment, I do not think so LIve version till now : https://roelofwobben.github.io/browser-extenstion/
ἔρως
ἔρως7mo ago
im on the phone, cant see the code
roelof
roelofOP7mo ago
No description
roelof
roelofOP7mo ago
my version till now :
No description
ἔρως
ἔρως7mo ago
the "extension list" and the filters are in the wrong place
roelof
roelofOP7mo ago
one thing I see is that the text has to be wrapped earlier
ἔρως
ἔρως7mo ago
the text wrapping in something you cant control that well
roelof
roelofOP7mo ago
chips, that is somewhere lost, that the heading and buttons must be on the same line
ἔρως
ἔρως7mo ago
oh, by the way, the title of the page is too big and has too much font-weight and needs to be center aligned vertically that alignment has to be done for the button and switch too
roelof
roelofOP7mo ago
solved
ἔρως
ἔρως7mo ago
nice
roelof
roelofOP7mo ago
No description
ἔρως
ἔρως7mo ago
i was wrong, it needs more font-weight and the filters are less wide
roelof
roelofOP7mo ago
the title "Extensions" ??
ἔρως
ἔρως7mo ago
and the red is wrong yes
roelof
roelofOP7mo ago
for the red I have these choices

--red400: hsl(3, 86%, 64%);
--red500: hsl(3, 71%, 56%);
--red700: hsl(3, 77%, 44%);

--red400: hsl(3, 86%, 64%);
--red500: hsl(3, 71%, 56%);
--red700: hsl(3, 77%, 44%);
roelof
roelofOP7mo ago
No description
ἔρως
ἔρως7mo ago
try the 700 the 700 no doubt
roelof
roelofOP7mo ago
No description
roelof
roelofOP7mo ago
and you had a remark about the buttons
ἔρως
ἔρως7mo ago
looks correct to me yes: they are too wide remove the padding
roelof
roelofOP7mo ago
the filter buttons ?
ἔρως
ἔρως7mo ago
yes
roelof
roelofOP7mo ago
looks not right to me now
roelof
roelofOP7mo ago
No description
roelof
roelofOP7mo ago
Thet looking very small to me
ἔρως
ἔρως7mo ago
okay, then put 4px 0px for the padding
roelof
roelofOP7mo ago
No description
roelof
roelofOP7mo ago
you both happy nowa and I can implement that switch ?
ἔρως
ἔρως7mo ago
it's still too wide
roelof
roelofOP7mo ago
😢
ἔρως
ἔρως7mo ago
remove the width
roelof
roelofOP7mo ago
now they are looking very ugly
No description
ἔρως
ἔρως7mo ago
did you use flex for that? buttons arent supposed to do that
roelof
roelofOP7mo ago
nope, I do not use flex
ἔρως
ἔρως7mo ago
width: min-content try that
roelof
roelofOP7mo ago
nothing changes also max-content changes nothing
ἔρως
ἔρως7mo ago
Edit fiddle - JSFiddle - Code Playground
JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.
ἔρως
ἔρως7mo ago
something else is causing troubles, and i bet it is the flex on the parent
roelof
roelofOP7mo ago
As far as I can see not
ἔρως
ἔρως7mo ago
just move on to the switch then
roelof
roelofOP7mo ago
.filter-options is the direct parent and that one has not display: flex
ἔρως
ἔρως7mo ago
we will figure if out later the parent of that one
roelof
roelofOP7mo ago
filter-container has display: flex but that one I need to place the title and the buttons on the right place and removing that one changes nothing on the buttons
ἔρως
ἔρως7mo ago
then something else is doing that but move on to the switch
roelof
roelofOP7mo ago
oke boss 😛
ἔρως
ἔρως7mo ago
do you have any idea on how you will do it?
roelof
roelofOP7mo ago
yes first make a div I think I calll card-footer in that the button and the switch like this :
<input type="checkbox">
<input type="checkbox">
the div I can use display: flex and justify-content: space-around to put them hopefully on the right place and then google how to make the switch like the picture looks to me that I have to "remove" the old one and make then a new one which looks like I want to
ἔρως
ἔρως7mo ago
that is not a good implementation
roelof
roelofOP7mo ago
😦
ἔρως
ἔρως7mo ago
the checkbox isnt focusable no focus means phisically debilitated people can't use tab navigation or other methods and visually impaired will never know the input is there
roelof
roelofOP7mo ago
That is the disadvantage of using google You never know if the person who wrote it , knows things
ἔρως
ἔρως7mo ago
listen, 99% of it will well implemented it's just this big issue that causes it to be a "nope"
roelof
roelofOP7mo ago
I understand
ἔρως
ἔρως7mo ago
you can use it, but be aware of the issue it's fine for what you are doing for a real project for the public, then it isnt a good implementation
roelof
roelofOP7mo ago
Oke and I like to learn things well so my feeling is now if a big implementation is not right I do not want to learn that way
ἔρως
ἔρως7mo ago
there are way too many ways to skin this cat what you can do is to use a label with a visually hidden text for visually impaired
roelof
roelofOP7mo ago
I know
ἔρως
ἔρως7mo ago
then put the checkbox inside the label
roelof
roelofOP7mo ago
Creating a CSS-Only Toggle Switch
How to create a functional and accessible switch component with HTML and CSS (without JavaScript) There are many articles online about how to create a switch using HTML and CSS only, without any JavaScript. How will this one be different? What value will it add to the existing articles? Why did I write it? :: Blog post at Alvaro Montoro's Person...
roelof
roelofOP7mo ago
ask 10 developers to solve this and you get between 10 - 20 solutions and they all work and they are all good
ἔρως
ἔρως7mo ago
honestly, that is a really good article and parrots some of the things i said follow his final approach then tweak it to fit your colors
roelof
roelofOP7mo ago
oke, boss :p The only thing I have to find out is the colors and maybe the dimisions you mean this css :
input:where([type="checkbox"][role="switch"]) {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
position: relative;
font-size: inherit;
width: 2em;
height: 1em;
box-sizing: content-box;
border: 1px solid;
border-radius: 1em;
vertical-align: text-bottom;
margin: auto;
color: inherit;
}

input:where([type="checkbox"][role="switch"])::before {
content: "";
position: absolute;
top: 50%;
left: 0;
transform: translate(0, -50%);
box-sizing: border-box;
width: 0.7em;
height: 0.7em;
margin: 0 0.15em;
border: 1px solid;
border-radius: 50%;
background: currentcolor;
}

input:where([type="checkbox"][role="switch"]):checked::before {
left: 1em;
}
input:where([type="checkbox"][role="switch"]) {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
position: relative;
font-size: inherit;
width: 2em;
height: 1em;
box-sizing: content-box;
border: 1px solid;
border-radius: 1em;
vertical-align: text-bottom;
margin: auto;
color: inherit;
}

input:where([type="checkbox"][role="switch"])::before {
content: "";
position: absolute;
top: 50%;
left: 0;
transform: translate(0, -50%);
box-sizing: border-box;
width: 0.7em;
height: 0.7em;
margin: 0 0.15em;
border: 1px solid;
border-radius: 50%;
background: currentcolor;
}

input:where([type="checkbox"][role="switch"]):checked::before {
left: 1em;
}
ἔρως
ἔρως7mo ago
yup
roelof
roelofOP7mo ago
oke, will be tomorrow
ἔρως
ἔρως7mo ago
alright
roelof
roelofOP7mo ago
im tired today because my guts feel not right
ἔρως
ἔρως7mo ago
go rest then
roelof
roelofOP7mo ago
I will I did some naps during the day
ἔρως
ἔρως7mo ago
naps are good
roelof
roelofOP7mo ago
Thanks for being my mentor today @ἔρως @vince
ἔρως
ἔρως7mo ago
you're welcome
roelof
roelofOP7mo ago
got a feeling I can be a good FE dev as a hobby @ἔρως hopefully we will find out why the buttons act so wierd
ἔρως
ἔρως7mo ago
it takes practice i will take a peek in an hour or 2
roelof
roelofOP7mo ago
and a person or persons who teach you things that you did not see
ἔρως
ἔρως7mo ago
that comes from experience and practice
roelof
roelofOP7mo ago
again both thanks
ἔρως
ἔρως7mo ago
you're welcome
roelof
roelofOP7mo ago
Nobody still a idea why my filter buttons are messed up ?
ἔρως
ἔρως7mo ago
i haven't checked im tired today
roelof
roelofOP7mo ago
oke, then take rest I can tommrrow try to make the switch
ἔρως
ἔρως7mo ago
yeah, try to make it
roelof
roelofOP7mo ago
with the tutorial I found, it schould not be too difficult
ἔρως
ἔρως7mo ago
it won't
roelof
roelofOP7mo ago
oke, time to take my heart drugs and back to bed
ἔρως
ἔρως7mo ago
do that. tomorrow, there's more work for you
roelof
roelofOP7mo ago
yep bring my daugther to work , make that switch and maybe begin with the dark theme
ἔρως
ἔρως7mo ago
should be pretty relaxed
roelof
roelofOP7mo ago
yep day after tomorrow , therapy day so a little less relaxed GN
ἔρως
ἔρως7mo ago
goodnight
roelof
roelofOP7mo ago
@ἔρως @vince it looks to me I still need a width to make alll three buttons the same width
ἔρως
ἔρως7mo ago
i don't know why it is doing that, and i am all out of ideas
roelof
roelofOP7mo ago
me too but I hate it that it is looking so wierd now
ἔρως
ἔρως7mo ago
just set the width
roelof
roelofOP7mo ago
oke, then time for the switch something like this :
roelof
roelofOP7mo ago
No description
ἔρως
ἔρως7mo ago
yeah, you can set the width a bit smaller for the first one, but that is fine
roelof
roelofOP7mo ago
o, I always thought they need all three to be a even width
ἔρως
ἔρως7mo ago
no, you can set a width for just the first one
roelof
roelofOP7mo ago
chips, you are right All three have a different width I hope then I can solve this with n-child I can I think
roelof
roelofOP7mo ago
This looks good :
No description
ἔρως
ἔρως7mo ago
it does look a lot better not perfect, but a lot better
roelof
roelofOP7mo ago
chips. I wanted it to be perfect 😢
ἔρως
ἔρως7mo ago
the padding is too little
roelof
roelofOP7mo ago
on all three ?? This is what is the paddig now :
padding: 4px 0px;
padding: 4px 0px;
maybe something like
padding: 8px 2px
padding: 8px 2px
?
roelof
roelofOP7mo ago
So like this :
No description
ἔρως
ἔρως7mo ago
like that, but the width is incorrect
roelof
roelofOP7mo ago
😢 which width ? this better
roelof
roelofOP7mo ago
No description
roelof
roelofOP7mo ago
I forgot to commit the lastest code
ἔρως
ἔρως7mo ago
yeah, it is better
roelof
roelofOP7mo ago
oke, Then now take care that my daugther comes home from work And then the switch then the dark theme and then a lot of js 😦
ἔρως
ἔρως7mo ago
lots of js? for what?
roelof
roelofOP7mo ago
To make the theme switcher work To make the filtering work to change from active to not-active
ἔρως
ἔρως7mo ago
if you use isotope, you don't have to implement the filtering css does that
roelof
roelofOP7mo ago
oke but still I need then to store or change things in localstorage then I need to use js
ἔρως
ἔρως7mo ago
yeah, but it isn't as much as you think
roelof
roelofOP7mo ago
we see when we get there but isotope looks a good way I see that there even is animations like I have in mind
ἔρως
ἔρως7mo ago
yup, and you don't have to do 3000 lines of js and css to handle that it's okay to use things that others did, specially if they did it way better than we can do it i know i couldn't do it without spending a buttload of time on it
roelof
roelofOP7mo ago
🙂 it feels cheating but I see your point Why invent what is already invented
ἔρως
ἔρως7mo ago
precisely! and no, it isnt cheating
roelof
roelofOP7mo ago
for me it feels like cheating My biggest mental hole I fall in is that I feel I must do everything myself and I have to do it Failing is not a option
ἔρως
ἔρως7mo ago
that's the thing: you don't imagine writting the entire network stack from js because you dont want to use fetch you should use existing solutions for existing problems
roelof
roelofOP7mo ago
I know but a voice inside of me says I have to do it myself THat is one of the reason I get therapy now Time for the switch thing
ἔρως
ἔρως7mo ago
i know what you mean, but that will go away when you have to implement datatables
roelof
roelofOP7mo ago
this is not only when developing but in my whole life
ἔρως
ἔρως7mo ago
yeah, that is not good
roelof
roelofOP7mo ago
I going crazy
roelof
roelofOP7mo ago
No description
roelof
roelofOP7mo ago
I had three columns and suddenly it does not work anymore and I cannot set the switch to another state 😢
ἔρως
ἔρως7mo ago
probably something is overflowing in the browser tools, add an outline of 1px to everything
roelof
roelofOP7mo ago
the text says that flex-direction is not working with grid
vince
vince7mo ago
is it uploaded to the live site can u link plz
roelof
roelofOP7mo ago
live link : https://roelofwobben.github.io/browser-extenstion/ I think somehow the switch is too blame Before it worked well
ἔρως
ἔρως7mo ago
i think so too
roelof
roelofOP7mo ago
I have it the extension div was not closed properly so the layout is allright now but still the switch does not work I cannot change it
vince
vince7mo ago
your html is messed up
No description
vince
vince7mo ago
oh okay was just about t say that lol
roelof
roelofOP7mo ago
sorry any idea why I cannot change the "status" of the switch ?
vince
vince7mo ago
No idea tbh, don't know why it isn't working
roelof
roelofOP7mo ago
I also not
vince
vince7mo ago
Oh it's because you have role="switch" you probably need custom js to get it to work with that, idk I've never worked with aria roles
roelof
roelofOP7mo ago
Wierd then
vince
vince7mo ago
MDN Web Docs
ARIA: switch role - ARIA | MDN
The ARIA switch role is functionally identical to the checkbox role, except that instead of representing "checked" and "unchecked" states, which are fairly generic in meaning, the switch role represents the states "on" and "off."
vince
vince7mo ago
MDN docs use a button not an input
roelof
roelofOP7mo ago
I borrowed the code here : https://codepen.io/alvaromontoro/pen/OJZOXMG and there no js is used
vince
vince7mo ago
You'll definitely need custom js I don't think theirs even works Like it moves the switch thing but the inputs never have the checked state
roelof
roelofOP7mo ago
aha and with me , i cannot move it
vince
vince7mo ago
<button
type="button"
role="switch"
aria-checked="true"
id="speakerPower"
class="switch">
<span aria-hidden="true">off</span>
<span aria-hidden="true">on</span>
</button>
<label for="speakerPower" class="switch">Speaker power</label>
<button
type="button"
role="switch"
aria-checked="true"
id="speakerPower"
class="switch">
<span aria-hidden="true">off</span>
<span aria-hidden="true">on</span>
</button>
<label for="speakerPower" class="switch">Speaker power</label>
I would just use this from MDN and customize it Style it based off if aria-checked='true' and in JS, when you click it make aria-checked either true or false depending on its previous state
roelof
roelofOP7mo ago
Creating a CSS-Only Toggle Switch
How to create a functional and accessible switch component with HTML and CSS (without JavaScript) There are many articles online about how to create a switch using HTML and CSS only, without any JavaScript. How will this one be different? What value will it add to the existing articles? Why did I write it? :: Blog post at Alvaro Montoro's Person...
roelof
roelofOP7mo ago
That trick I never saw. Use a button for a switch Most people uses a checkbox to make it work I do not use then the label because in the example there is no label for the switch
ἔρως
ἔρως7mo ago
that is going above and beyond to make it responsive i mean, accessible
roelof
roelofOP7mo ago
I do not think this is a remark for me ?
ἔρως
ἔρως7mo ago
no it isnt
roelof
roelofOP7mo ago
oke, so "must" I do it like vince says Or later make the js to make the switch work like the person who wrote the tutorial says :
The solution for many of these implementation issues: use JavaScript. Let's face it, HTML and CSS are powerful, but they are limited languages for some things. A progressive enhancement approach could be great with the initial HTML+CSS described above and minimal JS complementing it. No need for bloated HTML, CSS, or JavaScript. Let the browser do the job for you!
The solution for many of these implementation issues: use JavaScript. Let's face it, HTML and CSS are powerful, but they are limited languages for some things. A progressive enhancement approach could be great with the initial HTML+CSS described above and minimal JS complementing it. No need for bloated HTML, CSS, or JavaScript. Let the browser do the job for you!
vince
vince7mo ago
I just don't know how it would work with how he's done it - I checked the codepen and looked at the DOM and the inputs don't get a checked attribute? Maybe I'm missing something If the inputs don't have a checked attribute when you click them then why even use an input
roelof
roelofOP7mo ago
Like I posted before . He lets the reader write and think of how it must work in js but you have a point That is why I hate custom html things Very difficult to make it work properly
ἔρως
ἔρως7mo ago
you are: the :checked pseudo-class
vince
vince7mo ago
I thought the :checked psuedo class worked off if the input had a checked state Or is it independent Because look at the DOM in that codepen, if you click the input it doesn't get a checked attr That's why I'm like huh lol
roelof
roelofOP7mo ago
sorry im very confused now For me one is saying go further with what I have and the other is saying go for another approach 😢
vince
vince7mo ago
Just ignore for now lol You can do the approach u found i just don't know how to fix it for u
ἔρως
ἔρως7mo ago
it's independent it works with the property of the element, not the attribute
roelof
roelofOP7mo ago
still very wierd that on the codepen , it moves and on my site I cannot move that stupid thing
ἔρως
ἔρως7mo ago
probably something is missing
vince
vince7mo ago
I see, then what's really the point of using this over a button if we're just going to treat it like a button via JS? E.g input.onClick(toggle()) it's not like we're making use of the checked attribute to do anything
ἔρως
ἔρως7mo ago
because it's the correct element
vince
vince7mo ago
Is it though? Because the MDN article used a button instead
ἔρως
ἔρως7mo ago
also, we are: when you submit a form, the value is stored and he's supposed to make it save too
roelof
roelofOP7mo ago
found it I missed this on my css :

input:where([type="checkbox"][role="switch"]):checked::before {
left: 1em;
}

input:where([type="checkbox"][role="switch"]):checked::before {
left: 1em;
}
ἔρως
ἔρως7mo ago
that is an important one personally, i would use transform: translateX(-100%) for gpu acceleration, but that is good too it does the same, but is more performant
vince
vince7mo ago
i didn't know that was a thing goodd to know
roelof
roelofOP7mo ago
oke
ἔρως
ἔρως7mo ago
it is a thing
roelof
roelofOP7mo ago
switch is working and for me it is looking well
No description
ἔρως
ἔρως7mo ago
you can leave it as-is, dont worry
roelof
roelofOP7mo ago
so can I tomorrow work on the dark theme or must I change there something
vince
vince7mo ago
it's fine but id still use a button here but thats me 😉
ἔρως
ἔρως7mo ago
the colors and size have to be adjusted checkbox all the way
roelof
roelofOP7mo ago
o, I thought the size was allright @ἔρως
ἔρως
ἔρως7mo ago
you cant uncheck a button it's 4-6px too big
vince
vince7mo ago
u cant check a checkbox either though with how it's setup rn 😭 otherwise id agree
ἔρως
ἔρως7mo ago
yes you can
vince
vince7mo ago
look at the dom in that codepen bro 😭
ἔρως
ἔρως7mo ago
but it looks like a switch
roelof
roelofOP7mo ago
This better :
No description
roelof
roelofOP7mo ago
@ἔρως
ἔρως
ἔρως7mo ago
you dont need the checked attribute for it to be checked
vince
vince7mo ago
then how do screenreaders know its checked
ἔρως
ἔρως7mo ago
the size looks a lot closer now
roelof
roelofOP7mo ago
🙂
ἔρως
ἔρως7mo ago
the property not the attribute property
roelof
roelofOP7mo ago
Then finally tomorrow make the dark theme work
vince
vince7mo ago
idk what the difference is ill have to look it up, u mean css property? i didnt know screen readers could read those
roelof
roelofOP7mo ago
very maybe FE work can be a nice hobby
ἔρως
ἔρως7mo ago
no, js property try it yourself go to the mdn page for the checkboxes, and inspect the "horns" checkbox use the accessibility tools on the right, it will say "checked: false" check the "horns" checkbox then click on another element, in the accessibility tree, then go back to the "horns" checkbox what does it say? it is a nice hobby, but sometimes a pita
vince
vince7mo ago
interesting, i just dont know why it wouldnt add a checked attribute by default if its adding the js prop?? seems kinda stupid
ἔρως
ἔρως7mo ago
because it isnt a property that live updates the attribute when you set false, the correct way to handle the attribute is to remove it and that doesnt make sense that is why the :checked pseudo-class was added: to work around the fact the attribute wasnt updating or being added/removed because of the property name, id and class are some of the few that are updated when you set a value in the property, from js side
vince
vince7mo ago
ill have to read more into this
roelof
roelofOP7mo ago
colors worked also So if you both do not have any feedback it is time tomorrow for working on the dark theme 🙂 pita ?
ἔρως
ἔρως7mo ago
pain in the ass what do you have so far?
roelof
roelofOP7mo ago
yes, expecially when you both wanted very small changes 🙂 I have now the light theme working
ἔρως
ἔρως7mo ago
hey, the small changes are what takes it from "good" to "perfect"
roelof
roelofOP7mo ago
Todo : - dark theme - theme switcher in js - sorting in js - make the switch working in js
ἔρως
ἔρως7mo ago
there is a way to make the theme switching without js
roelof
roelofOP7mo ago
I know but they cost a lot of time and sometimes frustating
ἔρως
ἔρως7mo ago
i know it is
roelof
roelofOP7mo ago
@ἔρως only with css ? Then I think I have to rewrite a lot of css and html to make it work
ἔρως
ἔρως7mo ago
no, not at all
roelof
roelofOP7mo ago
and Kevin has a good tutorial to make it work with js
ἔρως
ἔρως7mo ago
it's a big shoddy, but will work
roelof
roelofOP7mo ago
shoddy ??
ἔρως
ἔρως7mo ago
yes, shoddy as in, not a great or ok solution
roelof
roelofOP7mo ago
I do not know that word oke
roelof
roelofOP7mo ago
I was using this as a example : https://codepen.io/kevinpowell/pen/EMdjOV
Kevin
CodePen
darkmode
...
vince
vince7mo ago
something like body:has(#dark-mode:checked) { --props }?
roelof
roelofOP7mo ago
O, i forget on my todo list - read the json file and use that for displaying the data so my todo is : Todo : 1) dark theme, make the active, focus and hover states work 2) theme switcher in js, 3) sorting in js, 4) make the switch working in js 5) read the json and make that display with js so a long way to go before this is ready I do not think that will work The icon is a button not a checkbox
vince
vince7mo ago
Hmmmmmmm wonder if it should be a checkbox 🤔 I don't know how other people implement it fyi I would totally make it a button too, but trying to think outside the box of what I usually do lol
roelof
roelofOP7mo ago
oke, I see that Kevin uses a button in his example
ἔρως
ἔρως7mo ago
yes, but > with a more specific selector too that is the last step personally, i like to either use a checkbox or a select (for 3+ themes)
roelof
roelofOP7mo ago
but still curious what @ἔρως has thought of a css solution
ἔρως
ἔρως7mo ago
literally this with tiny changes
roelof
roelofOP7mo ago
but that is the same as Kevin does in his tutorial but then he uses js to add and delete a class and to store the status in localstorage or do I misunderstood things
vince
vince7mo ago
it's really up to you however you want to do it you'll need js no matter what to save the preference to local storage anyway i think
roelof
roelofOP7mo ago
@vince off topic question : Who are on your avatar ?
vince
vince7mo ago
it's from a game called Yakuza
roelof
roelofOP7mo ago
oke The :focus is only for screen-readers or also for the rest of the world
ἔρως
ἔρως7mo ago
you do, yeah both
roelof
roelofOP7mo ago
oke because here I have to do something with the focus, active and hover states
vince
vince7mo ago
yea those are a real PITA I hate doing input styles 😂 So many states
roelof
roelofOP7mo ago
not so many changes are asked for if I look at the images Sometimes the background changes, sometimes the border so not a lot of work
ἔρως
ἔρως7mo ago
border is for focused, background is for checked but only change the border color, not size
roelof
roelofOP7mo ago
correct if I look very swift
ἔρως
ἔρως7mo ago
usually, that is how it works then there is hover, which changes the border and/or the background and/or the tick mark
roelof
roelofOP7mo ago
I have to think if I do this first or first the dark theme but first dinner and relaxing Tomorrow a lot of therapy 😦
ἔρως
ἔρως7mo ago
and rest
roelof
roelofOP7mo ago
I already slept from 9 till 14.00 hours today 🙂 and sleeping is around 22:00 h so I think first the states and then the dark theme @ἔρως is there also a js library for a dark / light theme switcher
ἔρως
ἔρως7mo ago
probably i dont know any
vince
vince7mo ago
You don't want to use one there's no point, it's easily done with regular css / js You can do most of it with :root:has(#dark-mode-checkbox:checked) { --props } if you use a checkbox instead of a button So you would do something like
:root {
--text-color: black;
}

:root:has(#dark-mode-checkbox:checked) {
--text-color: white;
}
:root {
--text-color: black;
}

:root:has(#dark-mode-checkbox:checked) {
--text-color: white;
}
Then the only thing you'd need to do I believe is save the preference to localStorage w/ JS
ἔρως
ἔρως7mo ago
basically it's also nice to have a way to use the system setting, but it's fine if you dont use it
vince
vince7mo ago
Ye which is with https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
@media (prefers-color-scheme: dark) {}
@media (prefers-color-scheme: dark) {}
Though maybe that's why Kevin uses a class, how would you write this because you'd have to duplicate the props no?
ἔρως
ἔρως7mo ago
basically, yes
vince
vince7mo ago
I think I'd still rather keep it to css even if it's duplicated honestly Less logic but that's just me
ἔρως
ἔρως7mo ago
actually no you can check a media query and use js to set the checked state of the checkbox you can do this: - read from local storage - check if dark mode is set in the media query - fallback to light mode you can use a class, or an attribute - both work or just set the checkbox on loading
roelof
roelofOP7mo ago
Oke so change the button to a checkbox Can i then use the different icons when only use css when using a checkbox?
ἔρως
ἔρως7mo ago
yes hide one and show the other
roelof
roelofOP7mo ago
maybe use the same trick as I used to make the switch work ?
ἔρως
ἔρως7mo ago
like the switch, but instead of moving left and right you show a different icon
roelof
roelofOP7mo ago
oke then I have to look where I use that icon exactly In the content or in a another property so some css to rewrite 😦
ἔρως
ἔρως7mo ago
under the checkbox
roelof
roelofOP7mo ago
??
ἔρως
ἔρως7mo ago
- checkbox - icon 1 - icon 2
roelof
roelofOP7mo ago
o I thought I could do this :
:root:has(#dark-mode-checkbox:checked) {
background-image : url(./asset/images/moon.svg)
:root:has(#dark-mode-checkbox:checked) {
background-image : url(./asset/images/moon.svg)
And then on root :

:root {
back-ground-image: url(./asset/images/sun.svg)
}

:root {
back-ground-image: url(./asset/images/sun.svg)
}
or something similar with the right classes for the checkbox @ἔρως and then in the css
background-image : var(--back-ground-image) ;
background-image : var(--back-ground-image) ;
on the right class
ἔρως
ἔρως7mo ago
you can, but that is not how i would do it
roelof
roelofOP7mo ago
How would you then do it ?
ἔρως
ἔρως7mo ago
as i said: the icons after the checkbox then show/hide based on the checked state
roelof
roelofOP7mo ago
Hmm have to think how to make that work. Right now i do not see it
ἔρως
ἔρως7mo ago
same thing as the switch but show/hide the elements afted the checkbox
vince
vince7mo ago
input:checked ~ .icon {}
input:checked ~ .icon {}
ἔρως
ἔρως7mo ago
basically
roelof
roelofOP7mo ago
what does ~ mean ? and how do I then do the unchecked state sorry, I find your way still confusing
ἔρως
ἔρως7mo ago
the unchecked state is the default
roelof
roelofOP7mo ago
so it will be
input ~ .icon {}
input ~ .icon {}
ἔρως
ἔρως7mo ago
yeah
roelof
roelofOP7mo ago
oke, then checked can be the dark theme and unchecked the light theme or the other way around
ἔρως
ἔρως7mo ago
it's however you want
roelof
roelofOP7mo ago
exactly so I still learn things on css after 2 years doing fem challenges maybe I will use this "trick" tomorrow to look if I can change the icon before Im going to work on the dark theme
vince
vince7mo ago
Google 'what is tilde selector in css'
roelof
roelofOP7mo ago
done it looks for siblings
ἔρως
ἔρως7mo ago
yup, it will select the next siblings after the element in this case, input ~.icon will select all .icon elements after the <input>
roelof
roelofOP7mo ago
so I can do :
<input = "checkbox" />
<img src="" alt="icon for the darjk theme"
<input = "checkbox" />
<img src="" alt="icon for the darjk theme"
Sorry, I do not see where I can make the icons siblings
ἔρως
ἔρως7mo ago
what's a sibling?
roelof
roelofOP7mo ago
For me a sibling is a child of something So it has to be inside the parent
ἔρως
ἔρως7mo ago
exactly and to be a sibling of the input, it has to?
roelof
roelofOP7mo ago
so
<div class="parent">
<div class="sibling1">
<div class="sibling2"
</div>
<div class="parent">
<div class="sibling1">
<div class="sibling2"
</div>
ἔρως
ἔρως7mo ago
yup
roelof
roelofOP7mo ago
LIke I said inside a parent
ἔρως
ἔρως7mo ago
but the selector only works in which children?
roelof
roelofOP7mo ago
but input is a self closing one so I do not see how to use it inside it in this example something of a class icon ?
ἔρως
ἔρως7mo ago
you didn't catch on how it works you should re-read it carefully
roelof
roelofOP7mo ago
yes You wrote that it looks for all .icon after the input but that is not like the definition I gave
ἔρως
ἔρως7mo ago
exactly no it isn't
roelof
roelofOP7mo ago
so this is confusing me It looks like I do not understand sibligs right
ἔρως
ἔρως7mo ago
can you check the + selector then?
roelof
roelofOP7mo ago
the plus is the next sibling
ἔρως
ἔρως7mo ago
and the tilde is?
roelof
roelofOP7mo ago
The CSS next-sibling combinator (+) is used to select an element that is placed immediately after another specific element.
The CSS next-sibling combinator (+) is used to select an element that is placed immediately after another specific element.
ἔρως
ἔρως7mo ago
the tilde does the same, but for all elements after the input
roelof
roelofOP7mo ago
The CSS subsequent-sibling combinator (~) matches all occurrences of element2 that follow the first element (element1).
The CSS subsequent-sibling combinator (~) matches all occurrences of element2 that follow the first element (element1).
ἔρως
ἔρως7mo ago
can you see the difference?
roelof
roelofOP7mo ago
oke so I can do this :
<input = "checkbox" />
<img src="" alt="icon for the darjk theme" class="icon">
<img src="" alt="icon for the light theme" class="icon">
<input = "checkbox" />
<img src="" alt="icon for the darjk theme" class="icon">
<img src="" alt="icon for the light theme" class="icon">
but then I have to hide one of the two and take care that the icon is placed above the checkbox so the user do not see the checkbox
ἔρως
ἔρως7mo ago
basically, yes
roelof
roelofOP7mo ago
oke, nice puzzle for tomorrow how to do that I m getting a head-ache again 😦
ἔρως
ἔρως7mo ago
thinking too much does that to me
roelof
roelofOP7mo ago
I feel that the heart problems I have with a too low heart rate and yesterday my guts that hurt and where not working properly Have made me mental unstable again 😦 one question : schould then the checkbox not the same width and height as the icon ? @vince thanks for the support
vince
vince7mo ago
nw mostly all epic lol i just chime in to argue
ἔρως
ἔρως7mo ago
you also help yes, no ... depends on how you implement but i would say "yes"
roelof
roelofOP7mo ago
I was thinking that because the user clicks on the icon but in real the checkbox is changes if the checkbox is smaller, the theme change would not work with pure html and css Or am I again misunderstanding things but also from your argue with epic I learn a lot
vince
vince7mo ago
me too lol
roelof
roelofOP7mo ago
and if im confused I will say it That is also one of my learning points Take care of my boundaries
ἔρως
ἔρως7mo ago
i commit mistakes too, so, not gonna say im perfect gotta learn from that too
roelof
roelofOP7mo ago
We here say : Nobody is perfect so im nobody
ἔρως
ἔρως7mo ago
yup, and you can also decide to use a background image instead of having 2 icons there 🤣 so you're perfect?
roelof
roelofOP7mo ago
yeaah and that is why now I have mental problems 😢 hmm, then I have to look how I can make a difference between the dark and light icon a lot of times FE work is the same as BE work A lot of ways to do things 😦
ἔρως
ἔρως7mo ago
exactly it's how you feel about it
roelof
roelofOP7mo ago
and what somepne has teach me I think my former "work" has learned me good things about css but also some very bad things I still doubt between Kevin ways of using a button or your way of using a checkbox with some extra css to make things work
ἔρως
ἔρως7mo ago
you can try both
roelof
roelofOP7mo ago
im planning that I have time
ἔρως
ἔρως7mo ago
the best way to understand why we decide a way is for you to do both
roelof
roelofOP7mo ago
Like I said already im planning to try both Then I also learn the good and bad parts of a way @ἔρως I think I will try your first because It only needs html and css and that is what I have already
ἔρως
ἔρως7mo ago
i think it is the easiest one too
roelof
roelofOP7mo ago
The only thing I do not see how the icon should overlap the checkbox but maybe I can look how some others did that
ἔρως
ἔρως7mo ago
you can use a background image instead
roelof
roelofOP7mo ago
??
ἔρως
ἔρως7mo ago
a background image for checked and unchecked
roelof
roelofOP7mo ago
oke looks like the way I would solve it
ἔρως
ἔρως7mo ago
it works
roelof
roelofOP7mo ago
???
ἔρως
ἔρως7mo ago
the background image
roelof
roelofOP7mo ago
I was thinking I "have" to use this html
<input = "checkbox" />
<img src="" alt="icon for the darjk theme" class="icon">
<img src="" alt="icon for the light theme" class="icon">
<input = "checkbox" />
<img src="" alt="icon for the darjk theme" class="icon">
<img src="" alt="icon for the light theme" class="icon">
so I wonder how the img would overlap the checkbox
ἔρως
ἔρως7mo ago
you can, but you don't have to you can simply make it into a grid with everything centered
roelof
roelofOP7mo ago
it looks to me that with the background-image I do not have to use that html So you offer another solution
ἔρως
ἔρως7mo ago
there are so many solutions
roelof
roelofOP7mo ago
I know The greatest frustation of developes there are a lot of solutions to a problem and not one is a bad one maybe I go for my own solution. that one I understand
ἔρως
ἔρως7mo ago
go for it
roelof
roelofOP7mo ago
yep, after some sleep and if I surive all the therapy tomorrow 😦
ἔρως
ἔρως7mo ago
you did a lot today
roelof
roelofOP7mo ago
yep, maybe too much but we see in hopefully 45 till 60 min bedtime
ἔρως
ἔρως7mo ago
you should rest early then?
roelof
roelofOP7mo ago
That is why im.watching tv right now
ἔρως
ἔρως7mo ago
tv usually doesn't have anything interesting for me
vince
vince7mo ago
off topic but this might be the longest thread ive seen on the server haha
No description
ἔρως
ἔρως7mo ago
not even close me and roelof had one with about 4500 messages
vince
vince7mo ago
omg lol
ἔρως
ἔρως7mo ago
it was about a wordpress plugin
vince
vince7mo ago
sounds about right lol
ἔρως
ἔρως7mo ago
lol wordpress is a mess
roelof
roelofOP7mo ago
Chips. and my idea was if im good in FE work to look if I can learn how to make good block templates for wordpress And later learn to be a block plugin developer so I can help volunteer organisations with no money to have a nice wordpress site
ἔρως
ἔρως7mo ago
you can still do that
roelof
roelofOP7mo ago
I know but I have also doubt because I still cannot find good resources to learn that for free And I cannot see if the resources are good or not. I see that a lot of wordpress people writes things where I ask myself do they really have the xp and knowlegde about the subject
ἔρως
ἔρως7mo ago
learn by example copy the 2025 theme and just mess around
roelof
roelofOP7mo ago
oke, that is the way I can learn to make templates from nothing in the future ?
ἔρως
ἔρως7mo ago
it's a way, yes you can see what it does, how it does it and change or mess about to try to do your own thing while you experiment
roelof
roelofOP7mo ago
oke, I was trying to remake the layout of nice websites's I found on the net
ἔρως
ἔρως7mo ago
then try it you have nothing to lose
roelof
roelofOP7mo ago
maybe I will after I done more FEM challenges to get more cofident in FE work
roelof
roelofOP7mo ago
I was looking at this one : https://mindspring-light.webflow.io/
MindSpring Light – Webflow HTML website template
Welcome to the MindSpring Academy, where we nurture each student's unique strengths, helping them grow into confident, capable individuals ready to succeed in life and beyond.
roelof
roelofOP7mo ago
I know it copyrighted but I wanted to do it jut for learning purposes but this is going really off-topic We were talking and discussing the FEM challenge
ἔρως
ἔρως7mo ago
it sounds like a good starting point how's the challenge going?
roelof
roelofOP7mo ago
good , only today no time yet to change things I hope at the end of the afternoon or begin evening I can do a little bit and I hope I can make it work that the switch is a checkbox instead of a button and hope that it will not costs a lot of time have to leave
ἔρως
ἔρως7mo ago
it probably will, as making a dark-mode sometimes just starts to get super buggy
roelof
roelofOP7mo ago
we see first make that "stupid" checkbox working somewhere today or tomorrow
ἔρως
ἔρως7mo ago
🤣 it will work
roelof
roelofOP7mo ago
I can do nothing more then my best
ἔρως
ἔρως7mo ago
and that is all you should do
roelof
roelofOP7mo ago
exactly maybe a stupid question but where can I then see if a checkbox is checked or not when using this html
<input type="checkbox" id="theme-toggle" />
<input type="checkbox" id="theme-toggle" />
?
ἔρως
ἔρως7mo ago
in js or in the devtools, when you check the properties
roelof
roelofOP7mo ago
and where in the devtools do I find this ? Right now in the html I do not see any difference
ἔρως
ἔρως7mo ago
no, you wont see any difference there on the panel on the right of the devtools, where you have the "styles" tab selected, look for ">>" and click it then you will see the "properties" option there
roelof
roelofOP7mo ago
oke, found it I had to enable it first and it seems to work now the css to make the icon work sorry
ἔρως
ἔρως7mo ago
it will be easier than you imagine
roelof
roelofOP7mo ago
I do not see how to make the sun icon visble and the moon icon not with this css
#theme-toggle ~ .icon {


}
#theme-toggle ~ .icon {


}
`
ἔρως
ἔρως7mo ago
you hide one and show the other when checked
roelof
roelofOP7mo ago
oke, but I do not see how
ἔρως
ἔρως7mo ago
that's because you will use that to show the hidden one and hide the one that was visible
roelof
roelofOP7mo ago
sorry, still do not understand lets say I have this :
<img src="" alt="icon for the darjk theme" class="icon">
<img src="" alt="icon for the light theme" class="icon">
<img src="" alt="icon for the darjk theme" class="icon">
<img src="" alt="icon for the light theme" class="icon">
how on earth do I select one of the two ? within the css I just posted
ἔρως
ἔρως7mo ago
you add a class or an id
roelof
roelofOP7mo ago
oke but I cannot use a id within a css declaration as far as I know
vince
vince7mo ago
You can add an ID to both images like dark-mode-image and then if input:checked ~ #dark-mode-image display block Probably a cleaner way but that should work
roelof
roelofOP7mo ago
oke that is another way as I thought me was talked yesterday Then we had about this css
#theme-toggle ~ .icon {


}
#theme-toggle ~ .icon {


}
ἔρως
ἔρως7mo ago
the .icon is just a "placeholder" for the real deal
vince
vince7mo ago
Yea sorry forgot to put sibling selector in last message
roelof
roelofOP7mo ago
aha, and I took it litteral because of my "stupid" autism
vince
vince7mo ago
no it's not your fault i missed it, i would have taken it literally too
roelof
roelofOP7mo ago
so I must then make 4 css classes. two checked one with both images And two unchecked with the two images To make the right one visible or hidden
vince
vince7mo ago
not necessarily Honestly I'd recommend doing something like this
<div aria-hidden="true">
<input>
<div id="toggle-image">
</div>
<div aria-hidden="true">
<input>
<div id="toggle-image">
</div>
input ~ #toggle-image {
background-image: url('/path/to/light-mode-image');
}

input:checked ~ #toggle-image {
background-image: url('dark-mode-image');
}
input ~ #toggle-image {
background-image: url('/path/to/light-mode-image');
}

input:checked ~ #toggle-image {
background-image: url('dark-mode-image');
}
You can get away with using a div instead of an image I think because it's not supposed to be accessible Anyway I actually need to be productive at work today (they want an EOD showcase) and I'm already like 2 hours in with barely anything done so I gotta get on that 😅 I'll respond when I have time
roelof
roelofOP7mo ago
of course @vince
ἔρως
ἔρως7mo ago
thats a huge waste of html and css just make the input have the background image
roelof
roelofOP7mo ago
im now very confused by all the options I quit for today
vince
vince7mo ago
lol no epic is right don't listen to me there's always a lot of options in the frontend
ἔρως
ἔρως7mo ago
as i said, there are a ton of ways to do this what im saying is to set the background image for the input instead of using other elements this way, everything uses 1 element and you dont have to worry about things like pointer events and positioning
roelof
roelofOP7mo ago
oke So something like this :
:root {
-background-image = "assests/images/sun.svg
}

.darkmode {

- background-image = "assets/images/moon.jpg
}

.toggle-theme {
background-image : url(var(--background-image));
}
:root {
-background-image = "assests/images/sun.svg
}

.darkmode {

- background-image = "assets/images/moon.jpg
}

.toggle-theme {
background-image : url(var(--background-image));
}
ἔρως
ἔρως7mo ago
something like:
input {
background-image: ...;
}

input:checked {
background-image: ...;
}
input {
background-image: ...;
}

input:checked {
background-image: ...;
}
roelof
roelofOP7mo ago
oke I have then to use a class because I have more inputs on the page but I get the idea chips not working I have this html :

<input type="checkbox" id="theme-toggle" />

<input type="checkbox" id="theme-toggle" />
and this css :
#theme-toggle {
border: none;
height: 50px;
width: 50px;
cursor: pointer;
background-image: url('./assets/images/icon-sun.svg');
}

#theme-toggle:checked {
background-image: url('./assets/images/icon-moon.svg');
}
#theme-toggle {
border: none;
height: 50px;
width: 50px;
cursor: pointer;
background-image: url('./assets/images/icon-sun.svg');
}

#theme-toggle:checked {
background-image: url('./assets/images/icon-moon.svg');
}
but still no image to see 😦 I checked and the url looks right to me
ἔρως
ἔρως7mo ago
you should use an id
roelof
roelofOP7mo ago
??? As far as I know I use a id
ἔρως
ἔρως7mo ago
that is all you need for this
roelof
roelofOP7mo ago
Why on earth do I not see the images but when checked a big checkmark also this is not working
#theme-toggle {
border: none;
height: 50px;
width: 50px;
cursor: pointer;
display: none
}

#theme-toggle::after {
display: block;
background-image: url('./assets/images/icon-sun.svg');

}
#theme-toggle {
border: none;
height: 50px;
width: 50px;
cursor: pointer;
display: none
}

#theme-toggle::after {
display: block;
background-image: url('./assets/images/icon-sun.svg');

}
no idea what I do wrong so no coding for me today
ἔρως
ἔρως7mo ago
you have to change the appearance to none the ::before and ::after MUST have a content set to a string, or it won't exist at all just add content: ""; and you are half-set and by changing the appearance to none, it should work as you want
roelof
roelofOP7mo ago
still no image
#theme-toggle {
border: none;
height: 50px;
width: 50px;
cursor: pointer;
appearance: none;
}

#theme-toggle::before {
content:"";
display: block;
background-image: url('./assets/images/icon-sun.svg');

}
#theme-toggle {
border: none;
height: 50px;
width: 50px;
cursor: pointer;
appearance: none;
}

#theme-toggle::before {
content:"";
display: block;
background-image: url('./assets/images/icon-sun.svg');

}
ἔρως
ἔρως7mo ago
you have to give it a width and height then make sure it is on top of the input
roelof
roelofOP7mo ago
still no luck
roelof
roelofOP7mo ago
No description
ἔρως
ἔρως7mo ago
try to set the input to block
roelof
roelofOP7mo ago
??
ἔρως
ἔρως7mo ago
display: block on the input
Chris Bolson
Chris Bolson7mo ago
Try giving the pseudo element some height, eg height:100% so that it has the same height as it's parent, by default the pseudo element will have a height of 0 as it has no content.
roelof
roelofOP7mo ago
@Chris Bolson I did already give it a height and width
Chris Bolson
Chris Bolson7mo ago
ah yes, sorry
roelof
roelofOP7mo ago
@ἔρως if you mean this , it changes nothing
#theme-toggle {
border: none;
height: 50px;
width: 50px;
cursor: pointer;
appearance: none;
}

#theme-toggle::before {
content:"";
display: block;
background-image: url('./assets/images/icon-sun.svg');
width: 50px;
height: 50px;


}

input {
display: block;
}
#theme-toggle {
border: none;
height: 50px;
width: 50px;
cursor: pointer;
appearance: none;
}

#theme-toggle::before {
content:"";
display: block;
background-image: url('./assets/images/icon-sun.svg');
width: 50px;
height: 50px;


}

input {
display: block;
}
Chris Bolson
Chris Bolson7mo ago
maybe the icon is too big? try adding background-size:cover; to ensure that it remains within the bounds of the psuedo element
ἔρως
ἔρως7mo ago
that is a good callout, as people make the worst junky svgs with 30000x30000 of size
roelof
roelofOP7mo ago
no luck
#theme-toggle::before {
content:"";
display: block;
background-image: url('./assets/images/icon-sun.svg');
width: 50px;
height: 50px;
background-size: cover;

}
#theme-toggle::before {
content:"";
display: block;
background-image: url('./assets/images/icon-sun.svg');
width: 50px;
height: 50px;
background-size: cover;

}
ἔρως
ἔρως7mo ago
does the image exist? add a background-color: red for testing also, add position: relative to the input, and position: absolute; top: 0; bottom: 0; left: 0; right: 0;
roelof
roelofOP7mo ago
he, then I see it so I need to change the background-color to the right one
roelof
roelofOP7mo ago
see :
No description
roelof
roelofOP7mo ago
No description
ἔρως
ἔρως7mo ago
ah, crap
roelof
roelofOP7mo ago
now work a little more on the colors but the idea is working 🙂 first dinner
ἔρως
ἔρως7mo ago
oh, i see what it was and what i had in mind wasnt an issue afterall but yeah, go have dinner
roelof
roelofOP7mo ago
oke, sometimes FE work is really a PITA
ἔρως
ἔρως7mo ago
told you
roelof
roelofOP7mo ago
I know expecially when you do not have a idea what is wrong and I tried that background-color more and then nothing happens wierd things browsers
ἔρως
ἔρως7mo ago
just rest, it's alright
roelof
roelofOP7mo ago
Oke boss 😛 And tomorrow make the dark them work ??
ἔρως
ἔρως7mo ago
yup
roelof
roelofOP7mo ago
hopefully I can make that work in 1 day or afternoon and then a "lot' of js to write - to store the theme _ filtering (but hat can be done with the library you told me ) - chancing and store the active or non-active part so this is keeping me busy for 1 week
ἔρως
ἔρως7mo ago
with time, you will get faster at it
roelof
roelofOP7mo ago
We see
ἔρως
ἔρως7mo ago
yeah, we will see
roelof
roelofOP7mo ago
@ἔρως and do you think im a good student ?
ἔρως
ἔρως7mo ago
it's hard to pass on knowledge to you, and i notice you lose context easily but besides that, yeah, i think you're a good "student"
roelof
roelofOP7mo ago
I know that problem. My mind has then a fixed idea of how to solve a problme And I do have problems to see another way compkete @ἔρως
ἔρως
ἔρως7mo ago
meanwhile, i see all the ways to complete this
roelof
roelofOP7mo ago
im not my mind is running in circles at the way I thought I can solve it Can yopu help me one more time with a color ? I have this as choices :
--heading-font-color: hsl(227, 75%, 14%);
--neutral800: hsl(226, 25%, 17%);
--neutral700: hsl(225, 23%, 24%);
--font-color: hsl(226, 11%, 37%);
--heading-font-color: hsl(227, 75%, 14%);
--neutral800: hsl(226, 25%, 17%);
--neutral700: hsl(225, 23%, 24%);
--font-color: hsl(226, 11%, 37%);
What is the background-color of the sun-icon I doubt between 800 and 700
roelof
roelofOP7mo ago
No description
ἔρως
ἔρως7mo ago
i have no idea maybe the 700, but you have to test it
roelof
roelofOP7mo ago
I will try maybe a stupid question But how do I change the backgroundcolor of the header when the darkmode is enabled for my feeling I have to combine #theme-toggle:checked and header somehow ? or am I on the wrong way ?
ἔρως
ἔρως7mo ago
i would have to see how you're doing that
roelof
roelofOP7mo ago
I have no idea that is why I asked here Im looking for a way I can tell that the header must be some other colors when the darkmode is enabled
ἔρως
ἔρως7mo ago
you won't have to, kinda
roelof
roelofOP7mo ago
??? The colors on the dark mode are totally other Or do you mean use the variables somehow ?
ἔρως
ἔρως7mo ago
just use the variables then we change the variables
roelof
roelofOP7mo ago
sorry, I still do not see it Maybe i do
#theme-toggle:checked {
--heading-font-color: <new_color>
}
#theme-toggle:checked {
--heading-font-color: <new_color>
}
and so on ?
ἔρως
ἔρως7mo ago
yup then you just change the value of the heading variables
roelof
roelofOP7mo ago
and the rest that I need to change on the same way
ἔρως
ἔρως7mo ago
yup
roelof
roelofOP7mo ago
Nice work for tomorrow Now time to sleep
ἔρως
ἔρως7mo ago
you should be able to finish tomorrow
roelof
roelofOP7mo ago
We see Some colors are difficult to see which color it is
ἔρως
ἔρως7mo ago
use the trick i told you about yesterday
roelof
roelofOP7mo ago
Oke i will
ἔρως
ἔρως7mo ago
now it's resting time
roelof
roelofOP7mo ago
Yep Tried this :
#theme-toggle:checked {
--body-background: linear-gradient(180deg, #040918 0%, #091540 100%);
}
#theme-toggle:checked {
--body-background: linear-gradient(180deg, #040918 0%, #091540 100%);
}
but the background-color does not change 😦
ἔρως
ἔρως7mo ago
because that is being applied to the input, and only the input and it's children have access to that due to the scope
roelof
roelofOP7mo ago
Then I have to read how we yesyterday discussed how to solve this we said that way I now try
sorry, I still do not see it
Maybe i do

#theme-toggle:checked {
--heading-font-color: <new_color>
}

and so on ?
ἔρως

gisteren om 22:07
yup
then you just change the value of the heading variables
sorry, I still do not see it
Maybe i do

#theme-toggle:checked {
--heading-font-color: <new_color>
}

and so on ?
ἔρως

gisteren om 22:07
yup
then you just change the value of the heading variables
ἔρως
ἔρως7mo ago
it's more of a html:has(#theme-toggle:checked) but there are better ways to do it
roelof
roelofOP7mo ago
and of course I do not see that better way
ἔρως
ἔρως7mo ago
i can see a few, but i am working now i can think of using the checkbox just as a representation of the mode, while the real value is somewhere else
roelof
roelofOP7mo ago
oke, I still do not see it at all my first idea is then that the value is also stored in a css variable or do you mean store into localstorage but then I need to use js And my plan was first to do all the css and then do the js
ἔρως
ἔρως7mo ago
you do need the local storage, but that is the next step
roelof
roelofOP7mo ago
Then I do not see it and I will wait till you back from work and have time to learn me your way
ἔρως
ἔρως7mo ago
do you know how to use localstorage?
roelof
roelofOP7mo ago
yep, witj js localStorage.setItem(key, value);
There i put something in localstorage And with localStorage.getitem(key) I can get a value out of it And I know nothing more about localStorage except it lives within the browser
ἔρως
ἔρως7mo ago
you need to be aware that EVERYTHING into local storage is converted to a string
roelof
roelofOP7mo ago
With the theme selector I do not have a problem. I thought of using enabled for the dark and disabled or null for the light theme
ἔρως
ἔρως7mo ago
that makes the light mode the default
roelof
roelofOP7mo ago
yep. that would then my choice
ἔρως
ἔρως7mo ago
that should be easy then
roelof
roelofOP7mo ago
? if it is so easy why do I then not see the step before storing it into localstorage
ἔρως
ἔρως7mo ago
you just have to do something like this and set the right colors for the elements
roelof
roelofOP7mo ago
I did use that and it works I now can change the background-color but I stopped finding out the rest of the colors because I thought there would be a total other plan chips, all colors almost done except the background-color of the icon I quit for today the colors make me crazy I cannot get them right Will upload it to github
roelof
roelofOP7mo ago
This is what I have now:
No description
roelof
roelofOP7mo ago
and this what it should be :
No description
roelof
roelofOP7mo ago
all those dark colors looks a lot the same
- **Neutral 900**: `hsl(227, 75%, 14%)`
- **Neutral 800**: `hsl(226, 25%, 17%)`
- **Neutral 700**: `hsl(225, 23%, 24%)`
- **Neutral 600**: `hsl(226, 11%, 37%)`
- **Neutral 900**: `hsl(227, 75%, 14%)`
- **Neutral 800**: `hsl(226, 25%, 17%)`
- **Neutral 700**: `hsl(225, 23%, 24%)`
- **Neutral 600**: `hsl(226, 11%, 37%)`
tomorrow maybe another try
ἔρως
ἔρως7mo ago
without a conversion to rgb or hex, i have no idea what those colors are but then again, i would do what you are doing: trial and error
Ganesh
Ganesh7mo ago
why not use a color picker and just pick from the image
roelof
roelofOP7mo ago
I try that but the colors code does not match 😦
Ganesh
Ganesh7mo ago
hmm which one are you using
roelof
roelofOP7mo ago
paint and pain shop pro
Ganesh
Ganesh7mo ago
haven't used those. usually use microsoft powertoys color picker. do you have a working codepen or repo or something. I want to see if that will be more accurate
roelof
roelofOP7mo ago
hsl(227, 75%, 14%) rgb(9, 21, 62) #09153e
hsl(226, 25%, 17%) rgb(33, 38, 54) #212636
hsl(225, 23%, 24%) rgb(47, 54, 75) #2f364b
hsl(226, 11%, 37%) rgb(84, 89, 105) #545969
hsl(227, 75%, 14%) rgb(9, 21, 62) #09153e
hsl(226, 25%, 17%) rgb(33, 38, 54) #212636
hsl(225, 23%, 24%) rgb(47, 54, 75) #2f364b
hsl(226, 11%, 37%) rgb(84, 89, 105) #545969
@ἔρως @Ganesh
Live version : https://roelofwobben.github.io/browser-extenstion/
roelof
roelofOP7mo ago
What it schould be :
No description
roelof
roelofOP7mo ago
it that what you mean ?
Ganesh
Ganesh7mo ago
yeah sure that works
roelof
roelofOP7mo ago
otherwise Here is the repo with my code and in the design is also a good picture https://github.com/RoelofWobben/browser-extenstion
GitHub
GitHub - RoelofWobben/browser-extenstion
Contribute to RoelofWobben/browser-extenstion development by creating an account on GitHub.
roelof
roelofOP7mo ago
@Ganesh
Ganesh
Ganesh7mo ago
No description
Ganesh
Ganesh7mo ago
what i get from a quick edit it's not perfect though also I didn't do any changes to the linear gradiant applied to body. I'm no good with linear gradiant
roelof
roelofOP7mo ago
The linear gradient is given and I think that one did not have to change how does the icon which you can change from dark to light theme looks like ? @Ganesh
Ganesh
Ganesh7mo ago
No description
roelof
roelofOP7mo ago
looks better then I could make may I know where which colors you use
Ganesh
Ganesh7mo ago
--font-color: hsl(225deg 5.78% 55.2%);
--button-border-color: hsl(227, 6%, 45%)
--background-color : hsl(224, 26%, 16%);
//red background for the toggle switch == hsl(2, 88%, 65%)
--font-color: hsl(225deg 5.78% 55.2%);
--button-border-color: hsl(227, 6%, 45%)
--background-color : hsl(224, 26%, 16%);
//red background for the toggle switch == hsl(2, 88%, 65%)
I just dropped this by picking from powertoys color picker
roelof
roelofOP7mo ago
oke
Ganesh
Ganesh7mo ago
also do note that some of these might not be acessible. I had to tweak --font-color for example so that it would reach 4 contrast ratio
roelof
roelofOP7mo ago
maybe I have to change the given colors a little I was trying to use the given colors for this challege and then you cannot make it work Thanks for the help @Ganesh @ἔρως that is what i hate about FEM challenges sometimes the given colors are not right
ἔρως
ἔρως7mo ago
maybe they only let people pick colors from a predefined palette?
roelof
roelofOP7mo ago
Hmm They say this :
There is also a `style-guide.md` file containing the information you'll need, such as color palette and fonts.
There is also a `style-guide.md` file containing the information you'll need, such as color palette and fonts.
but also this :
The designs are in JPG static format. Using JPGs will mean that you'll need to use your best judgment for styles such as `font-size`, `padding` and `margin`.
The designs are in JPG static format. Using JPGs will mean that you'll need to use your best judgment for styles such as `font-size`, `padding` and `margin`.
so it looks to me that there is room to adapt the colors
ἔρως
ἔρως7mo ago
oh, a jpeg yeah, the colors will be wrong
roelof
roelofOP7mo ago
ads far as I can see , with the given pallet I cannot solve this challenge
ἔρως
ἔρως7mo ago
you have to zoom in a lot and MAYBE you will have an usable color
roelof
roelofOP7mo ago
Im thinkimg of using the colors from Ganesh and callit a day instead of trying to use the given colors or accept that it is not looking like the picture
ἔρως
ἔρως7mo ago
just use what looks the closest
roelof
roelofOP7mo ago
That are the numbers that Ganesh has found then it looks most close to the picture
ἔρως
ἔρως7mo ago
go for it then
roelof
roelofOP7mo ago
@Ganesh one question What was your color for the background of the icon
Ganesh
Ganesh7mo ago
which icon
roelof
roelofOP7mo ago
The icon to change from dark to light them so the sun one
Ganesh
Ganesh7mo ago
don't think i changed that I kept it as yours is only changed the --background-color css variable
roelof
roelofOP7mo ago
Thanks @ἔρως maybe im going tomorrow further. Have to think how I name and what colors the filter buttons must have Think I need more css variables 😢 This is really a PITA work right now I do not find it fun anymore
ἔρως
ἔρως7mo ago
it does get irritating at points
roelof
roelofOP7mo ago
oke could not stand that it was not working
roelof
roelofOP7mo ago
What do you think of this try
No description
roelof
roelofOP7mo ago
orginal:
No description
roelof
roelofOP7mo ago
Did I do a good job I only have to find out how to change the color of the svg And I know that is also not funny maybe go tomorrow for the easy solution and change the svg to currentColor instead of a fixed one Otherwise I have to make a filter and that is a really PITA Time to rest hope I still a good student
vince
vince7mo ago
I've been very busy at work so haven't been able to look as much, you're doing great. There's still some inconsistencies with your design and the original but if you're not having fun anymore don't bother with the small stuff it's close enough
ἔρως
ἔρως7mo ago
it's close the red is off, the color of the buttons needs changes and the checkboxes aren't colored yet (the switch ones)
roelof
roelofOP7mo ago
oke So tomorrow : - choose another red between these : - Red 400: hsl(3, 86%, 64%) - Red 500: hsl(3, 71%, 56%) - Red 700: hsl(3, 77%, 44%)
ἔρως
ἔρως7mo ago
another red for the dark mode
roelof
roelofOP7mo ago
- choose another red for the dark mode - look better at the colors of the buttons (I think you mean the filter buttons) - color the checkboxes in dark mode - add switches to the rest of the cards - add hover and the other states and then js time wil also be fun 😢
ἔρως
ἔρως7mo ago
you will see that it isn't as hard as you imagine
roelof
roelofOP7mo ago
we see I do not know how hard the library is that you mentioned for the filtering the part of adding, chancing , deleting items in localstorage is I think not so hard
ἔρως
ἔρως7mo ago
it's extremely easy you just have to: - access the file somehow - add buttons - minimal setup the example code is a fully working demo
roelof
roelofOP7mo ago
we see when I get there first the 5 css "problems" to solve @ἔρως @vince still in doubt if I can be a good hobby FE developer at the moment What do you think of what I have done so far ?
vince
vince7mo ago
If your goal is to just have fun you don't need to be good at it If your goal is to make websites for people, I was worse when I started You're ready to do volunteer work if you wanted to ever try it You want to be a professional at it? Lots of practice and real world experience
ἔρως
ἔρως7mo ago
i can't classify you as "good" or "bad": just junior and in need of more challenges
roelof
roelofOP7mo ago
oke, there are more then enough FEM challenges to go
ἔρως
ἔρως7mo ago
you just need to practice do you have 1 or 2 displays, by the way?
roelof
roelofOP7mo ago
@vince for the volunteer work I have to learn how to make wordpress block themes But first I want to be more confident with doing it with just html, css and css
vince
vince7mo ago
You don't even need that
roelof
roelofOP7mo ago
At home I have 1 display. At "work" there are places with 1 and places with 2 displays
ἔρως
ἔρως7mo ago
you should get a 2nd display if you have the space
roelof
roelofOP7mo ago
I know but my computer cabinet is too small for 2 displays:(
vince
vince7mo ago
I have 2 but I only really use the second one for music lol
ἔρως
ἔρως7mo ago
i use both
roelof
roelofOP7mo ago
At work I maybe can arrange for a place with 2 displays but there I go for 2 mornings in a week so some 8 hours but then I have to ask if I can do FE work there but first try to solve this one and then maybe look for another challenge Like I said FEM challenges enought to practice @vince what do you meant with " you do not need that "
ἔρως
ἔρως7mo ago
you don't need html, css and js to make a theme elementor can do a ton of stuff i think it is paid
vince
vince7mo ago
I meant the other way actually, you don't need wordpress if you're volunteer and they just want something really simple up but epic makes a good point too
ἔρως
ἔρως7mo ago
yeah, not using wordpress is good too
vince
vince7mo ago
I had one client for a while where the site was 2 pages in basically just html, css, and js and he'd pay me when he wanted edits done lol
ἔρως
ἔρως7mo ago
hey, money is money
roelof
roelofOP7mo ago
yep, and I want to learn to make it with only the current "page" builder I forget the name
vince
vince7mo ago
Gutenburg?
roelof
roelofOP7mo ago
but also I doubt if I want to learn wordpress because the docs and the help is a mess Or as beginner you get the answer there is a plugin or aa answer use GPT With both ways I do not learn anything That what I was thinking of
vince
vince7mo ago
Just gotta use what you're comfortable with and gets the job done if you want to do volunteer / professional work (learning doesn't matter as much), otherwise if you just do your own stuff learn whatever you want and take it one step at a time
roelof
roelofOP7mo ago
exactly but for now GN maybe after a few FEM challenges we can look what the right steps will be to also be good at that GM Do I have a good list to work on today ? I mean this list : - choose another red for the dark mode, - look better at the colors of the buttons (I think you mean the filter buttons), - color the checkboxes in dark mode, - add switches to the rest of the cards, - add hover and the other states @vince @ἔρως
I m going crazy According to the picture the filter buttons and the cards should have the same background And they have But why does it then look different ?
roelof
roelofOP7mo ago
does this red look better ?
No description
ἔρως
ἔρως7mo ago
for dark mode, it's the ugly pink-ish red well, not pink-ish, but the muted one. also, the selected filter has dark text and no border
roelof
roelofOP7mo ago
Then I have to be :
No description
roelof
roelofOP7mo ago
other choices of red are not given in the readme oke, now I think I understand what you mean with
look better at the colors of the buttons
look better at the colors of the buttons
ἔρως
ἔρως7mo ago
there are 2 different red colors the light mode and dark mode have different reds
roelof
roelofOP7mo ago
I know I try to find the red one for the dark mode
ἔρως
ἔρως7mo ago
just extract the color
roelof
roelofOP7mo ago
oke
ἔρως
ἔρως7mo ago
it's annoying, i know
roelof
roelofOP7mo ago
very annoying
ἔρως
ἔρως7mo ago
but it is what it is
roelof
roelofOP7mo ago
yep but these little details are really a PITA and make me wonder if I really like FE work But on the other hand I want to make it as close as possible
ἔρως
ἔρως7mo ago
this is part of implementing any design yourself one in figma would help a lot
roelof
roelofOP7mo ago
I know but then I have to pay 😦
ἔρως
ἔρως7mo ago
you don't need it
roelof
roelofOP7mo ago
and again the color of the jpg of the red is not in the given colors 😢
ἔρως
ἔρως7mo ago
if you can leave a comment, say there that the colors are wrong and some are missing
roelof
roelofOP7mo ago
Im throwing my computer out of the windos according to PSP the red color is (1,228%,168%) but as I use it like this :
background-color: hsl(1,228%,168%);
background-color: hsl(1,228%,168%);
then I see a white color
ἔρως
ἔρως7mo ago
228% and 168% are impossible values just get the color in rgb
roelof
roelofOP7mo ago
then it schould be :
No description
ἔρως
ἔρως7mo ago
the switch does look a lot closer
roelof
roelofOP7mo ago
now the rest: I mean this list : - choose another red for the dark mode, (done) - look better at the colors of the buttons (I think you mean the filter buttons), - color the checkboxes in dark mode, - add switches to the rest of the cards, (done) - add hover and the other states with the colors of the buttons , you mean the text-color of the active one and the border of the active one ?
ἔρως
ἔρως7mo ago
yes, and the border of those filter buttons
roelof
roelofOP7mo ago
oke, so in the dark mode no borders Have to think how to do that because on the light one they have borders
ἔρως
ἔρως7mo ago
no, it has a border and a background it's hard to see, but it has a border
roelof
roelofOP7mo ago
I take a break before I become really crazy
ἔρως
ἔρως7mo ago
you should take regular breaks
roelof
roelofOP7mo ago
yes, boss 😛 this details work costs a lot mental
ἔρως
ἔρως7mo ago
i know it does
roelof
roelofOP7mo ago
I will see when I have the energy to workk further on this
ἔρως
ἔρως7mo ago
you seem to need the weekend off
roelof
roelofOP7mo ago
for sure tomorrow . Then we celebrate my mothers birthday And maybe Sunday to recharge from the Saturday We see if I get some energy today 2 out of 5 ready 🙂
ἔρως
ἔρως7mo ago
lets see how it goes
roelof
roelofOP7mo ago
exactly It will be after weekend I think I see that with the filter buttons I have to make 2 new css variables - filter-button-background-color - font-color - filter-button-border-color To make things right I need a lot of css variables here. With those 3 there are then 11 css variables wonder if that is not too much and I have to combine some variables
ἔρως
ἔρως7mo ago
how is it 11 variables?
roelof
roelofOP7mo ago
I use now these variables for the dark modus
html:has(#theme-toggle:checked) {
--body-background: linear-gradient(180deg, #040918 0%, #091540 100%);
--heading-font-color: hsl(0, 0%, 93%);
--font-color: hsl(225deg 5.78% 55.2%);
--button-border-color: hsl(227, 6%, 45%);
--background-color : hsl(224, 26%, 16%);
--background-color-icon: hsl(225, 23%, 24%);
--filter-button-color: hsl(0, 0%, 93%);
--checkbox-point-color: hsl(0, 0%, 93%);
}
html:has(#theme-toggle:checked) {
--body-background: linear-gradient(180deg, #040918 0%, #091540 100%);
--heading-font-color: hsl(0, 0%, 93%);
--font-color: hsl(225deg 5.78% 55.2%);
--button-border-color: hsl(227, 6%, 45%);
--background-color : hsl(224, 26%, 16%);
--background-color-icon: hsl(225, 23%, 24%);
--filter-button-color: hsl(0, 0%, 93%);
--checkbox-point-color: hsl(0, 0%, 93%);
}
and that is I think 8 and then 3 new ones
ἔρως
ἔρως7mo ago
if you are using repeated colors, you can do, for example, --filter-button-color: var(--checkbox-point-color);
roelof
roelofOP7mo ago
oke, right now totally no energy so I see when and if im going to work further on this
ἔρως
ἔρως7mo ago
dont worry about it
roelof
roelofOP7mo ago
I do not have the engery to worrry about anything 🙂 but I wonder if my css is going the right way or could be cleaned up a lot
ἔρως
ἔρως7mo ago
make it work, make it good, make it fast that is the way just worry about making it work
roelof
roelofOP7mo ago
yep and that is difficult enough
ἔρως
ἔρως7mo ago
why worry about anything else then?
roelof
roelofOP7mo ago
one of my other pittfals is that I want to finisch it yesterday I want to do things fast and perfect
ἔρως
ἔρως7mo ago
so, you want pink fluffy unicorns dancing on rainbows yeah, that is not how it works
roelof
roelofOP7mo ago
in my head it should work that way That is why I get a lot of therapy on my "old" age To see where the problems are and how I can solve them or learn to live with it
ἔρως
ἔρως7mo ago
i think you are expecting everything to be a walk in the park, then get frustrated with things when it takes "too long" despite being about the normal time
roelof
roelofOP7mo ago
I know, My autism and youth has thought me very bad things to survive But as I said I work on that and it has the highest priority for me
ἔρως
ἔρως7mo ago
it should have
roelof
roelofOP7mo ago
time to relax , Feel very bad today
ἔρως
ἔρως7mo ago
go relax
vince
vince7mo ago
in frontend the concept of perfect is not a thing lol i get caught up in that too 'i want it to be really good / perfect' but it will never be so don't worry about it
ἔρως
ἔρως7mo ago
even i, at work, wont get it perfect
vince
vince7mo ago
Just do your best, and over time the concept of 'your best' will evolve/ change Whenever there's a client involved there is no perfect 😂
ἔρως
ἔρως7mo ago
for example, i have a design in figma of things i have to implement but figma can't do sub-pixel rendering it says that a text of 16px with line height of 1.2 is 19px tall, which is wrong it is 19.2px - otherwise you get 1.1875 of line height you arent expected to do everything pixel perfect, even when you have a design for you to check against
roelof
roelofOP7mo ago
I know
ἔρως
ἔρως7mo ago
the best any of us could do right now is to have a cold drink
roelof
roelofOP7mo ago
I already did Right now this challenge is costing me too much energy SO like i said I take a long break
ἔρως
ἔρως7mo ago
i have a cold drink too
roelof
roelofOP7mo ago
almost weekend. After weekend I will look if I go for FE work or for arduino
ἔρως
ἔρως7mo ago
it's weekend for me
roelof
roelofOP7mo ago
For me also Hopefully within 1 hour to bed Tommorow birtday of my mother so a lot of stimulusses 😢
ἔρως
ἔρως7mo ago
just relax and forget that the code exist, and try to have a good day
roelof
roelofOP7mo ago
I try but I have a mother who can talk 16 hours into 8 hours so no time to think about anything
ἔρως
ἔρως7mo ago
i know the pain
roelof
roelofOP7mo ago
and hopefully I can Monday solve that stupid button problems and the other problems
ἔρως
ἔρως7mo ago
don't think about it
roelof
roelofOP7mo ago
oke, boss 😛 GN
ἔρως
ἔρως7mo ago
goodnight
roelof
roelofOP7mo ago
How was the day with no questions from me ?
ἔρως
ἔρως7mo ago
still pretty hot
roelof
roelofOP7mo ago
o, here wet and cold 13 degrees and the whole dau little rain 😦 and made yesterday a bug report on the colors : https://discord.com/channels/824970620529279006/1214860504103657493/threads/1375499496552923176
ἔρως
ἔρως7mo ago
i can't see what's there
roelof
roelofOP7mo ago
here the copied text :
For example the readme gives this as choices for red

- **Red 400**: `hsl(3, 86%, 64%)`
- **Red 500**: `hsl(3, 71%, 56%)`
- **Red 700**: `hsl(3, 77%, 44%)`



but if I look with a color picker it gives me this red color :

hsl(0, 91,65)



The same with the background of the sun icon
According to the color picker it is

hsl(222°, 20%, 23%)



and also that one is not mentioned in the readme.
For example the readme gives this as choices for red

- **Red 400**: `hsl(3, 86%, 64%)`
- **Red 500**: `hsl(3, 71%, 56%)`
- **Red 700**: `hsl(3, 77%, 44%)`



but if I look with a color picker it gives me this red color :

hsl(0, 91,65)



The same with the background of the sun icon
According to the color picker it is

hsl(222°, 20%, 23%)



and also that one is not mentioned in the readme.
ἔρως
ἔρως7mo ago
lets see what they say
roelof
roelofOP7mo ago
exactky I think I hear nothing
ἔρως
ἔρως7mo ago
you did your part
roelof
roelofOP7mo ago
the same problem as you hvae when you try to het a review for a challege yep, and it is now out of my hands
ἔρως
ἔρως7mo ago
yup, and you just have to rest too
roelof
roelofOP7mo ago
yep I hope one day is enough after a visit to my parents but we will see
ἔρως
ἔρως7mo ago
you can continue this on monday
roelof
roelofOP7mo ago
we see I have make no plans
ἔρως
ἔρως7mo ago
it's a good weekend to relax at home
roelof
roelofOP7mo ago
oke boss GN
ἔρως
ἔρως7mo ago
goodnight
roelof
roelofOP7mo ago
@ἔρως this is the first respons I got from a moderator of the FEM discord channels
Hey! Which elements exactly have the wrong colors? I just checked the red colors in the design with a color picker and they seem to be correct

Also the background color behind the sun icon in the theme button is hsl(225, 23%, 24%) which is the neutral 700 color 👍
Hey! Which elements exactly have the wrong colors? I just checked the red colors in the design with a color picker and they seem to be correct

Also the background color behind the sun icon in the theme button is hsl(225, 23%, 24%) which is the neutral 700 color 👍
ἔρως
ἔρως7mo ago
at least someone answered but it's easy: they give you 1 red, the light and dark mode have 2 different reds
roelof
roelofOP7mo ago
that is right with 99,9% of the reviews you do not get any respons
ἔρως
ἔρως7mo ago
yeah, you got lucky
roelof
roelofOP7mo ago
No no, they gave you 3 reds im never got lucky. Still waiting on feedback on my first two ones of a few months ago 😦 one of the reasons i got fed up with FE work no respons to questions or a totally beginner tries to help you 😦
ἔρως
ἔρως7mo ago
do they get lots of messages?
roelof
roelofOP7mo ago
For help of for reviews ? with help I see the last 2 - 3 days 3 questions with reviews between 6 and 11 a day
ἔρως
ἔρως7mo ago
that's quite a fair bit of review requests
roelof
roelofOP7mo ago
I know and it looks like 1 a day get a review Still enjoying your lazy weekend ??
ἔρως
ἔρως7mo ago
yup, i love lazy weekends
roelof
roelofOP7mo ago
mee too expecially now the heart drugs not working properly The specialist and I are trying now for 2 weeks what the right dose it I have now a bloodpressure and heart rate are almost under or just above the border of being a problem But it is now steady
ἔρως
ἔρως7mo ago
which makes it not worth it to get angry at the code
roelof
roelofOP7mo ago
nope health is the most important in life and im not crazy about the code but on the FEM community It looks it always your fault and they never make mistakes
ἔρως
ἔρως7mo ago
that's because they don't want to double-check or are tired of people saying there's mistakes
roelof
roelofOP7mo ago
Could be, I think the easist way it to solve it Then it would not be al lot of people saying it again and again my 2 cts
ἔρως
ἔρως7mo ago
but new devs do get a ton of things wrong
roelof
roelofOP7mo ago
yep that is also why I hear not to use FEM to practice with FE work but it is the only free recourse as far as I know
ἔρως
ἔρως7mo ago
i don't know any other
roelof
roelofOP7mo ago
so the same as with wordpress beginners are not lucky get no good help to get good
ἔρως
ἔρως7mo ago
wordpress' help is pretty eh anyways
roelof
roelofOP7mo ago
exactly use GPT or use a plugin is not always the right way to learn things if you want to learn to make custom thimgs but learning things like Laravel and/or Symphony is very diffcult
ἔρως
ἔρως7mo ago
chatgpt is a terrible idea if you don't know how to do it without chatgpt
roelof
roelofOP7mo ago
Exactly so if im going on with FE work I have to look which way im going
ἔρως
ἔρως7mo ago
front-end or back-end, but need practice in the end
roelof
roelofOP7mo ago
yep but FE can be wordpress work, work with js framework , work with a php framework and so on
ἔρως
ἔρως7mo ago
yeah, it very diverse
roelof
roelofOP7mo ago
or maybe go for full stack js or maybe even a language like ruby Think that c++ is not very usable as full stack
ἔρως
ἔρως7mo ago
no, c++ isn't that usable for this, and very easy to make huge costly mistakes
roelof
roelofOP7mo ago
What do you recommend ?
ἔρως
ἔρως7mo ago
what do you really want to do?
roelof
roelofOP7mo ago
making nice websites for volunteer organisations and challenged myself to become better and better
ἔρως
ἔρως7mo ago
then html, css and javascript
roelof
roelofOP7mo ago
oke, what I do now but first try to finisch this sometimes annoying challenge
ἔρως
ἔρως7mo ago
yes, finish this challenge
roelof
roelofOP7mo ago
and then look for another and another and another 😛 but im happy you and vince are helping me . The FEM comminity is not always very helpfull
Ganesh
Ganesh7mo ago
I keep confusing frontend mentors with frontend masters
roelof
roelofOP7mo ago
🙂 @Ganesh I was complaing that the colors in the readme do not equal the colors of the image And according to a mod on the FEM discord channel you and I are wrong The colors do match
Ganesh
Ganesh7mo ago
according to me they are wrong we can all live in our own realities
roelof
roelofOP7mo ago
I agree for both statements but it makes me wonder if I want to stay with a community which offers very little help
Ganesh
Ganesh7mo ago
It's your choice. There are multiple communities out there at least so it won't be the end
roelof
roelofOP7mo ago
I know this is one of the most welcome and helpfull community I could find Dinner time
Ganesh
Ganesh7mo ago
hope it is tasty
roelof
roelofOP7mo ago
it was tasty. Pasta with tomatos , courgette and some garlic sauce and some ham @Ganesh dark theme almost done Some details to do and that one is also perfect see : https://roelofwobben.github.io/browser-extenstion/ @ἔρως
roelof
roelofOP7mo ago
Border color of the filter buttons is now allright :
No description
roelof
roelofOP7mo ago
or schould it be more dark or bigger then 1px ?
ἔρως
ἔρως7mo ago
can you send the original?
roelof
roelofOP7mo ago
of course
roelof
roelofOP7mo ago
No description
roelof
roelofOP7mo ago
here a better picture
roelof
roelofOP7mo ago
No description
ἔρως
ἔρως7mo ago
the filter buttons are bigger and the active one has no border the "extensions" part needs way higher border radius and a border the dark/light mode checkbox needs border radius too the "extensions list" text needs more font weight
roelof
roelofOP7mo ago
😦 list get longer and longer I tought the light one was already improved 😢 oops. and i missed also the box shadow. Also a PITA one Todo list : - the filter buttons are bigger - and the active one has no border - the "extensions" part needs way higher border radius and a border - the dark/light mode checkbox needs border radius too - the "extensions list" text needs more font weight - choose another red for the dark mode, (done), - look better at the colors of the buttons (I think you mean the filter buttons),, - color the checkboxes in dark mode,, - add switches to the rest of the cards, (done), - look at the box shadows of all blocks - add hover and the other states @ἔρως Do you miss anything ?
ἔρως
ἔρως7mo ago
doesn't look like it
roelof
roelofOP7mo ago
happy to hear if I see the big list I almost loose confident that I ever finisch this one
ἔρως
ἔρως7mo ago
and when it's done, you will be happy about the list being gone
roelof
roelofOP7mo ago
I know but right now the list is getting bigger and bigger every time I ask you for a review but I also know you do that to learn me proper FE
ἔρως
ἔρως7mo ago
it's not just that it's for you to see that, yes, things are too different
roelof
roelofOP7mo ago
sorry what "should" I see ?
ἔρως
ἔρως7mo ago
the differences all of them then you implement a design in css and html, you're supposed to compare both side-by-side and check the differences except when there isn't a design and you're told to "use your best judgement
roelof
roelofOP7mo ago
I see old problem where I have learned to slow down and be more in the moment but still practising to make it myself in the real world With FEM they said this :
Your challenge is to build out this browser extension manager UI and get it looking as close to the design as possible.
Your challenge is to build out this browser extension manager UI and get it looking as close to the design as possible.
very vaque what is "as close as possible"
ἔρως
ἔρως7mo ago
as close as you can
curiousmissfox
curiousmissfox7mo ago
icodethis and scrimba are both free resources to learn FE- scrimba is interactive course platform and ICT gives you challenges where they provide the reference and you rebuild it in their code editor. After you submit your challenge you can look at other submissions and observe how other people approached the same challenge. I found it very helpful and learned a lot from my peers code
iCodeThis
Projects to improve your coding skills!
Learn to code with Scrimba
Scrimba is the fast way of learning to code! Our interactive courses and tutorials will teach you React, Vue, Angular, Web Development, Node.JS, JavaScript, HTML, CSS, and more.
Ganesh
Ganesh7mo ago
Note that I code this only provides design picture and no info on colors font etc.
ἔρως
ἔρως7mo ago
if it is a png, it's good enough if it is a jpeg, you're in deep hell
Ganesh
Ganesh7mo ago
I'm not sure what it is. The platform is web based ide and i didn't see a download option, besides the right click
ἔρως
ἔρως7mo ago
you have to login the icodethis has a reference to your username on that website. im not sure if you intend us to know that information and if it is against the #📝rules - the ones about self-promotion
curiousmissfox
curiousmissfox7mo ago
Def not trying to promote my profile , changed, thanks!
ἔρως
ἔρως7mo ago
i was more worried about you sharing your username unintentionally than the rules, but, you're welcome
roelof
roelofOP7mo ago
Everyone a good weekend ?
ἔρως
ἔρως7mo ago
it was short
roelof
roelofOP7mo ago
I know the feeling I want a week with 4 days weekend and 3 days work
ἔρως
ἔρως7mo ago
i woke up at 6am because it was too bright
roelof
roelofOP7mo ago
Therefore we have curtains that make the room very dark
ἔρως
ἔρως7mo ago
i need the light 😦
roelof
roelofOP7mo ago
me too but not on 6 o clock in the morning @ἔρως you said this :
the filter buttons are bigger
the filter buttons are bigger
` Do you mean the width or the height or both ?
ἔρως
ἔρως7mo ago
both they need to be wider and taller
roelof
roelofOP7mo ago
oke I hope I tommorow have the energy to work on this Today I heared that the hearts drugs needs to be changed again
ἔρως
ἔρως7mo ago
don't worry, the challenge isn't going anywhere
roelof
roelofOP6mo ago
i know is there a "trick" I can see how bigger the buttons must be. Right now it feels im not getting any closer to finisch this project
ἔρως
ἔρως6mo ago
yes: - go to photopea.com - take a screenshot and paste it - upload the image of the challenge - make the challenge image transparent - align the image - increase/decrease opacity and see what's wrong
roelof
roelofOP6mo ago
thanks for the hint
ἔρως
ἔρως6mo ago
you're welcome
roelof
roelofOP6mo ago
When I see the list of things that need to be changed getting longer and longer I loose hope
ἔρως
ἔρως6mo ago
that's normal just focus on one thing at a time
roelof
roelofOP6mo ago
I tried that trick with photopea but my layout is so different from the orginal I cannot see how much I have to change on the buttons and so on
ἔρως
ἔρως6mo ago
then crop to the buttons, if you can
roelof
roelofOP6mo ago
Tried also that one
ἔρως
ἔρως6mo ago
then use just that, and try to make both look the same
roelof
roelofOP6mo ago
I mean, then i also do not see it yes, the buttons are too small but because the gap is also different it is a big mess on the screen Too much for me to see what I exactly need to change
ἔρως
ἔρως6mo ago
try to fix the gap and width
roelof
roelofOP6mo ago
bummer, buttons need a lot bigger
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
yup, make the first button the same size, then move on
roelof
roelofOP6mo ago
Height not so much , I think 2 - 4 pixels But the width a lot 😦 Hopefully I can find out how big they need to be
ἔρως
ἔρως6mo ago
here's an idea: go by huge increments of 20 or 10 pixels then reduce to 5 pixels
roelof
roelofOP6mo ago
looks to me the width needs to be 2 times it is now 😦
ἔρως
ἔρως6mo ago
then 1 pixel do it
roelof
roelofOP6mo ago
This will be a lot of trying , making a screenshot and looking 😦
ἔρως
ἔρως6mo ago
you can use the snipping tool for a smaller screenshot area
roelof
roelofOP6mo ago
If I want it really the same I have to do that a lot I think the header is also not perfect as a example
ἔρως
ἔρως6mo ago
yeah, which is why you try to fix more things at once like the grid
roelof
roelofOP6mo ago
maybe , I see at the header that the height is not well and the icon is bigger and more nearby the border So if I want to make it perfect, I have to change a lot of things 😦
ἔρως
ἔρως6mo ago
yup
roelof
roelofOP6mo ago
but I wonder if I have to do it
ἔρως
ἔρως6mo ago
nope you don't have to do it just has to be as close as possible
roelof
roelofOP6mo ago
still a vague description for someone with autism
ἔρως
ἔρως6mo ago
basically, it means "if you're happy with it, that's enough" perfection isn't required or expected
roelof
roelofOP6mo ago
oke, and im happy as it is almost perfect. Perfection is required by myself When I do what you said I see 100 things that need to be changed And that makes me feel like I said earlier
ἔρως
ἔρως6mo ago
i know how it feels
roelof
roelofOP6mo ago
Time to sleep now And if I try to make it more perfect then I have to do it one part by 1 part So it will takes some time before I can goto js 😦
ἔρως
ἔρως6mo ago
you did a lot today
roelof
roelofOP6mo ago
yep, but not on this challenge 🙂
ἔρως
ἔρως6mo ago
and that's perfectly fine
roelof
roelofOP6mo ago
I know a lot to do to make this very good I have to see when I have time and energy for it
ἔρως
ἔρως6mo ago
maybe on friday, so you rest tomorrow?
roelof
roelofOP6mo ago
have to see I like to do every day a little
ἔρως
ἔρως6mo ago
just a little
roelof
roelofOP6mo ago
oke boss then tomorrow look if I can get the height of the header right
ἔρως
ἔρως6mo ago
you should be able to
roelof
roelofOP6mo ago
we see
ἔρως
ἔρως6mo ago
you can do it
roelof
roelofOP6mo ago
I know but we see if I can do it in one day or that it costs me more days
ἔρως
ἔρως6mo ago
if it takes more days, then it takes more days
roelof
roelofOP6mo ago
exactly perfection costs time
vince
vince6mo ago
Couldn't you just add something like padding: 6px to the button and be done with it? Are you trying to manually set the widths and heights? don't do that if you are
ἔρως
ἔρως6mo ago
adjusting paddings does work and that's what's needed
roelof
roelofOP6mo ago
I have set a this :
padding: 6px 2px
padding: 6px 2px
I tried to adjust it but then the text is not in the middle somehow So I add a width to the second and thirth button @vince
vince
vince6mo ago
Don't add a width but I know you're going to bed soon so we can talk tomorrow or whenever Keep it simple
roelof
roelofOP6mo ago
oke I can delete it I think the numbers will be something like this :
padding: 12px 4px
padding: 12px 4px
i needs a very little higher and about 2x the width it has now
vince
vince6mo ago
The width of those buttons are determined by the text inside of it, so you shouldn't need to do anything other than put the same padding on all of the buttons and let the content dictate the width You might need a larger font size Idk though I don't have the design on hand
roelof
roelofOP6mo ago
oke I tried the padding but no luck
roelof
roelofOP6mo ago
No description
roelof
roelofOP6mo ago
and it has to be
No description
roelof
roelofOP6mo ago
the buttons make me crazy @vince @ἔρως GN live link : https://roelofwobben.github.io/browser-extenstion/
vince
vince6mo ago
gn You don't need to make them exact
vince
vince6mo ago
No description
vince
vince6mo ago
No description
vince
vince6mo ago
I increased the font-size to 1.125rem, padding: 8px 16px, line-height: 1, and align-items: center in the parent container.
roelof
roelofOP6mo ago
Thanks looks very good to me Forget the line height
vince
vince6mo ago
You don't need it, I just like being intentional about it (when I remember lol). Go to bed though this is tomorrow / Friday thing
roelof
roelofOP6mo ago
Yes boss😴 Why crying ?
ἔρως
ἔρως6mo ago
that's not a tear, that's a drool drop from a sleepy emoji
roelof
roelofOP6mo ago
sorry
ἔρως
ἔρως6mo ago
for?
roelof
roelofOP6mo ago
mis reading the emonicon I just read that it means something else @vince align-items on the button does not work because it is not a grid or flex item. When adding it it messed up my layout hmm, which parent does Vince mean here :
and align-items: center in the parent container
and align-items: center in the parent container
I tried several but still no luck so please some help to figure this out ?
ἔρως
ἔρως6mo ago
use inline-flex
roelof
roelofOP6mo ago
I will try after lunch you mean on the button ??
ἔρως
ἔρως6mo ago
yes
roelof
roelofOP6mo ago
Does not make the text centered on the buttons :
No description
ἔρως
ἔρως6mo ago
no, but makes it so you can center it with the property vince told you
roelof
roelofOP6mo ago
I did that as far as I know :
and align-items: center in the parent container
and align-items: center in the parent container
vince
vince6mo ago
The parent container that holds the Extension List title and buttons Remove the widths from buttons
ἔρως
ἔρως6mo ago
oh, thst that
roelof
roelofOP6mo ago
Then still the text in the buttons is not right:
No description
ἔρως
ἔρως6mo ago
dont give them a width
roelof
roelofOP6mo ago
I did not I disabled all the widths as far as I know
vince
vince6mo ago
You haven't You have a width on all of them using :nth-child() selector
roelof
roelofOP6mo ago
I disabled it :
No description
ἔρως
ἔρως6mo ago
the last one still has a width
roelof
roelofOP6mo ago
then I have to look where that width is coming from
ἔρως
ἔρως6mo ago
just inspect the button
roelof
roelofOP6mo ago
found it
ἔρως
ἔρως6mo ago
delete it
roelof
roelofOP6mo ago
I will do
roelof
roelofOP6mo ago
buttons looks good now I hope when I compare them with the orginal they are good now
No description
ἔρως
ἔρως6mo ago
it's possible that there are tiny differences
roelof
roelofOP6mo ago
css can sometimes be a real PITA
vince
vince6mo ago
Capture the 'essence' of the design, doesn't have to be exact. So I made those buttons that big because that's what it looked like proportionally in the design to the title 'Extensions List' You can also bend the design a bit too if you're just working on it yourself
roelof
roelofOP6mo ago
oke so one of my list 🙂 Todo list : the filter buttons are bigger (done) and the active one has no border, the "extensions" part needs way higher border radius and a border, the dark/light mode checkbox needs border radius too, the "extensions list" text needs more font weight, choose another red for the dark mode, (done),, look better at the colors of the buttons (I think you mean the filter buttons),,, color the checkboxes in dark mode,,, add switches to the rest of the cards, (done),, look at the box shadows of all blocks, add hover and the other states,
ἔρως
ἔρως6mo ago
the list is smaller bow now
roelof
roelofOP6mo ago
yep one real pita is still there . the box shadows 😦 I hope I can do that one for last
vince
vince6mo ago
https://getcssscan.com/css-box-shadow-examples This is my go to. I just pick one based off what would look good or close to the design for each project If you have a figma file you can get the exact box-shadow, but even then sometimes it doesn't look good in the browser, so I end up just using something from that site
roelof
roelofOP6mo ago
that is handy I doubt between 2 and 6
vince
vince6mo ago
You want something more subtle since there's going to be a lot of box shadows right next to each other (since they're going on cards), so maybe something like #36 - #39 but play around with whatever on there and see what works
roelof
roelofOP6mo ago
im thinking then more about #36 #39 seems to big
roelof
roelofOP6mo ago
@vince @ἔρως what do you think about the box shadow :
No description
roelof
roelofOP6mo ago
orginal :
No description
vince
vince6mo ago
looks really good!
roelof
roelofOP6mo ago
I thought also another problem solved 🙂
vince
vince6mo ago
Add a very slight 1px solid gray border (gray being whatever color they gave you for light gray) idk how it'll look but we can try it
roelof
roelofOP6mo ago
I have three grays
roelof
roelofOP6mo ago
which one do you think of :
No description
roelof
roelofOP6mo ago
I doubt between : - button border color - filter-button-color
ἔρως
ἔρως6mo ago
try them all
roelof
roelofOP6mo ago
oke boss 😛 will be tomorrow.. Dinner is almost ready And I need time to rest but you mean as border and then the shadow ?
vince
vince6mo ago
Yea both
vince
vince6mo ago
I don't think your font is loading correctly?
No description
vince
vince6mo ago
Looks like the url path is messed up Maybe it's not though? I've just never seen it like that Nevermind don't listen to me it's loading correctly
vince
vince6mo ago
No description
roelof
roelofOP6mo ago
yep, old problem first time it does not show up in the network tab and when you do ctrl f5 then it shows up still I wonder if the path should be ./assets....... ? oke, it loaded so I think the path is allright
vince
vince6mo ago
Yep path is correct 😁
No description
roelof
roelofOP6mo ago
happy to hear if the todo list gets longer I become more crazy then I m now
vince
vince6mo ago
How about we just say this one's finished, it doesn't seem like you're having fun with it anymore You're doing this as a hobby treat it like one, not work
roelof
roelofOP6mo ago
I know and I want to make the last todo also work and of course the js and maybe later some things that are not asked but could be nice to have as adding or editing cards oke, changed it on the real site @vince @ἔρως happy so far https://roelofwobben.github.io/browser-extenstion/
ἔρως
ἔρως6mo ago
i will check in a bit, playing overwatch now
roelof
roelofOP6mo ago
NP
vince
vince6mo ago
looks good!
roelof
roelofOP6mo ago
@vince thanks Todo list : - and the active button one has no border, - the "extensions" part needs way higher border radius and a border, - the dark/light mode checkbox needs border radius too, - the "extensions list" text needs more font weight, - look better at the colors of the buttons (I think you mean the filter buttons),,, - color the checkboxes in dark mode,,, - add hover and the other states, 7 to go then some are really simple
ἔρως
ἔρως6mo ago
did you color the switches?
roelof
roelofOP6mo ago
nope, still on the todo list second last one I only make the buttons good and add box-shadow where needed @ἔρως
ἔρως
ἔρως6mo ago
oh, that's what you meant 7 things that's not bad at all
roelof
roelofOP6mo ago
maybe tomorrow I can try to solve 2- 3 things
ἔρως
ἔρως6mo ago
and today, you rest
roelof
roelofOP6mo ago
Most difficult one I think is the bigger border-radius on things yep I hope between now and a hour to sleep
ἔρως
ἔρως6mo ago
just do what i said before: go big and then adjust
roelof
roelofOP6mo ago
What do you mean exactly with go big ??
ἔρως
ἔρως6mo ago
just pick a random value that's seems about correct which will probably be too much for the border radius
roelof
roelofOP6mo ago
if I think really really big it will be a fullstack one with a database But then I think I need to use a framework and therefore it is now to early
ἔρως
ἔρως6mo ago
what?
roelof
roelofOP6mo ago
chips , I forget one thing on my todo Make it work so it reads the json
ἔρως
ἔρως6mo ago
that's the last one
roelof
roelofOP6mo ago
could be I think I have then to rewrite some html so that js makes the card But we see when we get there
vince
vince6mo ago
You could make it a variable like var(--border-radius) and then just change it once and it applies to everything
ἔρως
ἔρως6mo ago
that's what those are for
roelof
roelofOP6mo ago
could be a good solution
vince
vince6mo ago
It is the professional solution
roelof
roelofOP6mo ago
I only have to find the good value I do now 8px and according to the feedback of one of you two that is too small so some trying to do tomorrow to find the right value maybe around 20px ? GN both
ἔρως
ἔρως6mo ago
goodnight
roelof
roelofOP6mo ago
GM
roelof
roelofOP6mo ago
What do you think of this border-radius:
No description
ἔρως
ἔρως6mo ago
for the filters?
roelof
roelofOP6mo ago
for the header, and the cards and the moon icon I changed the border-radius I thought the filters had a good one @ἔρως A quick detour : Could this not be a wordpress theme or plugin or both in the far far future ?
ἔρως
ἔρως6mo ago
the moon checkbox is missing the border radius it could, if the license allows you to use the design for anything outside the project
roelof
roelofOP6mo ago
chips I have then to look where things went wrong
ἔρως
ἔρως6mo ago
that checkbox (for the light/dark theme) just needs the same border radius as the header
roelof
roelofOP6mo ago
hmm, then it looks not good to me
No description
roelof
roelofOP6mo ago
it schould look like this :
No description
roelof
roelofOP6mo ago
so I think the icon needs to be bigger or the border-radius needs to be smaller I tried to make everything 30px bigger but then the icon looks very big
ἔρως
ἔρως6mo ago
you are right, the 2nd one looks a lot better and seems closer to the design
roelof
roelofOP6mo ago
the second is the design 🙂 so back to a border-radius of 8 - 10 pixels ?
ἔρως
ἔρως6mo ago
is the border radius in a variable?
roelof
roelofOP6mo ago
at this moment it is with a value of 20px But I think that is too big for the icon
ἔρως
ἔρως6mo ago
then do this: border-radius: max(0px, var(--variable-name) - 4px); the max function selects the highest value - if the variable has 20px then it will pick 16px (20 - 4) because 16 is higher than 0 if you set the variable to 4px or lower, then it will be 0px, because negative values are lower than 0px if you need, adjust the 4px for something else
roelof
roelofOP6mo ago
thanks
roelof
roelofOP6mo ago
this looks well to me :
No description
roelof
roelofOP6mo ago
but I see something wierd I suddenly have this :

#theme-toggle::before {
content:"";
display: block;
background-image: url('./assets/images/icon-sun.svg');
width: 50px;
height: 50px;
background-size: cover;
background-color: var( --background-color-icon);

}


#theme-toggle::before {
content:"";
display: block;
background-image: url('./assets/images/icon-moon.svg');
width: 30px;
height: 30px;
background-size: cover;




}

#theme-toggle::before {
content:"";
display: block;
background-image: url('./assets/images/icon-sun.svg');
width: 50px;
height: 50px;
background-size: cover;
background-color: var( --background-color-icon);

}


#theme-toggle::before {
content:"";
display: block;
background-image: url('./assets/images/icon-moon.svg');
width: 30px;
height: 30px;
background-size: cover;




}
two times the same selector does not look well to me
ἔρως
ἔρως6mo ago
are those in separated places?
roelof
roelofOP6mo ago
yep deleted the second and adapted the :"checked one and everything works fine but what do you think of the border-radius of the icon ?
ἔρως
ἔρως6mo ago
i think it looks close enough since we dont have dimensions, im guestimating everything
roelof
roelofOP6mo ago
yep. the disadvantage of only having pictures instead of design files
ἔρως
ἔρως6mo ago
i did notice that the spacing at the top and bottom is too big maybe the size of it is incorrect or the text is too big
roelof
roelofOP6mo ago
todo list gets smaller and smaller : - and the active button one has no border,, - the "extensions" part needs a border,, - the "extensions list" text needs more font weight,, - look better at the colors of the buttons (I think you mean the filter buttons),,,, - color the checkboxes in dark mode,,,, - add hover and the other states, - read the json and use that Which spacing the spacing in the header ?
ἔρως
ἔρως6mo ago
yes, but at the top and bottom
roelof
roelofOP6mo ago
oke
roelof
roelofOP6mo ago
something like this :
No description
ἔρως
ἔρως6mo ago
you've reverted something, because the border radius is gone
roelof
roelofOP6mo ago
no , I did not submit something one change was local , the other in the browser 😦 all changes are submitted I think it needs to be bigger the icon looks now very very big
roelof
roelofOP6mo ago
No description
roelof
roelofOP6mo ago
for my oponion this looks better :
No description
ἔρως
ἔρως6mo ago
it looks much closed, but now the "extensions" text is misaligned
roelof
roelofOP6mo ago
on the second one ?
roelof
roelofOP6mo ago
this better :
No description
ἔρως
ἔρως6mo ago
no, it's not properly aligned it's too at the top
roelof
roelofOP6mo ago
oke then i have to think how to solve it
ἔρως
ἔρως6mo ago
is that a grid?
roelof
roelofOP6mo ago
At this moment, it is a flex instead of a grid
ἔρως
ἔρως6mo ago
eh, it works inspect it
roelof
roelofOP6mo ago
This is the css at the moment
header {
width: 100%;
max-width: 1200px;
display: flex;
justify-content: space-between;
background-color: var(--background-color);
margin-top: 1em;
padding: 0.5em;
border-radius: var(--border-radius);
box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.06) 0px 1px 2px 0px;
}
header {
width: 100%;
max-width: 1200px;
display: flex;
justify-content: space-between;
background-color: var(--background-color);
margin-top: 1em;
padding: 0.5em;
border-radius: var(--border-radius);
box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.06) 0px 1px 2px 0px;
}
ἔρως
ἔρως6mo ago
then click next to the display: flex click on the buttons that have something showing a line in the middle
roelof
roelofOP6mo ago
sorry. I miss you I have this :
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
you see the display flex? it has a button
roelof
roelofOP6mo ago
where do you see buttons that show a line in the middle
ἔρως
ἔρως6mo ago
click it
roelof
roelofOP6mo ago
I did that and then I see this
ἔρως
ἔρως6mo ago
then click on whatever buttons have a line in the middle
roelof
roelofOP6mo ago
sorry, that button I do not see anywhere
ἔρως
ἔρως6mo ago
oh, right, in firefox the button does something else do it on chrome, if you have it or on edge
roelof
roelofOP6mo ago
you mean the align-items button ?
ἔρως
ἔρως6mo ago
yes, or the other one i forget the names
roelof
roelofOP6mo ago
np
ἔρως
ἔρως6mo ago
clicking the buttons and seeing things happen is easier
roelof
roelofOP6mo ago
I already add that in the latest screenshot
ἔρως
ἔρως6mo ago
alright
roelof
roelofOP6mo ago
No description
roelof
roelofOP6mo ago
is this allright ? Then I hope in the weekend i can solve the rest of the todo now time to rest
ἔρως
ἔρως6mo ago
nope, try the align-content too
roelof
roelofOP6mo ago
Then nothing happens I tried that also
ἔρως
ἔρως6mo ago
is it live?
roelof
roelofOP6mo ago
the site is live from the begining https://roelofwobben.github.io/browser-extenstion/ this is without the align stuff
ἔρως
ἔρως6mo ago
this is the problem
No description
ἔρως
ἔρως6mo ago
just add this to that element:
display: grid;
align-items: center;
display: grid;
align-items: center;
roelof
roelofOP6mo ago
oke I thought of :

align-items: center;
display: flex;

align-items: center;
display: flex;
ἔρως
ἔρως6mo ago
that causes the image to take too much space
roelof
roelofOP6mo ago
oke I take your suggestiojn
roelof
roelofOP6mo ago
and it looks now like this :
No description
ἔρως
ἔρως6mo ago
perfectly centered
roelof
roelofOP6mo ago
happy to hear another problem bites the dust
ἔρως
ἔρως6mo ago
can you share the original one?
roelof
roelofOP6mo ago
of course:
No description
roelof
roelofOP6mo ago
@ἔρως still a few things to solve
Ganesh
Ganesh6mo ago
I think you can just pin the original design pic since so people don't have to scroll to top everytime or ask you to post it
ἔρως
ἔρως6mo ago
change the grid to flex and then increase the padding we don't have permission to pin things
Ganesh
Ganesh6mo ago
Same for the site url Oh right Only mods can do that
roelof
roelofOP6mo ago
@ἔρως where do I have to change it
Ganesh
Ganesh6mo ago
Thought at least forms would allow the creator to pin stuff too
ἔρως
ἔρως6mo ago
the grid to flex is the same place the padding is on the header we can ask the moderators for that permission, but i think we don't have because it applies to the entire forum: including the post list
roelof
roelofOP6mo ago
I miss you That is already a grid

.logo-container {
display: grid;
align-items: center;

}

.logo-container {
display: grid;
align-items: center;

}
ἔρως
ἔρως6mo ago
this
roelof
roelofOP6mo ago
@ἔρως in the github it is already flex
Ganesh
Ganesh6mo ago
Ah damn that's not very convenient if it applies to whole form
roelof
roelofOP6mo ago
padding is now 0.8 rem Back to 1rem on the header I will change that after a big break Heading to bed to take a long break
ἔρως
ἔρως6mo ago
you sound like you need a big nap forums were an afterthought like many things discord does
Ganesh
Ganesh6mo ago
Main features seem like an afterthought too these days
ἔρως
ἔρως6mo ago
yup
roelof
roelofOP6mo ago
Padding of the header back to 1rem ??
ἔρως
ἔρως6mo ago
try it
roelof
roelofOP6mo ago
with padding 1 rem it looks like this:
No description
ἔρως
ἔρως6mo ago
can you compare to the original, like how i explained yesterday?
roelof
roelofOP6mo ago
looks good to me
ἔρως
ἔρως6mo ago
keep it then
roelof
roelofOP6mo ago
oke then still to do : - and the active button one has no border,,, - the "extensions" part needs a border,,, - look better at the colors of the buttons (I think you mean the filter buttons),,,,, - color the checkboxes in dark mode,,,,, - add hover and the other states,, still a big list but 2 of them bite the dust today the first one needs some fiddeling . no idea what color red is the border but first time for dinner 🙂
ἔρως
ἔρως6mo ago
dont push yourself too hard too
roelof
roelofOP6mo ago
I know that is for the weekend and maybe even after it
ἔρως
ἔρως6mo ago
maybe monday?
roelof
roelofOP6mo ago
can be or saturday 2 , sunday 2 and monday 1 Monday also a appoiment with the dentist 😦 and I still hope im a good junior which learns a lot
ἔρως
ἔρως6mo ago
well, i noticed something you're so unsure of yourself you're not being able to see that something isn't exactly correct
roelof
roelofOP6mo ago
I know. Im very unsure of myself. There were and are moments I do not feel worthy.
ἔρως
ἔρως6mo ago
pointing out that something you've done isn't "correct" is an important skill too and not being right is fine
roelof
roelofOP6mo ago
and the surgery of December has made me mental very vry unstable
ἔρως
ἔρως6mo ago
today, i had to replicate a design and i did some things that weren't 100% perfect and guess what? nobody cares
roelof
roelofOP6mo ago
I know that im not always right and have to learn a lot
ἔρως
ἔρως6mo ago
as long as it looks close enough when comparing your version with the design, that is absolutely fine
roelof
roelofOP6mo ago
That is why I m happy with the therapy I get. We have it now about that im much too strict of myself and how I can turn that around but it needs time to change. What im done in almost 60 years is not changed in a few days I still feel that everything has to be perfect to the design
ἔρως
ἔρως6mo ago
that's the problem: it will never be and i mean never just a difference in dpi or screen resolution will change everything even a different version of the fonts will change everything
roelof
roelofOP6mo ago
I know but a voice inside me says it needs to be I have to let see how good Im for myself I must solve this challenge and be already finisned it but we are going off topic
ἔρως
ἔρως6mo ago
you can consider your project finished at any time you think you're happy about it
roelof
roelofOP6mo ago
that is the problem Im never be happy I always see things to improve or things to add
ἔρως
ἔρως6mo ago
knowing when a project is done is an important skill
roelof
roelofOP6mo ago
oke I m now looking for the color of the active button border
ἔρως
ἔρως6mo ago
alright
roelof
roelofOP6mo ago
Borders around the filter buttons schould also be good
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
they do look good
roelof
roelofOP6mo ago
Thanks what was already the problem here :
the "extensions" part needs a border,,,
the "extensions" part needs a border,,,
if you mean the cards , they already have a box-shadow so they need also a border ?
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
no, it was the "extensions" part the whole thing
roelof
roelofOP6mo ago
oke, I do not see a border on the light theme also not on the dark theme
ἔρως
ἔρως6mo ago
move along then
roelof
roelofOP6mo ago
oke Then for the weekend : oke then still to do : - look better at the colors of the buttons (I think you mean the filter buttons),,,,, - color the checkboxes in dark mode,,,,, - add hover and the other states,, The first one I need to look well what was meant then
ἔρως
ἔρως6mo ago
it was the filter buttons but check if the colors are correct in dark mode the enable/disable checkboxes have the wrong color in light mode too
roelof
roelofOP6mo ago
Oke nice to do in the weekend
vince
vince6mo ago
have mercy 😂 @ἔρως (jokes)
roelof
roelofOP6mo ago
The last one looks simplex to solve for me @vince why?
vince
vince6mo ago
lol I was just making a joke about how they're adding more to your to do list 😂
roelof
roelofOP6mo ago
One very little thing thst Costa a few minuten to solve
vince
vince6mo ago
that's a relief 😄
roelof
roelofOP6mo ago
Hru? @vince And hru? @ἔρως
ἔρως
ἔρως6mo ago
cooking in this heat it's 31ºc in my bedroom
roelof
roelofOP6mo ago
Bummer You are a late eater Im watching tv
ἔρως
ἔρως6mo ago
it's 7:39pm not that late
roelof
roelofOP6mo ago
For dutch People it is late
ἔρως
ἔρως6mo ago
not for me sometimes i eat dinner at midnight
roelof
roelofOP6mo ago
I have to be in bed around 22.30 - 23.00 to feel like a human the next day
vince
vince6mo ago
Tired as always It's 15:00 here
roelof
roelofOP6mo ago
Here it is 21.00
ἔρως
ἔρως6mo ago
here's 8pm
roelof
roelofOP6mo ago
Three man three timezones Beauty of internet
ἔρως
ἔρως6mo ago
my timezone is easy: same as uk
roelof
roelofOP6mo ago
oke @ἔρως you live in France if im not mistaken I thought that they just like me are in the Europe/Amsterdam timezone
ἔρως
ἔρως6mo ago
nope, not france portugal
roelof
roelofOP6mo ago
almost good 😛 Time to sleep
ἔρως
ἔρως6mo ago
yes, too hot here goodnight
roelof
roelofOP6mo ago
Here it is at the moment 18 degrees outside and 22 inside So I hope I can sleep
ἔρως
ἔρως6mo ago
31ºc in my bedroom
roelof
roelofOP6mo ago
then I wish you good luck when you try to sleep later GN for real
ἔρως
ἔρως6mo ago
goodnight
roelof
roelofOP6mo ago
The last remarks solving will take some longer I still think the colors of some things are not right
ἔρως
ἔρως6mo ago
double-check the colors
roelof
roelofOP6mo ago
I will do that this weekend
ἔρως
ἔρως6mo ago
do it when you wish, as long as you don't overdo yourself
roelof
roelofOP6mo ago
that I try to do still learning
ἔρως
ἔρως6mo ago
it takes time, but don't worry
roelof
roelofOP6mo ago
yep, time , practice and a lot of failing and trying again just like verything you try to learn in life
ἔρως
ἔρως6mo ago
yup, but we can tell you what's wrong instead of you finding it all by yourself
roelof
roelofOP6mo ago
You can I like the current therapy because first we see a bad behaviour and then we practice a lot with some better behaviour And there I learn a lot from So I still think I messed up the css stuff with the colors. If I would do it again, I would leave the colors as It is And use that names for things like background-color. I think it is then easier to change because now I see that some colors are used on multiple places
ἔρως
ἔρως6mo ago
yup, and those colors can be set to variables which are used for multiple places
roelof
roelofOP6mo ago
exactly more code but I think in the long run easier to maintain then the mess I made
ἔρως
ἔρως6mo ago
and easier to change too
roelof
roelofOP6mo ago
do we not both say the same ??
ἔρως
ἔρως6mo ago
no, easier to maintain doesn't mean easier to change
roelof
roelofOP6mo ago
oke for me it feels the same
ἔρως
ἔρως6mo ago
i honestly can see them as almost the same thing
roelof
roelofOP6mo ago
oke more work to do 😦
ἔρως
ἔρως6mo ago
a little, yeah
roelof
roelofOP6mo ago
Work for tomorrow I think Almost time for dinner Off topic question: What stack do you work with ? @ἔρως
ἔρως
ἔρως6mo ago
at work, i've been using php (with wordpress), html, css, js, mysql i've used other languages before, like blade from laravel, use scss as well and use typescript as just a type checking tool
roelof
roelofOP6mo ago
oke
ἔρως
ἔρως6mo ago
i do know and use a lot more than this, but that's what i use daily for work
roelof
roelofOP6mo ago
I have a hate/live relationship with wordpress Sometimes I looks a fun tool to help volunteer organisation to get nice websites I know a site where very little volunteer organisations asked for a wordpress developer to update the theme but the help ypu get from the community is almost none for a beginner like me
ἔρως
ἔρως6mo ago
if you just want to learn wordpress, now-a-days, the best is to make a block-based theme
roelof
roelofOP6mo ago
i know but I find no free good courses or tutorials how I can approach this if I want to build a new theme from stratch Do I put the colors and css in the json or in the database ? So a lot of question and no answers but as I said earlier First practice a lot with html css and js
ἔρως
ἔρως6mo ago
yeah, i don't think there's any (paid or free) content, but i didn't try to find much
roelof
roelofOP6mo ago
if I see how long it cost me now to make this one ready . I think it will costs me a lot more practice to get really comfertable with just html , css and js and I noticed for real custom sites you need a lot of custom css in wordpress So that is why I first want to be good at it and then in the far far future learn to write my own plugins So I can make in wordpress what I have in mind To come back at the FEM challenges I also have a dream to solve all the free challenges there
ἔρως
ἔρως6mo ago
you will need to finish the next project a little faster then
roelof
roelofOP6mo ago
I hope I can depends on how difficult the next one is There are beginnes challenges , you can do in a afternoon And there are ones that costs some time
roelof
roelofOP6mo ago
Frontend Mentor
Frontend Mentor | Social links profile coding challenge
In this small project, you'll build out your social link-sharing profile. You can even personalize it and use it to share all your social profiles!
roelof
roelofOP6mo ago
Frontend Mentor
Frontend Mentor | Interactive comments section coding challenge
This is project will put your JavaScript skills to the test. We provide a JSON file to pull the data, but it's also a perfect project to build as a full-stack CRUD app!
roelof
roelofOP6mo ago
Frontend Mentor
Frontend Mentor | E-commerce product page coding challenge
In this challenge, you'll build a beautiful product page. We'll be putting your JS skills to the test with a lightbox product gallery and cart functionality!
ἔρως
ἔρως6mo ago
try this one next
roelof
roelofOP6mo ago
Which one?
ἔρως
ἔρως6mo ago
the first one
roelof
roelofOP6mo ago
Oke is a beginners one where the one im woeking now is a junior one But that is not a problem
ἔρως
ἔρως6mo ago
it's a quick win to keep your spirit up
roelof
roelofOP6mo ago
I hope so
roelof
roelofOP6mo ago
I wanted to show you one challenge which is bugging me still https://www.frontendmentor.io/challenges/room-homepage-BtdBY_ENq the layout is simple but making it work that the image slide and the text next to it , has never be a success for me
Frontend Mentor
Frontend Mentor | Room homepage coding challenge
This small homepage challenge packs a big punch to test your layout skills. There's also a slider in there to add a JS layer for extra practice.
roelof
roelofOP6mo ago
no idea if you an reach this page : https://www.frontendmentor.io/challenges?type=free%2Cfree-plus but that are all free challenges
Frontend Mentor
Frontend Mentor | Challenges
Browse through the front-end coding challenges on Frontend Mentor. Find interesting projects to practice your HTML, CSS and JavaScript
roelof
roelofOP6mo ago
@ἔρως but I can do the social link thing after i finished this one after that we can look again @vince and enjoying the weekend ?
vince
vince6mo ago
Lots of stuff to do haha What aboht u
roelof
roelofOP6mo ago
Still struggeling to make the colors right so also a lot to do I hope after this weekend , i finally can begin with the js and call it a day
ἔρως
ἔρως6mo ago
yeah, do the social links first
roelof
roelofOP6mo ago
and work on two at the same time Is that good ? Time to do the dishes 😦
ἔρως
ἔρως6mo ago
after you finish this one
roelof
roelofOP6mo ago
oke, that was also my idea I think making the js work, takes not so many time after I have to colors right 😦
ἔρως
ἔρως6mo ago
it will be the easier part
roelof
roelofOP6mo ago
we see js cana also be a PITA sometimes
ἔρως
ἔρως6mo ago
yeah, but it's easier than css to debug
roelof
roelofOP6mo ago
we see it I think the js for this one schould not be very hard - reading and parsing the json to localstorage - storing the theme into localstorange and for filtering you have a library that can help so maybe 1 or 2 afternoons work Time to watch tv and hopefullu in 2 - 2 and a 1/2 hour sleeping
ἔρως
ἔρως6mo ago
it should be about that
roelof
roelofOP6mo ago
maybe tomrrow or Monday after a dentist appoinment I can try to write some js And then later look again at those stupid dark colors
ἔρως
ἔρως6mo ago
do it when you can
roelof
roelofOP6mo ago
of course but I had the idea to do all the css first and the js after that But css makes me a little crazy but maybe time to set it on later and work on the js Gn both
ἔρως
ἔρως6mo ago
goodnight
curiousmissfox
curiousmissfox6mo ago
Good looking out, appreciate that ✨️
roelof
roelofOP6mo ago
GM MissFox @vince @ἔρως today no working on this project. Since ysterday evening I do not feel very well but well enough to not call for a doctor
ἔρως
ἔρως6mo ago
you're welcome yeah, you should fix yourself then, and take a few days
roelof
roelofOP6mo ago
I know but I also learned easy fixes do not exist
ἔρως
ἔρως6mo ago
they do, but not always
roelof
roelofOP6mo ago
for a lot of problems in life , there are no quick fixes I mean Most problems can only be solved by hard work 😦
ἔρως
ἔρως6mo ago
and in your case, resting
roelof
roelofOP6mo ago
also a good part and a important part but fixing myself will costs I think some months , maybe even years
ἔρως
ἔρως6mo ago
yeah, but don't overdo yourself because of a challenge
roelof
roelofOP6mo ago
i take care of that I look every day what I can do and cannot
ἔρως
ἔρως6mo ago
i know you do
roelof
roelofOP6mo ago
🙂 but thanks for looking after me (I hope I use the right words)
ἔρως
ἔρως6mo ago
you did use the right words, and you're welcome
roelof
roelofOP6mo ago
maybe my dream of becoming a good hobby wordpress developer can become true, even on very "old" age
ἔρως
ἔρως6mo ago
it can, but you still need to practice
roelof
roelofOP6mo ago
a lot of practice with html, css and js And then a lot of practice with making good block themes And then maybe a lot of practice with making block plugins So I will be busy till I die sometimes 😛
ἔρως
ἔρως6mo ago
i think you will finish the next ones a lot faster
roelof
roelofOP6mo ago
we see when we get there little step at the time bring you the most far
ἔρως
ἔρως6mo ago
exactly, and each step helps
roelof
roelofOP6mo ago
yep, I saw a nice quote on a sporting school You never loose, you win or you learn something
ἔρως
ἔρως6mo ago
and that is the truth
roelof
roelofOP6mo ago
was a litle playing But what do you think of this edit button which we can use later on
No description
Ganesh
Ganesh6mo ago
The order annoys me Or maybe it's the distance between first two being less than second teo Feels off
roelof
roelofOP6mo ago
order can be changed the distance I have to look but I will delete it. was a little playing for maybe a future idea first I have to make the current things work properly
Ganesh
Ganesh6mo ago
Yeah sure. Easier to finish the spec first
roelof
roelofOP6mo ago
exactky but it was a idea when everything is ready to add also a edit and a add @Ganesh to make it "perfect"
Ganesh
Ganesh6mo ago
XD Well it wouldn't be a bad idea imo
roelof
roelofOP6mo ago
I thought that also Why only a delete one Have to think where I put a button or link for adding things but as I said that can all be later
ἔρως
ἔρως6mo ago
since you're doing a challenge, it's best to keep it within the parameters of the challenge - at least until you finish everything personally, i don't like it because it looks like the delete button and because it is centered
roelof
roelofOP6mo ago
oke this are the requiremtents :
Your users should be able to:

- Toggle extensions between active and inactive states
- Filter active and inactive extensions
- Remove extensions from the list
- Select their color theme
- View the optimal layout for the interface depending on their device's screen size
- See hover and focus states for all interactive elements on the page
Your users should be able to:

- Toggle extensions between active and inactive states
- Filter active and inactive extensions
- Remove extensions from the list
- Select their color theme
- View the optimal layout for the interface depending on their device's screen size
- See hover and focus states for all interactive elements on the page
but I also have heared that to build a real portfolio it is better to make some extra miles and add things yopu like
ἔρως
ἔρως6mo ago
yes, but you should add after you're done with the base level
roelof
roelofOP6mo ago
of course Wish me luck with the dentist tomorrow First a checkup and then I have to goto a dental hygienist to make my thooth very clean because of the operation
ἔρως
ἔρως6mo ago
good luck
roelof
roelofOP6mo ago
thanks Can someone help me how to change the color of the logo ?
vince
vince6mo ago
If it's an svg you can change it with color, otherwise you'll have to use a different image / background image
roelof
roelofOP6mo ago
no luck
roelof
roelofOP6mo ago
No description
roelof
roelofOP6mo ago
chips I see it It still have a fill on it with a color shoot me out of this mess in the browser I see a fill but when I open the svg with a text-editor it has a fill of none Anyone still a idea ?
vince
vince6mo ago
the fill should be currentColor If that doesn't work instead of using an image use the actual svg, like take the svg code and put it where the img is
roelof
roelofOP6mo ago
oke, I will try that tomorrow
ἔρως
ἔρως6mo ago
or just do <svg><use href="..."></svg>
roelof
roelofOP6mo ago
Changed the fill to currentColor but still no luck
<svg xmlns="http://www.w3.org/2000/svg" width="179" height="41" fill="currentColor" viewBox="0 0 179 41">
<svg xmlns="http://www.w3.org/2000/svg" width="179" height="41" fill="currentColor" viewBox="0 0 179 41">
`
ἔρως
ἔρως6mo ago
you're loading it as an image it won't work
roelof
roelofOP6mo ago
😦
Ganesh
Ganesh6mo ago
You'll probably need to copy the whole svg code and past it inline in html
ἔρως
ἔρως6mo ago
or do what i said both work
Ganesh
Ganesh6mo ago
Oh i didn't know about use element. Neat
ἔρως
ἔρως6mo ago
it's awesome if you have the logo as a <symbol>, you can set the href to #id and it uses that symbol
Ganesh
Ganesh6mo ago
I assume you can also manipulate the svg with css using it?
ἔρως
ἔρως6mo ago
no, because it isn't part of the dom yes, because chrome applies the css in the svg to the svg
Ganesh
Ganesh6mo ago
So inline css works but not the external css?
ἔρως
ἔρως6mo ago
yeah and no depends on what you mean
Ganesh
Ganesh6mo ago
Inline as in css that's directly applied to inside the element but i guess at that point you'd just use fill and other svg attribute. External would be a separate style element or a link element linking to a stylesheet
ἔρως
ἔρως6mo ago
well, yes, inline css works you can have a <style> element in the svg too but no, external css is disabled for security reasons so, you can't do an @import in the css
Ganesh
Ganesh6mo ago
Gotcha makes sense
ἔρως
ἔρως6mo ago
i think you can use external fonts, in some situations, but i won't promise that i think excalidraw uses external fonts
Ganesh
Ganesh6mo ago
Humuhumu It's still handy for duplicating the svg code right? As you said assign an ID to symbol then use the use element where you need it
ἔρως
ἔρως6mo ago
yeah, and it is great when you use the same symbols multiple times stuff like logos and icons
roelof
roelofOP6mo ago
oke, what must be then in the href part ?
<svg><use href="..."></svg>
<svg><use href="..."></svg>
ἔρως
ἔρως6mo ago
the url of the svg file
roelof
roelofOP6mo ago
oke, so it will be :

<svg><use href="./assets/images/logo.svg"></svg>

<svg><use href="./assets/images/logo.svg"></svg>
?
ἔρως
ἔρως6mo ago
yup that should do it
roelof
roelofOP6mo ago
chips
roelof
roelofOP6mo ago
now the logo is gone
No description
roelof
roelofOP6mo ago
and giving it a height . width and color does not show it
ἔρως
ἔρως6mo ago
can you send the svg?
roelof
roelofOP6mo ago
ἔρως
ἔρως6mo ago
yeah, forget the color of the logo trust me, you don't want to go into that rabbit hole that svg is not the worst ive seen, but it's really bad
roelof
roelofOP6mo ago
I find svg a big rabbit hole 😦
ἔρως
ἔρως6mo ago
just revert to what you had before and ignore the logo color
roelof
roelofOP6mo ago
I cannot in light theme the text schould be black And in dark theme it must be white
ἔρως
ἔρως6mo ago
then you have to open the svg, find the color #091540 and replace with currentColor
Ganesh
Ganesh6mo ago
The name is in the svg?
ἔρως
ἔρως6mo ago
yes, it's a path
Ganesh
Ganesh6mo ago
I don't like whoever created this svg
ἔρως
ἔρως6mo ago
same this svg was created by the devil himself and the requirement to change the text color is understandable, but horrible with this hunk of junk
roelof
roelofOP6mo ago
by the people who made all the FEM Challenges 🙂
ἔρως
ἔρως6mo ago
seriously, this svg is absolute hell
roelof
roelofOP6mo ago
yep I think all the FEM challenges are made by 1 - 2 people
roelof
roelofOP6mo ago
and things are still not working
No description
ἔρως
ἔρως6mo ago
now, copy all the svg code and throw where the image is
roelof
roelofOP6mo ago
still no luck
No description
ἔρως
ἔρως6mo ago
style="color: aquamarine oh, you added it manually well, it's meant to work if you did everything right by the way, remove the xmlns attribute
roelof
roelofOP6mo ago
then I do not have a idea what I have done wrong as far as I know I did everything exactly as you said
ἔρως
ἔρως6mo ago
did you replace the fill color, as i said?
roelof
roelofOP6mo ago
I thought I did but will be checking it again
ἔρως
ἔρως6mo ago
is it updated on github?
roelof
roelofOP6mo ago
im going crazy in a text-editor I can see that the color is changed but on the browser I still see the old color code
ἔρως
ἔρως6mo ago
is it on github?
roelof
roelofOP6mo ago
it is now
ἔρως
ἔρως6mo ago
can you send the link?
roelof
roelofOP6mo ago
GitHub
browser-extenstion/assets/images/logo.svg at main · RoelofWobben/b...
Contribute to RoelofWobben/browser-extenstion development by creating an account on GitHub.
ἔρως
ἔρως6mo ago
you copied the code from the original file, without the modification https://github.com/RoelofWobben/browser-extenstion/blob/main/index.html <-- search for "currentColor" and there's only 1 result
roelof
roelofOP6mo ago
yep
ἔρως
ἔρως6mo ago
it's supposed to be 2 results
roelof
roelofOP6mo ago
and if you look at the logo itself , you find two results
ἔρως
ἔρως6mo ago
i know the logo you're no longer referring from the html
ἔρως
ἔρως6mo ago
1/1 means you have copied the wrong version
No description
roelof
roelofOP6mo ago
pfff I m sure I was putting the img version back oke, I did that locally but then no luck
ἔρως
ἔρως6mo ago
can you update the github?
roelof
roelofOP6mo ago
done updated to this :
<div class="logo-container">
<img src="./assets/images/logo.svg" alt="Logo" class="logo">

</div>
<div class="logo-container">
<img src="./assets/images/logo.svg" alt="Logo" class="logo">

</div>
ἔρως
ἔρως6mo ago
that's the method that won't work
roelof
roelofOP6mo ago
oke, so back to the svg one
ἔρως
ἔρως6mo ago
yes, but copy the right version of the svg the one i told you to replace the color
roelof
roelofOP6mo ago
finally I can change it with color
ἔρως
ἔρως6mo ago
awesome!
roelof
roelofOP6mo ago
bring my daugther to work and then somewhere today I try to find the right colors And hopefully the css part is then done and my versions are "perfect"
ἔρως
ἔρως6mo ago
it should be close enough
roelof
roelofOP6mo ago
i hope so
ἔρως
ἔρως6mo ago
just a few more days and you should be done
roelof
roelofOP6mo ago
I hope so this one is sometimes very frustating
ἔρως
ἔρως6mo ago
this is an intermediate challenge, right?
roelof
roelofOP6mo ago
I thought a junior one
ἔρως
ἔρως6mo ago
ive never seen this
roelof
roelofOP6mo ago
yep a junior one (level 2) Level 1 is newbie
ἔρως
ἔρως6mo ago
the page itself i would put this on level 3
roelof
roelofOP6mo ago
that would be intermediate level 4 is advanced And level 5 is guru
ἔρως
ἔρως6mo ago
i mean, do you think this is a junior challenge?
roelof
roelofOP6mo ago
nope
ἔρως
ἔρως6mo ago
me neither
roelof
roelofOP6mo ago
not with the colors which is not very clear
ἔρως
ἔρως6mo ago
that's the least of it's problems
roelof
roelofOP6mo ago
layout wise this is not a very hard one but the colors and use of svg make it hard
ἔρως
ἔρως6mo ago
they do and soon, js
roelof
roelofOP6mo ago
yep no idea if a junior can made the filtering
ἔρως
ἔρως6mo ago
nope no change at all even i shy away from doing filtering stuff myself it's annoying and there's so many edge-cases
roelof
roelofOP6mo ago
then this is for sure not a junior one
ἔρως
ἔρως6mo ago
it's not
roelof
roelofOP6mo ago
I would also not know how to do that filtering with plain js Maybe with a js framework it would be less hard
ἔρως
ἔρως6mo ago
it's possible in css, but again, edge cases
roelof
roelofOP6mo ago
yep, the edge cases costs the most time I know
Ganesh
Ganesh6mo ago
Filtering?
ἔρως
ἔρως6mo ago
yes, the buttons to only show active or inactive ones
roelof
roelofOP6mo ago
or all 🙂
Ganesh
Ganesh6mo ago
You mean the categories highlighting hemselves
ἔρως
ἔρως6mo ago
and changing the cards
Ganesh
Ganesh6mo ago
Is that in the challenge? I thought it was only the layout and design implementation
ἔρως
ἔρως6mo ago
it is and loading the data about which one is and isn't active
Ganesh
Ganesh6mo ago
Wao
ἔρως
ἔρως6mo ago
and storing into local storage it's not a junior challenge
Ganesh
Ganesh6mo ago
Yeah that is not lol. I thought it was only layout and role of was added the javascript stuff from his side for practice
ἔρως
ἔρως6mo ago
it's a challenge that's been taking him a long time too
Ganesh
Ganesh6mo ago
Humuhumu
roelof
roelofOP6mo ago
yep but learnig and practising things costs time expecially when the images provided are not the best
roelof
roelofOP6mo ago
@ἔρως @vince Is this good enough ? my light version :
No description
roelof
roelofOP6mo ago
orginal :
No description
roelof
roelofOP6mo ago
my dark version :
No description
roelof
roelofOP6mo ago
orginal :
roelof
roelofOP6mo ago
No description
Ganesh
Ganesh6mo ago
The theme toggle doesn't seem to have a lighter background in dark version
ἔρως
ἔρως6mo ago
the color of the switches is still wrong
roelof
roelofOP6mo ago
😢 @Ganesh what do you mean with does not seem to have a ligther background ?
Ganesh
Ganesh6mo ago
No description
Ganesh
Ganesh6mo ago
No description
Ganesh
Ganesh6mo ago
below is yours
roelof
roelofOP6mo ago
oke
roelof
roelofOP6mo ago
The best I can find it this:
No description
roelof
roelofOP6mo ago
but still not much difference 😦
Ganesh
Ganesh6mo ago
do you mean the background not being apparant enough with this color or do you mean the missing padding
roelof
roelofOP6mo ago
no, I mean that I find that this color, which is the lighest gray does not make the difference as shown in the picture 😦
ἔρως
ἔρως6mo ago
the background of the header seems to be supposed to be darker
Ganesh
Ganesh6mo ago
yeah header and the cards are darker in design what is the color on your toggle buttons that seems darker
ἔρως
ἔρως6mo ago
you are right
Ganesh
Ganesh6mo ago
maybe swap that with cards and header color nvm they are the same
ἔρως
ἔρως6mo ago
the background color of it all needs to be darker
Ganesh
Ganesh6mo ago
just seem differnent
ἔρως
ἔρως6mo ago
it's the same color
roelof
roelofOP6mo ago
maybe like this :
No description
Ganesh
Ganesh6mo ago
well excpet the toggle button background in extension card that uses the lighter one. but yeah
roelof
roelofOP6mo ago
chips , there is no ligther color grey
Ganesh
Ganesh6mo ago
why are there two colors now
roelof
roelofOP6mo ago
??? two colors ??
roelof
roelofOP6mo ago
but then I wonder if the header stands out against the body back ground color:
No description
roelof
roelofOP6mo ago
He. the colors here are otherwise then I see on my browser
roelof
roelofOP6mo ago
No description
roelof
roelofOP6mo ago
send me to the mental institution. Those colors make me crazy
Ganesh
Ganesh6mo ago
No description
Ganesh
Ganesh6mo ago
I meant this the icon has grey background then there is some padding of darker grey/blue around it is the grey background backed into the icon? is it not transparent?
roelof
roelofOP6mo ago
oke no they need to be the same
ἔρως
ἔρως6mo ago
remove the background that's on the icon
roelof
roelofOP6mo ago
pfff., another fight with a svg 😢
Ganesh
Ganesh6mo ago
No description
Ganesh
Ganesh6mo ago
you don't need to mess with the svg the background of the icon is set by you in css isn't it
roelof
roelofOP6mo ago
😦
Ganesh
Ganesh6mo ago
it's because your background color for the header bar and the extension cards isn't dark enough in dark mode you only need to change the background color variable to something dark and it'll become visible again
roelof
roelofOP6mo ago
oke, and that also solved that two colors problem but darker as this does not exist I have choosen already for the darkest grey and the lighest grey given
Ganesh
Ganesh6mo ago
well the given ones don't seem to match sooo, time to hack your own thing
roelof
roelofOP6mo ago
oke
ἔρως
ἔρως6mo ago
i wouldn't say "change" but "remove"
roelof
roelofOP6mo ago
oke, but as far as I can see I never set the background-color two times
Ganesh
Ganesh6mo ago
what do you mean two times
roelof
roelofOP6mo ago
This picture you placed
No description
Ganesh
Ganesh6mo ago
well I'm not sure what is going on here in your live version you have --background-color-icon on the input and the before pseudo element
roelof
roelofOP6mo ago
IM also not I only know that I think im busy with this css and colors for 2 - 3 weeks and still not good
ἔρως
ἔρως6mo ago
it needs to be removed from the pseudo-element
Ganesh
Ganesh6mo ago
oh yeah putting it on psuedo element is redundant I was talking about changing/darkening the background color of cards and header bar here so the icon would become visible
roelof
roelofOP6mo ago
oke, the pseudo element does not have the color anymore
ἔρως
ἔρως6mo ago
that should be enough
roelof
roelofOP6mo ago
and now I hope I or with your help can solve those stupid color problem That is bugging me for a long time and tried everything I know to solve it
ἔρως
ἔρως6mo ago
colors are always a pita
roelof
roelofOP6mo ago
expecially with this one
ἔρως
ἔρως6mo ago
all websites will have this level of difficulty or higher
roelof
roelofOP6mo ago
Then I really have to think if FE is for me That icon thing is bugging me for weeks now and I have no idea how to solve it anymore. Tried the given colors , tried custom colors and still not right
ἔρως
ἔρως6mo ago
which icon thing?
roelof
roelofOP6mo ago
The colors of the header and that sun icon We now talk a "long" time about it
ἔρως
ἔρως6mo ago
what do you have now?
roelof
roelofOP6mo ago
this :
No description
roelof
roelofOP6mo ago
I made it a few seconds ago with the given colors
ἔρως
ἔρως6mo ago
comparing to this, you need the darker version
roelof
roelofOP6mo ago
?? So this is still not good
ἔρως
ἔρως6mo ago
the dark theme checkbox is too light
roelof
roelofOP6mo ago
oke moment
roelof
roelofOP6mo ago
with 700:
No description
roelof
roelofOP6mo ago
and with 800:
No description
ἔρως
ἔρως6mo ago
do you have a 900?
roelof
roelofOP6mo ago
yep
ἔρως
ἔρως6mo ago
then try the 900 for the navbar
roelof
roelofOP6mo ago
with 900:
No description
ἔρως
ἔρως6mo ago
leave the rest as is now try the oposite of that
roelof
roelofOP6mo ago
here it is : Header 900 icon :600
No description
roelof
roelofOP6mo ago
I think it is much too blue
ἔρως
ἔρως6mo ago
you are right 800 on the header, 700 on the checkbox
roelof
roelofOP6mo ago
I think this could be the one : Header : 800 icon: 700
No description
roelof
roelofOP6mo ago
so now only the switch colors
vince
vince6mo ago
I saw you using Photopea before @roelof , that's what I use... why not just use it to color pick the colors??
roelof
roelofOP6mo ago
I tried that one but also do not get the right colors @vince
vince
vince6mo ago
Seems right to me
ἔρως
ἔρως6mo ago
the problem is that the original image is a jpeg
vince
vince6mo ago
No description
vince
vince6mo ago
Yea it won't be exact but it's close enough https://codepen.io/vince1444/pen/NPqRqpX
vince
vince6mo ago
No description
vince
vince6mo ago
And you can always color pick then mess around with the color in devtools
vince
vince6mo ago
No description
roelof
roelofOP6mo ago
That are the colors we have already header : 800 icon background : 700 Im setteling for those numbers and now I hope I can find the right color for the background of the switch in dark mode
Ganesh
Ganesh6mo ago
The toggle button in extension card? Seems like it's same as background of theme toggle and inactive category button
roelof
roelofOP6mo ago
also on the dark theme ? it looks more grey to me then the buttons
ἔρως
ἔρως6mo ago
do the light theme first, then you can worry about the dark theme
roelof
roelofOP6mo ago
o, is there the background also wrong ? 😢
ἔρως
ἔρως6mo ago
all the colors are wrong and the size too
roelof
roelofOP6mo ago
😦
ἔρως
ἔρως6mo ago
and it isnt supposed to have a border
roelof
roelofOP6mo ago
I take a break , Right now this challenge is making me crazy 😦
ἔρως
ἔρως6mo ago
yoy should you
roelof
roelofOP6mo ago
yes boss 🙂 Got more and more the feeling the css is never ready but with the border are we still talking about the switches ? @ἔρως
ἔρως
ἔρως6mo ago
yes
roelof
roelofOP6mo ago
I do not understand the Switches have a border the switches have the same border color as the button next to it
ἔρως
ἔρως6mo ago
which is wrong
No description
ἔρως
ἔρως6mo ago
there is no border there: just jpeg artifacts and padding
roelof
roelofOP6mo ago
oke, then I must think well how to make that work with only the colors seems also wierd to me
ἔρως
ἔρως6mo ago
that is how it is
roelof
roelofOP6mo ago
oke
roelof
roelofOP6mo ago
so something like this :
No description
roelof
roelofOP6mo ago
so it looks like this :
No description
roelof
roelofOP6mo ago
No description
roelof
roelofOP6mo ago
Ship it or are there more things not good ?
ἔρως
ἔρως6mo ago
the circle is the wrong color on light mode
roelof
roelofOP6mo ago
circle ???
ἔρως
ἔρως6mo ago
and the spacing is a bit too big yes
roelof
roelofOP6mo ago
sorry, I do not see any circle in the design ? or do you mean the switch is not right
ἔρως
ἔρως6mo ago
the circle on the switches it's supposed to always be the same color
roelof
roelofOP6mo ago
this better :
No description
roelof
roelofOP6mo ago
dinner ready and what do you mean with :
and the spacing is a bit too big
and the spacing is a bit too big
which spacing and where ?? @ἔρως
ἔρως
ἔρως6mo ago
the spacing around the switches
roelof
roelofOP6mo ago
you mean, more right margin and more bottom margin Sorry, I do not see it
ἔρως
ἔρως6mo ago
no, it needs to be centered
roelof
roelofOP6mo ago
?? it should be centered if im looking at the css of the parent :
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
ἔρως
ἔρως6mo ago
something is wrong then is the github updated?
roelof
roelofOP6mo ago
all changes are pushed now wait till github made a new version yep, github is now up to date
ἔρως
ἔρως6mo ago
alright, i will check it later
roelof
roelofOP6mo ago
Thanks and take the time you need
ἔρως
ἔρως6mo ago
alright, so, the sizes are all wrong this is using em for the size, which is below optimal i dare to say "wrong" the input should have this:
width: 36px;
height: 20px;
width: 36px;
height: 20px;
and the circle is supposed to be 16x16px and has 2px margin all around oh, and remove the border on it
ἔρως
ἔρως6mo ago
i found it by counting the pixels in the original screenshot
No description
roelof
roelofOP6mo ago
oke
roelof
roelofOP6mo ago
I think I misunderstood you with that margin :
No description
ἔρως
ἔρως6mo ago
No description
ἔρως
ἔρως6mo ago
this is how it looks like for me in the pseudo-element, set the margin to 2px
roelof
roelofOP6mo ago
I did as seen in the screenshot but then the point is on the bottom
ἔρως
ἔρως6mo ago
that's the wrong place
roelof
roelofOP6mo ago
this is the pseudo element
input:where([type="checkbox"][role="switch"])::before
input:where([type="checkbox"][role="switch"])::before
ἔρως
ἔρως6mo ago
yes, but that's not where you've put the margin
roelof
roelofOP6mo ago
aha, when I did it on
input:where([type="checkbox"][role="switch"])
input:where([type="checkbox"][role="switch"])
it looks well to me
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
it's not
roelof
roelofOP6mo ago
😦
ἔρως
ἔρως6mo ago
No description
ἔρως
ἔρως6mo ago
look at the left side: yours is touching the white, mine isn't
roelof
roelofOP6mo ago
then I do not understand which pseudo element you mean
ἔρως
ἔρως6mo ago
here not here that one doesn't have any margins
roelof
roelofOP6mo ago
I have two
input:where([type="checkbox"][role="switch"]) {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
position: relative;
font-size: inherit;
width: 36px;
height: 20px;
box-sizing: content-box;
border-radius: 1em;
vertical-align: text-bottom;
background: var(--neutral_300);

}

input:where([type="checkbox"][role="switch"])::before {
content: "";
position: absolute;
top: 50%;
left: 0;
transform: translate(0, -50%);
box-sizing: border-box;
width: 16px;
height: 16px;
margin: 2px;
border: 1px solid var(--neutral200);
border-radius: 50%;
background: var(--neutral_0);
}
input:where([type="checkbox"][role="switch"]) {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
position: relative;
font-size: inherit;
width: 36px;
height: 20px;
box-sizing: content-box;
border-radius: 1em;
vertical-align: text-bottom;
background: var(--neutral_300);

}

input:where([type="checkbox"][role="switch"])::before {
content: "";
position: absolute;
top: 50%;
left: 0;
transform: translate(0, -50%);
box-sizing: border-box;
width: 16px;
height: 16px;
margin: 2px;
border: 1px solid var(--neutral200);
border-radius: 50%;
background: var(--neutral_0);
}
`
ἔρως
ἔρως6mo ago
this needs 2px of margin you only have 1 border-radius: 1em; <-- set this to 16px
roelof
roelofOP6mo ago
Then I stil see this :
No description
roelof
roelofOP6mo ago
in FF so still against the border with this as css :
input:where([type="checkbox"][role="switch"]) {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
position: relative;
font-size: inherit;
width: 36px;
height: 20px;
box-sizing: content-box;
border-radius: 16px;
vertical-align: text-bottom;
background: var(--neutral_300);
margin: 2px;

}

input:where([type="checkbox"][role="switch"])::before {
content: "";
position: absolute;
top: 50%;
left: 0;
transform: translate(0, -50%);
box-sizing: border-box;
width: 16px;
height: 16px;
border: 1px solid var(--neutral200);
border-radius: 50%;
background: var(--neutral_0);
}
input:where([type="checkbox"][role="switch"]) {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
position: relative;
font-size: inherit;
width: 36px;
height: 20px;
box-sizing: content-box;
border-radius: 16px;
vertical-align: text-bottom;
background: var(--neutral_300);
margin: 2px;

}

input:where([type="checkbox"][role="switch"])::before {
content: "";
position: absolute;
top: 50%;
left: 0;
transform: translate(0, -50%);
box-sizing: border-box;
width: 16px;
height: 16px;
border: 1px solid var(--neutral200);
border-radius: 50%;
background: var(--neutral_0);
}
ἔρως
ἔρως6mo ago
you're right, it is broken it has to be margin: 0 2px
ἔρως
ἔρως6mo ago
then it works
No description
roelof
roelofOP6mo ago
Still see this :
No description
ἔρως
ἔρως6mo ago
can you update the github?
ἔρως
ἔρως6mo ago
i haven't done any other changes than what i've said here
No description
No description
roelof
roelofOP6mo ago
done
ἔρως
ἔρως6mo ago
still has the old styles
roelof
roelofOP6mo ago
I know but when I do the margin on this :
input:where([type="checkbox"][role="switch"])::before
input:where([type="checkbox"][role="switch"])::before
roelof
roelofOP6mo ago
then I see this :
No description
ἔρως
ἔρως6mo ago
that is correct this was wrong but this is correct
roelof
roelofOP6mo ago
happy to hear this how the light version looks like now
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
and the dark theme?
roelof
roelofOP6mo ago
now without the border :
No description
roelof
roelofOP6mo ago
dark theme :
No description
ἔρως
ἔρως6mo ago
the background color is wrong, but the shape is right
roelof
roelofOP6mo ago
oke, one for tomorrow
roelof
roelofOP6mo ago
something like this :
No description
roelof
roelofOP6mo ago
then it will 300 in the light theme and 600 in the dark theme GN
ἔρως
ἔρως6mo ago
goodnight
roelof
roelofOP6mo ago
are the colors right ??
ἔρως
ἔρως6mo ago
i think so? it does look right to me
roelof
roelofOP6mo ago
😀 maybe finally i can begin with the js 🙂
ἔρως
ἔρως6mo ago
not yet the cards are too light
ἔρως
ἔρως6mo ago
compare both
No description
roelof
roelofOP6mo ago
😦 What do you think of this 700 color
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
too bright also, you don't have a border and the border on the button is too bright
roelof
roelofOP6mo ago
800:
No description
ἔρως
ἔρως6mo ago
too light
roelof
roelofOP6mo ago
hmm, and 900 I find too blue :
No description
ἔρως
ἔρως6mo ago
800 then paint reads the color as #1F2535
ἔρως
ἔρως6mo ago
No description
ἔρως
ἔρως6mo ago
224º, 42%, 21%
roelof
roelofOP6mo ago
And i have these colors :
--neutral_900: hsl(227, 75%, 14%);
--neutral_800: hsl(226, 25%, 17%);
--neutral_700: hsl(225, 23%, 24%);
--neutral_600: hsl(226, 11%, 37%);
--neutral_900: hsl(227, 75%, 14%);
--neutral_800: hsl(226, 25%, 17%);
--neutral_700: hsl(225, 23%, 24%);
--neutral_600: hsl(226, 11%, 37%);
ἔρως
ἔρως6mo ago
can you send the link of the challenge?
roelof
roelofOP6mo ago
of course
roelof
roelofOP6mo ago
Frontend Mentor
Frontend Mentor | Browser extension manager UI coding challenge
This project will be a fun way to practice working with dynamic data, filtering data, color theming, building a responsive grid, and more!
roelof
roelofOP6mo ago
GN
ἔρως
ἔρως6mo ago
the image on the website has the same color, so, there should be another color
No description
ἔρως
ἔρως6mo ago
goodnight
roelof
roelofOP6mo ago
If you can find it in the readme then im happy As far as i can see there is no other color
ἔρως
ἔρως6mo ago
can you send the readme?
roelof
roelofOP6mo ago
of course
ἔρως
ἔρως6mo ago
very undescriptive
roelof
roelofOP6mo ago
yep,I know but it what I have to do with it this way all FEM challenges work
ἔρως
ἔρως6mo ago
yeah, they want you to buy the pro version
roelof
roelofOP6mo ago
I think so and I will not do that 8 or 12 dollar a month I find expensive for some design files
ἔρως
ἔρως6mo ago
it is super expensive
roelof
roelofOP6mo ago
So what do we do with the color of the cards or header Let it as It is or use your color ?
ἔρως
ἔρως6mo ago
use the color that is the closest
roelof
roelofOP6mo ago
oke, I lost where we working on Was it the header background-color or the card background-color
ἔρως
ἔρως6mo ago
both are the same both have the same background color
roelof
roelofOP6mo ago
oke, this is with my colors :
No description
roelof
roelofOP6mo ago
This is with your color:
No description
roelof
roelofOP6mo ago
and this is the orginal :
No description
roelof
roelofOP6mo ago
Then it looks to me that your color is more like the picture then my color Agreed ?
ἔρως
ἔρως6mo ago
i agree
roelof
roelofOP6mo ago
Then that will be the color of the header and the cards in dark mode last problem. The color of the border of the cards
ἔρως
ἔρως6mo ago
it is the same as the buttons the "delete" button remove
roelof
roelofOP6mo ago
oke
roelof
roelofOP6mo ago
then this is now the light theme :
No description
roelof
roelofOP6mo ago
orginal :
No description
roelof
roelofOP6mo ago
dark theme from me :
No description
roelof
roelofOP6mo ago
orginal :
No description
roelof
roelofOP6mo ago
looks like the cards border must have another color Or do we say ship it
ἔρως
ἔρως6mo ago
i would say "meh, close enough" but the red of the filter is different and the selected option has dark text, not white
roelof
roelofOP6mo ago
The last one is easyJet to change The first is more difficult because i do not have more sort of red
ἔρως
ἔρως6mo ago
try the lighter red
vince
vince6mo ago
Why not use the method i showed yesterday and eyeball it?
ἔρως
ἔρως6mo ago
i am eyeballing it
vince
vince6mo ago
Meant roelof
roelof
roelofOP6mo ago
tried it but then according to epic the colors were not right
roelof
roelofOP6mo ago
Button with red 500
No description
roelof
roelofOP6mo ago
and with red 400
No description
roelof
roelofOP6mo ago
I find them all to light
ἔρως
ἔρως6mo ago
that is the right red for dark mode only this is the right red for light mode only
roelof
roelofOP6mo ago
oke so I need two reds for both modes
ἔρως
ἔρως6mo ago
no, one red for each mode and it is the same red everywhere
roelof
roelofOP6mo ago
oke, that is what I mean Sorry
ἔρως
ἔρως6mo ago
then yeah, that is what you have to do
roelof
roelofOP6mo ago
Feels like i never finisched this 😢
ἔρως
ἔρως6mo ago
you will finish it
roelof
roelofOP6mo ago
in 2040 I think
ἔρως
ἔρως6mo ago
soon
roelof
roelofOP6mo ago
yeah yeah Everytime I think im ready you find new things that are nor right 🙂 just joking
roelof
roelofOP6mo ago
Red is now hooefully good :
No description
roelof
roelofOP6mo ago
@ἔρως @vince can you help me why the red has disappeared in the dark theme?
vince
vince6mo ago
Use --red_400 instead of --red
vince
vince6mo ago
or make this var(--red_400)
No description
roelof
roelofOP6mo ago
I did
--red:- var(--red_400);
--red:- var(--red_400);
`
vince
vince6mo ago
Look again brother 🙂
roelof
roelofOP6mo ago
chips, I found it I has to be :
--red: var(--red_400);
--red: var(--red_400);
vince
vince6mo ago
Yep
roelof
roelofOP6mo ago
It definity not my day today
vince
vince6mo ago
We all have those days lol
roelof
roelofOP6mo ago
I know I hope everything is now good with the css
roelof
roelofOP6mo ago
LIght :
No description
roelof
roelofOP6mo ago
dark :
No description
vince
vince6mo ago
No description
roelof
roelofOP6mo ago
?? What do you mean?
ἔρως
ἔρως6mo ago
the color is wrong it has to be darker it's the blue 900 the buttons also are missing the border - same color as the cards
roelof
roelofOP6mo ago
Oke will charge it ad soon as i can use the computer Change it The filter ones? As far as i remember you told me that the filter buttons did not had a border
roelof
roelofOP6mo ago
This better :
No description
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
the background is the same color as the border, in the original design
roelof
roelofOP6mo ago
sorry I do not understand the question or remark
roelof
roelofOP6mo ago
but the borders are all the same color :
No description
roelof
roelofOP6mo ago
Ship it or is there still work to do with the css
vince
vince6mo ago
There's always work to be done with css but I'd say just ship it for now and work on the js
roelof
roelofOP6mo ago
happy to hear I think that will after the checkups tomorrow in hospital Finally it happens 🎉
roelof
roelofOP6mo ago
Tomorrow I will begin with the storing of dark or light mode in localstorage Then the reading of the json and then the filtering And thne done 🙂 Or do I forget something ? GN
ἔρως
ἔρως6mo ago
goodnight we will find tomorrow if you forgot something
roelof
roelofOP6mo ago
I know a thing Chancing the status from active to non-active and the other way around and this code for storing and reading the darkmode works
let darkMode = localStorage.getItem('darkMode');

const darkModeToggle = document.querySelector('#theme-toggle');

console.log(darkModeToggle);
console.log(darkMode);

const enableDarkMode = () => {
darkModeToggle.checked = true;
localStorage.setItem('darkMode', 'enabled');
}

const disableDarkMode = () => {
darkModeToggle.checked = false;
localStorage.setItem('darkMode', null);
}

if (darkMode === 'enabled') {
enableDarkMode();
}

darkModeToggle.addEventListener('change', () => {
darkMode = localStorage.getItem('darkMode');
if (darkMode !== 'enabled') {
enableDarkMode();
} else {
disableDarkMode();
}
});
let darkMode = localStorage.getItem('darkMode');

const darkModeToggle = document.querySelector('#theme-toggle');

console.log(darkModeToggle);
console.log(darkMode);

const enableDarkMode = () => {
darkModeToggle.checked = true;
localStorage.setItem('darkMode', 'enabled');
}

const disableDarkMode = () => {
darkModeToggle.checked = false;
localStorage.setItem('darkMode', null);
}

if (darkMode === 'enabled') {
enableDarkMode();
}

darkModeToggle.addEventListener('change', () => {
darkMode = localStorage.getItem('darkMode');
if (darkMode !== 'enabled') {
enableDarkMode();
} else {
disableDarkMode();
}
});
another problem bites the dust 🙂 tomorrow the reading from json and displaying things
ἔρως
ἔρως6mo ago
instead of doing const enableDarkMode = () => {...}, just use a properly named function just function enableDarkMode() {...} when you have issues and start to debug the code, having a named function will save you hours of frustration
Ganesh
Ganesh6mo ago
I see these function expressions in some courses. Full stack open does it too and it just weirds me out when there's no reason not to use a proper function declaration
ἔρως
ἔρως6mo ago
also, you can throw those functions at the end of the code, so you can focus more on the logic it just makes things so much harder to read and debug if an error is thrown, you will just see <anonymous function> everywhere
Ganesh
Ganesh6mo ago
Yeah
ἔρως
ἔρως6mo ago
debugging something a few anonymous functions deep will be hell
Ganesh
Ganesh6mo ago
I can't imagine nesting them. Only time I use arrow functions is in short callbacks or someplace when I need to preserve this like streamlining the binding of this in class components (tho the latter probably suffers the same problem of anonymous function when debugging)
roelof
roelofOP6mo ago
so this is better :
let darkMode = localStorage.getItem('darkMode');

const darkModeToggle = document.querySelector('#theme-toggle');

console.log(darkModeToggle);
console.log(darkMode);

darkModeToggle.addEventListener('change', () => {
darkMode = localStorage.getItem('darkMode');
if (darkMode !== 'enabled') {
enableDarkMode();
} else {
disableDarkMode();
}
});

function enableDarkMode() {
darkModeToggle.checked = true;
localStorage.setItem('darkMode', 'enabled');
}

function disableDarkMode () {
darkModeToggle.checked = false;
localStorage.setItem('darkMode', null);
}

if (darkMode === 'enabled') {
enableDarkMode();
}
let darkMode = localStorage.getItem('darkMode');

const darkModeToggle = document.querySelector('#theme-toggle');

console.log(darkModeToggle);
console.log(darkMode);

darkModeToggle.addEventListener('change', () => {
darkMode = localStorage.getItem('darkMode');
if (darkMode !== 'enabled') {
enableDarkMode();
} else {
disableDarkMode();
}
});

function enableDarkMode() {
darkModeToggle.checked = true;
localStorage.setItem('darkMode', 'enabled');
}

function disableDarkMode () {
darkModeToggle.checked = false;
localStorage.setItem('darkMode', null);
}

if (darkMode === 'enabled') {
enableDarkMode();
}
ἔρως
ἔρως6mo ago
that last if can be moved higher
roelof
roelofOP6mo ago
oke, where do you want it then ?
ἔρως
ἔρως6mo ago
i would move it to under the 2 console.log calls
roelof
roelofOP6mo ago
oke changed
ἔρως
ἔρως6mo ago
and since they are real named functions, javascript will hoist the functions and everything will be fine now, wrap it all in an anonymous function
roelof
roelofOP6mo ago
I checked already and everything still seems to work
ἔρως
ἔρως6mo ago
as it should
roelof
roelofOP6mo ago
exactly What do you mean with wrap it all in a anonumous function ?
ἔρως
ἔρως6mo ago
all the code inside an anonymous function and then, you call the function in the last line
Ganesh
Ganesh6mo ago
Are you suggesting an iife?
ἔρως
ἔρως6mo ago
like this:
(function() {
...
})();
(function() {
...
})();
this looks weird as hell, but, it prevents all your local variables from being global variables i forgot what iife means, but i think it is this
Ganesh
Ganesh6mo ago
https://developer.mozilla.org/en-US/docs/Glossary/IIFE Here's is a link if you want to look up more about iife Immediately invoked function expression
ἔρως
ἔρως6mo ago
yup, that is the idea and in this decade, maybe it should be async function instead of just function
Ganesh
Ganesh6mo ago
A bit curious tho. If roleOf was using modules he wouldn't need this right? He can just do a side effect import then
roelof
roelofOP6mo ago
Does things still works ??
ἔρως
ἔρως6mo ago
i think you have to export something from the module it's supposed to
roelof
roelofOP6mo ago
yes, I checked
ἔρως
ἔρως6mo ago
now, you need to enable strict mode
roelof
roelofOP6mo ago
inside that function we just made ??
ἔρως
ἔρως6mo ago
inside the function, as the first line, you need to add this:
'use strict';
'use strict';
yes
roelof
roelofOP6mo ago
and what does that do ??
Ganesh
Ganesh6mo ago
I checked it out. You don't need to export anything for side-effect imports. Works both in node and the browser Prevents assigning global variables like this
myGlobalVar = "hello"
myGlobalVar = "hello"
This would throw an error in strict mode
roelof
roelofOP6mo ago
oke, so two prevents for global variables 🙂
Ganesh
Ganesh6mo ago
Also throws errors when assigning to non writeable properties like NaN, undefined etc. normally it doesn't throw Along with some more things
ἔρως
ἔρως6mo ago
it also throws syntax errors for some things, but i dont remember exactly what https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode <-- it's important to read this but seriously, strict mode helps a lot that is interesting, not gonna lie
roelof
roelofOP6mo ago
Almost time for lunch And then checkup for my heart in the hospital Since the operation they are checking things reguarly
Ganesh
Ganesh6mo ago
Aight. Hope lunch's good
roelof
roelofOP6mo ago
yes, bread, bread,bread and do not forget bread 🙂
Ganesh
Ganesh6mo ago
Mmm bread with bread inside more bread
ἔρως
ἔρως6mo ago
a bread toast
roelof
roelofOP6mo ago
no, 4 pieces of bread 🙂 but this js code is not good enought to send to github as ready
(function() {

'use strict';

let darkMode = localStorage.getItem('darkMode');

const darkModeToggle = document.querySelector('#theme-toggle');

if (darkMode === 'enabled') {
enableDarkMode();
}

darkModeToggle.addEventListener('change', () => {
darkMode = localStorage.getItem('darkMode');
if (darkMode !== 'enabled') {
enableDarkMode();
} else {
disableDarkMode();
}
});

function enableDarkMode() {
darkModeToggle.checked = true;
localStorage.setItem('darkMode', 'enabled');
}

function disableDarkMode () {
darkModeToggle.checked = false;
localStorage.setItem('darkMode', null);
}
})()
(function() {

'use strict';

let darkMode = localStorage.getItem('darkMode');

const darkModeToggle = document.querySelector('#theme-toggle');

if (darkMode === 'enabled') {
enableDarkMode();
}

darkModeToggle.addEventListener('change', () => {
darkMode = localStorage.getItem('darkMode');
if (darkMode !== 'enabled') {
enableDarkMode();
} else {
disableDarkMode();
}
});

function enableDarkMode() {
darkModeToggle.checked = true;
localStorage.setItem('darkMode', 'enabled');
}

function disableDarkMode () {
darkModeToggle.checked = false;
localStorage.setItem('darkMode', null);
}
})()
ἔρως
ἔρως6mo ago
looks good to me you should try to use jsdoc
roelof
roelofOP6mo ago
so something like this for every part :
/**
* Represents a book.
* @constructor
* @param {string} title - The title of the book.
* @param {string} author - The author of the book.
*/
/**
* Represents a book.
* @constructor
* @param {string} title - The title of the book.
* @param {string} author - The author of the book.
*/
ἔρως
ἔρως6mo ago
yup, on the variables, constants and functions
roelof
roelofOP6mo ago
oke. I have to look when I do this just back from the hospital
ἔρως
ἔρως6mo ago
just relax for now then
roelof
roelofOP6mo ago
oke boss that is why I said tomorrow reading the json and display things is on the plan
ἔρως
ἔρως6mo ago
and you are half-way there
roelof
roelofOP6mo ago
half way of solving this challenge or half way of writing the js ????
ἔρως
ἔρως6mo ago
the js
roelof
roelofOP6mo ago
o, I think reading and displaying things will also a big file The filtering I do not know how big it would be And the active thing could also be a smalll one
ἔρως
ἔρως6mo ago
it is easier than you imagine
roelof
roelofOP6mo ago
we see like I said several times one problem at the time The reading in and storing into localstorage is not so much code I think But the remaking of the divs will be a big function chips. I forget the hover and so states in css 😢 maybe I will do that one tomorrow
Ganesh
Ganesh6mo ago
You can reduce boilerplate a bit by making smaller utility functions. function createElement (type, classesArray, text) that takes element type, array of classes and the text then returns the created element with text and classes applied
roelof
roelofOP6mo ago
I will see I know I have to make this again :
<div class="extension">

<div class="content-extension">
<img src="./assets/images/logo-devlens.svg" alt="" class="extension-icon">
<div class="extension-info">
<h2>DevLens</h2>
<p>Quickly inspect page layouts and visualize element boundaries.</p>
</div>
</div>
<div class="status">
<button class="remove-button">Remove</button>
<label for="ms1"></label>
<input type="checkbox" role="switch" id="ms1" />
</div>
</div>
<div class="extension">

<div class="content-extension">
<img src="./assets/images/logo-devlens.svg" alt="" class="extension-icon">
<div class="extension-info">
<h2>DevLens</h2>
<p>Quickly inspect page layouts and visualize element boundaries.</p>
</div>
</div>
<div class="status">
<button class="remove-button">Remove</button>
<label for="ms1"></label>
<input type="checkbox" role="switch" id="ms1" />
</div>
</div>
Ganesh
Ganesh6mo ago
Lots of divs
roelof
roelofOP6mo ago
yep One less. the extensions would be the parent one so if im looking wel 3 div's , one img , one p , one button and one input
ἔρως
ἔρως6mo ago
use the <template> tag
roelof
roelofOP6mo ago
Does plain js have that I thought I need to use
var div = document.querySelector('.extensions');
var newElement = document.createElement('div');
newElement.classList.add('content-extension`)
div.appendChild(newElement);
var div = document.querySelector('.extensions');
var newElement = document.createElement('div');
newElement.classList.add('content-extension`)
div.appendChild(newElement);
And so on
Ganesh
Ganesh6mo ago
it's related to shadow dom I haven't really used that but I think it's related to web components. lets you have resueable html markup or something
roelof
roelofOP6mo ago
moment, my solution or the template solution ?? I know template only from js frameworks not from plain js
Ganesh
Ganesh6mo ago
your solution is using usual dom. What epic suggested is the web component thing
roelof
roelofOP6mo ago
oke and can I use that web component thing with plain js ??? that is my question
Ganesh
Ganesh6mo ago
it seems so
<template id="example">
<h1></h1>
<p></p>
</template>


const template = document.querySelector("#example");

// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);
let h1 = clone.querySelectorAll("h1");
let para = clone.querySelectorAll("p");
h1.textContent = "1235646565";
para.textContent = "Stuff";
<template id="example">
<h1></h1>
<p></p>
</template>


const template = document.querySelector("#example");

// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);
let h1 = clone.querySelectorAll("h1");
let para = clone.querySelectorAll("p");
h1.textContent = "1235646565";
para.textContent = "Stuff";
your extension card can be inside the template tag then you can clone it using the above js then using query selector modify their textContent
roelof
roelofOP6mo ago
oke, then I have to play with it Right now I do not see the whole picture
vince
vince6mo ago
don't use var use let or const like Ganesh pointed out
Ganesh
Ganesh6mo ago
where did this var came from oh his previous code
roelof
roelofOP6mo ago
Can I do then that clone part for every card My idea was to convert the json into objects and then do that template things I believe 10 till 12 times
Ganesh
Ganesh6mo ago
yeah var bad yes you can create howevery many clones you want
roelof
roelofOP6mo ago
oke, Like I said earlier I will play with it the next few days just 2 hours ago I had some checkups in the hospital and got some info I have to let that sink in
Ganesh
Ganesh6mo ago
do it when you feel like it 👍
roelof
roelofOP6mo ago
of course That is why I try to make every day a small part maybe I m going to take some rest the next few days The meeting with the cardiologist has more impact then I thought it thought it would be
ἔρως
ἔρως6mo ago
the <template> tag is awesome you throw some html in it, and then you can just clone it whatever you put inside isn't rendered at all
roelof
roelofOP6mo ago
Like I said , Somewhere these days I will play with it First I have to come with things the cardiologist have said yesterday
ἔρως
ἔρως6mo ago
just take your time
roelof
roelofOP6mo ago
I will and before I can display things, I first have to read them 🙂 is this a good way to read the json and convert to js objects :
fetch('sample.json')
.then(response => response.json()) // Parse JSON
.then(data => console.log(data)) // Work with JSON data
.catch(error => console.error('Error fetching JSON:', error));
fetch('sample.json')
.then(response => response.json()) // Parse JSON
.then(data => console.log(data)) // Work with JSON data
.catch(error => console.error('Error fetching JSON:', error));
ἔρως
ἔρως6mo ago
looks good to me
roelof
roelofOP6mo ago
The only thing i have to rewrite is that the data is stored in a global variable with the second then or directly stored in localstorage What is "better" First use a global variable and put that into localstorage or put things directly in localstorage ??
ἔρως
ἔρως6mo ago
put directly into storage and NEVER use a global variable
roelof
roelofOP6mo ago
oke, can I then put also the display stuff in the part after the then ??
ἔρως
ἔρως6mo ago
after the what?
roelof
roelofOP6mo ago
After the then So instead of console.log(data) Something like this :
fetch('sample.json')
.then(response => response.json()) // Parse JSON
.then(data => ??? // write the json to localstorage
// display the data on the page
.catch(error => console.error('Error fetching JSON:', error));
fetch('sample.json')
.then(response => response.json()) // Parse JSON
.then(data => ??? // write the json to localstorage
// display the data on the page
.catch(error => console.error('Error fetching JSON:', error));
ἔρως
ἔρως6mo ago
yup, you can do like that but honestly, i would use await you first check if there is anything in the local storage if there isnt, you load everything with fetch but await it, so it doesn't go forward to await, you will need to change the first line to have async on it
roelof
roelofOP6mo ago
oke And how do we then display the whole thing ?
Ganesh
Ganesh6mo ago
First line? Are you saying to use top level awaits. Wouldn't that create global variables? Unless this fetch code is inside a function (is it?)
roelof
roelofOP6mo ago
For me it feels not right that first you read from the file , store it on localstorage and then again read from localstorae because you already have the data
Ganesh
Ganesh6mo ago
Well can user change the data?
roelof
roelofOP6mo ago
Later on the user can change the isActive nothing more if we keep on what the challenge ask
Ganesh
Ganesh6mo ago
Well i think it's more like only reading the data directly from fetch on the first attempt is a bit wonky consider later when it changes you'll read from local storage If you want extension active state saved then there will also be scenario where user closes the browser then opens the page again. In that case you would check if local storage has data or not Unless that's not a requirement
roelof
roelofOP6mo ago
is not a requirement but I agree if the user changes the state , it would be handy that it is stored somewhere but I was thinking if we read from localstorage or the file , how do we take care that the data is displayed when we do not use a local variable but that is the way I would make that part work - read if localstorage has data - if not, read the data from the file and store it on localstorage - and then display it like we do now
Ganesh
Ganesh6mo ago
Why would local variable be a problem it's the globals that are the problem
roelof
roelofOP6mo ago
Could also be working But how do I take care that the data that comes from the localstorage is also used in the display function
Ganesh
Ganesh6mo ago
You can just get the data from local storage at the start of the function. let data = localStorage.getItem("extensionData)
roelof
roelofOP6mo ago
oke, and when I read the file, store it in localstorage and read localstorage again ??
Ganesh
Ganesh6mo ago
Yes
roelof
roelofOP6mo ago
feels wierd to read then the data 2 times
Ganesh
Ganesh6mo ago
You fetch data only once while all the other time you get data for rendering from local storage So while it may seem like reading 2 times. Your only reading two times at the first render, every other change that triggers render is using local storage
vince
vince6mo ago
let data = localStorage.getItem("extensionData");

if (!data) {
// read from file
data = data from file
localStorage.setItem("extensionData", data);
}

// display logic
let data = localStorage.getItem("extensionData");

if (!data) {
// read from file
data = data from file
localStorage.setItem("extensionData", data);
}

// display logic
Could you do something like this?
roelof
roelofOP6mo ago
I thougth that but Epic says that I then use global variables and that is not good
vince
vince6mo ago
You'd put it inside a function
roelof
roelofOP6mo ago
an then I get confused
ἔρως
ἔρως6mo ago
the first line is an iife
roelof
roelofOP6mo ago
aha, the same "trick" I did yeseterday with that anymous function ??
ἔρως
ἔρως6mo ago
no, but yes
Ganesh
Ganesh6mo ago
Yeah that makes sense
ἔρως
ἔρως6mo ago
yes, but with await inside the if
vince
vince6mo ago
const getExtensions = () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
extensions = data from file
localStorage.setItem("extensionData", data);
}

return extensions;
}

const displayExtensions = (data) => {
// display logic
}

const extensions = getExtensions();
displayExtensions(extensions);
const getExtensions = () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
extensions = data from file
localStorage.setItem("extensionData", data);
}

return extensions;
}

const displayExtensions = (data) => {
// display logic
}

const extensions = getExtensions();
displayExtensions(extensions);
I'm not the best at JS but I'd do something like this
Ganesh
Ganesh6mo ago
Why function expression
vince
vince6mo ago
just what im used to
ἔρως
ἔρως6mo ago
i mean, that would work the name is bad, but it could work
vince
vince6mo ago
yea maybe like retrieveData or something
ἔρως
ἔρως6mo ago
you arent initting anything: you are getting data just getExtensions or something simple
vince
vince6mo ago
fixed
roelof
roelofOP6mo ago
Thanks for showing this weekend i will work further on this project
ἔρως
ἔρως6mo ago
if you need, you can rest
roelof
roelofOP6mo ago
I know maybe I will Sunday birthday of my father 😦
ἔρως
ἔρως6mo ago
just rest this weekend
roelof
roelofOP6mo ago
oke, boss 😛
ἔρως
ἔρως6mo ago
take this oportunity and code for fun for the #code-challenges
roelof
roelofOP6mo ago
I saw it
ἔρως
ἔρως6mo ago
lets see what you come up with
roelof
roelofOP6mo ago
we see if I have energy to make it if no css is needed it schould not be a hard one
ἔρως
ἔρως6mo ago
css isnt required, but you can post css
roelof
roelofOP6mo ago
IM thinking of this :
<div class="card">
<p class="tag"> Feature </p>
<h1> Never miss your important meetings </h1>
<p>
Elementary tracks all the events for the day as you scheduled and you will never have to worry
</p>
<a href="#"> Learn more -> </a>
</div>
<div class="card">
<p class="tag"> Feature </p>
<h1> Never miss your important meetings </h1>
<p>
Elementary tracks all the events for the day as you scheduled and you will never have to worry
</p>
<a href="#"> Learn more -> </a>
</div>
first idea I have
ἔρως
ἔρως6mo ago
you should discuss it in #Challenge general chat or just try it out and see how it works
roelof
roelofOP6mo ago
Why does this not work:
const getExtensions = () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {

// read from file
extensions = fetch('data.json') // Fetch JSON file
.then(response => response.json()) // Parse JSON
.catch(error => console.error('Error fetching JSON:', error));
localStorage.setItem("extensionData", extensions);
}

return extensions;
}

const displayExtensions = (data) => {
console.log("Extensions Data:", data);
}

const extensions = getExtensions();
displayExtensions(extensions);
const getExtensions = () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {

// read from file
extensions = fetch('data.json') // Fetch JSON file
.then(response => response.json()) // Parse JSON
.catch(error => console.error('Error fetching JSON:', error));
localStorage.setItem("extensionData", extensions);
}

return extensions;
}

const displayExtensions = (data) => {
console.log("Extensions Data:", data);
}

const extensions = getExtensions();
displayExtensions(extensions);
I got now a Promise
ἔρως
ἔρως6mo ago
because that's what fetch returns and the .then and .catch return new promises as i said: use await or a 2nd .then after the one you have, to set the value of the extensions variable
roelof
roelofOP6mo ago
oke, and then I have to make the getExensions function async ?? or do you mean something like this :

const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
}
} else {
extensions = JSON.parse(extensions);
}

return extensions;
}

const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
}
} else {
extensions = JSON.parse(extensions);
}

return extensions;
}
When I do this :
const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
await fetch('data.json') // Fetch JSON file
.then(response => response.json()) // Parse JSON
.then(data => extensions = data ) // Work with JSON data
.catch(error => console.error('Error fetching JSON:', error));
localStorage.setItem("extensionData", extensions);
}

return extensions;
}

const displayExtensions = (data) => {
// display logic
}

const extensions = getExtensions();
displayExtensions(extensions);
const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
await fetch('data.json') // Fetch JSON file
.then(response => response.json()) // Parse JSON
.then(data => extensions = data ) // Work with JSON data
.catch(error => console.error('Error fetching JSON:', error));
localStorage.setItem("extensionData", extensions);
}

return extensions;
}

const displayExtensions = (data) => {
// display logic
}

const extensions = getExtensions();
displayExtensions(extensions);
` Then still I get a promise and the first one gives also a Promise but then rejected stupid js
ἔρως
ἔρως6mo ago
both look good to me
roelof
roelofOP6mo ago
oke, but when I try them they both do not give me back the categorys but a Promise
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
the first one is literally impossible to return a promise
roelof
roelofOP6mo ago
Chips I forget that the script first look at localStorage yep the first one gives me the good data
ἔρως
ἔρως6mo ago
exactly
roelof
roelofOP6mo ago
second one gives something wierd
No description
ἔρως
ἔρως6mo ago
it gives you the correct data however, you're throwing an array of objects into the localstorage localstorage only accepts strings
roelof
roelofOP6mo ago
After weekend I have to look what to change to get the right data
ἔρως
ἔρως6mo ago
you need to json-encode before putting into local storage
roelof
roelofOP6mo ago
I give it up for today Now I see a null

const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
await fetch('data.json') // Fetch JSON file
.then(response => response.json()) // Parse JSON
.then(data => extensions = json.stringify(data) ) // Work with JSON data
.catch(error => console.error('Error fetching JSON:', error));
localStorage.setItem("extensionData",extensions);
}

return extensions;
}

const displayExtensions = (data) => {
// display logic
}

const extensions = getExtensions();
displayExtensions(extensions);

const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
await fetch('data.json') // Fetch JSON file
.then(response => response.json()) // Parse JSON
.then(data => extensions = json.stringify(data) ) // Work with JSON data
.catch(error => console.error('Error fetching JSON:', error));
localStorage.setItem("extensionData",extensions);
}

return extensions;
}

const displayExtensions = (data) => {
// display logic
}

const extensions = getExtensions();
displayExtensions(extensions);
ἔρως
ἔρως6mo ago
you are awaiting the wrong promise
roelof
roelofOP6mo ago
sorry im now really confused are there more promises then ?
ἔρως
ἔρως6mo ago
yes every .then or .catch returns a new promise
roelof
roelofOP6mo ago
oke So it must be like this :
const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
fetch('data.json') // Fetch JSON file
.then(response => await response.json()) // Parse JSON
.then(data => await extensions = json.stringify(data) ) // Work with JSON data
.catch(error => console.error('Error fetching JSON:', error));
localStorage.setItem("extensionData",extensions);
}

return extensions;
}

const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
fetch('data.json') // Fetch JSON file
.then(response => await response.json()) // Parse JSON
.then(data => await extensions = json.stringify(data) ) // Work with JSON data
.catch(error => console.error('Error fetching JSON:', error));
localStorage.setItem("extensionData",extensions);
}

return extensions;
}

ἔρως
ἔρως6mo ago
no, because the localstorage will run before the request finishes
roelof
roelofOP6mo ago
Time to sleep This make me crazy
ἔρως
ἔρως6mo ago
use the await version it's easier to understand
roelof
roelofOP6mo ago
you mean this one :
const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
}
} else {
extensions = JSON.parse(extensions);
}

return extensions;
}
const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
}
} else {
extensions = JSON.parse(extensions);
}

return extensions;
}
but that does not looks the same as your boilerplate GN
ἔρως
ἔρως6mo ago
yup, it's better goodnight
roelof
roelofOP6mo ago
@ἔρως @vince
Is this the good code for the reading and displaying of the cards
const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
}
} else {
extensions = JSON.parse(extensions);
}

return extensions;
}

<div class="extension">
<div class="content-extension">
<img src="" alt="" class="extension-icon" />
<div class="extension-info">
<h2></h2>
<p></p>
</div>
</div>
<div class="status">
<button class="remove-button">Remove</button>
<label for="ms1"></label>
<input type="checkbox" role="switch" id="ms1" />
</div>
</div>


const displayExtensions = (data) => {
for (const extension of data) {
const template = document.querySelector("#extensions");

// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);

let image = clone.querySelectorAll("img");
image = extension.icon;

let h2 = clone.querySelectorAll("h2");
h2 = extension.name;

let p = clone.querySelectorAll("p");
p = extension.description;

}}

const extensions = getExtensions();
displayExtensions(extensions);
const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
}
} else {
extensions = JSON.parse(extensions);
}

return extensions;
}

<div class="extension">
<div class="content-extension">
<img src="" alt="" class="extension-icon" />
<div class="extension-info">
<h2></h2>
<p></p>
</div>
</div>
<div class="status">
<button class="remove-button">Remove</button>
<label for="ms1"></label>
<input type="checkbox" role="switch" id="ms1" />
</div>
</div>


const displayExtensions = (data) => {
for (const extension of data) {
const template = document.querySelector("#extensions");

// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);

let image = clone.querySelectorAll("img");
image = extension.icon;

let h2 = clone.querySelectorAll("h2");
h2 = extension.name;

let p = clone.querySelectorAll("p");
p = extension.description;

}}

const extensions = getExtensions();
displayExtensions(extensions);
` if so , then I make it also a anymous function with use strict as we did with the dark mode
ἔρως
ἔρως6mo ago
why is there html in the middle of the js?
roelof
roelofOP6mo ago
could be in another place But that is the template that the display function uses
ἔρως
ἔρως6mo ago
okay, but there is no element with the id extensions also querySelectorAll returns a nodelist you want to use querySelector instead, which returns a node
roelof
roelofOP6mo ago
o, I thought it need to be the parent element
ἔρως
ἔρως6mo ago
well, the element isn't there also, you're trying to find the same element over and over and over again
roelof
roelofOP6mo ago
yes, I have some 12 cards so I need to make the html for 12 cards
ἔρως
ἔρως6mo ago
const template = document.querySelector("#extensions"); <-- this should be outside all functions, and you need to check if it exists right at the top also use document.getElementById() for this
roelof
roelofOP6mo ago
chips now I do not see any cards 😦
ἔρως
ἔρως6mo ago
something like this:
(async function() {
'use strict';

/** @type {HTMLTagElement|null} */
const template = document.getElementById('extensions');
if(!template) {
return;
}

...
})();
(async function() {
'use strict';

/** @type {HTMLTagElement|null} */
const template = document.getElementById('extensions');
if(!template) {
return;
}

...
})();
roelof
roelofOP6mo ago
still no cards to see :
(async function () {
'use strict';

/** @type {HTMLTagElement|null} */
const template = document.getElementById('extensions');
if (!template) {
return;
}

const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
}
} else {
extensions = JSON.parse(extensions);
}

return extensions;
}

<div class="extension">
<div class="content-extension">
<img src="" alt="" class="extension-icon" />
<div class="extension-info">
<h2></h2>
<p></p>
</div>
</div>
<div class="status">
<button class="remove-button">Remove</button>
<label for="ms1"></label>
<input type="checkbox" role="switch" id="ms1" />
</div>
</div>


const displayExtensions = (data) => {
for (const extension of data) {


// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);

let image = clone.querySelector("img");
image = extension.icon;

let h2 = clone.querySelector("h2");
h2 = extension.name;

let p = clone.querySelector("p");
p = extension.description;

}
}

const extensions = getExtensions();
displayExtensions(extensions);


})();
(async function () {
'use strict';

/** @type {HTMLTagElement|null} */
const template = document.getElementById('extensions');
if (!template) {
return;
}

const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
}
} else {
extensions = JSON.parse(extensions);
}

return extensions;
}

<div class="extension">
<div class="content-extension">
<img src="" alt="" class="extension-icon" />
<div class="extension-info">
<h2></h2>
<p></p>
</div>
</div>
<div class="status">
<button class="remove-button">Remove</button>
<label for="ms1"></label>
<input type="checkbox" role="switch" id="ms1" />
</div>
</div>


const displayExtensions = (data) => {
for (const extension of data) {


// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);

let image = clone.querySelector("img");
image = extension.icon;

let h2 = clone.querySelector("h2");
h2 = extension.name;

let p = clone.querySelector("p");
p = extension.description;

}
}

const extensions = getExtensions();
displayExtensions(extensions);


})();
ἔρως
ἔρως6mo ago
press f12 and check the console also, why is there still html in the javascript?
roelof
roelofOP6mo ago
because I do not know a better place for it
ἔρως
ἔρως6mo ago
inside the <template> tag with the correct id in the html
roelof
roelofOP6mo ago
pff, im going crazy
Uncaught (in promise) TypeError: data is not iterable
Uncaught (in promise) TypeError: data is not iterable
oke I cannot do this :
const displayExtensions = (data) => {
for (const extension of data) {
const displayExtensions = (data) => {
for (const extension of data) {
back to the drawing table Async stuff is really a very big PITA
ἔρως
ἔρως6mo ago
what's in data can be null
roelof
roelofOP6mo ago
??? sorry, I do not understand the question ?
Ganesh
Ganesh6mo ago
if data is null can you use for of loop on it? you need to check if it is not null
roelof
roelofOP6mo ago
nope
Ganesh
Ganesh6mo ago
also this error happened because data was a promise you did not await the getExtensions
roelof
roelofOP6mo ago
chips another problem when I add this :
if (data === null || data.length === 0) {
console.error("No extensions found or data is empty.");
return;
}
if (data === null || data.length === 0) {
console.error("No extensions found or data is empty.");
return;
}
ἔρως
ἔρως6mo ago
you need to await that
roelof
roelofOP6mo ago
I see the console.erorr every time
ἔρως
ἔρως6mo ago
did you await this?
roelof
roelofOP6mo ago
how can I then use await in a if then ??
ἔρως
ἔρως6mo ago
when you use async, you await
roelof
roelofOP6mo ago
sorry, I miss the point I have now this :
const displayExtensions = (data) => {

if (data === null || data.length === 0) {
console.error("No extensions found or data is empty.");
return;
}

for (const extension of data) {


// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);

let image = clone.querySelector("img");
image = extension.icon;

let h2 = clone.querySelector("h2");
h2 = extension.name;

let p = clone.querySelector("p");
p = extension.description;

}
}

const extensions = await getExtensions();
displayExtensions(extensions);
const displayExtensions = (data) => {

if (data === null || data.length === 0) {
console.error("No extensions found or data is empty.");
return;
}

for (const extension of data) {


// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);

let image = clone.querySelector("img");
image = extension.icon;

let h2 = clone.querySelector("h2");
h2 = extension.name;

let p = clone.querySelector("p");
p = extension.description;

}
}

const extensions = await getExtensions();
displayExtensions(extensions);
ἔρως
ἔρως6mo ago
you await all async functions
roelof
roelofOP6mo ago
where do I await to make the data avaible
ἔρως
ἔρως6mo ago
ALL ASYNC FUNCTION all of them
Ganesh
Ganesh6mo ago
if you are inside a function that is marked as an async funtion you can use await anywhere inside it, except if there are more functions declared inside it you can't use await in those functions unless they are also async
ἔρως
ἔρως6mo ago
and when you call it and you want the value from it, you have to await and you are trying to get the value from it
roelof
roelofOP6mo ago
oke, so displayExtensions also need to be a async function ?
ἔρως
ἔρως6mo ago
no you just need to await the getExtensions
roelof
roelofOP6mo ago
I did that already As shown in the last code snippet I posted
ἔρως
ἔρως6mo ago
that should be it
roelof
roelofOP6mo ago
but as I said the display function returns now that there are no extensions found
ἔρως
ἔρως6mo ago
then use a console.log before the call to that function or use the debugger to pause before the call
roelof
roelofOP6mo ago
This is the output I see from the display function
No extensions found or data is empty.
No extensions found or data is empty.
ἔρως
ἔρως6mo ago
don't do data === null, just do !data
Ganesh
Ganesh6mo ago
epic means check the value of extensions variable
ἔρως
ἔρως6mo ago
yup you need to see what's the value you're getting from the function
roelof
roelofOP6mo ago
oke I try to find out how I can do that in VS Code
ἔρως
ἔρως6mo ago
you can't
roelof
roelofOP6mo ago
😦
ἔρως
ἔρως6mo ago
you debug it while running or type //@ts-check at the very top then vscode gives you some errors
Ganesh
Ganesh6mo ago
he technically can if he uses debug url but yeah it'll just attach to the browser. better use browser debugger
ἔρως
ἔρως6mo ago
but even then, how good is it? besides, you can press f12 for amazing debugging tools
roelof
roelofOP6mo ago
oke
roelof
roelofOP6mo ago
it seems extensions is null
No description
Ganesh
Ganesh6mo ago
servicable for small projects like this. I used it when I was learning js but there's no reason to do it unless you prefer vscode debugger
ἔρως
ἔρως6mo ago
the value is null
roelof
roelofOP6mo ago
Why is it now null, Yesterday it worled all well 😢
ἔρως
ἔρως6mo ago
try doing what i said here vscode will complain about things basically, you will be using typescript to typecheck your code, and it should get pretty angry at your code
roelof
roelofOP6mo ago
I did that
roelof
roelofOP6mo ago
but no new things on the console :
No description
ἔρως
ἔρως6mo ago
what does vscode say?
roelof
roelofOP6mo ago
this :
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
that's because HTMLTagElement doesn't exist should be HTMLTemplateElement if i wrote that, my bad im playing overwatch
roelof
roelofOP6mo ago
I take a break then I see more and more errors now
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
good that's very good
roelof
roelofOP6mo ago
??
ἔρως
ἔρως6mo ago
change the check to htmlelement then on the next line check if it is an instance of htmltemplatelement
roelof
roelofOP6mo ago
how do I do that ? and when I change it to htmlelement I see this :
Property 'content' does not exist on type 'HTMLElement'.
Property 'content' does not exist on type 'HTMLElement'.
ἔρως
ἔρως6mo ago
on the if, check if it is an instance of HTMLTemplateElement if(!template || !(template instanceof HTMLTemplateElement))
roelof
roelofOP6mo ago
??? Where is the data ?
ἔρως
ἔρως6mo ago
what do you mean?
roelof
roelofOP6mo ago
The parameter of the function is named data and earlier we checked if that exist
roelof
roelofOP6mo ago
i have now this and it is a big mess :
No description
ἔρως
ἔρως6mo ago
data is not an html element you are trying to check if data is an html element something i didn't tell you to do
roelof
roelofOP6mo ago
oke
roelof
roelofOP6mo ago
I hope this will us closer to the solution :
No description
ἔρως
ἔρως6mo ago
that check is in the wrong place you're supposed to check it at the top of the function
roelof
roelofOP6mo ago
i thought I did
ἔρως
ἔρως6mo ago
you're checkin inside the displayExtensions function while it is good, it's unnecessary if you did it before
roelof
roelofOP6mo ago
this better ?
(async function () {
'use strict';



/** @type {HTMLElement|null} */
const template = document.getElementById('extension-template');
if(!template || !(template instanceof HTMLTemplateElement)) {
console.error("template is not good.");
return;
}
(async function () {
'use strict';



/** @type {HTMLElement|null} */
const template = document.getElementById('extension-template');
if(!template || !(template instanceof HTMLTemplateElement)) {
console.error("template is not good.");
return;
}
if so, still we have this error :
Property 'querySelector' does not exist on type 'Node'.
Property 'querySelector' does not exist on type 'Node'.
like here :
let image = clone.querySelector("img");
image = extension.icon;

let image = clone.querySelector("img");
image = extension.icon;

ἔρως
ἔρως6mo ago
you have to check that the return of cloneNode is an isntance of DocumentFragment
roelof
roelofOP6mo ago
oke So like this :
let image = clone.querySelector("img");

if (!image instancof DocumentFragmenr) {
console.log("image is not a document fragment")
return
}
let image = clone.querySelector("img");

if (!image instancof DocumentFragmenr) {
console.log("image is not a document fragment")
return
}
ἔρως
ἔρως6mo ago
no, the return value of cloneNode for that one, you have to check it is an instance of HTMLImageElement
roelof
roelofOP6mo ago
oke, no error message
// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);

if (!(clone instanceof DocumentFragment)) {
console.error("Clone is not a DocumentFragment.");
return;
}
// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);

if (!(clone instanceof DocumentFragment)) {
console.error("Clone is not a DocumentFragment.");
return;
}
` wierd, now no error messages in VS Code but data is still empty
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
can you send the code?
roelof
roelofOP6mo ago
of course :
// @ts-check


(async function () {
'use strict';



/** @type {HTMLElement|null} */
const template = document.getElementById('extension-template');
if(!template || !(template instanceof HTMLTemplateElement)) {
console.error("template is not good.");
return;
}


const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
}
} else {
extensions = JSON.parse(extensions);
}

return extensions;
}




const displayExtensions = (data) => {

if (!data) {
console.error("No data to display or data is not an array.");
return;
}

for (const extension of data) {


// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);

if (!(clone instanceof DocumentFragment)) {
console.error("Clone is not a DocumentFragment.");
return;
}

let image = clone.querySelector("img");


image = extension.icon;

let h2 = clone.querySelector("h2");
h2 = extension.name;

let p = clone.querySelector("p");
p = extension.description;

}
}

const extensions = await getExtensions();
displayExtensions(extensions);


})();
// @ts-check


(async function () {
'use strict';



/** @type {HTMLElement|null} */
const template = document.getElementById('extension-template');
if(!template || !(template instanceof HTMLTemplateElement)) {
console.error("template is not good.");
return;
}


const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions) {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
}
} else {
extensions = JSON.parse(extensions);
}

return extensions;
}




const displayExtensions = (data) => {

if (!data) {
console.error("No data to display or data is not an array.");
return;
}

for (const extension of data) {


// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);

if (!(clone instanceof DocumentFragment)) {
console.error("Clone is not a DocumentFragment.");
return;
}

let image = clone.querySelector("img");


image = extension.icon;

let h2 = clone.querySelector("h2");
h2 = extension.name;

let p = clone.querySelector("p");
p = extension.description;

}
}

const extensions = await getExtensions();
displayExtensions(extensions);


})();
I hit the shower
ἔρως
ἔρως6mo ago
for (const extension of data) { wait, no, this is correct what's in localstorage?
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
localstorage isn't empty it contains the string 'null' delete it
roelof
roelofOP6mo ago
this looks better
roelof
roelofOP6mo ago
No description
roelof
roelofOP6mo ago
but on the page I still do not see the cards only the template part
Ganesh
Ganesh6mo ago
You're not appending anything
ἔρως
ἔρως6mo ago
you have to add the clone to the document
Ganesh
Ganesh6mo ago
The clone stays in memory if you don't append and never appears on dom
roelof
roelofOP6mo ago
oke then I have to figure out how to do that
ἔρως
ἔρως6mo ago
get the element that should have the extensions, like you did with the template then .appendChild(clone) on it
roelof
roelofOP6mo ago
I did now I see 12 cards but no text or image

for (const extension of data) {


// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);

if (!(clone instanceof DocumentFragment)) {
console.error("Clone is not a DocumentFragment.");
return;
}

let image = clone.querySelector("img");


image = extension.icon;

let h2 = clone.querySelector("h2");
h2 = extension.name;

let p = clone.querySelector("p");
p = extension.description;

extensionTable.appendChild(clone);

}

for (const extension of data) {


// Clone the new row and insert it into the table
const clone = template.content.cloneNode(true);

if (!(clone instanceof DocumentFragment)) {
console.error("Clone is not a DocumentFragment.");
return;
}

let image = clone.querySelector("img");


image = extension.icon;

let h2 = clone.querySelector("h2");
h2 = extension.name;

let p = clone.querySelector("p");
p = extension.description;

extensionTable.appendChild(clone);

}
ἔρως
ἔρως6mo ago
h2 = extension.name; <-- you're assigning extension.name to h2 you need to set the textContent attribute instead h2 no longer is an element same for image and p
roelof
roelofOP6mo ago
for image I have to set the textContent. I want to fill in the src tag
ἔρως
ἔρως6mo ago
then set the src property
roelof
roelofOP6mo ago
I did :
image.src = extension.icon;

image.src = extension.icon;

but still no image now src= "undefined" oke, got it working but forget the switch
ἔρως
ἔρως6mo ago
what was the issue?
roelof
roelofOP6mo ago
icon schould be logo but it seems to work
roelof
roelofOP6mo ago
No description
roelof
roelofOP6mo ago
I now only see a lot of possible null error message where I know it cannot be null
No description
ἔρως
ἔρως6mo ago
yes, it is possible to be null by the way, id's are required to be unique, and you have non-unique ids
roelof
roelofOP6mo ago
I know How can I solve this At all things a check if they are not nullls and yes, I know That is why editing things is not imppssible I have to think well how to solve this
ἔρως
ἔρως6mo ago
yes as you should
roelof
roelofOP6mo ago
and another one :
if (!active) {
console.error("Checkbox element not found in the template.");
return;
}

active.checked = extension.isActive;
if (!active) {
console.error("Checkbox element not found in the template.");
return;
}

active.checked = extension.isActive;
Property 'checked' does not exist on type 'Element'.
Property 'checked' does not exist on type 'Element'.
ἔρως
ἔρως6mo ago
you have to tell it it is an input html element you do it by checking if it is an instance of it
roelof
roelofOP6mo ago
oke this seems to solve it :
/** @type {HTMLInputElement|null} */
let active = clone.querySelector("#ms1");

if (!active) {
console.error("Checkbox element not found in the template.");
return;
}

active.checked = extension.isActive;
/** @type {HTMLInputElement|null} */
let active = clone.querySelector("#ms1");

if (!active) {
console.error("Checkbox element not found in the template.");
return;
}

active.checked = extension.isActive;
ἔρως
ἔρως6mo ago
yeah, kinda ... you're trusting on the untrustable
roelof
roelofOP6mo ago
😦
ἔρως
ἔρως6mo ago
you have to check that it is an instance of an html input element
roelof
roelofOP6mo ago
this is better ??
let active = clone.querySelector("#ms1");

if (!active || !(active instanceof HTMLInputElement)) {
console.error("Checkbox element not found in the template.");
return;
}
let active = clone.querySelector("#ms1");

if (!active || !(active instanceof HTMLInputElement)) {
console.error("Checkbox element not found in the template.");
return;
}
ἔρως
ἔρως6mo ago
yes
roelof
roelofOP6mo ago
oke, and everything seems to work fine two to go One the filtering Two the chancing of the status and store the change on localStorage but that will be next week Tomorrow a birthday and the day after is recover from it Parents are nice but make you also very tired mentally
ἔρως
ἔρως6mo ago
you should rest
roelof
roelofOP6mo ago
that is my plan and many thanks for your patience today was difficult sometimes but we made it
ἔρως
ἔρως6mo ago
you're welcome
roelof
roelofOP6mo ago
glad to hear still a lot to learn
ἔρως
ἔρως6mo ago
i know, but you will get there we're also doing it the right way, not the easy way
roelof
roelofOP6mo ago
yep
ἔρως
ἔρως6mo ago
but, it can be a lot better
roelof
roelofOP6mo ago
it can always a lot better but I do not have a clue how I can do it better
ἔρως
ἔρως6mo ago
one thing you don't do is to check what you get from localstorage
roelof
roelofOP6mo ago
you mean I can make a check for example null input here
if (!extensions) {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
}
} else {
extensions = JSON.parse(extensions);
}
if (!extensions) {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
}
} else {
extensions = JSON.parse(extensions);
}
ἔρως
ἔρως6mo ago
yes and you can actually say what the function returns and that can be used to typecheck the entire code and this way, you wouldn't have used icon by mistake
roelof
roelofOP6mo ago
o, I thought you can do that only with typescript not plain js typechecking things
ἔρως
ἔρως6mo ago
you can, with jsdoc and since you have //@ts-check, typescript is used to do typechecking on the code you can even add a .d.ts file with the type definitions
roelof
roelofOP6mo ago
🙂 Maybe convert the whole js to ts ? 😛
ἔρως
ἔρως6mo ago
nah, you need node for that and compile it and do all sorts of magic
roelof
roelofOP6mo ago
was joking I hate magic That was one of the reason I quit ruby and Ruby On Rials to much magic so change the code to this :
if (!extensions || extensions === "null") {
if (!extensions || extensions === "null") {
ἔρως
ἔρως6mo ago
not exactly, but it's a start
roelof
roelofOP6mo ago
😦 and with jsdoc you mean something like this :
/**
* Displays the list of extensions in the DOM.
* @param {Extension[]} data - Array of extension objects to display
* @returns {void}
*/
/**
* Displays the list of extensions in the DOM.
* @param {Extension[]} data - Array of extension objects to display
* @returns {void}
*/
ἔρως
ἔρως6mo ago
Extension <-- this doesn't exist you have to define the type
roelof
roelofOP6mo ago
oke like this :
/**
* @typedef {Object} Extension
* @property {string} logo - URL or path to the extension's logo image
* @property {string} name - Name of the extension
* @property {string} description - Description of the extension
* @property {boolean} isActive - Whether the extension is active
*/
/**
* @typedef {Object} Extension
* @property {string} logo - URL or path to the extension's logo image
* @property {string} name - Name of the extension
* @property {string} description - Description of the extension
* @property {boolean} isActive - Whether the extension is active
*/
ἔρως
ἔρως6mo ago
yup
roelof
roelofOP6mo ago
oops, and another type error 😦
ἔρως
ἔρως6mo ago
and this is why you add type checking
roelof
roelofOP6mo ago
and solved
roelof
roelofOP6mo ago
roelof
roelofOP6mo ago
and still evrything works well
ἔρως
ἔρως6mo ago
so much better than untyped code still needs some touches
roelof
roelofOP6mo ago
Did the same with darkmode.js and see there a type error I cannot solve
//@ts-check

/**
* Handles dark mode toggle functionality.
* Saves the user's preference in localStorage and updates the toggle state.
*
* Expects the following HTML structure:
* <input type="checkbox" id="theme-toggle" />
*/

(function() {
'use strict';

/** @type {string|null} */
let darkMode = localStorage.getItem('darkMode');

/** @type {HTMLInputElement|null} */
const darkModeToggle = /** @type {HTMLInputElement|null} */ (document.querySelector('#theme-toggle'));

if (darkMode === 'enabled') {
enableDarkMode();
}

if (darkModeToggle) {
darkModeToggle.addEventListener('change', () => {
darkMode = localStorage.getItem('darkMode');
if (darkMode !== 'enabled') {
enableDarkMode();
} else {
disableDarkMode();
}
});
}

/**
* Enables dark mode and updates localStorage and toggle state.
* @returns {void}
*/
function enableDarkMode() {
if (darkModeToggle) darkModeToggle.checked = true;
localStorage.setItem('darkMode', 'enabled');
}

/**
* Disables dark mode and updates localStorage and toggle state.
* @returns {void}
*/
function disableDarkMode () {
if (darkModeToggle) darkModeToggle.checked = false;
localStorage.setItem('darkMode', null);
}
})();
//@ts-check

/**
* Handles dark mode toggle functionality.
* Saves the user's preference in localStorage and updates the toggle state.
*
* Expects the following HTML structure:
* <input type="checkbox" id="theme-toggle" />
*/

(function() {
'use strict';

/** @type {string|null} */
let darkMode = localStorage.getItem('darkMode');

/** @type {HTMLInputElement|null} */
const darkModeToggle = /** @type {HTMLInputElement|null} */ (document.querySelector('#theme-toggle'));

if (darkMode === 'enabled') {
enableDarkMode();
}

if (darkModeToggle) {
darkModeToggle.addEventListener('change', () => {
darkMode = localStorage.getItem('darkMode');
if (darkMode !== 'enabled') {
enableDarkMode();
} else {
disableDarkMode();
}
});
}

/**
* Enables dark mode and updates localStorage and toggle state.
* @returns {void}
*/
function enableDarkMode() {
if (darkModeToggle) darkModeToggle.checked = true;
localStorage.setItem('darkMode', 'enabled');
}

/**
* Disables dark mode and updates localStorage and toggle state.
* @returns {void}
*/
function disableDarkMode () {
if (darkModeToggle) darkModeToggle.checked = false;
localStorage.setItem('darkMode', null);
}
})();
Argument of type 'null' is not assignable to parameter of type 'string'.
Argument of type 'null' is not assignable to parameter of type 'string'.
any hint ?
ἔρως
ἔρως6mo ago
which line?
roelof
roelofOP6mo ago
localStorage.setItem('darkMode', null);
localStorage.setItem('darkMode', null);
ἔρως
ἔρως6mo ago
localstorage only accepts strings null isn't a string
roelof
roelofOP6mo ago
oke, so I have to make it "null" and update the if then ?
ἔρως
ἔρως6mo ago
or just an empty string or remove the key
roelof
roelofOP6mo ago
oke, I removed it and everything is alright with the types but you want some touches on the read function
ἔρως
ἔρως6mo ago
/** @type {HTMLInputElement|null} */
const darkModeToggle = /** @type {HTMLInputElement|null} */ (document.querySelector('#theme-toggle'));
/** @type {HTMLInputElement|null} */
const darkModeToggle = /** @type {HTMLInputElement|null} */ (document.querySelector('#theme-toggle'));
^ you shouldn't do this you're forcing typescript to believe you
roelof
roelofOP6mo ago
oke, so the same "trick" as the rest
ἔρως
ἔρως6mo ago
yes, check that it is what you want it to be
roelof
roelofOP6mo ago
const darkModeToggle = document.querySelector('#theme-toggle');

if (!darkModeToggle) {
console.log("the toggle cannot be found");
return
}
const darkModeToggle = document.querySelector('#theme-toggle');

if (!darkModeToggle) {
console.log("the toggle cannot be found");
return
}
ἔρως
ἔρως6mo ago
and you have to check that it is an instance of an input
roelof
roelofOP6mo ago
/** @type {HTMLInputElement|null} */
const darkModeToggle = document.querySelector('#theme-toggle');

if (!darkModeToggle || !(darkModeToggle instanceof HTMLInputElement)) {
console.log("the toggle cannot be found");
return
}
/** @type {HTMLInputElement|null} */
const darkModeToggle = document.querySelector('#theme-toggle');

if (!darkModeToggle || !(darkModeToggle instanceof HTMLInputElement)) {
console.log("the toggle cannot be found");
return
}
ἔρως
ἔρως6mo ago
basically that
roelof
roelofOP6mo ago
Oke And which touches do you want on the redding functions
ἔρως
ἔρως6mo ago
i think that that's it
roelof
roelofOP6mo ago
then I will send the new code to github and next week I hope I can solve the last two - filtering - removing things and store the change in localstorage have a nice weekend and maybe give the items een numeric or uuid index so I can also easily change things and maybe even make the removing simpler but have to think how to make such index
ἔρως
ἔρως6mo ago
and fix the repeated id
roelof
roelofOP6mo ago
???
ἔρως
ἔρως6mo ago
you have a repeated id
roelof
roelofOP6mo ago
where ? If I look at localStorage no card have a id
ἔρως
ἔρως6mo ago
the switch has
roelof
roelofOP6mo ago
oke have also to think about that
ἔρως
ἔρως6mo ago
you probably don't need the id
roelof
roelofOP6mo ago
I do right now I use it here :
let active = clone.querySelector("#ms1");
let active = clone.querySelector("#ms1");
ἔρως
ἔρως6mo ago
you don't need the id you can use a css selector
roelof
roelofOP6mo ago
Maybe this one then :
input type="checkbox" role="switch" />
input type="checkbox" role="switch" />
ἔρως
ἔρως6mo ago
yup, you can find it by the type and role
roelof
roelofOP6mo ago
otherwise it will be a problem with the toggle if I only use input type="checkbox"
ἔρως
ἔρως6mo ago
im talking about the id
roelof
roelofOP6mo ago
so this is good :
let active = clone.querySelector('input type="checkbox" role="switch"');
let active = clone.querySelector('input type="checkbox" role="switch"');
ἔρως
ἔρως6mo ago
no, the selector is invalid
roelof
roelofOP6mo ago
this better ;
let active = clone.querySelector("input[type='checkbox'] role='switch'");
let active = clone.querySelector("input[type='checkbox'] role='switch'");
ἔρως
ἔρως6mo ago
almost there the selector is still invalid
roelof
roelofOP6mo ago
sorry, at the moment I do not see the right syntax
ἔρως
ἔρως6mo ago
that's fine, just relax
roelof
roelofOP6mo ago
Cannot relax when I cannot solve this stupid problem bummer when I do this
let active = clone.querySelector("[role='switch]");
let active = clone.querySelector("[role='switch]");
then the checkbox is not found and this is working
let active = clone.querySelector("[role='switch']");
let active = clone.querySelector("[role='switch']");
hopefully it is a good solution
ἔρως
ἔρως6mo ago
it is good enough, yes i would also select a checkbox, but that is fine
roelof
roelofOP6mo ago
could not make that work 😢
ἔρως
ἔρως6mo ago
does it work now?
roelof
roelofOP6mo ago
As far as i can see it works The site i mean works
ἔρως
ἔρως6mo ago
then that is good
roelof
roelofOP6mo ago
I mean I could not figure out how to make that call with the checkbox added to it
ἔρως
ἔρως6mo ago
what do you mean?
roelof
roelofOP6mo ago
I did this :
let active = clone.querySelector("[role='switch']");
let active = clone.querySelector("[role='switch']");
and then you said :
i would also select a checkbox, but that is fine
i would also select a checkbox, but that is fine
ἔρως
ἔρως6mo ago
yeah
roelof
roelofOP6mo ago
and I try to say that selecting the checbox together with the role I cannot make that work without making errors That is why I did it this way
ἔρως
ἔρως6mo ago
yes you can, you did it for the css it's nothing you haven't done before
roelof
roelofOP6mo ago
I tried and every time I see errors Wait is it this :
[type="checkbox"][role="switch"]
[type="checkbox"][role="switch"]
?
ἔρως
ἔρως6mo ago
and input but yes
roelof
roelofOP6mo ago
im happy This is also working
let active = clone.querySelector("input[type='checkbox'][role='switch']");
let active = clone.querySelector("input[type='checkbox'][role='switch']");
for now GN . Tomorrow a day that will make me very tired
ἔρως
ἔρως6mo ago
that's exactly what i meant hope you see why what you had before was wrong goodnight
roelof
roelofOP6mo ago
yep I missed the [] around the first part
ἔρως
ἔρως6mo ago
yup, it is easy to miss but very important
roelof
roelofOP6mo ago
back from the birtday of my father and I wonder one thing since yesterday Can it easily be done that all the items get or a numeric id or a uidd I think when that is working writing the remove part will be more easy
ἔρως
ἔρως6mo ago
yeah, that's something extremely trivial
roelof
roelofOP6mo ago
oke, I do not see it at the moment
ἔρως
ἔρως6mo ago
you will see
roelof
roelofOP6mo ago
maybe make a loop between the read and display function here :
const extensions = await getExtensions();
displayExtensions(extensions);
const extensions = await getExtensions();
displayExtensions(extensions);
? and can I then the best use a numeric one or a more complex one ?
ἔρως
ἔρως6mo ago
nope it's way simpler
roelof
roelofOP6mo ago
The most simple way is to change the json. But in real lif you cannot do that So this does not seem to be a solution otherwise totaly no idea
ἔρως
ἔρως6mo ago
nope. that's not an option
roelof
roelofOP6mo ago
exactly but I do not see a better option when looking and looking at the code so if I may have a hint ?
ἔρως
ἔρως6mo ago
it's when you are cloning and setting the display values right in that function
roelof
roelofOP6mo ago
hmm have to think about where and how then
ἔρως
ἔρως6mo ago
it's way easier than you think
roelof
roelofOP6mo ago
could be , I be stuck at that loop idea I think I cannot do something like this
Clone.id = id++
Clone.id = id++
because clone is a template not a record
ἔρως
ἔρως6mo ago
no, but you are clone
roelof
roelofOP6mo ago
??? do you mean close or is this a hint I do not understand at the moment
ἔρως
ἔρως6mo ago
it's a hint you don't understand at the moment but why do you need the unique id?
roelof
roelofOP6mo ago
because then with the remove I can filter on that id so the " record" is removed from localstorage And it will be easier to make code for example editing content If I filter on for example the title I never can get it changed
ἔρως
ἔρως6mo ago
you have to give the id to the card then
roelof
roelofOP6mo ago
exactly but I do not see how I make that id ?
ἔρως
ἔρως6mo ago
how do you think it is supposed to be done?
roelof
roelofOP6mo ago
normally at a database You made a field and the database does the magic But we do not have a database here 😦 So im stuck how I can make that work
ἔρως
ἔρως6mo ago
the json file is the data you would get from a database
roelof
roelofOP6mo ago
oke but I cannot change that because it it's was coming from a api I also cannot change it as far as I know
ἔρως
ἔρως6mo ago
you don't need to
roelof
roelofOP6mo ago
Sorry, I do not see it and get the feeling im running around in circles right npw
ἔρως
ἔρως6mo ago
you are
roelof
roelofOP6mo ago
😢
Ganesh
Ganesh6mo ago
The json file doesn't have ids?
vince
vince6mo ago
It's not optimal but when you're reading the local storage can't you just give the objects an ID based off the array index?
ἔρως
ἔρως6mo ago
or use the array index as part of the id
vince
vince6mo ago
Personally i would just give each object inside the json an ID field and do it that way
ἔρως
ἔρως6mo ago
i would just use the index for an id on the card
vince
vince6mo ago
No use following strictly the challenge it's not like u get anything for it
ἔρως
ἔρως6mo ago
i still would do the way i said
Ganesh
Ganesh6mo ago
Can probably just write a function that uses crypto.randomuuid and then modifies the fetched json to have ID for all objects before saving in local storage. But probably overkill for this
ἔρως
ἔρως6mo ago
very overkill
Ganesh
Ganesh6mo ago
Yeahhh
roelof
roelofOP6mo ago
and I still do not see it how I can get a id on the card
ἔρως
ἔρως6mo ago
you set the id on the card element
roelof
roelofOP6mo ago
How? That is the question I askked the whole day
vince
vince6mo ago
is one way of doing it you can add a data attribute too... you can add it to the json as well
ἔρως
ἔρως6mo ago
1- get the card element 2- make an id 3- set the id to the card this is the better option
roelof
roelofOP6mo ago
So something like :
card = document.querySelector('extension');
card.setAttrubute('id', ++id);
card = document.querySelector('extension');
card.setAttrubute('id', ++id);

? or
clone.setAttribute('id' , ++id)
clone.setAttribute('id' , ++id)
?
ἔρως
ἔρως6mo ago
something like the top one
roelof
roelofOP6mo ago
😢 Giving up for today Frustated because I still do not know how to add a simple id to the card last attempt :
card = clone.querySelector('extension');
card.setAttrubute('id', ++id);
card = clone.querySelector('extension');
card.setAttrubute('id', ++id);
ἔρως
ἔρως6mo ago
the <extension> tag doesn't exist
roelof
roelofOP6mo ago
then I gave it up Totally no idea then
Ganesh
Ganesh6mo ago
Query selector selects like how css would Do you think 'extension' selects the class extension or something else? How do you select classes in css
roelof
roelofOP6mo ago
chips , I see it I mean :
card = clone.querySelector('.extension');
card.setAttrubute('id', ++id);
card = clone.querySelector('.extension');
card.setAttrubute('id', ++id);
`
ἔρως
ἔρως6mo ago
that's almost there but id's shouldn't be numbers if you want it to be a number, use data-id instead
roelof
roelofOP6mo ago
id schould be a UIDD ? Then i have to search how to make that
ἔρως
ἔρως6mo ago
no, it doesn't need to be an uuid
roelof
roelofOP6mo ago
What is then a better altrnative then a number ?
ἔρως
ἔρως6mo ago
in your case: a number
roelof
roelofOP6mo ago
oke then we go for the code I made and then with a data-id
ἔρως
ἔρως6mo ago
just use data-id instead of id or use a prefix, like ext_
roelof
roelofOP6mo ago
oke
roelof
roelofOP6mo ago
So this code is good to ship it
ἔρως
ἔρως6mo ago
no, it isn't you have a bug id starts at data.length that means it will start at 11 or something, instead of 0 if that doesn't matter, then it's good
roelof
roelofOP6mo ago
I saw that I think it is the problem that there are already data in the localstorage and I can only delete them if im on the page So right now I do not see a solution for this problem
ἔρως
ἔρως6mo ago
uh, what do you mean?
roelof
roelofOP6mo ago
I could say that the id begins at zero But does it then work when I for example want to add a new card right now it looks how many cards there are already
ἔρως
ἔρως6mo ago
yes, it does
roelof
roelofOP6mo ago
oke, so it needs to be zero
ἔρως
ἔρως6mo ago
no i pointed as a bug because it could be unintentional
roelof
roelofOP6mo ago
oke, so again back to the drawing table
ἔρως
ἔρως6mo ago
what do you mean?
roelof
roelofOP6mo ago
That I have to think how to solve this bug
ἔρως
ἔρως6mo ago
just set it to 0 or do nothing
roelof
roelofOP6mo ago
now im confused , I just proposed it and then you said it was wrong
ἔρως
ἔρως6mo ago
no, i said you had a bug i didn't say it was wrong i also said it doesn't matter much
vince
vince6mo ago
is this written w/ ai?
roelof
roelofOP6mo ago
nope I never use ai my idea is that if you use ai you do not learn anything so that is why I do not use it @ἔρως I was pointing at this discussion
oke, so it needs to be zero
ἔρως

17:12
no
i pointed as a bug because it could be unintentional
oke, so it needs to be zero
ἔρως

17:12
no
i pointed as a bug because it could be unintentional
I think there we misunderstood each other
vince
vince6mo ago
I'm surprised you know some of the syntax, like I didn't know of for... of or ternaries until understanding js a bit better
roelof
roelofOP6mo ago
I see that on languages as c++ and then I tried if it working in js
ἔρως
ἔρως6mo ago
it is a new syntax, added a few years ago
roelof
roelofOP6mo ago
And ternaries I know a while but I do not use them a lot because I find it less readable then a normal if then im not totally new to developing with js and developing software / websites I only forget a lot because it is more then 1 year ago that I use css and js For a year Im more busy with c++ and the arduino and some old "mentors" have learned me the wrong way to do things 😢 @ἔρως oke, so setting it to 0 works Then next on my list make the filtering work and then the movement
ἔρως
ἔρως6mo ago
do you want to implement the filtering by yourself? or you want to use the library i sent you, a while ago?
roelof
roelofOP6mo ago
I m thinking to use the library you send me a while ago Why invent the wheel again
ἔρως
ἔρως6mo ago
check the instructions and follow them make sure your files have the attribute defer and the external file should be the first one
roelof
roelofOP6mo ago
oke So I have to add defer to these :
<script src="dark_mode.js"></script>
<script src="reading_data.js"></script>
<script src="dark_mode.js"></script>
<script src="reading_data.js"></script>
like this :
<script src="dark_mode.js" defer></script>
<script src="reading_data.js" defer></script>
<script src="dark_mode.js" defer></script>
<script src="reading_data.js" defer></script>
ἔρως
ἔρως6mo ago
yes
roelof
roelofOP6mo ago
done
ἔρως
ἔρως6mo ago
then follow the documentation for the library
roelof
roelofOP6mo ago
Was alsready my plan
roelof
roelofOP6mo ago
Can I use this one with the GPR : <script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.js"></scrip
ἔρως
ἔρως6mo ago
very likely, but im not a lawyer
roelof
roelofOP6mo ago
oke I asked because with google fontts , you said that is against that law
ἔρως
ἔρως6mo ago
websites have been fined for using google fonts, but not unpkg.com
roelof
roelofOP6mo ago
oke Tomorrow maybe time to study those pages and I hope the js to write can also be done in a seperate file
ἔρως
ἔρως6mo ago
it can't i mean, it can, but i wouldn't try it
roelof
roelofOP6mo ago
oke, so all the code must be in the html file ?? 😢
ἔρως
ἔρως6mo ago
no the code has to run for elements that don't exist yet
roelof
roelofOP6mo ago
oke, so before the two js files we have now but wierd that the code search then for element that do not exist but oke, if it works , it is fine with me
ἔρως
ἔρως6mo ago
you create the elements in js, so, the code has to run after the elements are created
roelof
roelofOP6mo ago
oke, that is more logical have to think how I can do that a lot the former "mentors" have not learned me
ἔρως
ἔρως6mo ago
you can have it in the same file or you can have it in a separated file with mutation observers and honestly? put in the same file
roelof
roelofOP6mo ago
I mean take care that the file is run after the read file is done
ἔρως
ἔρως6mo ago
just put it all in the same file
roelof
roelofOP6mo ago
oke, that will be a big one and the code for the filtering and the layout will be the last then ?
ἔρως
ἔρως6mo ago
and saving if the extension is or isn't active
roelof
roelofOP6mo ago
yep, that must also be after the reading but also after the filtering ? I thought it could be after the reading but before the filtering stuff and is one big file at a moment maintable ?
ἔρως
ἔρως6mo ago
you can try to make it into multiple files, but it will be more complex but you can try it
roelof
roelofOP6mo ago
oke Till now things are working fine with multiple files and till now things are working fine but if it's needed to make the filtering work to put everything in one file , I will do it
ἔρως
ἔρως6mo ago
if you want to do it with multiple files, go for it
roelof
roelofOP6mo ago
I think with multiple files , I know better when what happens then in one very big files
ἔρως
ἔρως6mo ago
that's up to you
roelof
roelofOP6mo ago
Then i think i go for multiple files But for now gn
ἔρως
ἔρως6mo ago
goodnight
roelof
roelofOP6mo ago
are these mutation observers then really needed to take care that the filtering thing is executed as last ?
ἔρως
ἔρως6mo ago
probably will be you can try to make it work without
roelof
roelofOP6mo ago
we see
ἔρως
ἔρως6mo ago
should be easier than expected
roelof
roelofOP6mo ago
oke, This looks to filter:

var elem = document.querySelector('.extensions');
var iso = new Isotope( elem, {
// options
itemSelector: '.extension',
layoutMode: 'fitRows'
});

iso.arrange({
// item element provided as argument
filter: function( itemElem ) {
var isActive = itemElem.querySelector("input[type='checkbox'][role='switch']");
return isActive && isActive.checked;
}
});

$('#active').on( 'click', 'button', function() {
var filterValue = $(this).attr('data-filter');
$grid.isotope({ filter: filterValue });
});

var elem = document.querySelector('.extensions');
var iso = new Isotope( elem, {
// options
itemSelector: '.extension',
layoutMode: 'fitRows'
});

iso.arrange({
// item element provided as argument
filter: function( itemElem ) {
var isActive = itemElem.querySelector("input[type='checkbox'][role='switch']");
return isActive && isActive.checked;
}
});

$('#active').on( 'click', 'button', function() {
var filterValue = $(this).attr('data-filter');
$grid.isotope({ filter: filterValue });
});
but the layout is now a big big mes
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
you dont need jquery and there should be an option to tell it that it is a grid layout
roelof
roelofOP6mo ago
I hope I m on the right track
var elem = document.querySelector('.extensions');
var iso = new Isotope( elem, {
// options
itemSelector: '.extension',
layoutMode: 'fitRows'
});

var filterFns = {
// show if number is greater than 50
isActiveCard: function( itemElem ) {
// use itemElem argument for item element
var isActive = itemElem.querySelector(".isActive");
return isActive && !isActive.checked;
},
}
var elem = document.querySelector('.extensions');
var iso = new Isotope( elem, {
// options
itemSelector: '.extension',
layoutMode: 'fitRows'
});

var filterFns = {
// show if number is greater than 50
isActiveCard: function( itemElem ) {
// use itemElem argument for item element
var isActive = itemElem.querySelector(".isActive");
return isActive && !isActive.checked;
},
}
but the fitering still happens after loading the page instead of pushing a button and the layout is stil a mess I find the docs very confusing because they talk about jquery and plain js this is my html ` <div class="filter-container"> <h1>Extensions List</h1> <div class="filter-options"> <button class="active">All</button> <button class="Isactive" data-filter="active">Active</button> <button>Inactive</button> </div> </div> `
Ganesh
Ganesh6mo ago
Why are there vars here instead of let and const
roelof
roelofOP6mo ago
The examples on the book uses this code as a example @Ganesh
Ganesh
Ganesh6mo ago
Book? Sorry is this an npm package?
roelof
roelofOP6mo ago
see this page : https://isotope.metafizzy.co/filtering Sorry I mean tutorial
Isotope Filtering
Filter & sort magical layouts
ἔρως
ἔρως6mo ago
that was written at a time when let and const didn't exist
b1mind
b1mind6mo ago
Hot tip
b1mind
b1mind6mo ago
Ben Myers
Style with Stateful, Semantic Selectors
See how building with accessible semantics from the get-go can give you expressive, meaningful style hooks for free.
Ganesh
Ganesh6mo ago
8 years last publish
b1mind
b1mind6mo ago
Anytime I see a .active class 🥲😅
Ganesh
Ganesh6mo ago
The last npm package I used around this age was passport js Or passport local i guess. Passport js keeps updating readme
roelof
roelofOP6mo ago
oke, @ἔρως has said this is a good library to make the filtering work so that is why I try to use it
Ganesh
Ganesh6mo ago
Humuhumu
ἔρως
ἔρως6mo ago
i've used it semi-recently, and it worked fine it does work - the website is working, right? but maybe it's time for a new library i don't know new ones
Ganesh
Ganesh6mo ago
Yeah as long as there aren't any vlunrabilities it's fine web keeps support for old shit anyway. The age is just a surprise
ἔρως
ἔρως6mo ago
yeah, it is the only one i know
roelof
roelofOP6mo ago
and I cannot work but I get lost in the docs because they put jquery code next to plain js code
ἔρως
ἔρως6mo ago
yeah, it was made for jquery
roelof
roelofOP6mo ago
😢
ἔρως
ἔρως6mo ago
it works without
roelof
roelofOP6mo ago
oke, but I cannot make it work so it works only when I pres a button and not when I load the site I have this in my filter.js
var elem = document.querySelector('.extensions');
var iso = new Isotope( elem, {
// options
itemSelector: '.extension',
layoutMode: 'fitRows'
});

var filterFns = {
// show if number is greater than 50
isActiveCard: function( itemElem ) {
// use itemElem argument for item element
var isActive = itemElem.querySelector(".isActive");
return isActive && !isActive.checked;
},
}
var elem = document.querySelector('.extensions');
var iso = new Isotope( elem, {
// options
itemSelector: '.extension',
layoutMode: 'fitRows'
});

var filterFns = {
// show if number is greater than 50
isActiveCard: function( itemElem ) {
// use itemElem argument for item element
var isActive = itemElem.querySelector(".isActive");
return isActive && !isActive.checked;
},
}
and this in my html

<script src="dark_mode.js" defer></script>
<script src="reading_data.js" defer></script>
<script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script>
<script src="filter.js" defer></script>

<script src="dark_mode.js" defer></script>
<script src="reading_data.js" defer></script>
<script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script>
<script src="filter.js" defer></script>
<button class="Isactive" data-filter="active">Active</button>
<button class="Isactive" data-filter="active">Active</button>
ἔρως
ἔρως6mo ago
i think it is time to skip this and do it with css
roelof
roelofOP6mo ago
css for filtering ?? I thought I need js for it and maybe css for the animations
ἔρως
ἔρως6mo ago
you can with css or with js
Ganesh
Ganesh6mo ago
Probably means assigning, removing classes. The classes can have display none style
ἔρως
ἔρως6mo ago
if im not mistaken, the filter buttons are just radio inputs change the value, hide the others in css
roelof
roelofOP6mo ago
no no, the filter buttons are buttons you can set a card from active to not active with a switch which is really a radio button
Ganesh
Ganesh6mo ago
Isn't switch a check box?
ἔρως
ἔρως6mo ago
it is
Ganesh
Ganesh6mo ago
Radio can't be toggled off iirc
ἔρως
ἔρως6mo ago
no, but can change
Ganesh
Ganesh6mo ago
Also I had to think for a moment but we're you hinting at using the checked psuedo class with siblings selector ?
ἔρως
ἔρως6mo ago
yup, with :has() to detect the checked radio button but it can be used with a class too
roelof
roelofOP6mo ago
oke, then again and again back to the drawing table to find out how this works Will be at first tomorrow Now to tired to find that out
ἔρως
ἔρως6mo ago
there are many ways of doing this
roelof
roelofOP6mo ago
yep, the disadvantage of development. There are also multiple ways of doing things
ἔρως
ἔρως6mo ago
yup which way do you want to do it?
vince
vince6mo ago
that's a big plus so many times one way didn't work for my use case so I could use another way
roelof
roelofOP6mo ago
If it can be done with css i go for this Gn
ἔρως
ἔρως6mo ago
goodnight
roelof
roelofOP6mo ago
Does anyone then have a example or tutorial how I can make that filtering work with only css ?
Ganesh
Ganesh6mo ago
Chris Bier
CodePen
CSS-Only List Filtering
Filter a list with only CSS. I came up with this idea and finally was able to find time to give it a shot. It can use improvement. Due to the use of t...
Ganesh
Ganesh6mo ago
found this on google checkbox based but radio should be similiar
Ganesh
Ganesh6mo ago
my hastily put together radio version
roelof
roelofOP6mo ago
oke I see how it works
input[value=shape]:checked ~ .items div:not([data-type=shape]),
input[value=shape]:checked ~ .items div:not([data-type=shape]),
I think I can adapt this to my needs @Ganesh thanks Does this mean that if the status is changed , I also have to update the data-type every time ?
ἔρως
ἔρως6mo ago
no in your case, you hide based on if the switch is checked or not, the one on each extension
roelof
roelofOP6mo ago
yes, that is the first part :
input type="checkbox" role="switch":checked
input type="checkbox" role="switch":checked
but the seond part should be then this :

<div class="extension">

<div class="extension">
but there I cannot know if it the switch is checked or not
Ganesh
Ganesh6mo ago
You mean you can't know if switch is checked inside the extension div? Use the has pseudo class
roelof
roelofOP6mo ago
no I do not see how I can make this work for my site
input[value=shape]:checked ~ .items div:not([data-type=shape]),
input[value=shape]:checked ~ .items div:not([data-type=shape]),
It looks like to me that I forget to add something when I do :
input type="checkbox" role="switch":checked ~ extensions
input type="checkbox" role="switch":checked ~ extensions
looks now to me that it selects all the cards Not the cards where the switch is checked
ἔρως
ἔρως6mo ago
because the syntax is incorrect
roelof
roelofOP6mo ago
😢 and I do not see the right syntax
ἔρως
ἔρως6mo ago
the same as you did in js, a few days ago you've made the same exact mistake there
roelof
roelofOP6mo ago
oke Then it would be :
`[input type="checkbox"] [role="switch"]:checked ~ extensions
`[input type="checkbox"] [role="switch"]:checked ~ extensions
But that one does not respons on a button click
ἔρως
ἔρως6mo ago
close, but not there yet
roelof
roelofOP6mo ago
😢
Ganesh
Ganesh6mo ago
Can you use attribute selectors by themselves? I've never tried it without an element
ἔρως
ἔρως6mo ago
yes it's the same as *[id] for example if you dont specify a tag, * is always assumed that is why :root or just :where(p) works
roelof
roelofOP6mo ago
sorry, I do not see what I have done wrong and how I can make it work with a button click
Ganesh
Ganesh6mo ago
You use [] for attributes. In the code above you are putting something other than an attribute inside them brackets Gotcha gotcha
roelof
roelofOP6mo ago
chips , now I see it :
input[type="checkbox"] [role="switch"]:checked ~ .extensions
input[type="checkbox"] [role="switch"]:checked ~ .extensions
ἔρως
ἔρως6mo ago
the tag cant be inside the attributr selector also, extensions is a class, not a tag
roelof
roelofOP6mo ago
changed but still I do not see how to make that work after a button click Still think I need js for that
ἔρως
ἔρως6mo ago
well, if you change the buttons to labels with radio inputs inside, not really
roelof
roelofOP6mo ago
hmm, it is then not possibe that two buttons have both a checked status ?
ἔρως
ἔρως6mo ago
what do you mean?
roelof
roelofOP6mo ago
sorry, im mistaken you mean that every radio button looks like the button and then only 1 can be checked That will be writing a lot of css to make this work
ἔρως
ἔρως6mo ago
probably not you might have to throw away some js or implement the filtering in js
roelof
roelofOP6mo ago
some css so that the radio button looks like a button some css for the all filtering some css for the active filtering some css for the not active filtering
Ganesh
Ganesh6mo ago
You likely don't need to style the radio input itself to look like a button You can hide the radio input and instead style it's label Tho maybe that has some accessibility repercussions i don't know about
ἔρως
ἔρως6mo ago
it shouldnt but it shouldnt need much css work
roelof
roelofOP6mo ago
it schould n't As I see it , it costs some css to make the radip button looks like a button
ἔρως
ἔρως6mo ago
it shouldnt be any trouble
roelof
roelofOP6mo ago
we see but not today anymore
ἔρως
ἔρως6mo ago
you should rest
roelof
roelofOP6mo ago
yep tomorrow 2 things to do Groceries and someone going look at our water pipes it seems there is some sort of blockage somewhere in the kitchen and then I have to look how many energy is left
ἔρως
ἔρως6mo ago
you can continue next week, it's fine
roelof
roelofOP6mo ago
we see Still I wonder if this cannot be done with keeping it a button
ἔρως
ἔρως6mo ago
with js, yes
roelof
roelofOP6mo ago
oke, when I have some energy I will try to rebuild the buttons as radio things
ἔρως
ἔρως6mo ago
take your time with it
roelof
roelofOP6mo ago
I will do This challenge has costed me a lot of time so a few days longer do not matter 🙂 Is this a good start :
<div class="filter-options">
<input type="radio" id="all" name="status" value="ALL" checked>
<label for="html">All</label><br>
<input type="radio" id="active" name="status" value="ACTIVE">
<label for="ACTIVE">Active</label><br>
<input type="radio" id="not_active" name="status" value="NOT_ACTIVE">
<label for="NOT_ACTIVE">Inactive</label>
</div>
<div class="filter-options">
<input type="radio" id="all" name="status" value="ALL" checked>
<label for="html">All</label><br>
<input type="radio" id="active" name="status" value="ACTIVE">
<label for="ACTIVE">Active</label><br>
<input type="radio" id="not_active" name="status" value="NOT_ACTIVE">
<label for="NOT_ACTIVE">Inactive</label>
</div>
ἔρως
ἔρως6mo ago
without the <br>, it is but the inputs need a name i mean, a value
Ganesh
Ganesh6mo ago
Doesn't he have both name and value attributes? Or do you mean something else
ἔρως
ἔρως6mo ago
oh god i just noticed: the id and value are swapped also, it's a good idea to use a prefix for the ids
roelof
roelofOP6mo ago
??? How must the html code then look like ?
ἔρως
ἔρως6mo ago
can you paste here the html for the not active status? im on my phone
roelof
roelofOP6mo ago
I think you mean this ;
<input type="radio" id="not_active" name="status" value="NOT_ACTIVE">
<label for="NOT_ACTIVE">Inactive</label>
<input type="radio" id="not_active" name="status" value="NOT_ACTIVE">
<label for="NOT_ACTIVE">Inactive</label>
ἔρως
ἔρως6mo ago
like this:
<input type="radio" id="status-not_active" name="status" value="not_active">
<label for="status-not_active">Inactive</label>
<input type="radio" id="status-not_active" name="status" value="not_active">
<label for="status-not_active">Inactive</label>
roelof
roelofOP6mo ago
oke So this one :
<input type="radio" id="all" name="status" value="ALL" checked>
<label for="html">All</label><br>
<input type="radio" id="all" name="status" value="ALL" checked>
<label for="html">All</label><br>
<input type="radio" id="status_all" name="status" value="all" checked>
<label for="status_all">All</label><br>
<input type="radio" id="status_all" name="status" value="all" checked>
<label for="status_all">All</label><br>
` ?
ἔρως
ἔρως6mo ago
now you do the same i did
roelof
roelofOP6mo ago
is that bad ?
ἔρως
ἔρως6mo ago
what do you mean?
roelof
roelofOP6mo ago
I wonder if I do the same as you did is bad or not ?
ἔρως
ἔρως6mo ago
no, it isnt
roelof
roelofOP6mo ago
oke, So the active one has to change the same way ?
ἔρως
ἔρως6mo ago
would be ideal thst you do it for all
roelof
roelofOP6mo ago
yep this better ?
<div class="filter-options">

<input type="radio" id="status_all" name="status" value="all" checked>
<label for="status_all">All</label>

<input type="radio" id="status_active" name="status" value="active">
<label for="status_active">Active</label>

<input type="radio" id="status-not_active" name="status" value="not_active">
<label for="status-not_active">Inactive</label>

</div>
<div class="filter-options">

<input type="radio" id="status_all" name="status" value="all" checked>
<label for="status_all">All</label>

<input type="radio" id="status_active" name="status" value="active">
<label for="status_active">Active</label>

<input type="radio" id="status-not_active" name="status" value="not_active">
<label for="status-not_active">Inactive</label>

</div>
ἔρως
ἔρως6mo ago
it's better, but i've separated the value with - instead of _ to make it obvious
roelof
roelofOP6mo ago
oke changed then tomorrow rewrite some css to make it look like a button
ἔρως
ἔρως6mo ago
it will be easier than you think
roelof
roelofOP6mo ago
We see I hope I can just re-use the css I have used for the button
ἔρως
ἔρως6mo ago
you can, just need to change the selectors
roelof
roelofOP6mo ago
I mean this one :
.filter-options button {
border-radius: 8px;
padding: 8px 16px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
margin-left: 0.5em;
border-radius: 20px;
border: 1px solid var(--neutral_300);
background-color: var(--background-color);
color: var(--filter-button-color);
box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.06) 0px 1px 2px 0px;
}
.filter-options button {
border-radius: 8px;
padding: 8px 16px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
margin-left: 0.5em;
border-radius: 20px;
border: 1px solid var(--neutral_300);
background-color: var(--background-color);
color: var(--filter-button-color);
box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.06) 0px 1px 2px 0px;
}
`
ἔρως
ἔρως6mo ago
you change the button to label
roelof
roelofOP6mo ago
and hide the radio thing with
.filter-options input[type="radio"] {
display: none ;
}
.filter-options input[type="radio"] {
display: none ;
}
and how do I get the checked one then /
ἔρως
ἔρως6mo ago
something close to that, but not quite
roelof
roelofOP6mo ago
input:where([type="radio"]) {
appereance: none
}
input:where([type="radio"]) {
appereance: none
}
ἔρως
ἔρως6mo ago
oh, for the input this is perfect sorry
roelof
roelofOP6mo ago
sorry for what ? So this is the good one :
.filter-options input[type="radio"] {
display: none ;
}
.filter-options input[type="radio"] {
display: none ;
}
? schould it not be apperenace: none like we did earlier ? Oke This css seems to work :

.filter-options input[type="radio"] {
appearance: none;
}



.filter-options label {
border-radius: 8px;
padding: 8px 16px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
margin-left: 0.5em;
border-radius: 20px;
border: 1px solid var(--neutral_300);
background-color: var(--background-color);
color: var(--filter-button-color);
box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.06) 0px 1px 2px 0px;
}


.filter-options input[type="radio"]:checked + label {
background-color: var(--red);
border: 1px solid var(--red_700);
color: var(--button-font-color);
}

.filter-options input[type="radio"] {
appearance: none;
}



.filter-options label {
border-radius: 8px;
padding: 8px 16px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
margin-left: 0.5em;
border-radius: 20px;
border: 1px solid var(--neutral_300);
background-color: var(--background-color);
color: var(--filter-button-color);
box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.06) 0px 1px 2px 0px;
}


.filter-options input[type="radio"]:checked + label {
background-color: var(--red);
border: 1px solid var(--red_700);
color: var(--button-font-color);
}
ἔρως
ἔρως6mo ago
appearence change show it looks like display changes how it is displayed
roelof
roelofOP6mo ago
The only thing I need to figure out is how to make this one as checked
<input type="radio" id="status-all" name="status" value="all" >
<label for="status-all">All</label>
<input type="radio" id="status-all" name="status" value="all" >
<label for="status-all">All</label>
ἔρως
ἔρως6mo ago
in this case, hidding is probably better
roelof
roelofOP6mo ago
so this one will be red when first looking at the site
Ganesh
Ganesh6mo ago
Checked attribute
ἔρως
ἔρως6mo ago
.filter-options input[type="radio"]:checked + label <-- like this no, that doesn't work, it has to be the pseudo-class the attribute isn't updated when you set it from js or when you change the value
Ganesh
Ganesh6mo ago
I'm not following. You mean if I put checked attribute on one of the radio inputs in a radio group. Clicking other radio inputs won't remove the checked attribute from that input?
ἔρως
ἔρως6mo ago
are you talking about css, js or html?
Ganesh
Ganesh6mo ago
Html. Role of was asking how can he mark the all radio input as initially selected wasn't he?
ἔρως
ἔρως6mo ago
ah, yes, just the checked attribute on the first one
Ganesh
Ganesh6mo ago
Also I just noticed it's roelof dammit Cool, great
roelof
roelofOP6mo ago
Everything works now well With this as html :
<div class="filter-options">

<input type="radio" id="status-all" name="status" value="all" checked>
<label for="status-all">All</label>

<input type="radio" id="status-active" name="status" value="active">
<label for="status-active">Active</label>

<input type="radio" id="status-not-active" name="status" value="not_active">
<label for="status-not-active">Inactive</label>

</div>
<div class="filter-options">

<input type="radio" id="status-all" name="status" value="all" checked>
<label for="status-all">All</label>

<input type="radio" id="status-active" name="status" value="active">
<label for="status-active">Active</label>

<input type="radio" id="status-not-active" name="status" value="not_active">
<label for="status-not-active">Inactive</label>

</div>
And this as css :
.filter-options input[type="radio"] {
appearance: none;
}



.filter-options label {
border-radius: 8px;
padding: 8px 16px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
margin-left: 0.5em;
border-radius: 20px;
border: 1px solid var(--neutral_300);
background-color: var(--background-color);
color: var(--filter-button-color);
box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.06) 0px 1px 2px 0px;
}


.filter-options input[type="radio"]:checked + label {
background-color: var(--red);
border: 1px solid var(--red_700);
color: var(--button-font-color);
}
.filter-options input[type="radio"] {
appearance: none;
}



.filter-options label {
border-radius: 8px;
padding: 8px 16px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
margin-left: 0.5em;
border-radius: 20px;
border: 1px solid var(--neutral_300);
background-color: var(--background-color);
color: var(--filter-button-color);
box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.06) 0px 1px 2px 0px;
}


.filter-options input[type="radio"]:checked + label {
background-color: var(--red);
border: 1px solid var(--red_700);
color: var(--button-font-color);
}
Ganesh
Ganesh6mo ago
Epic can you elaborate on this You mean depending on the device/browser it can look different?
ἔρως
ἔρως6mo ago
no, you tell it to render like a checkbox, a button or other controls https://developer.mozilla.org/en-US/docs/Web/CSS/appearance
Ganesh
Ganesh6mo ago
Isn't that considered a misfeature Mdn mentions that it isn't that right behaviour Or wait it says elements shown as widget was misfeature. So widget (radio) shown as another widget (button) isn't?
ἔρως
ἔρως6mo ago
yes, it is the way it is written is confusing as hell, not gonna lie but it is a misfeature
Ganesh
Ganesh6mo ago
What is the use for these values then? Are they just there for compatibility
ἔρως
ἔρως6mo ago
🤔 good question i just use none
Ganesh
Ganesh6mo ago
So why is hiding the radio input in this case better instead of appearance none?
ἔρως
ἔρως6mo ago
because you don't want it to show that's it
Ganesh
Ganesh6mo ago
Oh! I thought it would work since roleof said it looks right. Haven't used appearance myself so didn't consider how it does things
ἔρως
ἔρως6mo ago
try it: the link lets you mess with a button
Ganesh
Ganesh6mo ago
I will later. Currently on mobile right now
ἔρως
ἔρως6mo ago
that's fine it's possible to make it work with apearence: none but a display: none is more appropriate
roelof
roelofOP6mo ago
As far as i know display removes the radio thing so the css would bot work
ἔρως
ἔρως6mo ago
it would you can check and uncheck hidden inputs
Ganesh
Ganesh6mo ago
Would display none break tabbing onto the input. I forgot if labels were focusable by default if input gets hidden
roelof
roelofOP6mo ago
Exactly and you cannot check and uncheck a removed inputs
Ganesh
Ganesh6mo ago
You can with a click on the label associated with that input I'm just not sure if keyboard navigation still works Another thing to try later
ἔρως
ἔρως6mo ago
yes it will remove the input you can add a tabindex to it and it becomes focusable
Ganesh
Ganesh6mo ago
Gotcha
ἔρως
ἔρως6mo ago
not that it works, but it is focusable
Ganesh
Ganesh6mo ago
Welp. Visually hide the input then with width, height etc set to 0? Instead of display or visibility properties
ἔρως
ἔρως6mo ago
or make it take the entire space of the label
Ganesh
Ganesh6mo ago
You mean position label above it so it covers and hides the input?
ἔρως
ἔρως6mo ago
yup and the input stays visible and is focusable
Ganesh
Ganesh6mo ago
Nice
ἔρως
ἔρως6mo ago
but would probably be a good idea to put each inside a <div>
roelof
roelofOP6mo ago
But is my solution good or not?
ἔρως
ἔρως6mo ago
so far, looks like it
roelof
roelofOP6mo ago
Thanks
ἔρως
ἔρως6mo ago
i am too tired to think about the code
roelof
roelofOP6mo ago
Goto bed now @ἔρως Gn So I can filter the active one with
#status_all::checked ~ extension.where([input type="checkbox"):checked {}
#status_all::checked ~ extension.where([input type="checkbox"):checked {}
?
ἔρως
ἔρως6mo ago
close, very close
roelof
roelofOP6mo ago
tweede poging
#status_all::checked ~ extension.where([input type="checkbox"]):not(checked) {}
#status_all::checked ~ extension.where([input type="checkbox"]):not(checked) {}
`
ἔρως
ἔρως6mo ago
not quite there
roelof
roelofOP6mo ago
oops, things are going the wrong way
ἔρως
ἔρως6mo ago
first, for the "all" status you just need to do ... nothing and for the others, the code is pretty close it won't work, but it's close
roelof
roelofOP6mo ago
#status-active::checked ~ extension.where([input type="checkbox"]):not(checked) {}

#status-active::checked ~ extension.where([input type="checkbox"]):not(checked) {}

ἔρως
ἔρως6mo ago
close, but not yet
roelof
roelofOP6mo ago
I will sleep about it
ἔρως
ἔρως6mo ago
you will need to use :has
roelof
roelofOP6mo ago
Right now I looks more a guessing game
ἔρως
ἔρως6mo ago
and you're doing the same mistake you always do: - extensions is a class, not a tag, but you have a tag in the code - checked is a pseudo-class, but you're using it as a tag - .where is being used as a class, but it is a pseudo-class - ::checked isn't a valid pseudo-element just basic css errors it is a trial and error game
roelof
roelofOP6mo ago
#status-active:checked ~ .extension:where([input type="checkbox"]):not(:checked) {}
#status-active:checked ~ .extension:where([input type="checkbox"]):not(:checked) {}
and now really time for me to sleep GN
ἔρως
ἔρως6mo ago
not everything is fixed, but that's for tomorrow then goodnight
roelof
roelofOP6mo ago
oke, Fell out of bed today with the hot weather What is still wrong at my code ?
Ganesh
Ganesh6mo ago
Input inside attribute selector
roelof
roelofOP6mo ago
aha, old error then it would be :
#status-active:checked ~ .extension:where(input[type="checkbox"]):not(:checked) {
appearence : none // or
display: none
}
#status-active:checked ~ .extension:where(input[type="checkbox"]):not(:checked) {
appearence : none // or
display: none
}
still not working When I try it nothing changes on the site 😢
ἔρως
ἔρως6mo ago
remember i said something about :has()?
roelof
roelofOP6mo ago
yep so where has to become has ? still no luck

#status-active:checked ~ .extension:has(input[type="checkbox"]):not(:checked) {
display : none ;
}

#status-active:checked ~ .extension:has(input[type="checkbox"]):not(:checked) {
display : none ;
}
Still nothing changes 😢
ἔρως
ἔρως6mo ago
that's for multiple reasons, but the biggest one is that #status-active isn't above .extension
roelof
roelofOP6mo ago
you mean in the html or in the css ? in the css it is #status-active is on line 205 And extension on line 217 in the css and in the html Status is on line 51 and extension on line 61 So I do not understand what you mean
Zach Jensz
Zach Jensz6mo ago
3600 message thread still going?
roelof
roelofOP6mo ago
yep last bits that are the hardest
ἔρως
ἔρως6mo ago
in the html what's the common parent element for the inputs and the .extension cards?
roelof
roelofOP6mo ago
main
ἔρως
ἔρως6mo ago
that means that the radio buttons are on a different parent, right?
roelof
roelofOP6mo ago
yes, the radio buttons have a parent of filter-options and that has a parent of filter-container the switch has a parent of 'status and that has a parent of extension which has a parent of extensions and then both have then a parent main`
ἔρως
ἔρως6mo ago
so, in the main element, you need to check if it has the radio button checked then, you need to select the .extensions that have a checked or unchecked switch, based on the radio button you matched before
roelof
roelofOP6mo ago
oke There I have to think about
ἔρως
ἔρως6mo ago
you will have to use :has()
roelof
roelofOP6mo ago
so something like :
main.has(#status-active:checked) main.has(has(#extension.input[type="checkbox"]):not(:checked) {}
main.has(#status-active:checked) main.has(has(#extension.input[type="checkbox"]):not(:checked) {}
ἔρως
ἔρως6mo ago
close, but no :has is the correct syntax, but still wouldn't be correct as you can't nest :has()
roelof
roelofOP6mo ago
main:has(#status-active:checked) main:has(#extension.input[type="checkbox"]):not(:checked) {}
main:has(#status-active:checked) main:has(#extension.input[type="checkbox"]):not(:checked) {}
?
ἔρως
ἔρως6mo ago
remember this: - . <-- class - : <-- pseudo-class - :: <-- pseudo-element you're checking for main inside main
roelof
roelofOP6mo ago
😢 I have to think well then how to make the second part work I try to see that Im looking for the calss extension in the main
ἔρως
ἔρως6mo ago
yes, but you have an id in the :has as well, for some reason
roelof
roelofOP6mo ago
chips that needs to be a class but then still you said im looking for a main inside main can I delete then the second main ?
ἔρως
ἔρως6mo ago
you have to
roelof
roelofOP6mo ago
oke Then it would be :
main:has(#status-active:checked) :has(.extension.input[type="checkbox"]):not(:checked) {}
main:has(#status-active:checked) :has(.extension.input[type="checkbox"]):not(:checked) {}
?
ἔρως
ἔρως6mo ago
it's very close, but no
roelof
roelofOP6mo ago
😢
ἔρως
ἔρως6mo ago
you're checking if every single element has an element with the classes extension input and the attribute [type="checkbox"] and if that parent element isn't checked
roelof
roelofOP6mo ago
looks like the second has is not needed
ἔρως
ἔρως6mo ago
it is, it's just in the wrong place
roelof
roelofOP6mo ago
main:has(#status-active:checked) .extension:has(input[type="checkbox"]):not(:checked)) {}
main:has(#status-active:checked) .extension:has(input[type="checkbox"]):not(:checked)) {}
time for a late lunch
ἔρως
ἔρως6mo ago
very very very very close
roelof
roelofOP6mo ago
😢
ἔρως
ἔρως6mo ago
actually you did it just add a display: none and you're done oh, wait, you have a syntax error remove the ) before the :not
roelof
roelofOP6mo ago
still something wrong when I press the button , I do not see any cards at all found it It has to be this :
main:has(#status-active:checked) .extension:has(input[type="checkbox"]:not(:checked)) {
display: none;
}
main:has(#status-active:checked) .extension:has(input[type="checkbox"]:not(:checked)) {
display: none;
}
yep filering is working
main:has(#status-active:checked) .extension:has(input[type="checkbox"]:not(:checked)),
main:has(#status-not-active:checked) .extension:has(input[type="checkbox"]:checked)
{
display: none;
}
main:has(#status-active:checked) .extension:has(input[type="checkbox"]:not(:checked)),
main:has(#status-not-active:checked) .extension:has(input[type="checkbox"]:checked)
{
display: none;
}
one js problem to go change the status and store it on localstorage chips, I have given the card a id but not put the id on the localstorage So still I cannot filter things on localstorage
ἔρως
ἔρως6mo ago
when the switch changes, you have to store the new status on localstorage
roelof
roelofOP6mo ago
yes, seems a good way to make things persitent And im looking at this code to change
const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions || extensions === "null") {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
extensions = "";
}
} else {
try {
extensions = JSON.parse(extensions);
} catch (e) {
console.error('Error parsing extension data from localStorage:', e);
extensions = "";
}
}

return Array.isArray(extensions) ? extensions : [];
}
const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions || extensions === "null") {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
localStorage.setItem("extensionData", JSON.stringify(extensions));
} catch (error) {
console.error('Error fetching JSON:', error);
extensions = "";
}
} else {
try {
extensions = JSON.parse(extensions);
} catch (e) {
console.error('Error parsing extension data from localStorage:', e);
extensions = "";
}
}

return Array.isArray(extensions) ? extensions : [];
}
but I do not see where and how I can add a id Think I need to sleep about this No, right now I see no possiblity to add a id to my records in localstorage
ἔρως
ἔρως6mo ago
you can't change that to do what you need
roelof
roelofOP6mo ago
I was already afraid of that Then i have to see where i can do that Maybe a function for that
ἔρως
ἔρως6mo ago
you will need a new function, yes
roelof
roelofOP6mo ago
const giveIdToRecords(records) {
let id = 1 ;
for (record to records) {
record.id = id
++id
}
localstorage.setItem('extensionData', json.stringify(records);
return records;
}

const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions || extensions === "null") {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
giveIDToRecord(extensions);

} catch (error) {
console.error('Error fetching JSON:', error);
extensions = "";
}
} else {
try {
extensions = JSON.parse(extensions);
} catch (e) {
console.error('Error parsing extension data from localStorage:', e);
extensions = "";
}
}

return Array.isArray(extensions) ? extensions : [];
}
const giveIdToRecords(records) {
let id = 1 ;
for (record to records) {
record.id = id
++id
}
localstorage.setItem('extensionData', json.stringify(records);
return records;
}

const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions || extensions === "null") {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
giveIDToRecord(extensions);

} catch (error) {
console.error('Error fetching JSON:', error);
extensions = "";
}
} else {
try {
extensions = JSON.parse(extensions);
} catch (e) {
console.error('Error parsing extension data from localStorage:', e);
extensions = "";
}
}

return Array.isArray(extensions) ? extensions : [];
}
Something like this ?
ἔρως
ἔρως6mo ago
what's that function?
roelof
roelofOP6mo ago
I try to iterate throught the array and add a id to the record and then store it on localstorage 😦
ἔρως
ἔρως6mo ago
that doesn't make sense to be in a new function also, it's a bug: you're saving the data to local storage
roelof
roelofOP6mo ago
?? You said earlier I need to use a new function for making the id works
ἔρως
ἔρως6mo ago
no, i said you need a new function to save the state
roelof
roelofOP6mo ago
that is correct that I save the dat to the localstorage I use only the json file as there is no info in localstorage
ἔρως
ἔρως6mo ago
that's a bug, in that function
roelof
roelofOP6mo ago
How so saving the state You mean for saving if a card is active or not I was talking about adding a id to the data so that removing would be more easy I forget that the active or not schould also be stored or changed in localstorage but for that it would be handy if a entry in localstorage has a id , i think so still im trying to find out how I can add the id to localstorage where schould i then put the code to store on localstorage in the readExtensions function ?
ἔρως
ἔρως6mo ago
you save it in a different function
roelof
roelofOP6mo ago
Sorry i miss what you mean
ἔρως
ἔρως6mo ago
you save the state in a different function
roelof
roelofOP6mo ago
oke, I did that now in the ReadExtensions function
roelof
roelofOP6mo ago
GitHub
browser-extenstion/reading_data.js at main · RoelofWobben/browser-...
Contribute to RoelofWobben/browser-extenstion development by creating an account on GitHub.
roelof
roelofOP6mo ago
Sorry. But if I cannot make the id work then I also cannot make the changes to localstorage So I have to set this project on hold
Ganesh
Ganesh6mo ago
what isn't working?
roelof
roelofOP6mo ago
No idea how to make it work to add a id to the records in localstorage. And where to put the code to store in localstorage
Ganesh
Ganesh6mo ago
if I had to do it I would make your give id function only add id to the records then return the modified records. saveExtensions could be it's own function that takes records as argument and saves them in local storage I can't be totally sure of what epic was saying above but he was probably pointing out that you should not save to local storeage when the function is for giving ids to the object. It is making the function do multiple things
roelof
roelofOP6mo ago
oke, so if I understand you right , you mean like this :
const saveRecords(records) {
localstorage.setItem('extensionData', json.stringify(records);
}

const giveIdToRecords(records) {
let id = 1 ;
for (record to records) {
record.id = id
++id
}

return records;
}

const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions || extensions === "null") {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
let records = giveIDToRecord(extensions);
saveRecords(records);

} catch (error) {
console.error('Error fetching JSON:', error);
extensions = "";
}
} else {
try {
extensions = JSON.parse(extensions);
} catch (e) {
console.error('Error parsing extension data from localStorage:', e);
extensions = "";
}
}

return Array.isArray(extensions) ? extensions : [];
}
const saveRecords(records) {
localstorage.setItem('extensionData', json.stringify(records);
}

const giveIdToRecords(records) {
let id = 1 ;
for (record to records) {
record.id = id
++id
}

return records;
}

const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions || extensions === "null") {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
let records = giveIDToRecord(extensions);
saveRecords(records);

} catch (error) {
console.error('Error fetching JSON:', error);
extensions = "";
}
} else {
try {
extensions = JSON.parse(extensions);
} catch (e) {
console.error('Error parsing extension data from localStorage:', e);
extensions = "";
}
}

return Array.isArray(extensions) ? extensions : [];
}
out of my head and not tested @Ganesh
Ganesh
Ganesh6mo ago
I would name them saveExtensions etc as to be consistent but yes something like that
roelof
roelofOP6mo ago
@ἔρως are you happy with the new code ??
Ganesh
Ganesh6mo ago
there can be another solution but it depends on if you actually need to store extensions with id in local storage, or you only need id for tracking in the dom
roelof
roelofOP6mo ago
as far as I know I need to store the id on localstorage to know which records I have to change when the status is chancing or which record to remove from localstorage
Ganesh
Ganesh6mo ago
that should be what I would go with then
roelof
roelofOP6mo ago
You mean my last code?
ἔρως
ἔρως6mo ago
the saveRecords function has a syntax error
roelof
roelofOP6mo ago
I see it. I need a extra ) at the end , just before the ; @ἔρως am I now on the right track ??
vince
vince6mo ago
Why not try it and see if it works?
roelof
roelofOP6mo ago
of course I can but Epic says I have to put the saving on a new function and I wonder if IM now at a point he tries to teach me when I try the code and changes some bugs, it seems to work All records in Localstorage have now a field called id with a value code looks like this:
const saveRecords =(records) => {
localStorage.setItem('extensionData', JSON.stringify(records));
}

const giveIdToRecords = (records) => {
let id = 1;
for (const record of records) {
record.id = id;
++id;
}

return records;
}

const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions || extensions === "null") {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
let records = giveIdToRecords(extensions);
saveRecords(records);

} catch (error) {
console.error('Error fetching JSON:', error);
extensions = "";
}
} else {
try {
extensions = JSON.parse(extensions);
} catch (e) {
console.error('Error parsing extension data from localStorage:', e);
extensions = "";
}
}

return Array.isArray(extensions) ? extensions : [];
}
const saveRecords =(records) => {
localStorage.setItem('extensionData', JSON.stringify(records));
}

const giveIdToRecords = (records) => {
let id = 1;
for (const record of records) {
record.id = id;
++id;
}

return records;
}

const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions || extensions === "null") {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
extensions = await response.json(); // Parse JSON
let records = giveIdToRecords(extensions);
saveRecords(records);

} catch (error) {
console.error('Error fetching JSON:', error);
extensions = "";
}
} else {
try {
extensions = JSON.parse(extensions);
} catch (e) {
console.error('Error parsing extension data from localStorage:', e);
extensions = "";
}
}

return Array.isArray(extensions) ? extensions : [];
}
` I only have to find out what type records is now
roelof
roelofOP6mo ago
oke TS itself says this :
* @param {Extension[]} records
* @param {Extension[]} records
ἔρως
ἔρως6mo ago
how about you call it "extensions"? use descriptive names
roelof
roelofOP6mo ago
@ἔρως so I can make the code to change the status or remove records/cards ?
ἔρως
ἔρως6mo ago
yeah
roelof
roelofOP6mo ago
oke, name is changed next week the last few pieces and then finally done I think both are not very difficult but we will see
ἔρως
ἔρως6mo ago
no, they're not, but a bit annoying since you're dealing with localstorage
roelof
roelofOP6mo ago
yep I think it would be - reading from localstorage - changed what I want - store the data back in localstorage so I think I do both in the same new file
ἔρως
ἔρως6mo ago
that's basically it
roelof
roelofOP6mo ago
I wonder . Can I make a file where I put the write and read functions and use it on other files
ἔρως
ἔρως6mo ago
yeah, you can there's no reason for it but you can
roelof
roelofOP6mo ago
I had that idea because on two seperate files I use now the read and write thing Or I must place the status change one and the remove function on the read_data.js but then I have to look how I can take care that only when you press a button or change a switch this function is executed or is the change status as simple as :

.addEventListener('change', function() {}

.addEventListener('change', function() {}
and the press button like this :

.addEventListener("click", function() {}

.addEventListener("click", function() {}
ἔρως
ἔρως6mo ago
it's this
roelof
roelofOP6mo ago
oke, then I think I have this working without any problem And I understand why you want the read and store to be seperate functions I can now re-use them on both cases that I have to make
ἔρως
ἔρως6mo ago
you can make it return the data that's in storage, after you try to write to it
roelof
roelofOP6mo ago
yes, I can But why schould i read after a write?
ἔρως
ἔρως6mo ago
to make sure your local copy of everything is the same as what is in the local storage
roelof
roelofOP6mo ago
and it that not when I store the local copy everytime in localstorage then ?
ἔρως
ἔρως6mo ago
it's always a good idea to read it back in my opinion
roelof
roelofOP6mo ago
Wierd problem I have this code :
onst switchElements = document.querySelector("input[type='checkbox'][role='switch']");
if (!switchElements) {
console.error("No switch elements found in the document.");
return;
}
onst switchElements = document.querySelector("input[type='checkbox'][role='switch']");
if (!switchElements) {
console.error("No switch elements found in the document.");
return;
}
and this in my html :
<input type="checkbox" role="switch" />

<input type="checkbox" role="switch" />

why on earth do I get a message that no switch is found
ἔρως
ἔρως6mo ago
where is that code?
roelof
roelofOP6mo ago
the js code in the reading_data.js file The input on the html file github.com/RoelofWobben/browser-extenstion/blob/main/index.html#L66
ἔρως
ἔρως6mo ago
why is it in a different file?
roelof
roelofOP6mo ago
??
roelof
roelofOP6mo ago
GitHub
browser-extenstion/index.html at main · RoelofWobben/browser-exten...
Contribute to RoelofWobben/browser-extenstion development by creating an account on GitHub.
roelof
roelofOP6mo ago
and why on seperate files. We had that discussion earlier and I do it to keep track of what does what
ἔρως
ἔρως6mo ago
because it doesnt exist when the code runs you will have to listen to the change event on the .extensions element, and then try to find the parent .extension to do what you need to do or, do it in the same file, and you wont need to worry about this
roelof
roelofOP6mo ago
pfff and I thought this was was a easy one
ἔρως
ἔρως6mo ago
it is, if it is in the same file
Ganesh
Ganesh6mo ago
or if you import using modules.
roelof
roelofOP6mo ago
but the making of the divs and now making a evenlisterer is on the same file
roelof
roelofOP6mo ago
GitHub
browser-extenstion/reading_data.js at main · RoelofWobben/browser-...
Contribute to RoelofWobben/browser-extenstion development by creating an account on GitHub.
roelof
roelofOP6mo ago
GitHub
browser-extenstion/reading_data.js at main · RoelofWobben/browser-...
Contribute to RoelofWobben/browser-extenstion development by creating an account on GitHub.
ἔρως
ἔρως6mo ago
what's wrong with that?
roelof
roelofOP6mo ago
nothing if I may believe you but still the switch is not found
ἔρως
ἔρως6mo ago
it isnt found because it doesnt exist try adding a debugger statement before the return
roelof
roelofOP6mo ago
oke and how do I make it exists then looks like I can onky make this eventhandler if the rest is ready
ἔρως
ἔρως6mo ago
do as i said: - option 1 - same file - option 2 - add the change handler to .extensions and find the parent .extension inside the event handler - option 3 - add mutation observers to add the event to every single switch as they are added to the document ive sorted from easiest and most sensible to harder and more annoying
roelof
roelofOP6mo ago
Thanks, I will look what I can do oke DId another try but get stuck again I have this html :
<template id="extension-template">
<div class="extension">
<div class="content-extension">
<img src="" alt="" class="extension-icon" />
<div class="extension-info">
<h2></h2>
<p></p>
</div>
</div>
<div class="status">
<button class="remove-button">Remove</button>
<input type="checkbox" role="switch" />
</div>
</div>
</template>
<template id="extension-template">
<div class="extension">
<div class="content-extension">
<img src="" alt="" class="extension-icon" />
<div class="extension-info">
<h2></h2>
<p></p>
</div>
</div>
<div class="status">
<button class="remove-button">Remove</button>
<input type="checkbox" role="switch" />
</div>
</div>
</template>
and I use this js to fetch the button press :
const enableEventhandlers = () => {
// find removeButton
let removeButtons = document.querySelectorAll('.remove-button');
// add Eventlisteners
for (let i = 0; i < 11; i++) {
removeButtons[i].addEventListener("click", (e) => {
// search for data-id
// ???
});
}
}
const enableEventhandlers = () => {
// find removeButton
let removeButtons = document.querySelectorAll('.remove-button');
// add Eventlisteners
for (let i = 0; i < 11; i++) {
removeButtons[i].addEventListener("click", (e) => {
// search for data-id
// ???
});
}
}
But how do I find the parent of the button that has been pressed which hold the extension class ?
ἔρως
ἔρως6mo ago
when the button is clicked, you can do something like this:
const button = e.target;
const extension = button.closest('.extension');
const button = e.target;
const extension = button.closest('.extension');
the extension constant will be the parent .extension element https://developer.mozilla.org/en-US/docs/Web/API/Element/closest obviously, do proper type checking and all that
roelof
roelofOP6mo ago
then I see this error :
Property 'closest' does not exist on type 'EventTarget'.
Property 'closest' does not exist on type 'EventTarget'.
ἔρως
ἔρως6mo ago
because you are doing e.closest e is the event, not an element you need e.target
roelof
roelofOP6mo ago
no no This is the code so far:
const enableEventhandlers = () => {
// find removeButton
let removeButtons = document.querySelectorAll('.remove-button');
// add Eventlisteners
for (let i = 0; i < 11; i++) {
removeButtons[i].addEventListener("click", (e) => {

const button = e.target;
if (!button || !(button instanceof Element)) {
console.error("Button is null or not an Element.");
return;
}
const cardElement = button.closest('.extension');
if (!cardElement) {
console.error("Could not find closest .extension element.");
return;
}
const card_id = cardElement.getAttribute('data-id');
if (!card_id) {
console.error("data-id attribute not found on .extension element.");
return;
}

// read the data from localStorage
let extensions = localStorage.getItem("extensionData");

if (!extensions || extensions === "null") {
console.error("No extension data found in localStorage.");
}

//filter out the extension with the given id
extensions = JSON.parse(extensions);
extensions = extensions.filter(extension => extension.id !== parseInt(card_id));

// save the new data to localStorage
saveRecords(extensions);
})
}
}
const enableEventhandlers = () => {
// find removeButton
let removeButtons = document.querySelectorAll('.remove-button');
// add Eventlisteners
for (let i = 0; i < 11; i++) {
removeButtons[i].addEventListener("click", (e) => {

const button = e.target;
if (!button || !(button instanceof Element)) {
console.error("Button is null or not an Element.");
return;
}
const cardElement = button.closest('.extension');
if (!cardElement) {
console.error("Could not find closest .extension element.");
return;
}
const card_id = cardElement.getAttribute('data-id');
if (!card_id) {
console.error("data-id attribute not found on .extension element.");
return;
}

// read the data from localStorage
let extensions = localStorage.getItem("extensionData");

if (!extensions || extensions === "null") {
console.error("No extension data found in localStorage.");
}

//filter out the extension with the given id
extensions = JSON.parse(extensions);
extensions = extensions.filter(extension => extension.id !== parseInt(card_id));

// save the new data to localStorage
saveRecords(extensions);
})
}
}
on extensions ts is still not happy
ἔρως
ἔρως6mo ago
what does it say?
roelof
roelofOP6mo ago
Argument of type 'string | null' is not assignable to parameter of type 'string'.
Type 'null' is not assignable to type 'string'.
Argument of type 'string | null' is not assignable to parameter of type 'string'.
Type 'null' is not assignable to type 'string'.
ἔρως
ἔρως6mo ago
where? can you send a screenshot with the error?
roelof
roelofOP6mo ago
No description
ἔρως
ἔρως6mo ago
inside the if, a few lines above, you forgot a return
roelof
roelofOP6mo ago
thanks
roelof
roelofOP6mo ago
Another one :
No description
ἔρως
ἔρως6mo ago
you are mixing up types
roelof
roelofOP6mo ago
This better :
const enableEventhandlers = () => {
// find removeButton
let removeButtons = document.querySelectorAll('.remove-button');
// add Eventlisteners
for (let i = 0; i < 11; i++) {
removeButtons[i].addEventListener("click", (e) => {

const button = e.target;
if (!button || !(button instanceof Element)) {
console.error("Button is null or not an Element.");
return;
}
const cardElement = button.closest('.extension');
if (!cardElement) {
console.error("Could not find closest .extension element.");
return;
}
const card_id = cardElement.getAttribute('data-id');
if (!card_id) {
console.error("data-id attribute not found on .extension element.");
return;
}

// read the data from localStorage
let extensions = localStorage.getItem("extensionData");

if (!extensions || extensions === "null") {
console.error("No extension data found in localStorage.");
return;
}

//filter out the extension with the given id
const extensions_array = JSON.parse(extensions);
if (Array.isArray(extensions)) {

extensions = extensions_array.filter(extension => extension.id !== parseInt(card_id));
// save the new data to localStorage
saveRecords(extensions_array);
} else {
console.error("Parsed extensions is not an array.");
}
displayExtensions(extensions_array);
})
}
}
const enableEventhandlers = () => {
// find removeButton
let removeButtons = document.querySelectorAll('.remove-button');
// add Eventlisteners
for (let i = 0; i < 11; i++) {
removeButtons[i].addEventListener("click", (e) => {

const button = e.target;
if (!button || !(button instanceof Element)) {
console.error("Button is null or not an Element.");
return;
}
const cardElement = button.closest('.extension');
if (!cardElement) {
console.error("Could not find closest .extension element.");
return;
}
const card_id = cardElement.getAttribute('data-id');
if (!card_id) {
console.error("data-id attribute not found on .extension element.");
return;
}

// read the data from localStorage
let extensions = localStorage.getItem("extensionData");

if (!extensions || extensions === "null") {
console.error("No extension data found in localStorage.");
return;
}

//filter out the extension with the given id
const extensions_array = JSON.parse(extensions);
if (Array.isArray(extensions)) {

extensions = extensions_array.filter(extension => extension.id !== parseInt(card_id));
// save the new data to localStorage
saveRecords(extensions_array);
} else {
console.error("Parsed extensions is not an array.");
}
displayExtensions(extensions_array);
})
}
}
ἔρως
ἔρως6mo ago
almost you have some bugs there you are checking if extensions is an array - it will never be
roelof
roelofOP6mo ago
Chips I hate bugs IRL
ἔρως
ἔρως6mo ago
you are assigning the filtered extensions_array to extensions but then you are passing the extensions variable to saveRecords
roelof
roelofOP6mo ago
I take a break. This one is still confusing to solve and what is then the good type here :
if (Array.isArray(extensions_array)) {
if (Array.isArray(extensions_array)) {
ἔρως
ἔρως6mo ago
Extensions[]
roelof
roelofOP6mo ago
dank je Thanks Then I have to think how to change that line
ἔρως
ἔρως6mo ago
you dont why would you need?
roelof
roelofOP6mo ago
because you said this :
you are checking if extensions is an array - it will never be
you are checking if extensions is an array - it will never be
ἔρως
ἔρως6mo ago
that's the extensions variable, not extensions_array i said that so you use the correct variable
roelof
roelofOP6mo ago
oke this better :
const enableEventhandlers = () => {
// find removeButton
let removeButtons = document.querySelectorAll('.remove-button');
// add Eventlisteners
for (let i = 0; i < 11; i++) {
removeButtons[i].addEventListener("click", async (e) => {

const button = e.target;
if (!button || !(button instanceof Element)) {
console.error("Button is null or not an Element.");
return;
}
const cardElement = button.closest('.extension');
if (!cardElement) {
console.error("Could not find closest .extension element.");
return;
}
const card_id = cardElement.getAttribute('data-id');
if (!card_id) {
console.error("data-id attribute not found on .extension element.");
return;
}

// read the data from localStorage
let extensions = localStorage.getItem("extensionData");

if (!extensions || extensions === "null") {
console.error("No extension data found in localStorage.");
return;
}

//filter out the extension with the given id
const extensions_array = JSON.parse(extensions);
if (Array.isArray(extensions_array)) {

const filteredExtensions = extensions_array.filter(extension => extension.id !== parseInt(card_id));
// save the new data to localStorage
saveRecords(filteredExtensions);
} else {
console.error("Parsed extensions is not an array.");
}
const extensions_new = await getExtensions();
displayExtensions(extensions_new)
})
}
}

// Fetch and display extensions
const extensions = await getExtensions();
displayExtensions(extensions);
enableEventhandlers();
const enableEventhandlers = () => {
// find removeButton
let removeButtons = document.querySelectorAll('.remove-button');
// add Eventlisteners
for (let i = 0; i < 11; i++) {
removeButtons[i].addEventListener("click", async (e) => {

const button = e.target;
if (!button || !(button instanceof Element)) {
console.error("Button is null or not an Element.");
return;
}
const cardElement = button.closest('.extension');
if (!cardElement) {
console.error("Could not find closest .extension element.");
return;
}
const card_id = cardElement.getAttribute('data-id');
if (!card_id) {
console.error("data-id attribute not found on .extension element.");
return;
}

// read the data from localStorage
let extensions = localStorage.getItem("extensionData");

if (!extensions || extensions === "null") {
console.error("No extension data found in localStorage.");
return;
}

//filter out the extension with the given id
const extensions_array = JSON.parse(extensions);
if (Array.isArray(extensions_array)) {

const filteredExtensions = extensions_array.filter(extension => extension.id !== parseInt(card_id));
// save the new data to localStorage
saveRecords(filteredExtensions);
} else {
console.error("Parsed extensions is not an array.");
}
const extensions_new = await getExtensions();
displayExtensions(extensions_new)
})
}
}

// Fetch and display extensions
const extensions = await getExtensions();
displayExtensions(extensions);
enableEventhandlers();
ἔρως
ἔρως6mo ago
does it work?
roelof
roelofOP6mo ago
it deletes the card from localstorage but it is stil seen at the website , I was hoping the page would change so there is somewhere a bug 😦
ἔρως
ἔρως6mo ago
do you remove the element?
roelof
roelofOP6mo ago
no, im filtering it out so filteredExtensions contains all cards except the one I want to remove And that part works well The only thing that does not work is that the page does not refresh to show the filtered ones except all @ἔρως @vince any idea how to solve this ?
ἔρως
ἔρως6mo ago
you have to remove the element from the dom
roelof
roelofOP6mo ago
oke, have to think how to do that
ἔρως
ἔρως6mo ago
alright
roelof
roelofOP6mo ago
is this a good way to remove the card :
document.querySelector(`.extension[data-id='${card_id}']`)?.remove();
document.querySelector(`.extension[data-id='${card_id}']`)?.remove();
then one thing to do. Make almost the same code for storing the value of the switch and then finally done 🙂
ἔρως
ἔρως6mo ago
no, you have to remove the parent wait, you have to remove from the parent you have a bug
roelof
roelofOP6mo ago
😦 where ? When i test it , it seems to work as expected
ἔρως
ἔρως6mo ago
you are looping the buttons to add the event listeners but you are looping from 0 to 11 when you delete one, there wont be 12 buttons so, you will try to do things with indexes that dont exist
roelof
roelofOP6mo ago
chips, yeah I know , I hardcoded 11 to make sure things were working
ἔρως
ἔρως6mo ago
yup, and that is bad just use a forEach
roelof
roelofOP6mo ago
I have to look what variable I have to use A foreach could I work also, I think I have to rewrite some indexes then
ἔρως
ἔρως6mo ago
you wont have to do a ton of work
roelof
roelofOP6mo ago
i know first a late dinner for Dutch '"rules" Just back from my daugthers sport
ἔρως
ἔρως6mo ago
alright
roelof
roelofOP6mo ago
Can someone help me why localstorage is not updated for the switch
const enableEventhandlersSwitch = () => {
// find all switches
let switches = document.querySelectorAll('.extension input[type="checkbox"][role="switch"]');

// add Eventlisteners
switches.forEach(element => {
element.addEventListener("change", async (e) => {
const checkbox = e.target;
if (!checkbox || !(checkbox instanceof HTMLInputElement)) {
console.error("Checkbox is null or not an HTMLInputElement.");
return;
}
const cardElement = checkbox.closest('.extension');
if (!cardElement) {
console.error("Could not find closest .extension element.");
return;
}
const card_id = cardElement.getAttribute('data-id');
if (!card_id) {
console.error("data-id attribute not found on .extension element.");
return;
}

// read the data from localStorage
let extensions = localStorage.getItem("extensionData");
if (!extensions || extensions === "null") {
console.error("No extension data found in localStorage.");
return;
}

// parse the data and update the isActive property
const extensions_array = JSON.parse(extensions);
if (Array.isArray(extensions_array)) {
const extensionToUpdate = extensions_array.find(extension => extension.id === parseInt(card_id));
if (extensionToUpdate) {
extensionToUpdate.isActive = checkbox.checked; // Update isActive property
saveRecords(extensions_array); // Save updated records
} else {
console.error(`Extension with id ${card_id} not found.`);
}
} else {
console.error("Parsed extensions is not an array.");
}
});
});
};

const enableEventhandlersSwitch = () => {
// find all switches
let switches = document.querySelectorAll('.extension input[type="checkbox"][role="switch"]');

// add Eventlisteners
switches.forEach(element => {
element.addEventListener("change", async (e) => {
const checkbox = e.target;
if (!checkbox || !(checkbox instanceof HTMLInputElement)) {
console.error("Checkbox is null or not an HTMLInputElement.");
return;
}
const cardElement = checkbox.closest('.extension');
if (!cardElement) {
console.error("Could not find closest .extension element.");
return;
}
const card_id = cardElement.getAttribute('data-id');
if (!card_id) {
console.error("data-id attribute not found on .extension element.");
return;
}

// read the data from localStorage
let extensions = localStorage.getItem("extensionData");
if (!extensions || extensions === "null") {
console.error("No extension data found in localStorage.");
return;
}

// parse the data and update the isActive property
const extensions_array = JSON.parse(extensions);
if (Array.isArray(extensions_array)) {
const extensionToUpdate = extensions_array.find(extension => extension.id === parseInt(card_id));
if (extensionToUpdate) {
extensionToUpdate.isActive = checkbox.checked; // Update isActive property
saveRecords(extensions_array); // Save updated records
} else {
console.error(`Extension with id ${card_id} not found.`);
}
} else {
console.error("Parsed extensions is not an array.");
}
});
});
};

ἔρως
ἔρως6mo ago
that code doesn't do anything, unless you run the function
roelof
roelofOP6mo ago
I know that I run in from here :
const extensions = await getExtensions();
displayExtensions(extensions);
enableEventhandlersRemoveButtons();
enableEventhandlersSwitch();
const extensions = await getExtensions();
displayExtensions(extensions);
enableEventhandlersRemoveButtons();
enableEventhandlersSwitch();
ἔρως
ἔρως6mo ago
is displayExtensions async?
roelof
roelofOP6mo ago
that function is not async
roelof
roelofOP6mo ago
this is the whole file :
ἔρως
ἔρως6mo ago
add a debugger statement after the query selector
roelof
roelofOP6mo ago
oke, there are 9 switches found and that is correct as far as I can see
ἔρως
ἔρως6mo ago
what does the debugger says?
roelof
roelofOP6mo ago
this :
No description
roelof
roelofOP6mo ago
aha, Found a error message :
Extension with id 1 not found.
Extension with id 1 not found.
roelof
roelofOP6mo ago
I see the problem :
No description
roelof
roelofOP6mo ago
as soon as I delete some cards the id is not the same anymore then the data-id 😦 this function is causing this :
const giveIdToRecords = (extensions) => {
let id = 1;
for (const extension of extensions) {
extension.id = id;
++id;
}
return extensions;
};
const giveIdToRecords = (extensions) => {
let id = 1;
for (const extension of extensions) {
extension.id = id;
++id;
}
return extensions;
};
This works fine when reading a new file but fails when we read from localstorage where cards has already a id or this line in display
let id = 0;
let id = 0;
ἔρως
ἔρως6mo ago
that function shouldn't exist, and the code should be part of reading from the json file
roelof
roelofOP6mo ago
Oke, I made it so I could add a data-id to a card
ἔρως
ἔρως6mo ago
you're setting the id to a number wait, no, that's the id of the data from the json file
roelof
roelofOP6mo ago
Yep And i set it to the data-id Schould i not see that data-id to the id of the card
ἔρως
ἔρως6mo ago
i didn't say that ^ this is what i said
roelof
roelofOP6mo ago
I know
ἔρως
ἔρως6mo ago
then why the question?
roelof
roelofOP6mo ago
Because then I cannot see how to add the id to the items in localstorage if I deleted that code and the call to it
ἔρως
ἔρως6mo ago
you add it when reading the data from the json file
roelof
roelofOP6mo ago
oke, then I have to think how I do that
ἔρως
ἔρως6mo ago
exactly as i said
roelof
roelofOP6mo ago
but I do not see where . I have used that function , you told me to delete in the read function who looks like this ;
const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions || extensions === "null") {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
const json = await response.json(); // Parse JSON
saveRecords(json); // Save to localStorage
} catch (error) {
console.error('Error fetching JSON:', error);
extensions = "";
}
} else {
try {
extensions = JSON.parse(extensions);
} catch (e) {
console.error('Error parsing extension data from localStorage:', e);
extensions = "";
}
}
return Array.isArray(extensions) ? extensions : [];
};
const getExtensions = async () => {
let extensions = localStorage.getItem("extensionData");
if (!extensions || extensions === "null") {
// read from file
try {
const response = await fetch('data.json'); // Fetch JSON file
const json = await response.json(); // Parse JSON
saveRecords(json); // Save to localStorage
} catch (error) {
console.error('Error fetching JSON:', error);
extensions = "";
}
} else {
try {
extensions = JSON.parse(extensions);
} catch (e) {
console.error('Error parsing extension data from localStorage:', e);
extensions = "";
}
}
return Array.isArray(extensions) ? extensions : [];
};
ἔρως
ἔρως6mo ago
before you run saveRecords put the code there
roelof
roelofOP6mo ago
?? Then it will be the same as I had
ἔρως
ἔρως6mo ago
yes, like how it was meant to be
roelof
roelofOP6mo ago
Sorry, now in very very confused first you said that the code needs to be deleted and now you are saying that it needs to be pulled back ?
ἔρως
ἔρως6mo ago
i said the function shouldnt exist and the code should be in that place
roelof
roelofOP6mo ago
oke then I misunderstood you but then still the problem that the id can be different I think
ἔρως
ἔρως6mo ago
that wont matter
roelof
roelofOP6mo ago
Oke we see Wirh the old code the switch code would not work because the data id was not the same as the id on localstorage
vince
vince6mo ago
I still don't know why we couldn't just add the IDs to the json
ἔρως
ἔρως6mo ago
that is what i said, but from the code aide aide side read the json, loop, add id, move along it should work now, since you deleted the function
roelof
roelofOP6mo ago
Can you let me see what you mean?
ἔρως
ἔρως6mo ago
since this function doesn't exist anymore, and the code is where it should be, there's no problem with the ids
roelof
roelofOP6mo ago
Which code are we talking about? IM still try to figure out what to put there exactly
ἔρως
ἔρως6mo ago
the code there
roelof
roelofOP5mo ago
What is then wrong with calling a function that does the same ?
ἔρως
ἔρως5mo ago
it's a bug because you are calling the function where you shouldnt you are not supposed to re-do the ids
roelof
roelofOP5mo ago
oke, so no id in the display function
ἔρως
ἔρως5mo ago
that is not what i said i said to do not re-calculate the ids
Ganesh
Ganesh5mo ago
I think epic is saying to put the code for giving id inline in the try block
try {
const response = await fetch('data.json'); // Fetch JSON file
const json = await response.json(); // Parse JSON

// put the code for giving id to the extensions inline like this
let id = 1;
const extensions = json.map((extension) => {
const extensionWithId = {...extension, id};
id++;
return extensionWithId;

})

saveRecords(extensions); // Save to localStorage
}
try {
const response = await fetch('data.json'); // Fetch JSON file
const json = await response.json(); // Parse JSON

// put the code for giving id to the extensions inline like this
let id = 1;
const extensions = json.map((extension) => {
const extensionWithId = {...extension, id};
id++;
return extensionWithId;

})

saveRecords(extensions); // Save to localStorage
}
because we only give the id to the extensions data when we fetch them. We don't need a function as we will not be reusing this piece of code anywhere else the extensions saved to local storage already have id property on them so we won't need to reassign ids
ἔρως
ἔρως5mo ago
exactly
roelof
roelofOP5mo ago
oke, but I use also a id to give the cards a id Or must I gave it then the id of the item ?
vince
vince5mo ago
@roelof by doing it this way, you can just read from localStorage and each extension in the extensions Array will have it's id associated with it
// example data to show you what it (probably?) looks like
const extensions = [
{
"name": "extension-1",
"id": 1,
},
{ ... },
...
]
// example data to show you what it (probably?) looks like
const extensions = [
{
"name": "extension-1",
"id": 1,
},
{ ... },
...
]
Unless I read that code wrong
roelof
roelofOP5mo ago
I know
vince
vince5mo ago
I don't understand this then
roelof
roelofOP5mo ago
In my displayExtensions i now have this;
id++;
card.setAttribute('data-id', id.toString());
id++;
card.setAttribute('data-id', id.toString());
schould I also change the id part to use the id that I assign during the read
vince
vince5mo ago
You wouldn't need that since you can iterate over extensions[] and use the id provided Yes
roelof
roelofOP5mo ago
oke, now finally things are clear to me
vince
vince5mo ago
I don't know how you have your code setup though You just have one card -- where do you iterate over the html cards to assign the ids to them const cards = document.querySelectorAll('.card')? Or are you using template like Epic suggested (I think?)
roelof
roelofOP5mo ago
I hope then that the id of localstorage will be the same as the card data-id Now they can be different when you delete cards and that messed up the switch Change function
vince
vince5mo ago
I'm not really sure what the best approach to match the id of the localStorage to the cards
roelof
roelofOP5mo ago
GitHub
browser-extenstion/reading_data.js at main · RoelofWobben/browser-...
Contribute to RoelofWobben/browser-extenstion development by creating an account on GitHub.
vince
vince5mo ago
Oh okay cool I never used templates I was going to suggest something like
extensions.forEach((extension) => {
const card = document.createElement('article');
card.setAttribute('data-id', extension.id);
});
extensions.forEach((extension) => {
const card = document.createElement('article');
card.setAttribute('data-id', extension.id);
});
Maybe you can do something similar with templates? Not really sure, maybe Epic or Ganesh have better ideas
roelof
roelofOP5mo ago
Thanks, that is what I already thought I can change my code to reflect that and look if things are now working fine
ἔρως
ἔρως5mo ago
you can do exactly the same, you just need to find the element that is all
roelof
roelofOP5mo ago
@ἔρως @vince thanks Evrything seems to work I cannot find anything wrong So ship it ?
ἔρως
ἔρως5mo ago
ship it
roelof
roelofOP5mo ago
https://roelofwobben.github.io/browser-extenstion/ @ἔρως oke, I thought it was needed you look at the site and/or the code
ἔρως
ἔρως5mo ago
if it works, it works sometimes, it's more important to get it to work than to write the cleanest pristinest code
roelof
roelofOP5mo ago
oke, then I will submit it and see if I get feedback
ἔρως
ἔρως5mo ago
i would hold off i am too tired to check it today
roelof
roelofOP5mo ago
oke but I already submitted it on FEM sorry
ἔρως
ἔρως5mo ago
don't be sorry are you sure there was nothing missing?
roelof
roelofOP5mo ago
im farily sure
ἔρως
ἔρως5mo ago
then it's done
roelof
roelofOP5mo ago
- theme can be changed you can remove items you can change the status of a card but if you see some points to improve someday , just say it
ἔρως
ἔρως5mo ago
i will save it for another time im too tired
roelof
roelofOP5mo ago
I will take a break and do the next one on Monday https://www.frontendmentor.io/challenges/social-links-profile-UG32l9m6dQ
Frontend Mentor
Frontend Mentor | Social links profile coding challenge
In this small project, you'll build out your social link-sharing profile. You can even personalize it and use it to share all your social profiles!
roelof
roelofOP5mo ago
I know I already say someday
ἔρως
ἔρως5mo ago
you should be able to do it in a lot less time
roelof
roelofOP5mo ago
yep, I hope 1 a 2 mornings and when I finisch that one , I will look with you or @vince what will be the challenge after that there are I think some 60 free challenges and I have done now 3 , so choice enough Am i still a good junior or am I downgrade to amateur 😛 GN
ἔρως
ἔρως5mo ago
you picked a challenge that was too much for you, because it was presented as a lower difficulty than it was i can't judge your performance based on that
roelof
roelofOP5mo ago
we see how the rest goes
ἔρως
ἔρως5mo ago
it's a much simpler challenge
roelof
roelofOP5mo ago
I know
i_lost_to_loba_kreygasm
holy fuck , 4k comments
roelof
roelofOP5mo ago
yep, was a very diffcult challenge 🙂 Is there a way I can close this one ??
ἔρως
ἔρως5mo ago
just edit the post and add the "solved" tag
roelof
roelofOP5mo ago
GM , just im time

Did you find this page helpful?