-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[AppBar] Make composable #773
Comments
Related to #27 |
👍 |
👍 I really really need this. |
I've decided to work a new appbar component that addresses this milestone. I'll be following the Material design guidelines for appbar mostly. I have always tried to address issues filed with the [AppBar] prefix. I wanted to share some of my initial ideas here and see what you guys think:
What do you guys think? @quanglam2807 @oliviertassinari @hai-cea @slara @e-monson So far everything that I've described is a prop. Speaking of composability, I assume we mean something with |
@shaurya947 Sounds good to me - children should just be rendered inside the container element to provide some customization flexibility. |
Regarding composability my approach would be to have multiple AppBar... components. At least one for the container, one for elements at the left and the right. Would be close to what IconMenu is or the Toolbar or the Table. I like the idea of @quanglam2807. @shaurya947 I feel link your approach is close to what the ItemList is right now. We have seen the limitation of the long list of props of the ListItem. It's more restrictive, gives you less freedoom. |
@oliviertassinari 👍 Thank you for your support!!! 💯 Also, there will be also components which are specifically designed for AppBar, e.g To work on this idea, I simply modified Toolbar which AppBar's |
I agree guys, instead of using props, it would be nicer to have sub-components for each section of the appBar. I will work out an initial prototype soon and share it with y'all. |
If you think about it, AppBar really has 4 sections (from left to right):
If we're creating sub-components for each of these sections, I see two approaches:
I like the latter approach more. So if you imagine, you would be able to use the <AppBar>
<AppBarSubComponent type="navIcon" action={some_function()}>
//put whatever here, style it as you like, simply rendered
</AppBarSubComponent>
<AppBarSubComponent type="container">
//all code here is yours, again simply rendered
</AppBarSubComponent>
<AppBarSubComponent type="actionIcons">
//expects one child for each action icon
//can use IconButtons or whatever
//user defines action (pass it as prop)
//simply rendered from left to right in order specified
</AppBarSubComponent>
<AppBarSubComponent type="menuIcon" action={some_other_function()}>
//put whatever here, style it as you like, simply rendered
</AppBarSubComponent>
</AppBar> Feedback, guys? @quanglam2807 @oliviertassinari @hai-cea @slara @e-monson |
Nice works, @shaurya947. I think having a generic sub-component is the best choice as it's in parallel with |
Only reason I would prefer 4 types (2 sub-types for the right side) is so that we can handle the layout of actions icons and the menu icon internally (as per Material Design guidelines) without the user having to worry about it. Also, going back to your first comment on this issue, we could take this even further like so: <AppBarGroup>
<AppBar layout = "mobile">
<AppBarSubComponent type="navIcon" action={some_function()}>
//put whatever here, style it as you like, simply rendered
</AppBarSubComponent>
<AppBarSubComponent type="container">
//all code here is yours, again simply rendered
</AppBarSubComponent>
<AppBarSubComponent type="actionIcons">
//expects one child for each action icon
//can use IconButtons or whatever
//user defines action (pass it as prop)
//simply rendered from left to right in order of specification
</AppBarSubComponent>
<AppBarSubComponent type="menuIcon" action={some_other_function()}>
//put whatever here, style it as you like, simply rendered
</AppBarSubComponent>
</AppBar>
<AppBar layout = "tablet">
<AppBarSubComponent type="navIcon" action={some_function()}>
//put whatever here, style it as you like, simply rendered
</AppBarSubComponent>
<AppBarSubComponent type="container">
//all code here is yours, again simply rendered
</AppBarSubComponent>
<AppBarSubComponent type="actionIcons">
//expects one child for each action icon
//can use IconButtons or whatever
//user defines action (pass it as prop)
//simply rendered from left to right in order of specification
</AppBarSubComponent>
<AppBarSubComponent type="menuIcon" action={some_other_function()}>
//put whatever here, style it as you like, simply rendered
</AppBarSubComponent>
</AppBar>
...
</AppBarGroup> Thoughts? |
Agree. From my point of view, the main interest of the AppBar component is to render existing component like Paper, Icon, IconMenu, into something meaningfull. It's almost like a Layout. |
Here's some skeletal code: const AppBar = React.createClass({
//getInitialState and context stuff goes here
render () {
return (
<Paper
rounded={false}
className={props.className}
style={this.mergeAndPrefix(styles.root, props.style)}
zDepth={props.zDepth}>
{this._getNavIcon()}
{this._getContainer()}
{this._getActionsIcons()}
{this._getMenuIcon()}
</Paper>
);
},
_getNavIcon () {
if((this.props.children[0]).props.type === "navIcon")
{
//return something
}
},
_getContainer () {
let pos = -1;
if(
((this.props.children[0]).props.type === "container" && pos = 0) ||
((this.props.children[1]).props.type === "container" && pos = 1)
)
{
//return something
}
},
_getActionsIcons () {
let pos = -1;
if(
((this.props.children[0]).props.type === "actionIcons" && pos = 0) ||
((this.props.children[1]).props.type === "actionIcons" && pos = 1) ||
((this.props.children[2]).props.type === "actionIcons" && pos = 2)
)
{
//return something
}
},
_getMenuIcon () {
let pos = -1;
if(
((this.props.children[0]).props.type === "menuIcon" && pos = 0) ||
((this.props.children[1]).props.type === "menuIcon" && pos = 1) ||
((this.props.children[2]).props.type === "menuIcon" && pos = 2) ||
((this.props.children[3]).props.type === "menuIcon" && pos = 3)
)
{
//return something
}
},
}); I'm using Keeping you guys in the loop here for some incremental feedback :) |
Here's an initial prototype: https://github.com/shaurya947/material-ui/blob/new-app-bar/src/app-bar-new.jsx that's how you would use it: https://github.com/shaurya947/material-ui/blob/new-app-bar/docs/src/app/components/pages/components/app-bar.jsx#L140 What do you guys think? @quanglam2807 @oliviertassinari @hai-cea |
@shaurya947 Nicely done! I prefer 3 types but if you think 4 types fit Material Design better, it's perfectly fine for me 💃 |
👍 to this feature. |
Would also like to see AppBar use an approach similar to Toolbar/ToolbarGroup/etc |
Any updates?
|
@Domiii Nop, that's something we should try to address in the |
THere's been a lot of activity and discussion here, and I'm eager to find an AppBar implementation that is a bit more composabe. The most recent comment is that we wanted the comosable AppBar in 0.16.0 (on May 20 by newoga), but I haven't seen any mention, and the documentation still shows the old style. Any news here? |
Does anyone have an alternative to the AppBar? I want to have a search field in my main app header, which I'm currently using an AppBar for, and they don't quite play nicely together. |
Any way to create elements in the center of the AppBar? Here, the children of AppBar get located after the right icon, which means "right icon" isn't actually right-most. https://github.com/callemall/material-ui/blob/master/src/AppBar/AppBar.js#L323 |
So, is this being implemented? I have been using a hack and css tweaks to make the links show up properly. This should be part of the core material-ui lib. |
Anyone can share example of what they have accomplished so far using css tweaks? i am trying to get some inspiration to try and custom the app bar |
Anyone with leads on how to add a search input to the AppBar? |
@sfandrew, the website for the new version has an example (https://material-ui.com/): You can find the source here: https://github.com/mui/material-ui/blob/v1-beta/docs/src/modules/components/AppFrame.js#L199 |
@freb I don't see the AppSearch or AppFrame component installed in my node_modules/Material-UI dir. I have the latest version installed. Am I missing something? |
They aren't modules included with material-ui, so you won't find them in the node_modules folder. They are only visible if you've cloned the repo. They are components that were created for use with the documentation site (https://material-ui.com/). All of the code for the documentation site is found under the |
Thank you very much @freb! |
I believe this concern has already been solved with v1. The AppBar component is really simple now. It was breakdown into smaller parts, e.g. the Toolbar. It's not perfect, but we haven't seen any problem with the approach over the last 6 months. |
…close-inline [mui#773] Fix firing onChange with default date if null passed to Inline…
The AppBar is too limited with only a few options. Google implements their web apps with full-size menu (and auto collapse to side menu + hamburger in mobile), search box,... I suggest that we should move to prop.children instead.
Something like this
What is your idea? I will work on this as soon as we all agree.
The text was updated successfully, but these errors were encountered: