-
Notifications
You must be signed in to change notification settings - Fork 67
/
dialog-modal-example.js
69 lines (64 loc) · 2.06 KB
/
dialog-modal-example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import * as core from '@pluralsight/ps-design-system-core'
import Button from '@pluralsight/ps-design-system-button'
import Dialog from '@pluralsight/ps-design-system-dialog'
import React from 'react'
import * as Text from '@pluralsight/ps-design-system-text'
import { transparentize } from '@pluralsight/ps-design-system-util'
import { Head } from '../../src/ui/index.js'
export default class DialogModalExample extends React.Component {
constructor(props) {
super(props)
this.state = { isOpen: false }
this.handleButtonClick = this.handleButtonClick.bind(this)
}
handleButtonClick() {
this.setState({ isOpen: !this.state.isOpen })
}
render() {
return (
<div className="page">
<Head />
<div className="app" aria-hidden={this.state.isOpen}>
<Button onClick={this.handleButtonClick}>Open Modal</Button>
</div>
{this.state.isOpen && (
<Dialog modal onClose={this.handleButtonClick}>
<Text.Heading>
<h2>Lorem ipsum dolor sit amet.</h2>
</Text.Heading>
<div style={{ background: core.colors.bone, height: '176px' }} />
<div className="buttons">
<Button appearance={Button.appearances.stroke}>Secondary</Button>
<Button>Primary button</Button>
</div>
</Dialog>
)}
<style jsx>{`
:global(body) {
margin: 0;
}
.page {
display: flex;
justify-content: center;
height: 100vh;
width: 100vw;
background-color: ${transparentize(0.5, core.colors.black)};
}
.app {
display: flex;
justify-content: center;
align-items: center;
}
.buttons {
display: flex;
justify-content: flex-end;
padding-top: ${core.layout.spacingMedium};
}
.buttons > :global(button) {
margin-left: ${core.layout.spacingMedium};
}
`}</style>
</div>
)
}
}