Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

feat: show name and menu in header only when user is logged in #146

Merged
merged 1 commit into from
Aug 31, 2022
Merged

feat: show name and menu in header only when user is logged in #146

merged 1 commit into from
Aug 31, 2022

Conversation

subhoghoshX
Copy link
Collaborator

This is the first of the series of PRs that improves the # and # flow. Please look at #140.

This PR hides the name and menu button when the user is not logged in. Instead, it only shows a link to the # page.

@vercel
Copy link

vercel bot commented Aug 30, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
defaang ✅ Ready (Inspect) Visit Preview Aug 30, 2022 at 3:56PM (UTC)

Copy link
Collaborator

@ykdojo ykdojo left a comment

Choose a reason for hiding this comment

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

looks good, thank you!

@benny123tw
Copy link
Contributor

maybe use clsx for constructing className strings conditionally?

<a
href='#'
className={classNames(
active ? 'bg-gray-100' : '',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
active ? 'bg-gray-100' : '',
active && 'bg-gray-100',

is this one better?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this case if active is true it'll return a string that is bg-gray-100 but if it is false it'll return a boolean i.e. false. So a class named false will probably be added to the list of class names.

And as we're using TypeScript it'll straight away show an error saying something like the value of boolean is not assignable, if that makes sense 😄 Thanks for the feedback.

Copy link
Contributor

Choose a reason for hiding this comment

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

false will filter out by classes.filter(Boolean).join(' ') XD
Thanks for the comment ❤️

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right. Didn't notice it before. But the TypeScript error would still be there if we use active && 'bg-gray-100'.

@subhoghoshX
Copy link
Collaborator Author

maybe use clsx for constructing className strings conditionally?

I'm not sure about adding another dependency for a simple case like this.

@subhoghoshX subhoghoshX merged commit 59ca166 into csdojo-defaang:main Aug 31, 2022
@subhoghoshX subhoghoshX deleted the if-not-logged-in-show-signin-link branch September 1, 2022 06:23
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants