Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade prettier, add some ui elements, add the Register page. #670

Merged
merged 5 commits into from
Aug 23, 2023

Conversation

acrantel
Copy link
Member

@acrantel acrantel commented Aug 20, 2023

Adds the register page.
UI elements added / styled (these have all been tested, see the Register.tsx page):

  • Button
  • FormError
  • FormLabel
  • Icon
  • Input
  • SelectMenu

Prettier changes:

  • Adds @headlessui/tailwindcss to style headless ui components based on state.
  • Adds prettier-plugin-tailwindcss to sort tailwind classes
  • Upgrades prettier so that prettier-plugin-tailwindcss works
  • Removes prettier precommit hook because it conflicts with having prettier-plugin-tailwindcss listed in prettierrc.json
  • Formats the entire project with the new prettier setup (it added a lot of commas lmao)

Before testing, make sure to run npm install to get the updated packages.

image

@acrantel acrantel changed the base branch from main to frontend2 August 20, 2023 18:30
@acrantel acrantel changed the title Upgrade prettier and add some ui elements Upgrade prettier, add some ui elements, add the Register page. Aug 20, 2023
@acrantel acrantel requested a review from n8kim1 August 20, 2023 18:47
information_circle: InformationCircleIcon24,
};

const icons20 = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need both 24 and 20? would it be worth it to cut down and only need to import one of them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(jumping in here as someone who hasn't been paying attention and who has just read some email digests)

I think it's ok to have both, because it makes sense to be able to tailor/change icon-sets for different episodes of Battlecode. But, this is conditioned on:

  • The setup being something easily extensible to n episodes of Battlecode for large n.
  • I think it's ok if this extensibility means defining a new dict/mapping for each episode, because that's unavoidable when each episode could be different.
  • However, it should also be implementable without changing the downstream rendering code, so this looks a bit more dubious. Perhaps it could be a single mapping that maps each episode name to one of these dicts?

Separately, curious how easy it would be to use this framework to add new menu items in the future with new icons? (possibly the answer is "very easy", I didn't read the code at all)

Copy link
Contributor

@n8kim1 n8kim1 Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(oops, 24/20 px not episode, sorry for the confusion)

Copy link
Member Author

@acrantel acrantel Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20/24 represents the icon size, not the episode of battlecode. We use smaller icons for buttons / form elements, and bigger icons are used for navigation.
We would use the same icon set across all episodes of battlecode.

Separately, curious how easy it would be to use this framework to add new menu items in the future with new icons? (possibly the answer is "very easy", I didn't read the code at all)

new menu items per episode can be added like this:

{episode === 'bc123' && 
    <SidebarItem
          iconName="whatever_icon_name"
          text="Resources"
          linkTo={`${linkBase}resources`}
    />
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, if either size gets used for different purposes, then sounds good
I'm a little wary of the extra overhead here -- if we want to add a new icon, then we'd have to import both sizes, and make sure the correct size gets used. But perhaps this is easier than I think. Most of all though, we could always come back to this later

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah fair, naming wasn't entirely clear but makes sense now

Copy link
Contributor

@lowtorola lowtorola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending resolution of Jerry & Nathan's comments 🙌

Comment on lines 38 to 40
console.log("logged in successfully");
} catch (error) {
console.log("failure to register", error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider showing a user-facing error, even just propagating the backend message up to the frontend is fine. (errors where nothing seems to happen would be annoying to user)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and it's not clear to me that the error does show, especially if it's in the login method? If it does feel free to ignore me, I haven't locally tested yet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do this in a separate PR, as this PR is already pretty big. In that PR I'm also planning on creating a reusable component for displaying these errors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooo a reusable error comment, niceeee

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually for this PR I can make a super simple error message and replace it in the later PR

Copy link
Contributor

@n8kim1 n8kim1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good, do see comments though!

@acrantel acrantel requested a review from j-mao August 22, 2023 16:37
@acrantel acrantel merged commit 0de1bc1 into frontend2 Aug 23, 2023
3 checks passed
@acrantel acrantel deleted the some-elements branch August 23, 2023 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants