-
-
Notifications
You must be signed in to change notification settings - Fork 311
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
[DashboardLayout] Add homeUrl
to branding
and appTitle
slot
#4477
Conversation
This one feels out of spirit for slot components to me. I don't think we should stretch the definition of slots beyond React components. |
I think calling the slot |
Fair enough, does renaming it to |
I think that's fine, or |
Now that we have the Update: Discussed with @mnajdova that an |
homeUrl
and branding
slothomeUrl
and appTitle
slot
homeUrl
and appTitle
slothomeUrl
to branding
and appTitle
slot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good, thanks for adding these!
But noticed a few improvements that would probably make sense.
Also I was a bit surprised by this logo at first, something about it seemed weird, but maybe I'm just used to the old one...
Would it maybe look better if the title was blue and bold? Not sure about it though, feel free to keep it if there's nothing obvious to do.
|
||
{{"demo": "DashboardLayoutBranding.js", "height": 400, "iframe": true}} | ||
|
||
:::info | ||
You may also override the default branding components by passing in your own component to the `branding` slot, as described in the [Slots section](#slots). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may also override the default branding components by passing in your own component to the `branding` slot, as described in the [Slots section](#slots). | |
You may also override the default branding components by passing in your own component to the `appTitle` slot, as shown in the [Slots section](#slots). |
It's called appTitle
after all, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this!
@@ -149,6 +153,8 @@ Some possibly useful slots: | |||
|
|||
- `sidebarFooter`: allows you to add footer content in the sidebar. | |||
|
|||
- `branding`: allows you to pass in your own component in the branding section. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `branding`: allows you to pass in your own component in the branding section. | |
- `appTitle`: allows you to customize the branding in the layout header. |
Rename to appTitle
and suggested an alternative for the description but doesn't need to be exactly like I suggested.
Also I'd list this slot first as visually it's present before the others in the layout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call it "app title" instead of "branding" in my first suggestion to match the description here more https://github.com/mui/toolpad/pull/4477/files#diff-87af69cfab4c32bae2f8f22cd3d491883936a394263a91aea7824875db51e2a7
const defaultTitle = useApplicationTitle(); | ||
const title = props?.title ?? defaultTitle; | ||
return ( | ||
<Link href={props?.homeUrl ?? '/'} style={{ color: 'red', textDecoration: 'none' }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why color: red
? :D Was it there before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, good catch! Missed removing this after using it to test :)
</Typography> | ||
</Stack> | ||
</Link> | ||
{slots?.appTitle ? <slots.appTitle /> : <AppTitleComponent {...appTitleProps} />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should people be able to pass in slotProps
of the type Branding
to the custom slot if they set it? Then it would match the props of AppTitleComponent
, right?
Also I'd just have a single branding
prop for these slot components instead of all the props inside Branding
, then maybe we could add other stuff later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should people be able to pass in
slotProps
of the typeBranding
to the custom slot if they set it? Then it would match the props ofAppTitleComponent
, right?
Agreed, missed this
Also I'd just have a single branding prop for these slot components instead of all the props inside Branding, then maybe we could add other stuff later.
Makes sense, so merge all the Branding
properties inside a single branding
prop for the AppTitle
For the slot type definition, if I used
appTitle?: React.JSXElementConstructor<AppTitleProps>;
that would cause type errors if someone wanted to create a custom element with their own props for this component, right? Would it be better to use React.ElementType
instead here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would cause type errors if someone wanted to create a custom element with their own props for this component, right? Would it be better to use React.ElementType instead here?
Could we make it so that the custom component automatically has these default props but can be expanded with whatever other properties people want to add?
But if not and that causes errors, we haven't really decided on a pattern for the slots yet so if using React.ElementType
fixes that we can go with that pattern.
In this particular case you don't even need to pass branding as a prop to the slot if that ends up solving this problem, those branding values can just be read from the context if that's the best solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess going with React.ElementType
like you did should work if it shows no errors. But it would be nice if it could be typed somehow.
@@ -73,6 +73,7 @@ function DashboardLayoutBranding(props) { | |||
branding={{ | |||
logo: <img src="https://mui.com/static/logo.png" alt="MUI logo" />, | |||
title: 'MUI', | |||
homeUrl: 'https://mui.com/toolpad/core/introduction', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you click this in the demo it just changes the page content to "Dashboard content for /toolpad/core/introduction".
So not sure if we should use a relative link?
Anyway this comment is just a thought - not sure what the best option would be...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll switch to the relative URL since the navigation doesn't actually work in the iframe demo
So homeUrl is finally available? |
You're right, in hindsight this demo wasn't really demonstrative at all, I've changed it to better reflect the utility of the slot |
…lpad into core/branding-slot
docs/data/toolpad/core/components/dashboard-layout/dashboard-layout.md
Outdated
Show resolved
Hide resolved
</Typography> | ||
</Stack> | ||
</Link> | ||
{slots?.appTitle ? <slots.appTitle /> : <AppTitleComponent {...appTitleProps} />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess going with React.ElementType
like you did should work if it shows no errors. But it would be nice if it could be typed somehow.
@@ -359,7 +360,11 @@ function DashboardLayout(props: DashboardLayoutProps) { | |||
</Box> | |||
</React.Fragment> | |||
) : null} | |||
{slots?.appTitle ? <slots.appTitle /> : <AppTitleComponent {...appTitleProps} />} | |||
{slots?.appTitle ? ( | |||
<slots.appTitle {...slotProps?.appTitle} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be cool if the custom component also gets branding
, but if that causes typing issues we can stay like this for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this originally but removed it after #4477 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for the changes!
Also the new slots title uses the same icon as the dashboard navigation item, maybe we could use a different one? Not too important.
Co-authored-by: Pedro Ferreira <10789765+apedroferreira@users.noreply.github.com> Signed-off-by: Bharat Kashyap <bharatkashyap@outlook.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is homeUrl released or not?
? |
Hi @ashishjaswal2002, the next release (v0.11.0) will have this feature. You can track when it comes out here: https://github.com/mui/toolpad/releases - it'll be sometime today or in the next few days |
@bharatkashyap how to use the latest version in the latest project |
homeUrl
attribute to thebranding
objectbranding
slot toDashboardLayout
to customize the branding section entirelybranding
override inDashboardLayout
to override individual properties of thebranding
prop passed inAppProvider
, instead of replacing the entire objectbranding
object as a prop to thebranding
slot componenthttps://deploy-preview-4477--mui-toolpad-docs.netlify.app/toolpad/core