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

Add application layout components #1031

Closed
wants to merge 16 commits into from

Conversation

huwshimi
Copy link
Collaborator

@huwshimi huwshimi commented Jan 24, 2024

Creating this draft in case anyone is planning to do something similar. I haven't had time to finish this, but these components are used in Juju Dashboard and ReBAC Admin.

TODO

  • Update imports
  • Add docs
  • Update tests to work in react-components
  • Export components and types

@webteam-app
Copy link

Demo starting at https://react-components-1031.demos.haus

Copy link
Contributor

@edlerd edlerd left a comment

Choose a reason for hiding this comment

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

Read through all the ApplicationLayout components and left some comments. Those seem very useful and well composable, thanks for adding them!

I made just a rough review of the Panel and SideNavigation components. Maybe factor them into a dedicated PR to make it easier to review? I think those two are a bit more controversial and might need more detailed alignment and discussions.

The demo build is failing due to:

13.43 src/components/ApplicationLayout/AppAside/AppAside.tsx(37,8): error TS2322: Type '{ children: ReactNode; controls: Element; contentClassName?: string; className?: string; dark?: boolean; wrapContent?: boolean; forwardRef?: Ref<HTMLDivElement>; ... 6 more ...; stickyHeader?: never; } | { ...; } | { ...; }' is not assignable to type 'IntrinsicAttributes & Props<LogoDefaultElement>'.
13.43   Type '{ children: ReactNode; controls: Element; contentClassName?: string; className?: string; dark?: boolean; wrapContent?: boolean; forwardRef?: Ref<HTMLDivElement>; ... 6 more ...; stickyHeader?: never; }' is not assignable to type 'IntrinsicAttributes & Props<LogoDefaultElement>'.
13.43     Type '{ children: ReactNode; controls: Element; contentClassName?: string; className?: string; dark?: boolean; wrapContent?: boolean; forwardRef?: Ref<HTMLDivElement>; ... 6 more ...; stickyHeader?: never; }' is not assignable to type 'LogoProps<LogoDefaultElement>'.
13.43       Property 'logo' is optional in type '{ children: ReactNode; controls: Element; contentClassName?: string; className?: string; dark?: boolean; wrapContent?: boolean; forwardRef?: Ref<HTMLDivElement>; ... 6 more ...; stickyHeader?: never; }' but required in type 'LogoProps<LogoDefaultElement>'.

src/components/ApplicationLayout/AppAside/AppAside.tsx Outdated Show resolved Hide resolved
src/components/ApplicationLayout/AppStatus/AppStatus.tsx Outdated Show resolved Hide resolved
}
>;

const ApplicationLayout = <
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure a combination of the other components is generic enough to have it in react-components. I'd assume our different applications have too different requirements to allow a reuse of this combination. Wdyt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This component has been working for the apps that I've tested in so far (ReBAC Admin, Juju Dashboard and Admin UI), so it's possible we can use this for common cases and then some apps might need to have their own implementation.

I plan to keep testing this with other apps to see where it doesn't meet our needs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It looks like MAAS-UI and and LXD-UI have some custom menu features that mean that the <ApplicationLayout> component doesn't quite work, or at least not without making it more complicated. In both these cases they can be composed using the child components.

canonical/lxd-ui#768
canonical/maas-ui#5434

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Turns out LXD just needed to pass a single class and it could use the ApplicationLayout component.

@huwshimi
Copy link
Collaborator Author

I made just a rough review of the Panel and SideNavigation components. Maybe factor them into a dedicated PR to make it easier to review? I think those two are a bit more controversial and might need more detailed alignment and discussions.

That's a good idea, I might split this up into a number of PRs once I have it all working together.

Copy link

This PR is being prevented from merging because it needs to be reviewed on Percy.

Go to Percy, find the build relevant to this PR and check if it looks as expected.

Once it's approved, add the label Review: Percy +1 to this PR.

@huwshimi
Copy link
Collaborator Author

Here are some tests I've conducted to see how these components would work in our apps:

canonical/lxd-ui#768
canonical/identity-platform-admin-ui#309
canonical/maas-ui#5434
canonical/juju-dashboard#1752
canonical/rebac-admin#106

@huwshimi huwshimi closed this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants