Frontend dev brushing up on frontend skills! Thanks for checking out my work, and please feel free to let me know if anything is not working as it should, especially the older projects. No browser extensions or Figma files are used in these projects, just my eyes 🙂
Latest solutions
Responsive news homepage with mobile nav and accessibility design
#accessibilitySubmitted over 1 year agoResponsive image slider/carousel built with SCSS and plain JS
#accessibility#sass/scssSubmitted almost 3 years ago
Latest comments
- @dboca93@elaineleung
Hey Dilhan, excellent job here, and it makes me want to go back and clean up some of my old code for this challenge!
The semantic HTML looks pretty clean to me :) In terms of suggestions, one I could think of would probably be just to add a
header
tag even though it can be optional, but it would be nice to have since you got amain
tag with anh1
in there, and I might put thath1
underheader
instead. (By the way, what you did with theh1
was also something I did for a lot of these component challenges... I think that's a good idea too!)One other thing I saw (which was also something I did in my own solution) was putting the stats in
p
tags. If I could do that differently now, I would have the stats as anul
list instead, as that might be easier to pick out for users with a screenreader.Once again, great work!!
Marked as helpful - @dhan5a@elaineleung
Hi Dhanya, first off, I think you did a great job putting this together! About the custom variables not working, it looks like there's a trailing curly brace in line 3 of your CSS file, and I think if you try to remove that, you'd be able to use the variables (I tried it in the browser just now using your code).
Some suggestions I have here: I'd remove the
width: 50%
from the body selector, and if you're hoping to put some space on the sides to prevent the component from touching the browser sides, instead of havingmax-width: 300px
on.card
, you can trywidth: min(90%, 300px)
. This declaration tells the browser to keep the width at 90% until it gets to 300px, at which point the width would be maintained at 300px as the max width.Lastly, about using fixed pixel values in font sizes: It's generally good practice to use relative units (such as rem), so that's something I encourage you to try as well (by default, 1 rem is 16px). One of the main reasons is because relative units allow users to have their own preferred browser/system settings and won't be locked into using fixed sizes in the code.
(Oh, and be sure to fix add alt tags in your
img
elements, otherwise these would show up in your report for sure)Hope this helps you out!
Marked as helpful - @Dytoma@elaineleung
Hi Dytoma, this looks like a great start, and I think your code works fine. I do suggest giving your classes and variables more meaning names, where instead of
const rating = document.querySelectorAll(".nbr");
... you can try something like this:
const ratingBtns = document.querySelectorAll(".rating"); // note that Btns stand for buttons since there is more than 1 button here!
For the
for
loop, I suggest usingclassList
instead ofclassName
so that you can easily add or remove a class instead of changing theclassName
attribute directly. I also don't thinkselected
needsquerySelectorAll
since there's only one button being selected. You can try this:for(let i = 0; i < rating.length; i++) { rating[i].addEventListener("click", function() { let selected = document.querySelector(".selected"); selected.classList.remove("selected") this.classList.add("selected"); }); }
Lastly, instead of having a default score of 1, I would just leave it empty and let the user choose. Sometimes users might accidentally click on the submit before they select the score, and you wouldn't want them to accidentally send a score of 1! Hope this helps you out a bit 🙂
- @trunglam7@elaineleung
Hi Trung, I think this looks quite well put together! If there's one thing I'd change, I would use a class to change the style of the selected button instead of using the
:focus
pseudo class, seeing that focus is meant to used for showing which element the user had last interacted with. If you accidentally click on something else like the background or the text, the selected button would go back to its unselected color because it has lost the focus, and that would make it seem like no button got selected, even though in the background JS is still keeping track which button got selected. I would just create a new class calledselected
, style the selected button with that class, and then use JS to add/remove the class as needed. Hope this helps you out a bit!Marked as helpful - @Owura-56@elaineleung
Hi Agyemang, good job putting this together! For the triangle with the
::after
pseudo element, instead of having justborder: solid transparent
, try specifying the sides, like this:.grid-item-3::after { top: 98%; right: 0; // remove left border-left: solid transparent; border-top: solid white; // rest of your code }
Also, change the border-radius in
.grid-item-3
toborder-radius: 8px 8px 0 8px;
, which should give you that sharp corner instead of a rounded one.With the media query, I'd choose a much higher breakpoint since right now when the layout changes, the sides are cut off. Also, there appears to be some overflow going on, and I think it may have to do with the large margins you're using (such as in
.grid-item-3
) to do positioning. I would actually suggest not having.grid-item-3
as a grid element but to have that as a child of.grid-item-2
instead, and I'd useposition: absolute
instead of using things likemargin-left: 21rem
, which is what I think is causing things to be pushed off to the right side of the screen.Hope this helps you out!
- @jodyvanhoose@elaineleung
Hi Jody, first off, great job in getting your solution to look very close to the design! 🙂 I think you did many things well; for instance, I like how readable and well-annotated your code is. There are just a few things I noticed in the area of responsive design that you can check out:
Breakpoint: The breakpoint is quite large, and you'll notice that the photo in the mobile view gets pixelated past its width of 686px, plus having the mobile view at such a wide width is not very optimal for this card component, as the photo would be gigantic while the lines of text and CTA button gets stretched. What I suggest is to use a smaller breakpoint: to find ideal point, simply see how wide the desktop view is meant to be and use that as a starting point. From what I recall, the design's desktop width should be about 600px.
Image distortion: The image at the desktop view is getting distorted, meaning that the original aspect ratio is being changed. To make sure the image doesn't get stretched or squished, add a
object-fit: cover
to the image class.Component width: Aside from changing the breakpoint, one other thing you can try is to ensure the mobile view card width doesn't get too wide. To do that, instead of just having
width: 93%
, trywidth: min(93%, 400px);
which tells the browser to keep the width at 93% if the width is smaller than 400px (you can use any value here you wish). Likewise, for the desktop view, trywidth: min(93%, 600px);
instead ofwidth: 35%
. Once you do that, you may find that thewidth
property for your desktop image doesn't have to be 25%; in fact, it can be 100% or 50% and still be the same width because you haveflex: 1
as a declaration, and you also have awidth: 50%
for your description container.Hope this can help you out!
Marked as helpful