How much do you break your code into smaller files/components? Is it worth to bother with too many components on this level of complexity? Reviews of my solution and code are greatly appreciated. Thx
Ren Ras
@renrasAll comments
- @JT1974Submitted over 2 years ago@renrasPosted over 2 years ago
I usually break the page down into components when the code gets too long as it's easier for me to manage. Usually my jsx has like a maximum 100 lines of code. But only the ui elements and others that will be re-used will be stored in the
components
folder. The other page components I just store it in a page folder likepages/home
so that you wouldn't have to deal with a lot of unnecessary components in thecomponents
folderMarked as helpful1 - @PaliTriesToDesignSubmitted over 2 years ago
I learned a lot building this project!
If you look closely to the triangle in the mobile menu you can see that it is not perfectly aligned to the right border. Any suggestions?
Also, what JS animations could I use for a web page like this one?
Thanks!
@renrasPosted over 2 years agoI was able to recreate what you were trying to do in this codepen: https://codepen.io/renras/pen/bGaZPJx,
Or you could just put them in a parent container and do
display: flex
instead of using the::after
approach.Marked as helpful1 - @muyiwa99Submitted over 2 years ago
One of my image gallery layouts seem to display a gap for the mobile section when testing on chrome, but not on Firefox. Any tips on this would be greatly appreciated.
@renrasPosted over 2 years ago- avoid setting fixed
width
for containers - try to use
max-width
,min-width
and percentages instead - try to make your flexbox and grid layouts responsive like :
.flex { display: flex; flex-wrap: wrap; .flex-children { flex: 1 1 0; } } .grid { grid-template-columns: repeat(4, auto); }
Marked as helpful0 - avoid setting fixed
- @misiucodesSubmitted over 2 years ago
Hi FEM community,
Who thought what looks like a simple landing page could be so difficult! Some of the areas I struggled with that I would love advice/words of wisdom on are:
- I coded this using React - any advice on how to structure my files/best practices for this would be great as I continue learning
- Are there any rule of thumbs for when to use flexbox vs. grid?
- When it came to making this design mobile-responsive, I really struggled and had to make a lot of media queries. How could I have structured my code better so that I only need to do minimal media queries?
- What's the best way to have coded the underline styling for the "learn more" buttons so that no matter what screen size, it remains responsive?
- Not sure about the code for my drop down menu - how can I make it ease out more smoothly when a user exits the drop-down menu?
Thanks all,
newbie coder
@renrasPosted over 2 years agoTry wrapping your
nav
inside adiv
and apply the positioning on that instead and addoverflow: hidden
on thenav
;<main style={{position: relative}}> <div style={{position: absolute}}> <nav style={{overflow: hidden}}></nav> </div> </main>
I successfully recreated the animation you're trying implement here in this codepen: https://codepen.io/renras/pen/XWVooXg
0 - @rawatdevSubmitted over 2 years ago
When I resize my window from large to small, then its navbar goes from desktop position to mobile position above the screen, which i don't want to see while resizing otherwise its working fine. How to solve this issue ?
@renrasPosted over 2 years agoYou can make a separate
nav
for mobile and desktop and make use ofdisplay: none
. This will reduce complexities in your layout. Otherwise, make yourtransition
more specific by targeting only the property you want animated.1 - @HolymarzSubmitted over 2 years ago
The footer links (facebook, instagram etc) could not highlight when hovering, I'm guessing because it's an image, any advice on how to highlight an image?
For the menu I wasn't sure on how to get that pointing like corner on the upper right corner, so I just settle with a regular box, any tips on how I can make that?
@renrasPosted over 2 years agoYou can put your icons in a container like a button and put a hover effect on that container instead. It's also fine if icons don't have a hover effect, most sites are like that.
Regarding your question about the the menu, the easy way would be making a triangular div and place it above your menu. Here's a useful link: https://css-tricks.com/snippets/css/css-triangle/
I believe you can also make use of
clip-path
. It's more complex than the first option but actually worth learning as it provides more flexibility and is often used in complex layouts.https://developer.mozilla.org/en-US/docs/Web/CSS/clip-pathMarked as helpful0 - @GloriaSekyereSubmitted over 2 years ago
I found this one exciting! This is my first advanced project. I struggled with styling the Filter by region select input so I have left it for now. Here are some additional features I added:
- A back to top button when the user scrolls a bit further below
- Show more button so not all the countries are displayed at one
- Persistent light/dark mode
- Fully responsive on all screen sizes
I am still a beginner in React and jumped a lot of challenges to this one so any feedback on the code and practices are welcome.
Also, can someone explain to me when to use useHistory and when to use <Link /> in routing?
Thank you!
@renrasPosted over 2 years agoLink
doesn't trigger a full page refresh compared to using ana tag
which would reset the application state. Normally, you'd always want to useLink
for navigating throughout different pages in your application. I believeuseHistory
is used for programmatically redirecting users to a different page where you can't useLink
. Like inside a code block:const history = useHistory(); const register = async () => { await register(user).then((username) => { history.push(`/profile/${userName}`); }) }
Marked as helpful1 - @murytarlahSubmitted over 2 years ago
I had a bit of difficulty with the filtering section but thanks to stack-overflow, I was able to find a solution Question: I re-render the countries grid view every time a key is pressed in the search input button looping through 250 each time. I feel this is bad practice but can't think of a better way to go through this, any help would be appreciated
@renrasPosted over 2 years agoYou could make use of debounce and throttling.
Here's a good youtube video to start with: Learn Debounce And Throttle In 16 Minutes by Web Dev Simplified
Also, I think it's better if you can merge your filter methods into one function. That way, the country and region will be in sync with each other.
0 - @ILikeCode1Submitted almost 3 years ago
My biggest project yet. I got the html and css under control but im stilll new to js. Im in needs of tips on how to fix mobile nav showing up when its not supposed to.
@renrasPosted almost 3 years agoAdd media query to mobileNav also and set display to none.
mobileNav.style.display = "none"; mobileMenu.style.opacity = 1;
In your script.js, you have these lines of codes outside your function. I believe you can remove these and set the default styling in your css instead.
0 - @surfruitSubmitted almost 3 years ago
Need help with responsive, also I don't know how to remove margins from header+main+footer. How to change svg color? How to calc width and height of 4 images before footer. thnx
@renrasPosted almost 3 years agoThere are a lot of things to improve on this project but here's a few to start with.
Just nest the margin and padding inside the * selector also since it applies to all html element.
*, *::before, *::after { font-family: 'Poppins', sans-serif; box-sizing: border-box; + margin: 0; + padding: 0; }
Your body has a max width making your page not extending on larger screens. You can apply this to the elements inside instead.
body { color: black; - max-width: 1440px; }
Your images are overflowing because they have a fixed width. What you can do is to apply properties like width:100%, max-width and min-width instead.
img { + width: 100%, + height: auto, }
You can apply this concept on your containers too.
You can change the color of the svg directly on the file by changing it's fill attribute. If I want two of them but different color I just make another copy.
Goodluck!
Marked as helpful0 - @titocsSubmitted almost 3 years ago
i dont know why the Trash Button cannot be targeted by event.target so it cannot be clicked? also, feedback are open :) Thanks
@renrasPosted almost 3 years agoYour trash button has a child element in it which is targetted instead. Try using e.currentTarget instead because it is attached to the one with the event listener. But still it wouldn't work because the event is firing from the document which you have another event listener attached to which also gets fired. Instead of adding another event listener of the same type to the same element just merge them so It'll be easier to debug.
0 - @basemosman2Submitted almost 3 years ago
I am testing my knowledge of vanilla JS, for that reason I forced myself not to use any framework for this challenge. I would like to receive feedback on things that can be improved. Thanks in advance.
best wishes
@renrasPosted almost 3 years agofew things I think it can improve on:
- your modal's height is not responsive to vh, I think position:fixed is better instead of absolute and top,left,right,bottom:0 will do the job instead of setting a height and width
let selectedThumbnail = selectedImg.slice(0,selectedImg.indexOf('.jpg'))+'-thumbnail.jpg';
I believe what you are trying to achieve here can be done using string.replace instead and is faster than slice.
function activethumbnailImg(thumbnailImgs,mainProductImg){ thumbnailImgs.forEach((img)=>{ img.addEventListener('click',(e)=>{ thumbnailImgs.forEach((img)=>{ img.parentElement.classList.remove('active'); }); let imgName = `images/image-${e.target.dataset.name}.jpg`; mainProductImg.setAttribute('src',imgName); e.target.parentElement.classList.add('active'); }); }); }
you are nesting a foreach inside a foreach which runs kinda slow. I believe this can still be optimized using event delegation instead and traversing
Marked as helpful1