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

feat: ButtonPopover and UserProfilePopover components #2406

Closed
wants to merge 15 commits into from

Conversation

benschell-okta
Copy link
Contributor

@benschell-okta benschell-okta commented Nov 4, 2024

OKTA-826088

Summary

A few proposed new (Labs) components:

  • ButtonPopover: uses a <Button> to trigger a MUI <Popover> to appear with some basic padding
  • UserProfilePopover: Similarly, uses a (MUI) <Button> with a <UserProfile> as the contents to trigger a MUI <Popover> to appear with some basic padding
  • Also UserProfile stories to storybook (alongside stories for each of the above). Added a new prop to UserProfile to have an icon next to the username (to have the v icon as pictured in Figma)

UserProfile needs additional styling, but that's true regardless of this new addition.

Testing & Screenshots

  • I have confirmed this change with my designer and the Odyssey Design Team.

ButtonPopover:
Screenshot 2024-11-04 at 2 36 21 PM

UserProfilePopover:
Screenshot 2024-11-04 at 2 36 41 PM

Practical usage in UIShell-based Admin:
Screenshot 2024-11-04 at 2 37 36 PM

Screenshot 2024-11-04 at 2 37 51 PM

@benschell-okta benschell-okta requested a review from a team as a code owner November 4, 2024 19:09
<>
<Button
{...buttonProps}
isDisabled={buttonProps.isDisabled || isOpen}
Copy link
Contributor

Choose a reason for hiding this comment

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

