Closed r002 closed 3 years ago
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/mithi/epic-react-exercises/7Lim7i8khUEc5FzWDutW1PNWkz7M
✅ Preview: https://epic-react-exercises-git-fork-r002-fix-116-mithi.vercel.app
@r002 Thanks so much for your effort! This is great! I made a couple of changes, let me know if it looks good on windows, before I merge it. Thanks again!
@mithi The code looks beautiful in Windows Chrome! 💯 I like the thinner scrollbars! 🙂
Basically, I tested two modes-- looking at in full-screen:
As well as mobile:
One question for you though: I noticed that in your Make nav buttons closer together
change, you directly edited the SqaureButton
React component in components/main/navbar.js
. While that definitely works, I'm curious: Is there a specific reason you did not create a new "Nav Button" else if
block inside of const SqaureButton
in components/button/index.js
? Or (maybe even better): Create an entirely new NavButton
component that extends SquareButton
but then just sets the { margin: "5px 10px" }
?
Generally, I just get nervous when I see CSS getting manually set in the style='....'
attribute inside of JSX. Like, I enjoy separating all styling concerns only to be the .css
file OR at the .js
level inside the actual component (eg. SqaureButton
).
Does that make? Just curious about your reasoning.
One question for you though: I noticed that in your Make nav buttons closer together change, you directly edited the SqaureButton React component in components/main/navbar.js. While that definitely works, I'm curious: Is there a specific reason you did not create a new "Nav Button" else if block inside of const SqaureButton in components/button/index.js? Or (maybe even better): Create an entirely new NavButton component that extends SquareButton but then just sets the { margin: "5px 10px" }? Generally, I just get nervous when I see CSS getting manually set in the style='....' attribute inside of JSX. Like, I enjoy separating all styling concerns only to be the .css file OR at the .js level inside the actual component (eg. SqaureButton).Does that make? Just curious about your reasoning.
Disclaimer: Note this is just an opinion, I'm not saying this is the best way to write this code, these are the things that go through my head as I was writing it... there are always tradeoffs! Don't get me wrong, I also like putting the styling inside the actual component... but there are other considerations here... (other than I can't put styles in a class because of specificity, it won't be able to override the styles inside the SquareButton
component)
(Also notice that I slightly refactored NavInner
, without making a new component (I double down on that)...I hope you like it 😅)
The SquareButton
is intended to be a general reusable component... Taking a look at the source code of SquareButton
You'd observe else if
block is only for checking the side
prop which can either be a falsey, large
, small
or some size like 15px
for example. You might realize now that wouldn't make sense to add additional specific cases like NavButton
or PaginationButton
or ThemeMenuButton
as it would go on and on and it goes against the api...
I read this
I have often found myself writing my API before I have even decided how I'd like to interact with it. After watching this series, I have started to write what I would expect my API to provide before actually writing it.
And I realize that I'm guilty of this, so now I try to think about the api first before creating components!
NavButton
because that's how I approached the reactMenu
buttons the react menu As you can see here:
duplication is far cheaper than the wrong abstraction - Sandi Metz
Here's some highly recommended reads/talks about this you haven't already!
The WET code base
https://overreacted.io/the-wet-codebase/Helper methods are object junk that we need to recreate and compare for no purpose other than superficially nicer looking syntax - Dan Abramov
React has a powerful composition model, and we recommend using composition instead of inheritance to reuse code between components.
It's nice to read and watch about Composition vs Inheritance
I'm not sure if you've tried tailwind but here's a quote from their site
Now I know what you're thinking, "this is an atrocity, what a horrible mess!" and you're right, it's kind of ugly. In fact it's just about impossible to think this is a good idea the first time you see it — you have to actually try it. But once you've actually built something this way, you'll quickly notice some really important benefits.....
Read more: https://tailwindcss.com/docs/utility-first
I know that not a lot of people may agree with it as you can see in the discussions from hacker news
But based on my experience...
When you realize how productive you can be working exclusively in HTML.... working any other way will feel like torture.
Wow... this is amazing. Thank you so much for writing this up! This is... a lot. I'll need some time to properly go through and think through all of this. I've never looked into Tailwind CSS but now I will!
(Just from the bit I have read, it's already resonated with me a ton though. Eg. I am super-guilty of making tons of nonsense CSS classes just to style stuff. 🙄)
Thank you so much for open-sourcing your project though! It's been hugely educational for me to just read through your codebase to see how you do things. I'm not proud of it, but for years I just worked solo and mooched off of other people's projects (npm install ... !
, stack overflow!
) without contributing anywhere. But recently, as a resolution for 2021, I've decided to try re-entering society. 😅 So instead of just spinning up new projects, I've made it a goal to scour Reddit and Discord, find existing projects that look friendly, and then try contributing. It has been so much fun! Your project was the first I made a PR to; so thank you for making it such a welcoming experience! 🙏
(This sounds weird, but I've actually (just recently, as ridiculous as it sounds) realized that reading code is a legit skill. Like, the ability to paradrop into a foreign territory, find the entry point, build and run locally, and then reason what's going on is a bonafide ability.)
Btw, have you considered enabling the Discussions
tab in your GitHub project? There are some general questions I'd love to ask you (if you're inclined, of course). And other folks who might be interested in contributing may also be curious as well. For example, looking through your history, I noticed:
And so not knowing a thing about Vercel or NextJS, I literally spent an entire day exploring that whole ecosystem. (Haha, I am the proud owner of a Vercel next-js-blog now! 😄) I'd love to know what you think about NextJS though. Personally, when I started getting back into webdev earlier this year, I planted my flag in the Google Firebase camp. I was impressed by their dev tooling (local auth and Firestore emulators!) and they also offer "preview channels" for PRs. But as always, I'm always curious what the landscape looks like and about other people's experiences with other tools/platforms. Always feels like 'the next big thing' is afoot and it's hard to keep up. 🤦♂️
PS. Btw, you might laugh, but back to the 'Nav Button' topic-- Years ago, on a previous codebase I'd worked on, we actually had a single "Button Factory"
class that was responsible for just giving all of the buttons. Like, you'd pass in the type of the button you wanted and, poof!-- the button would just appear. The code was astoundingly ugly (hundreds of lines of if/else blocks) but I remember thinking at the time, after actually using it-- "well, there are no dependencies!" It actually gave me a ton of confidence being able to add a new button or restyle an existing one bc everything was literally in a single place. Ergonomics, I guess, is what this is called nowadays? What a world; everything's come full-circle, in a way! ⭕
Hi @mithi -- So I finally beautified the scrollbars for Windows (well, Chrome) this morning. (Lol, I thought this was gonna be a ten-minute fix.... but nope! 🤦♂️) Anyway, it was fun! 👍
The "scrollbars bug" fix:
And when the screen resizes, I took care of giving
.main
scrollbars in the@media
section:There was one tricky thing that took me a literal hour to figure out, btw: In
main.js
inMainGrid
you'd hardcodedoverflow=auto
which had been overriding the css that I'd been trying to set inStyle.module.css
. Out of curiosity, was there a specific reason you'd hardcoded that there? I needed to delete that bit or else this would happen:With the
overflow=auto
hardcode removed, it now looks like:But in Edge, it still looks awful. I'd followed the below guide but it didn't work so I'm giving up on it. Sorry, Edge people! 🤷
PS. It me a few tries to get it right, so if you do merge my PR, you'll probably want to do a "squash & merge".
References: