Skip to content
This repository has been archived by the owner on Nov 2, 2019. It is now read-only.

Commit

Permalink
Update Dialog and add it to the website
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesplease committed Jun 7, 2018
1 parent 4949f37 commit 0ea1a16
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 22 deletions.
10 changes: 10 additions & 0 deletions docs/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,14 @@ export default [
materialDocsLink:
'https://material.io/design/components/selection-controls.html#radio-buttons',
},
{
name: 'Dialog',
url: 'dialog',
componentKey: 'dialog',
editorHeight: '500px',
description:
'Dialogs inform users about a task or decision that needs to be made.',
component: 'src/components/component-doc',
materialDocsLink: 'https://material.io/design/components/dialogs.html',
},
];
22 changes: 22 additions & 0 deletions docs/examples/dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class DialogExample extends Component {
render() {
return (
<Dialog style={{ maxWidth: '500px' }}>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Body>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Numquam
consequatur enim voluptates nobis perferendis voluptatibus alias
modi voluptate dolorum ipsa amet.
</p>
</Dialog.Body>
<Dialog.Actions>
<Button flat>Cancel</Button>
<Button flat>Accept</Button>
</Dialog.Actions>
</Dialog>
);
}
}

return <DialogExample />;
27 changes: 27 additions & 0 deletions docs/readmes/dialog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Usage

```jsx
import { Dialog } from 'materialish';
import 'materialish/dialog.css';
```

Take note of the fact that a dialog is made up of several components. To see how they
are used together, refer to the example above.

## Props

All of the components of a dialog receive the same props.

| Prop Name | Default Value | Required | Description |
| --------- | ------------- | -------- | ------------------------------------------------------------------ |
| className | | No | Additional class name(s) to add to the dialog component |
| ...rest | | No | Other props are placed on the root element of the dialog component |

## CSS Variables

These CSS variables should be applied to the `<Dialog/>` component, and not the sub-components.

| Variable | Default Value | Description |
| ----------------- | ------------- | ---------------------------------------------------------------------- |
| --mt-baseFontSize | 1rem | The text size and dimensions of the dialog are based off of this value |
| --mt-fontFamily | 'Roboto' | The font family to use for text |
5 changes: 5 additions & 0 deletions docs/src/components/component-doc.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@
align-items: center;
justify-content: center;
min-height: 150px;
padding: 50px;
background-color: #f2f2f2;
border-radius: 5px 5px 0 0;
margin-top: 50px;
}

.componentDoc_editor .CodeMirror {
min-height: var(--editorHeight, 300px);
}
4 changes: 4 additions & 0 deletions docs/src/components/component-doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class ComponentDoc extends Component {
componentKey,
sourceLink,
materialDocsLink,
editorHeight = '300px',
} = component;

