r/reactjs • • Mar 16 '23

Introducing react.dev: the new React docs site!

https://react.dev/blog/2023/03/16/introducing-react-dev
566 Upvotes

74 comments sorted by

View all comments

Show parent comments

12

u/rickhanlonii React core team Mar 16 '23

Thank you!

6

u/andrewsjustin Mar 16 '23

Curious what the sites built on? Next? Remix?

Really great work from what I’ve checked out so far, psyched to have this resource!

24

u/rickhanlonii React core team Mar 17 '23

It’s built on Next with tailwind. Check out the beta directory here: https://github.com/reactjs/reactjs.org

-1

u/Aswole Mar 17 '23

Ugh, I don't really feel like arguing with anyone right now about Tailwind, but it's discouraging to me that it's becoming so mainstream that the react docs are now using it. Literally the first element on your page contains some combination of responsive bugs (or at the very least redundant properties):

<div class="h-[40px] hidden lg:flex w-full bg-gray-100 dark:bg-gray-700 text-base md:text-lg py-2 sm:py-0 items-center justify-center flex-col sm:flex-row z-[100]">
 //Support Ukraine Content
</div>

Basically, it is hidden for every viewport except lg, despite there being explicit styling for md and sm viewports. Which is unfortunate given that the consequence is hiding something designed to promote a good cause. Because tailwind begins to look like hieroglyphics to me once a class has more than a handful of properties, I'll translate it to (s)css and try to understand the intent for each breakpoint:

.ukraine-banner {
  height: 40px;
  display: hidden;
  width: 100%;
  background-color: var(--gray100);
  font-size: 15px;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 100;

  @media (min-width: 640px) {
    padding-top: 0rem;
    padding-bottom: 0rem;
    flex-direction: row;
  }

  @media (min-width: 768px) {
    font-size: 17px;
  }

  @media (min-width: 1024px) {
    display: flex;
  }

  @media (prefers-color-scheme: dark) {
    background-color: var(--gray700);
  }
}

First, it's pretty clear that display: flex should at least coincide with flex-direction:row and thus be moved to the sm breakpoint (or in tailwind terms, lg:flex should be changed to sm:flex). What confuses me most is the display: hidden. Was the intent to have this not show up on mobile at all? I'm skeptical, because if so, then the py-2 and flex-col properties don't make sense as they are immediately overwritten at the first breakpoint where it actually does become visible. My guess is hidden was added as a panic fix because someone didn't know how to make it work in mobile, and accidentally broke it for everything but lg. In fact, just removing the hidden entirely fixes it for all but the smallest viewport (when the text begins to wrap), but changing height: 40px to min-height: 40px handles that.

3

u/gaearon React core team Mar 17 '23

Which is unfortunate given that the consequence is hiding something designed to promote a good cause.

Yeah, the problem there is that we've had bad random navigation glitches on iOS when we kept it position: sticky. Its mobile support still isn't great in WebKit. And making it always fixed as a permanent element you can't scroll away takes too much screen estate on mobile. The link is also not very useful on mobile (e.g. facebook mobile site just breaks with it) but it's the only one we could get approved by the lawyers. So I think it made sense to omit.

1

u/Aswole Mar 17 '23

I don’t think you should need to make it sticky — just the nav bar (which already is). At least on my version of iOS, it looks fine on mobile with basic navigation: https://streamable.com/frx4y6

Out of curiosity, was it an issue when the address bar is on the top? I’ve had nightmares wrestling with any sort of fixed elements and how they interact (or more specifically how they don’t interact) with floating browser ui elements across different engines