-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[docs] Add a Drawer section #6113
Conversation
src/Drawer/Drawer.js
Outdated
@@ -72,6 +72,7 @@ export default class Drawer extends Component { | |||
docked: PropTypes.bool, | |||
enterTransitionDuration: PropTypes.number, | |||
leaveTransitionDuration: PropTypes.number, | |||
onRequestClose: PropTypes.func, |
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 am not sure about this one. It is true that additional props specified will be passed to Modal, but that means for most basic use case (controlled open/close Drawer) you have to know implementation internals of Drawer. Which is why i included this explicit prop, which is only passed.
Any recommendations how to handle this type of situation?
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 think that you made a good call. Wrapping component should be exposing critical properties.
I know that it means duplication and violation of the DRY principal, but we haven't found better solutions.
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.
/**
* Callback fired when the internal modal requests to be closed.
*/
onRequestClose: PropTypes.func,
@ArcanisCz Thanks for your ongoing contributions to Would you mind though adding comment to each one though, either copying from Once you've done that you could generate updated API docs. |
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.
import Button from 'material-ui/Button'; | ||
import { MenuItem } from 'material-ui/Menu'; | ||
|
||
const styleSheet = createStyleSheet('Drawers', () => ({ |
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.
('UndockedDrawer', (
return ( | ||
<div> | ||
<Button onClick={this.handleOpen}>Open Drawer</Button> | ||
<Drawer open={this.state.open} anchor={this.state.anchor} onRequestClose={this.handleClose}> |
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.
this.state.anchor
?
src/Drawer/Drawer.js
Outdated
@@ -72,6 +72,7 @@ export default class Drawer extends Component { | |||
docked: PropTypes.bool, | |||
enterTransitionDuration: PropTypes.number, | |||
leaveTransitionDuration: PropTypes.number, | |||
onRequestClose: PropTypes.func, |
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 think that you made a good call. Wrapping component should be exposing critical properties.
I know that it means duplication and violation of the DRY principal, but we haven't found better solutions.
src/Drawer/Drawer.js
Outdated
@@ -72,6 +72,7 @@ export default class Drawer extends Component { | |||
docked: PropTypes.bool, | |||
enterTransitionDuration: PropTypes.number, | |||
leaveTransitionDuration: PropTypes.number, | |||
onRequestClose: PropTypes.func, |
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.
/**
* Callback fired when the internal modal requests to be closed.
*/
onRequestClose: PropTypes.func,
src/Drawer/Drawer.js
Outdated
@@ -132,6 +134,7 @@ export default class Drawer extends Component { | |||
|
|||
const containerProps = { | |||
className: classNames(classes.modal, className), | |||
onRequestClose, |
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.
We might not need to explicit it here. To try, eslint may complains.
@@ -38,6 +39,16 @@ export const styleSheet = createStyleSheet('ListItem', (theme) => { | |||
paddingLeft: 16, | |||
paddingRight: 16, | |||
}, | |||
button: { |
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.
Stolen from Button
, but not sure if correct approach. But <ListItem button>
didnt have proper hover effect of Button
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's not directly linked but we can nest a button inside a <ListItem />
. We do it with the documentation drawer nav items.
I think that you made a good call here too.
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.
Well, tried that Button
in ListItem
, but it seems its not ready yet, styles and paddings were weird.
@@ -0,0 +1,16 @@ | |||
/* eslint-disable */ |
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.
Added some icons from master, but i suppose they will be transferred all at some point?
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, once #6104 is done, we should be able to replace them.
@mbrookes Sure, i completely overlooked that api generation! thought that its manula, when .md files were in sources :X When tried to re-generate docs, it generated much more changes than only my Drawer, is it ok to commit that? (aside from some clrf problems) |
|
||
const styleSheet = createStyleSheet('UndockedDrawer', () => ({ | ||
list: { | ||
width: '280px', |
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 not using the same width than the documentation drawer? By the way, you don't need to add this px
.
width: 250,
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.
noticed that width in specs, but then realized that width prop is missing in Drawer anyway, so havent bothered with this much now. Sorry, will change to master's value!
<Button onClick={this.handleOpen}>Open Drawer</Button> | ||
<Drawer open={this.state.open} onRequestClose={this.handleClose}> | ||
<List className={classes.list} padding={false}> | ||
<ListItem button onClick={this.handleClose}> |
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 want to reduce boilerplate, you can move all those onClick handlers to the Drawer
. The event propagation will work fine.
src/Drawer/Drawer.js
Outdated
@@ -56,6 +56,9 @@ export const styleSheet = createStyleSheet('Drawer', (theme) => { | |||
*/ | |||
export default class Drawer extends Component { | |||
static propTypes = { | |||
/** | |||
* Side, which will `Drawer` appears from |
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.
For consistency, we add dots at the end of all our descriptions .
src/Drawer/Drawer.js
Outdated
*/ | ||
onRequestClose: PropTypes.func, | ||
/** | ||
* If true, the `Drawer` is opened. |
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 open.
@@ -0,0 +1,16 @@ | |||
/* eslint-disable */ |
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, once #6104 is done, we should be able to replace them.
src/List/ListItem.js
Outdated
@@ -38,6 +39,16 @@ export const styleSheet = createStyleSheet('ListItem', (theme) => { | |||
paddingLeft: 16, | |||
paddingRight: 16, | |||
}, | |||
button: { | |||
transition: transitions.multi(['background-color', 'box-shadow'], '250ms'), |
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.
No need to transition on the box-shadow
.
@@ -38,6 +39,16 @@ export const styleSheet = createStyleSheet('ListItem', (theme) => { | |||
paddingLeft: 16, | |||
paddingRight: 16, | |||
}, | |||
button: { |
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's not directly linked but we can nest a button inside a <ListItem />
. We do it with the documentation drawer nav items.
I think that you made a good call here too.
src/svg-icons/delete.js
Outdated
</SvgIcon> | ||
); | ||
ActionDelete = pure(ActionDelete); | ||
ActionDelete.displayName = 'ActionDelete'; |
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.
No need for the displayName
, but don't worry, this folder will soon be gone.
@ArcanisCz It's almost good to be merged 🎉 |
@ArcanisCz Sorry, could you fix the merge conflict? Nothing major - renaming of |
Created missing Drawer section base on same section on master branch. Included only what is already done in Drawer component
5e12608
to
9aab549
Compare
Sure, no problem! |
@ArcanisCz Thanks again! |
Created missing Drawer section base on same section on master branch. Included only what is already done in Drawer component