You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Make HKModal a controlled component again
Also update stories to properly consume the button events.
* Correction to first line of state flow
* Update storyshots snaps
* Get that lint off ya shoulder
* Adjust transition easing of flyout animation
* Address feedback
* Update storyshots
* Document HKModal in README
* Add an HKModal example with a type-to-confirm field
* Use HKButton for "Show the Modal"
* Break HKModal stories into initially open vs closed
Copy file name to clipboardExpand all lines: README.md
+53Lines changed: 53 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,60 @@ If you want to use `HKFlagIcon`, you will need to tell Webpack to copy the flag
36
36
See [react-hk-components.herokuapp.com](https://react-hk-components.herokuapp.com)
37
37
for a complete list of components that are available.
38
38
39
+
#### HKModal
40
+
41
+
The HKModal component displays modal dialogs of two kinds: normal, which appear in the middle of the browser viewport, and flyout, which slides in from the right. It takes the following props:
42
+
43
+
***`isFlyout`**: `boolean?`. Defaults to false.
44
+
***`show`**: `boolean`. Set it to `true` in order to trigger display of the modal, or `false` to trigger hiding.
45
+
***`type`**: `string?`. Set to `destructive` if you want the title of the modal to be rendered in red.
46
+
***`onDismiss`**: `(value?: string) => any`. A handler that is invoked with the close value when the modal is dismissed. Closing the modal by clicking outside the modal or by clicking on the X at the top-right of the modal will result in the handler being invoked with a value of `cancel`.
47
+
***`header`**: JSX element. What is rendered in the header of the modal.
48
+
***`buttons`**: `IButtonDefinition[]?`: an optional array of button definitions. These will be rendered left-to-right as buttons in the footer of the modal.
49
+
50
+
The contents of the modal are the children passed in the body of the react element, e.g. `<HKModal> stuff to render in body of modal </HKModal>`
51
+
52
+
Buttons are defined as follows:
53
+
54
+
***`text`**: `string`. The text on the button
55
+
***`type`**: `Button.Type`. Primary, secondary, danger, etc.
56
+
***`disabled`**: `boolean`. Set to `true` if you want the button disabled.
57
+
***`value`**: `string`. The value associated with the button. This is what will be remitted to the `onDismiss` handler when the user closes the modal by clicking on this button.
58
+
59
+
So here's a working example:
60
+
61
+
```tsx
62
+
publicclassMyModalWrapperextendsReact.Component {
63
+
handleDismiss = (value?:string):any=> {
64
+
switch(value) {
65
+
case'ok':
66
+
// handle the OK case
67
+
break
68
+
casecancel:
69
+
default:
70
+
// handle the cancel case, which is also the default
0 commit comments