Skip to content

Commit 39f32cc

Browse files
authored
Merge pull request #21 from Upmostly/v1.2
v1.2
2 parents 3b4fab2 + 6670374 commit 39f32cc

10 files changed

+231
-101
lines changed

.npmignore

+18
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,21 @@ examples
44
.babelrc
55
.gitignore
66
webpack.config.js
7+
8+
#tests
9+
test
10+
coverage
11+
12+
#build tools
13+
.travis.yml
14+
.jenkins.yml
15+
.codeclimate.yml
16+
17+
#linters
18+
.jscsrc
19+
.jshintrc
20+
.eslintrc*
21+
22+
#editor settings
23+
.idea
24+
.editorconfig

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,10 @@ Modali can be easily customized by passing in an object of key/value pairs to th
238238
| --- | --- | --- |
239239
| `title` | string | The text displayed in the upper left corner |
240240
| `message` | string | The text displayed in the body of the modal |
241-
| `buttons` | array | Displays components passed in the footer of the modal |
241+
| `buttons` | array | Displays whatever is passed in in the footer |
242242
| `closeButton` | true | Controls the visibility of the close button |
243243
| `animated` | false | Fades in the modal when it mounts to the DOM |
244+
| `centered` | false | Positions the modal in the center of the screen |
244245
| `large` | false | Changes the size of the modal to be 800px wide |
245246
| `overlayClose` | true | Disables clicking the modal overlay to hide it |
246247
| `keyboardClose` | true | Disables the ESC key hiding the modal |
@@ -251,7 +252,7 @@ Example
251252
const [exampleModal, toggleExampleModal] = useModali({
252253
animated: true,
253254
large: true,
254-
closeButton: false
255+
closeButton: false,
255256
});
256257

257258
```
@@ -267,7 +268,7 @@ function handleModalOnHide() {
267268
const [exampleModal, toggleExampleModal] = useModali({
268269
onHide: handleModalOnHide,
269270
large: true,
270-
closeButton: false
271+
closeButton: false,
271272
});
272273

273274
```

examples/src/GithubRibbon.css

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.github-corner:hover .octo-arm {
2+
animation: octocat-wave 560ms ease-in-out
3+
}
4+
5+
@keyframes octocat-wave {
6+
0 %,100% {
7+
transform:rotate(0)
8+
}
9+
20%,60%{
10+
transform:rotate(-25deg)
11+
}
12+
40%,80%{
13+
transform:rotate(10deg)
14+
}
15+
}
16+
17+
@media (max-width:500px) {
18+
.github-corner:hover .octo-arm{
19+
animation:none
20+
}
21+
.github-corner .octo-arm{
22+
animation:octocat-wave 560ms ease-in-out
23+
}
24+
}
25+
26+
svg {
27+
fill:#FD6C6C;
28+
color:#fff;
29+
position: absolute;
30+
top: 0;
31+
border: 0;
32+
right: 0;
33+
}

examples/src/GithubRibbon.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react';
2+
import './GithubRibbon.css';
3+
4+
const GithubRibbon = () => (
5+
<React.Fragment>
6+
<a href="https://github.com/Upmostly/modali" target="_blank" rel="noopener noreferrer" className="github-corner" aria-label="View source on GitHub">
7+
<svg
8+
width="80"
9+
height="80"
10+
viewBox="0 0 250 250"
11+
style={{
12+
fill: '#FD6C6C', color: '#fff', position: 'absolute', top: 0, border: 0, right: 0,
13+
}}
14+
aria-hidden="true"
15+
>
16+
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z" />
17+
<path
18+
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
19+
fill="currentColor"
20+
style={{ transformOrigin: '130px 106px' }}
21+
className="octo-arm"
22+
/>
23+
<path
24+
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
25+
fill="currentColor"
26+
className="octo-body"
27+
/>
28+
</svg>
29+
</a>
30+
</React.Fragment>
31+
);
32+
33+
export default GithubRibbon;

examples/src/OptionsModalsExample.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import React from 'react';
22
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
33
import { okaidia } from 'react-syntax-highlighter/dist/esm/styles/prism';
4-
import { options } from "./snippets/snippets";
4+
import { options } from './snippets/snippets';
55

66
import Modali, { useModali } from '../../src';
7-
import Button from "./Button";
7+
import Button from './Button';
88

99
const OptionsModalsExample = () => {
1010
const [firstModal, toggleFirstModal] = useModali({
1111
animated: true,
1212
large: true,
1313
closeButton: false,
14-
onHide: () => alert(`I'm now hidden`),
14+
onHide: () => alert('I\'m now hidden'),
1515
});
1616
return (
1717
<div className="row mt-5">
@@ -26,18 +26,18 @@ const OptionsModalsExample = () => {
2626
</Button>
2727
</div>
2828
<div className="col-12">
29-
<SyntaxHighlighter language='jsx' style={okaidia}>{options}</SyntaxHighlighter>
29+
<SyntaxHighlighter language="jsx" style={okaidia}>{options}</SyntaxHighlighter>
3030
</div>
3131
<Modali.Modal {...firstModal}>
3232
<div className="row my-3">
3333
<div className="col-12 d-flex justify-content-center">
3434
<p className="m-0">
35-
I'm a larger, animated modal, without a close button 🤘
35+
I'm a larger, animated modal that calls an alert when I close! 🤘
3636
</p>
3737
</div>
3838
</div>
3939
</Modali.Modal>
4040
</div>
41-
)
41+
);
4242
};
4343
export default OptionsModalsExample;

examples/src/index.js

+20-16
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Button from './Button';
88
import MultipleModalsExample from './MultipleModalsExample';
99
import OptionsModalsExample from './OptionsModalsExample';
1010
import CompleteExample from './CompleteExample';
11+
import GithubRibbon from './GithubRibbon';
1112

1213
const App = () => {
1314
const [exampleModal, toggleExampleModal] = useModali({
@@ -28,24 +29,27 @@ const App = () => {
2829
],
2930
});
3031
return (
31-
<div className="container my-5">
32-
<div className="row mt-5">
33-
<div className="col-12 d-flex justify-content-center">
34-
<img src="https://upmostly.com/wp-content/uploads/modali-logo.png" alt="modali logo" style={{ height: '250px' }} />
35-
</div>
36-
<div className="col-12 d-flex justify-content-center mt-5">
37-
<Button handleClick={toggleExampleModal}>
38-
Click me to open a Modal!
39-
</Button>
40-
<Modali.Modal {...exampleModal} />
32+
<React.Fragment>
33+
<GithubRibbon />
34+
<div className="container my-5">
35+
<div className="row mt-5">
36+
<div className="col-12 d-flex justify-content-center">
37+
<img src="https://upmostly.com/wp-content/uploads/modali-logo.png" alt="modali logo" style={{ height: '250px' }} />
38+
</div>
39+
<div className="col-12 d-flex justify-content-center mt-5">
40+
<Button handleClick={toggleExampleModal}>
41+
Click me to open a Modal!
42+
</Button>
43+
<Modali.Modal {...exampleModal} />
44+
</div>
4145
</div>
46+
<Installation />
47+
<BasicExample />
48+
<CompleteExample />
49+
<MultipleModalsExample />
50+
<OptionsModalsExample />
4251
</div>
43-
<Installation />
44-
<BasicExample />
45-
<CompleteExample />
46-
<MultipleModalsExample />
47-
<OptionsModalsExample />
48-
</div>
52+
</React.Fragment>
4953
);
5054
};
5155

examples/src/snippets/snippets.js

+73-73
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
1-
export const installation = `npm install --save modali`;
2-
export const usage = `import Modali, { useModali } from 'modali';`;
3-
export const basicExample = 'import React from \'react\';\n' +
4-
'import Modali, { useModali } from \'modali\';\n' +
5-
'\n' +
6-
'const App = () => {\n' +
7-
' const [exampleModal, toggleExampleModal] = useModali();\n' +
8-
'\n' +
9-
' return (\n' +
10-
' <div className="app">\n' +
11-
' <button onClick={toggleExampleModal}>\n' +
12-
' Click me to open a basic modal\n' +
13-
' </button>\n' +
14-
' <Modali.Modal {...exampleModal}>\n' +
15-
' Hi, I\'m a Modali!\n' +
16-
' </Modali.Modal>\n' +
17-
' </div>\n' +
18-
' );\n' +
19-
'};\n' +
20-
'\n' +
21-
'export default App;';
1+
export const installation = 'npm install --save modali';
2+
export const usage = 'import Modali, { useModali } from \'modali\';';
3+
export const basicExample = 'import React from \'react\';\n'
4+
+ 'import Modali, { useModali } from \'modali\';\n'
5+
+ '\n'
6+
+ 'const App = () => {\n'
7+
+ ' const [exampleModal, toggleExampleModal] = useModali();\n'
8+
+ '\n'
9+
+ ' return (\n'
10+
+ ' <div className="app">\n'
11+
+ ' <button onClick={toggleExampleModal}>\n'
12+
+ ' Click me to open a basic modal\n'
13+
+ ' </button>\n'
14+
+ ' <Modali.Modal {...exampleModal}>\n'
15+
+ ' Hi, I\'m a Modali!\n'
16+
+ ' </Modali.Modal>\n'
17+
+ ' </div>\n'
18+
+ ' );\n'
19+
+ '};\n'
20+
+ '\n'
21+
+ 'export default App;';
2222

23-
export const completeExampleSnippet = 'import React from \'react\';\n' +
24-
'import Modali, { useModali } from \'modali\';\n' +
25-
'\n' +
26-
'const [completeModal, toggleCompleteModal] = useModali({\n' +
27-
' animated: true,\n' +
28-
' title: \'Are you sure?\',\n' +
29-
' message: \'Deleting this user will be permanent.\',\n' +
30-
' buttons: [\n' +
31-
' <Modali.Button\n' +
32-
' label="Cancel"\n' +
33-
' isStyleCancel\n' +
34-
' onClick={() => toggleCompleteModal()}\n' +
35-
' />,\n' +
36-
' <Modali.Button\n' +
37-
' label="Delete"\n' +
38-
' isStyleDestructive\n' +
39-
' onClick={() => deleteUserWithId(123)}\n' +
40-
' />,\n' +
41-
' ],\n' +
42-
'});';
23+
export const completeExampleSnippet = 'import React from \'react\';\n'
24+
+ 'import Modali, { useModali } from \'modali\';\n'
25+
+ '\n'
26+
+ 'const [completeModal, toggleCompleteModal] = useModali({\n'
27+
+ ' animated: true,\n'
28+
+ ' title: \'Are you sure?\',\n'
29+
+ ' message: \'Deleting this user will be permanent.\',\n'
30+
+ ' buttons: [\n'
31+
+ ' <Modali.Button\n'
32+
+ ' label="Cancel"\n'
33+
+ ' isStyleCancel\n'
34+
+ ' onClick={() => toggleCompleteModal()}\n'
35+
+ ' />,\n'
36+
+ ' <Modali.Button\n'
37+
+ ' label="Delete"\n'
38+
+ ' isStyleDestructive\n'
39+
+ ' onClick={() => deleteUserWithId(123)}\n'
40+
+ ' />,\n'
41+
+ ' ],\n'
42+
+ '});';
4343

44-
export const multiple = 'import React from \'react\';\n' +
45-
'import Modali, { useModali } from \'modali\';\n' +
46-
'\n' +
47-
'const App = () => {\n' +
48-
' const [firstModal, toggleFirstModal] = useModali();\n' +
49-
' const [secondModal, toggleSecondModal] = useModali();\n' +
50-
' \n' +
51-
' return (\n' +
52-
' <div className="app">\n' +
53-
' <button onClick={toggleFirstModal}>\n' +
54-
' Click me to open the first modal!\n' +
55-
' </button>\n' +
56-
' <button onClick={toggleSecondModal}>\n' +
57-
' Click me to open the second modal!\n' +
58-
' </button>\n' +
59-
' <Modali.Modal {...firstModal}>\n' +
60-
' Hi, I\'m the first Modali\n' +
61-
' </Modali.Modal>\n' +
62-
' <Modali.Modal {...secondModal}>\n' +
63-
' And I\'m the second Modali\n' +
64-
' </Modali.Modal>\n' +
65-
' </div>\n' +
66-
' );\n' +
67-
'};\n' +
68-
'\n' +
69-
'export default App;';
44+
export const multiple = 'import React from \'react\';\n'
45+
+ 'import Modali, { useModali } from \'modali\';\n'
46+
+ '\n'
47+
+ 'const App = () => {\n'
48+
+ ' const [firstModal, toggleFirstModal] = useModali();\n'
49+
+ ' const [secondModal, toggleSecondModal] = useModali();\n'
50+
+ ' \n'
51+
+ ' return (\n'
52+
+ ' <div className="app">\n'
53+
+ ' <button onClick={toggleFirstModal}>\n'
54+
+ ' Click me to open the first modal!\n'
55+
+ ' </button>\n'
56+
+ ' <button onClick={toggleSecondModal}>\n'
57+
+ ' Click me to open the second modal!\n'
58+
+ ' </button>\n'
59+
+ ' <Modali.Modal {...firstModal}>\n'
60+
+ ' Hi, I\'m the first Modali\n'
61+
+ ' </Modali.Modal>\n'
62+
+ ' <Modali.Modal {...secondModal}>\n'
63+
+ ' And I\'m the second Modali\n'
64+
+ ' </Modali.Modal>\n'
65+
+ ' </div>\n'
66+
+ ' );\n'
67+
+ '};\n'
68+
+ '\n'
69+
+ 'export default App;';
7070

71-
export const options = 'const [exampleModal, toggleExampleModal] = useModali({\n' +
72-
' animated: true,\n' +
73-
' large: true,\n' +
74-
' closeButton: false,\n' +
75-
' onHide: () => alert(`I\'m hidden`),\n' +
76-
'});';
71+
export const options = 'const [exampleModal, toggleExampleModal] = useModali({\n'
72+
+ ' animated: true,\n'
73+
+ ' large: true,\n'
74+
+ ' closeButton: false,\n'
75+
+ ' onHide: () => alert(`I\'m hidden`),\n'
76+
+ '});';

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "modali",
3-
"version": "1.1.1",
3+
"version": "1.2.0",
44
"description": "A delightful modal dialog component for React, built from the ground up to support React Hooks.",
55
"main": "dist/index.js",
66
"license": "ISC",

src/index.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ const Modal = ({
8686
);
8787
}
8888

89+
const modaliWrapperClass = classNames({
90+
'modali-wrapper': true,
91+
'modali-wrapper-centered': options && options.centered,
92+
});
93+
8994
const modaliClass = classNames({
9095
modali: true,
9196
'modali-size-large': options && options.large,
@@ -96,7 +101,7 @@ const Modal = ({
96101
return isModalVisible ? ReactDOM.createPortal(
97102
<React.Fragment>
98103
<div className="modali-overlay" />
99-
<div className="modali-wrapper" aria-modal aria-hidden tabIndex={-1} role="dialog" onClick={handleOverlayClicked}>
104+
<div className={modaliWrapperClass} aria-modal aria-hidden tabIndex={-1} role="dialog" onClick={handleOverlayClicked}>
100105
<div className={modaliClass}>
101106
<div className="modali-content">
102107
{options !== undefined && options.closeButton === false ? null : (

0 commit comments

Comments
 (0)