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

[docs] Add a Drawer section #6113

Merged
merged 5 commits into from
Feb 12, 2017
Merged

Conversation

ArcanisCz
Copy link
Contributor

Created missing Drawer section base on same section on master branch. Included only what is already done in Drawer component

@@ -72,6 +72,7 @@ export default class Drawer extends Component {
docked: PropTypes.bool,
enterTransitionDuration: PropTypes.number,
leaveTransitionDuration: PropTypes.number,
onRequestClose: PropTypes.func,
Copy link
Contributor Author

@ArcanisCz ArcanisCz Feb 10, 2017

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?

Copy link
Member

@oliviertassinari oliviertassinari Feb 10, 2017

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.

Copy link
Member

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 ArcanisCz changed the title [docs] added Drawer section [docs] added Drawer section (next) Feb 10, 2017
@mbrookes
Copy link
Member

@ArcanisCz Thanks for your ongoing contributions to next! You're right to expose any sub-component props that are useful in the parent component, but no need to pull them out in the spread, they can just pass through in ...other.

Would you mind though adding comment to each one though, either copying from master or writing a new one? Those are used to build the API docs.

Once you've done that you could generate updated API docs.

@mbrookes mbrookes added PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI docs Improvements or additions to the documentation next and removed PR: Needs Review labels Feb 10, 2017
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

The example is simple, and that's ok to begging with. We could try to follow a more real life situation.

capture d ecran 2017-02-11 a 00 30 14

import Button from 'material-ui/Button';
import { MenuItem } from 'material-ui/Menu';

const styleSheet = createStyleSheet('Drawers', () => ({
Copy link
Member

@oliviertassinari oliviertassinari Feb 10, 2017

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}>
Copy link
Member

Choose a reason for hiding this comment

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

this.state.anchor?

@@ -72,6 +72,7 @@ export default class Drawer extends Component {
docked: PropTypes.bool,
enterTransitionDuration: PropTypes.number,
leaveTransitionDuration: PropTypes.number,
onRequestClose: PropTypes.func,
Copy link
Member

@oliviertassinari oliviertassinari Feb 10, 2017

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.

@@ -72,6 +72,7 @@ export default class Drawer extends Component {
docked: PropTypes.bool,
enterTransitionDuration: PropTypes.number,
leaveTransitionDuration: PropTypes.number,
onRequestClose: PropTypes.func,
Copy link
Member

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,

@@ -132,6 +134,7 @@ export default class Drawer extends Component {

const containerProps = {
className: classNames(classes.modal, className),
onRequestClose,
Copy link
Member

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: {
Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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 */
Copy link
Contributor Author

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?

Copy link
Member

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.

@ArcanisCz
Copy link
Contributor Author

ArcanisCz commented Feb 11, 2017

@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)
@oliviertassinari Nicer example added :)


const styleSheet = createStyleSheet('UndockedDrawer', () => ({
list: {
width: '280px',
Copy link
Member

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,

Copy link
Contributor Author

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}>
Copy link
Member

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.

@@ -56,6 +56,9 @@ export const styleSheet = createStyleSheet('Drawer', (theme) => {
*/
export default class Drawer extends Component {
static propTypes = {
/**
* Side, which will `Drawer` appears from
Copy link
Member

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 .

*/
onRequestClose: PropTypes.func,
/**
* If true, the `Drawer` is opened.
Copy link
Member

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 */
Copy link
Member

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.

@@ -38,6 +39,16 @@ export const styleSheet = createStyleSheet('ListItem', (theme) => {
paddingLeft: 16,
paddingRight: 16,
},
button: {
transition: transitions.multi(['background-color', 'box-shadow'], '250ms'),
Copy link
Member

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: {
Copy link
Member

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.

</SvgIcon>
);
ActionDelete = pure(ActionDelete);
ActionDelete.displayName = 'ActionDelete';
Copy link
Member

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.

@oliviertassinari
Copy link
Member

@ArcanisCz It's almost good to be merged 🎉

@oliviertassinari oliviertassinari changed the title [docs] added Drawer section (next) [docs] added Drawer section Feb 11, 2017
@oliviertassinari oliviertassinari added PR: Review Accepted and removed PR: Needs Review PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI labels Feb 11, 2017
@mbrookes
Copy link
Member

@ArcanisCz Sorry, could you fix the merge conflict? Nothing major - renaming of zDepth to elevation beside one of your changes.

@mbrookes mbrookes added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 11, 2017
@muibot muibot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 12, 2017
@ArcanisCz
Copy link
Contributor Author

Sure, no problem!

@oliviertassinari
Copy link
Member

@ArcanisCz Thanks again!

@ArcanisCz ArcanisCz deleted the feature/drawerDocs branch February 12, 2017 10:25
@oliviertassinari oliviertassinari changed the title [docs] added Drawer section [docs] Add a Drawer section Feb 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants