Skip to content

Commit

Permalink
add PropTypes for AlertDialog, Dialog, and WindowSize; fix warnings i…
Browse files Browse the repository at this point in the history
…n Rect examples
  • Loading branch information
Filip Danić authored and ryanflorence committed Jan 4, 2019
1 parent d069b01 commit 68fd4f2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
16 changes: 16 additions & 0 deletions packages/alert-dialog/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Component from "@reach/component-component";
import { DialogOverlay, DialogContent } from "@reach/dialog";
import { Consumer as IdConsumer } from "@reach/utils/lib/IdContext";
import invariant from "invariant";
import { func, bool, node } from "prop-types";

let AlertDialogContext = createContext();

Expand Down Expand Up @@ -30,6 +31,15 @@ let AlertDialogOverlay = ({ leastDestructiveRef, ...props }) => (
</IdConsumer>
);

let alertDialogPropTypes = {
isOpen: bool,
onDismiss: func,
leastDestructiveRef: func,
children: node
};

AlertDialogOverlay.propType = alertDialogPropTypes;

let AlertDialogContent = ({ children, ...props }) => (
<AlertDialogContext.Consumer>
{refs => (
Expand Down Expand Up @@ -60,6 +70,10 @@ let AlertDialogContent = ({ children, ...props }) => (
</AlertDialogContext.Consumer>
);

AlertDialogContent.propTypes = {
children: node
};

let AlertDialogLabel = props => (
<AlertDialogContext.Consumer>
{({ labelId }) => (
Expand All @@ -82,6 +96,8 @@ let AlertDialog = ({ isOpen, onDismiss, leastDestructiveRef, ...props }) => (
</AlertDialogOverlay>
);

AlertDialog.propType = alertDialogPropTypes;

export {
AlertDialog,
AlertDialogLabel,
Expand Down
6 changes: 6 additions & 0 deletions packages/dialog/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Component from "@reach/component-component";
import Portal from "@reach/portal";
import { checkStyles, wrapEvent } from "@reach/utils";
import createFocusTrap from "focus-trap";
import { func, bool } from "prop-types";

let createAriaHider = dialogNode => {
let originalValues = [];
Expand Down Expand Up @@ -139,4 +140,9 @@ let Dialog = ({ isOpen, onDismiss = k, ...props }) => (
</DialogOverlay>
);

Dialog.propTypes = {
isOpen: bool,
onDismiss: func
};

export { DialogOverlay, DialogContent, Dialog };
2 changes: 1 addition & 1 deletion packages/rect/examples/basic.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export let Example = () => (
{({ ref, rect }) => (
<div>
<pre>{JSON.stringify(rect, null, 2)}</pre>
<textarea>resize this</textarea>
<textarea defaultValue="resize this" />
<span
ref={ref}
contentEditable
Expand Down
2 changes: 1 addition & 1 deletion packages/rect/examples/pin.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Example extends React.Component {
<Rect observe={this.state.pin}>
{({ ref, rect }) => (
<div>
<textarea>resize this</textarea>
<textarea defaultValue="resize this" />
<span
ref={ref}
contentEditable
Expand Down

0 comments on commit 68fd4f2

Please sign in to comment.