If this button is disabled when it's open, how can it be closed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The MUI Popover handles closing (it handles an overlay and clicking anywhere outside of the popover closes it). Kinda like Modal IIRC. Popover has an onClose handler to let you know when it has closed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really feel like we really gain anything by disabling this button when the menu is open do we? Feels like we may as well just leave it enabled. Was there a certain issue you ran into that this was solving?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -37,6 +38,7 @@ const UserProfileIconContainer = styled("div", {
const UserProfileInfoContainer = styled("div")(() => ({
display: "flex",
flexDirection: "column",
textAlign: "left",
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't really seem like we need any of these styles. Fairly certain we can remove this styled component entirely and render either a plain div or a fragment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The textAlign is definitely needed (the default styles for <button> have text-align: center). As for the rest 🤷 ; the UserProfile component itself needs work more generally, I was just making modifications where necessary to get this Popover to work.

Copy link
Contributor

Choose a reason for hiding this comment

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

No worries. Just figured I'd flag it. If you need the text-align for a button, I'd probably just pull that button into it's own styled component and apply this there. That way it's a bit more clear what is happening/why this declaration is here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I wasn't very clear in my description.

In UserProfilePopover, I was wrapping this component with a MuiButton (here). In that scenario, a text-align from the button is causing a different layout here in the UserProfile. So this is to reset that / enforce the intended design of this component.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the extra context, I seen where you were wrapping this in a button. I was trying to say we should style that^ button with textAlign: "left" directly, rather than applying it here. The reasoning for the text align declaration would be more clear in that scenario, I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think my point, though, is that the UserProfile component should always be left aligned regardless of any container it is put in. In that case, it should ensure that it always has the correct alignment no matter what, which is why I'd advocate for having it here at a minimum. Basically, I'm suggesting we insulate this from any consumer doing something silly since this component is exported from Labs by itself as well.

tl;dr: what if someone did <center><UserProfile /></center>? We'd want the UserProfile component to render with proper alignment no matter what.

children: ReactNode | NullElement;
} & ButtonProps;

const ButtonPopover = (props: ButtonPopoverProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we name this something like... ButtonWithPopover or something similar? Just something that more accurately indicates what this component is/does? The current name leads me to believe that this component is just the popover. But, maybe that's just me. Any thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have zero opinions and am happy to name it whatever. This PR Is mainly to start a conversation (and get design blessing)

Copy link
Contributor

Choose a reason for hiding this comment

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

Got ya, sounds good. Let's go with adaptable ButtonWithPopover for now then, if you don't mind :)


disabled={isOpen}
onClick={openPopover}
variant={isOpen ? "secondary" : "floating"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing variant based on state isn't something we do anywhere else in the system. I'd probably recommend just leaving this in the floating style regardless of it's state

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I did this is that the "secondary" variant has a gray background, allowing you to see the outline of the triggering component, while "floating" more closely aligns with the way UserProfile is shown in Figma.

Frankly, in general, this PR is to start a conversation; there's nothing here that's been reviewed by designers.

<>
<MuiButton
{...muiProps}
// aria-controls={ariaControls}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied this from <Button> 's impl. I wasn't clear if / how many of these types of things should be set on something using <MuiButton>, so I commented them as a reminder to discuss this. Probably mostly a q for @KevinGhadyani-Okta

jordankoschei-okta and others added 13 commits November 15, 2024 10:00
DES-6713 feat: smarter column expansion
DES-6714 refactor: alphabetize props
feat: add the loading state
feat: add more a11y roles
feat(odyssey-storybook): add SideNavToggleButton
feat(odyssey-storybook): refacor and use new toggle button
test: add unit tests for SideNav
Merge branch 'bc-jk-sidenav-updates' of github.com:okta/odyssey into bc-jk-sidenav-updates
fix: add accessible heading role to sidenav
refactor: replace t with useTranslation in imports
feat(odyssey-storybook): add translations for toggle button
feat(odyssey-storybook): update padding and cleanup footer code
feat: add badge to SideNav
refactor: updating accessibility roles
Merge remote-tracking branch 'origin/main' into bc-jk-sidenav-updates
fix: fixes Side nav collapse icon wasn't showing up over the app content
fix: fix a11y role violations
feat: add overflow scroll to TopNav
fix: adjust width of Heading skeleton
feat(odyssey-storybook): add custom logo props
fix: moves banner above UI Shell

# Conflicts:
#	packages/odyssey-react-mui/src/labs/UiShell/UiShellContent.tsx
fix: fixes styling of TopNav slots and responsiveness

# Conflicts:
#	packages/odyssey-react-mui/src/labs/TopNav/TopNav.tsx
fix: refactors UI Shell scroll logic into useScrollState
fix: minor rename of useScrollState generic
feat(odyssey-storybook): more style updates to match Figma
feat: adds ability to know if UI Shell is rendered on the page
fix: fixes PageTemplate padding for UI Shell mode
fix: adds missing clip-path to TopNav shadow
fix: fixes border not showing up when scrolling side nav in UI Shell
fix: fixes topnav shadow not going over Surface
fix: removes unused expandedWidth
DES-6722 fix: update roadmap data
fix: update text
fix: update roadmap
fix: update data
DES-6729 feat(odyssey-react-mui): smaller nav items and focus ring
feat(odyssey-react-mui): increase inline padding to make room for button
feat(odyssey-react-mui): updated Surface appearance for white backgrounds
feat(odyssey-react-mui): build contrastmode into Surface
feat(odyssey-react-mui): updated taggle handle color and timing
OKTA-818689 chore(odyssey-react-mui): add namespace
DES-6753 test: fix broken SideNav tests
fix: change button role to button component
fix: revert broken change
OKTA-824071 feat: adds dran-n-drop feature to the sidenav
feat(odyssey-react-mui): smoother transition
fix: sidenav props in ui-shell stories
DES-6761 feat(odyssey-react-mui): add custom pagination props to DataView
feat(odyssey-react-mui): fix props import path
@benschell-okta
Copy link
Contributor Author

Closing in favor of the new #2414

@@ -225,7 +204,7 @@ const Button = ({
type={type}
variant={variant}
>
{label}
{children ?? label}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why we're adding the children prop here.

Comment on lines +251 to +255
<Box
sx={{
padding: odysseyDesignTokens.Spacing4,
}}
>
Copy link
Contributor

Choose a reason for hiding this comment

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

We should make sure these styles are memoized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KevinGhadyani-Okta this is the initial pass and has been closed. Please look at #2414 instead.

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.

7 participants