const sourceLinkToUse = sourceLink
Expand Down Expand Up @@ -74,6 +75,9 @@ export class ComponentDoc extends Component {
your changes.
</div>
<Editor
style={{
'--editorHeight': editorHeight,
}}
className="componentDoc_editor"
theme="oceanic-next"
codeText={code}
Expand Down
20 changes: 10 additions & 10 deletions docs/src/vendor/doc-components/editor/editor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import PropTypes from "prop-types";
import React from 'react';
import PropTypes from 'prop-types';

let CodeMirror;
if (typeof document !== 'undefined') {
Expand All @@ -14,15 +14,15 @@ class Editor extends React.Component {
onChange: PropTypes.func,
readOnly: PropTypes.bool,
tabSize: PropTypes.number,
theme: PropTypes.string
theme: PropTypes.string,
};

static defaultProps = {
className: "",
className: '',
lineNumbers: false,
readOnly: false,
tabSize: 2,
theme: "oceanic-next"
theme: 'oceanic-next',
};

componentDidMount() {
Expand All @@ -31,16 +31,16 @@ class Editor extends React.Component {
}

this.editor = CodeMirror.fromTextArea(this.refs.editor, {
mode: "javascript",
mode: 'javascript',
lineNumbers: this.props.lineNumbers,
smartIndent: false,
tabSize: this.props.tabSize,
matchBrackets: true,
theme: this.props.theme,
readOnly: this.props.readOnly
readOnly: this.props.readOnly,
});

this.editor.on("change", this.handleChange);
this.editor.on('change', this.handleChange);
}

componentDidUpdate() {
Expand All @@ -61,10 +61,10 @@ class Editor extends React.Component {
}

render() {
const { className } = this.props;
const { className, style } = this.props;

return (
<div className={className}>
<div className={className} style={style}>
<textarea ref="editor" defaultValue={this.props.codeText} />
</div>
);
Expand Down
2 changes: 2 additions & 0 deletions docs/static.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const readmes = {
icons: fs.readFileSync('./readmes/icons.md', { encoding: 'utf-8' }),
spinner: fs.readFileSync('./readmes/spinner.md', { encoding: 'utf-8' }),
radio: fs.readFileSync('./readmes/radio.md', { encoding: 'utf-8' }),
dialog: fs.readFileSync('./readmes/dialog.md', { encoding: 'utf-8' }),
};

const examples = {
Expand All @@ -25,6 +26,7 @@ const examples = {
icons: fs.readFileSync('./examples/icons.js', { encoding: 'utf-8' }),
spinner: fs.readFileSync('./examples/spinner.js', { encoding: 'utf-8' }),
radio: fs.readFileSync('./examples/radio.js', { encoding: 'utf-8' }),
dialog: fs.readFileSync('./examples/dialog.js', { encoding: 'utf-8' }),
};

// import { addSearchObjects } from './algolia'
Expand Down
21 changes: 12 additions & 9 deletions src/dialog/dialog.css
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
.mt-dialog {
font-family: var(--mt-fontFamily, 'Roboto');
font-size: var(--mt-baseFontSize, 1rem);
text-align: left;
background-color: #fff;
box-shadow: 0 11px 15px -7px rgba(0, 0, 0, 0.2),
0 24px 38px 3px rgba(0, 0, 0, 0.14), 0 9px 46px 8px rgba(0, 0, 0, 0.12);
padding: 0 0 0 1.5em;
text-align: left;
box-shadow: 0 11px 15px -7px rgba(0, 0, 0, 0.2), 0 24px 38px 3px rgba(0, 0, 0, 0.14), 0 9px 46px 8px rgba(0, 0, 0, 0.12);
border-radius: 0.125em;
color: #000;
}

.mt-dialog_title {
padding: 1.5em 0 0;
color: #212121;
font-size: 1.25em;
font-weight: 800;
padding: 1.2em 1.2em 0;
font-weight: 500;
}

.mt-dialog_content {
padding: 1.25em 1.5em 1.5em 0;
color: #757575;
margin: 1.25em 1.5em 1.5em;
}

.mt-dialog_actions {
padding: 0.5em 0.25em 0.5em 1.25em;
padding: 0.5em;
display: flex;
justify-content: flex-end;
}

.mt-dialog_actions .mt-button+.mt-button {
margin-left: 6px;
}
9 changes: 8 additions & 1 deletion src/dialog/dialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';

export default class Dialog extends Component {
class Dialog extends Component {
static Title = ({ className = '', ...props }) => (
<div className={`mt-dialog_title ${className}`} {...props} />
);
Expand All @@ -17,3 +18,9 @@ export default class Dialog extends Component {
return <div className={`mt-dialog ${className}`} {...props} />;
}
}

Dialog.propTypes = {
className: PropTypes.string,
};

export default Dialog;
4 changes: 2 additions & 2 deletions stories/dialog.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ storiesOf('Dialog', module).add('Regular', () => (
Lorem ipsum dolor sit amet consectetur adipisicing elit. Numquam
consequatur enim voluptates nobis perferendis voluptatibus alias modi
voluptate dolorum ipsa amet, aliquam similique blanditiis iusto ipsam,
atque beatae aliquid sit!Lorem ipsum dolor sit amet consectetur
atque beatae aliquid sit! Lorem ipsum dolor sit amet consectetur
adipisicing elit.
</p>
</Dialog.Body>
<Dialog.Actions>
<Button flat>Cancel</Button>
<Button flat>Nevermind</Button>
<Button flat>Accept</Button>
</Dialog.Actions>
</Dialog>
Expand Down

0 comments on commit 0ea1a16

Please sign in to comment.