├── .gitignore
├── .npmignore
├── LICENSE
├── README.md
├── example
├── dist
│ ├── JSXTransformer.js
│ ├── app.css
│ ├── app.js
│ ├── bundle.js
│ ├── codemirror.css
│ ├── codemirror.js
│ ├── common.js
│ ├── index.html
│ └── javascript.js
└── src
│ ├── app.js
│ ├── app.less
│ └── index.html
├── gulpfile.js
├── package.json
└── src
├── Boron.js
├── DropModal.js
├── FadeModal.js
├── FlyModal.js
├── OutlineModal.js
├── ScaleModal.js
├── WaveModal.js
└── modalFactory.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Coverage tools
11 | lib-cov
12 | coverage
13 |
14 | # Compiled binary addons (http://nodejs.org/api/addons.html)
15 | build/Release
16 |
17 | # Dependency directory
18 | node_modules
19 | .idea
20 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | example
2 | src
3 | bower.json
4 | gulpfile.js
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015-present Yuanyan Cao
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Boron [](http://badge.fury.io/js/boron)
2 | =====
3 |
4 | [](http://start.thinkful.com/react/?utm_source=github&utm_medium=badge&utm_campaign=boron)
5 |
6 | A collection of dialog animations with React.js.
7 |
8 | * React 0.14+ Use `boron 0.2`
9 | * React 0.12+ Use `boron 0.1`
10 |
11 | ## Demo & Examples
12 |
13 | Live demo: [yuanyan.github.io/boron](http://yuanyan.github.io/boron/)
14 |
15 | To build the examples locally, run:
16 |
17 | ```
18 | npm install
19 | gulp dev
20 | ```
21 |
22 | Then open [`localhost:9999`](http://localhost:9999) in a browser.
23 |
24 | ## Installation
25 |
26 | The easiest way to use `boron` is to install it from NPM and include it in your own React build process (using [Browserify](http://browserify.org), etc).
27 |
28 | You can also use the standalone build by including `dist/boron.js` in your page. If you use this, make sure you have already included React, and it is available as a global variable.
29 |
30 | ```
31 | npm install boron --save
32 | ```
33 |
34 | ## Usage
35 |
36 | ``` javascript
37 | var Modal = require('boron/DropModal');
38 | var Example = React.createClass({
39 | showModal: function(){
40 | this.refs.modal.show();
41 | },
42 | hideModal: function(){
43 | this.refs.modal.hide();
44 | },
45 |
46 | callback: function(event){
47 | console.log(event);
48 | },
49 |
50 | render: function() {
51 | return (
52 |
53 | Open
54 |
55 | I am a dialog
56 | Close
57 |
58 |
59 | );
60 | }
61 | });
62 | ```
63 |
64 | ## Props
65 |
66 | * className - Add custom class name.
67 | * keyboard - Receive a callback function or a boolean to choose to close the modal when escape key is pressed.
68 | * backdrop - Includes a backdrop element.
69 | * closeOnClick - Close the backdrop element when clicked.
70 | * onShow - Show callback.
71 | * onHide - Hide callback. Argument is the source of the hide action, one of:
72 | * hide - hide() method is the cause of the hide.
73 | * toggle - toggle() method is the cause of the hide
74 | * keyboard - keyboard (escape key) is the cause of the hide
75 | * backdrop - backdrop click is the cause of the hide
76 | * [any] - custom argument passed by invoking code into the hide() method when called directly.
77 | * modalStyle - CSS styles to apply to the modal
78 | * backdropStyle - CSS styles to apply to the backdrop
79 | * contentStyle - CSS styles to apply to the modal's content
80 |
81 | Note: If the hide() method is called directly, a custom source string can be
82 | passed as the argument, as noted above. For example, this might be useful if
83 | if multiple actions could cause the hide and it was desirable to know which of those
84 | actions was the trigger for the given onHide callback).
85 |
86 | # Custom Styles
87 | Objects consisting of CSS properties/values can be passed as props to the Modal component.
88 | The values for the CSS properties will either add new properties or override the default property value set for that Modal type.
89 |
90 | Modal with 80% width:
91 | ``` javascript
92 | var Modal = require('boron/ScaleModal');
93 |
94 | // Style object
95 | var modalStyle = {
96 | width: '80%'
97 | };
98 |
99 | var Example = React.createClass({
100 | showModal: function(){
101 | this.refs.modal.show();
102 | },
103 | hideModal: function(){
104 | this.refs.modal.hide();
105 | },
106 | render: function() {
107 | return (
108 |
109 | Open
110 |
111 | I am a dialog
112 | Close
113 |
114 |
115 | );
116 | }
117 | });
118 | ```
119 |
120 | Red backdrop with a blue modal, rotated at 45 degrees:
121 | ``` javascript
122 | var Modal = require('boron/FlyModal');
123 |
124 | // Individual styles for the modal, modal content, and backdrop
125 | var modalStyle = {
126 | transform: 'rotate(45deg) translateX(-50%)',
127 | };
128 |
129 | var backdropStyle = {
130 | backgroundColor: 'red'
131 | };
132 |
133 | var contentStyle = {
134 | backgroundColor: 'blue',
135 | height: '100%'
136 | };
137 |
138 | var Example = React.createClass({
139 | showModal: function(){
140 | this.refs.modal.show();
141 | },
142 | hideModal: function(){
143 | this.refs.modal.hide();
144 | },
145 | render: function() {
146 | return (
147 |
148 | Open
149 |
150 | I am a dialog
151 | Close
152 |
153 |
154 | );
155 | }
156 | });
157 | ```
158 |
159 |
160 | ## Modals
161 |
162 | * DropModal
163 | * FadeModal
164 | * FlyModal
165 | * OutlineModal
166 | * ScaleModal
167 | * WaveModal
168 |
169 | ## Browser Support
170 |
171 |  |  |  |  | 
172 | --- | --- | --- | --- | --- |
173 | IE 10+ ✔ | Chrome 4.0+ ✔ | Firefox 16.0+ ✔ | Opera 15.0+ ✔ | Safari 4.0+ ✔ |
174 |
175 | ## License
176 |
177 | Boron is [MIT licensed](./LICENSE).
178 |
--------------------------------------------------------------------------------
/example/dist/app.css:
--------------------------------------------------------------------------------
1 | *,
2 | *:before,
3 | *:after {
4 | -webkit-box-sizing: inherit;
5 | -moz-box-sizing: inherit;
6 | box-sizing: inherit;
7 | }
8 | html {
9 | -ms-text-size-adjust: 100%;
10 | -webkit-text-size-adjust: 100%;
11 | overflow-x: hidden;
12 | }
13 | body {
14 | background: #eee;
15 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
16 | margin: 0;
17 | line-height: 1.5;
18 | color: #2b303b;
19 | -webkit-box-sizing: border-box;
20 | -moz-box-sizing: border-box;
21 | box-sizing: border-box;
22 | -moz-osx-font-smoothing: grayscale;
23 | -webkit-font-smoothing: antialiased;
24 | }
25 | h1 {
26 | font-size: 2em;
27 | font-weight: 500;
28 | margin: 1em auto;
29 | text-align: center;
30 | }
31 | h2 {
32 | font-size: 32px;
33 | font-size: 2rem;
34 | }
35 | .center {
36 | text-align: center;
37 | }
38 | .example {
39 | margin-bottom: 20px;
40 | }
41 | .playground:after {
42 | content: "";
43 | display: table;
44 | clear: both;
45 | background: white;
46 | }
47 | .playgroundTab {
48 | border-bottom: none !important;
49 | border-radius: 3px 3px 0 0;
50 | padding: 6px 8px;
51 | font-size: 12px;
52 | font-weight: bold;
53 | color: #C94E50;
54 | display: inline-block;
55 | cursor: pointer;
56 | }
57 | .playgroundCode,
58 | .playgroundTab,
59 | .playgroundPreview {
60 | border: 1px solid rgba(16, 16, 16, 0.1);
61 | background: white;
62 | }
63 | .playgroundCode,
64 | .playgroundPreview {
65 | display: block;
66 | border-radius: 0 3px 3px 3px;
67 | }
68 | /* Layout */
69 | .container {
70 | margin: 0 auto;
71 | max-width: 960px;
72 | padding-left: 1em;
73 | padding-right: 1em;
74 | }
75 | .row {
76 | padding: 20px 0;
77 | padding: 1rem 0;
78 | }
79 | /* header */
80 | header {
81 | position: relative;
82 | padding-top: 36px;
83 | padding-bottom: 45px;
84 | margin-bottom: 3rem;
85 | }
86 | header:before {
87 | content: "";
88 | background: #C94E50;
89 | box-shadow: 0 15px 0 #B64042, 0 30px 0 #A33739, 0 45px 0 #942527;
90 | -webkit-transform: rotate(-5deg);
91 | -moz-transform: rotate(-5deg);
92 | transform: rotate(-5deg);
93 | margin-top: -170px;
94 | position: absolute;
95 | top: 0;
96 | right: -20%;
97 | left: -20%;
98 | bottom: 0;
99 | }
100 | .logo {
101 | font-size: 24px;
102 | font-size: 1.5rem;
103 | line-height: 1;
104 | height: 230px;
105 | margin: 0 auto;
106 | padding: 15px;
107 | position: relative;
108 | text-align: center;
109 | width: 230px;
110 | background: #C94E50;
111 | color: #fff;
112 | border: 22px solid #fff;
113 | text-rendering: optimizeLegibility;
114 | }
115 | .logo:before {
116 | content: "B";
117 | font-size: 140px;
118 | position: absolute;
119 | right: 0;
120 | bottom: 0;
121 | left: 0;
122 | line-height: 1;
123 | pointer-events: none;
124 | }
125 | main {
126 | padding-top: 36px;
127 | }
128 | .installer {
129 | display: inline-block;
130 | background: #2b303b;
131 | border: 1px solid #16191F;
132 | color: #fff;
133 | font-family: "Source Code Pro", monospace;
134 | font-size: 18px;
135 | line-height: 1.2;
136 | margin: 0 auto;
137 | padding: 16px 32px;
138 | }
139 | footer {
140 | background: #2b303b;
141 | color: #fff;
142 | }
143 | footer a {
144 | font-weight: 700;
145 | color: #C94E50;
146 | text-decoration: none;
147 | }
148 | footer a:hover,
149 | footer a:focus {
150 | color: #fff;
151 | }
152 | .CodeMirror {
153 | height: 800px;
154 | }
155 | .blur {
156 | -webkit-animation: blur 10s 3s ease-out infinite;
157 | }
158 | @-webkit-keyframes blur {
159 | from {
160 | transform: scaleX(1.1) scaleY(1.1);
161 | opacity: 0.8;
162 | }
163 | }
164 | .demo-enter {
165 | opacity: 0.01;
166 | height: 0px;
167 | padding: 0px 10px !important;
168 | transition: opacity 500ms ease-out, padding 500ms ease-out, height 500ms ease-out;
169 | }
170 | .demo-enter.demo-enter-active {
171 | opacity: 1;
172 | height: 16px;
173 | padding: 10px !important;
174 | }
175 | .demo-leave {
176 | opacity: 1;
177 | height: 16px;
178 | transition: opacity 500ms ease-out, padding 500ms ease-out, height 500ms ease-out;
179 | }
180 | .demo-leave.demo-leave-active {
181 | opacity: 0;
182 | height: 0px;
183 | padding: 0px 10px !important;
184 | }
185 |
--------------------------------------------------------------------------------
/example/dist/app.js:
--------------------------------------------------------------------------------
1 | require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o WebkitTransition)
61 | module.exports = function(prop, isSupportTest) {
62 |
63 | var vendorProp;
64 | if (prop in builtinStyle) return prop;
65 |
66 | var UpperProp = prop.charAt(0).toUpperCase() + prop.substr(1);
67 |
68 | if (domVendorPrefix) {
69 |
70 | vendorProp = domVendorPrefix + UpperProp;
71 | if (vendorProp in builtinStyle) {
72 | return vendorProp;
73 | }
74 | } else {
75 |
76 | for (var i = 0; i < prefixes.length; ++i) {
77 | vendorProp = prefixes[i] + UpperProp;
78 | if (vendorProp in builtinStyle) {
79 | domVendorPrefix = prefixes[i];
80 | return vendorProp;
81 | }
82 | }
83 | }
84 |
85 | // if support test, not fallback to origin prop name
86 | if (!isSupportTest) {
87 | return prop;
88 | }
89 |
90 | }
91 |
92 | },{"./builtinStyle":2}],5:[function(require,module,exports){
93 | 'use strict';
94 |
95 | var insertRule = require('./insertRule');
96 | var vendorPrefix = require('./getVendorPrefix')();
97 | var index = 0;
98 |
99 | module.exports = function(keyframes) {
100 | // random name
101 | var name = 'anim_' + (++index) + (+new Date);
102 | var css = "@" + vendorPrefix + "keyframes " + name + " {";
103 |
104 | for (var key in keyframes) {
105 | css += key + " {";
106 |
107 | for (var property in keyframes[key]) {
108 | var part = ":" + keyframes[key][property] + ";";
109 | // We do vendor prefix for every property
110 | css += vendorPrefix + property + part;
111 | css += property + part;
112 | }
113 |
114 | css += "}";
115 | }
116 |
117 | css += "}";
118 |
119 | insertRule(css);
120 |
121 | return name
122 | }
123 |
124 | },{"./getVendorPrefix":3,"./insertRule":6}],6:[function(require,module,exports){
125 | 'use strict';
126 |
127 | var extraSheet;
128 |
129 | module.exports = function(css) {
130 |
131 | if (!extraSheet) {
132 | // First time, create an extra stylesheet for adding rules
133 | extraSheet = document.createElement('style');
134 | document.getElementsByTagName('head')[0].appendChild(extraSheet);
135 | // Keep reference to actual StyleSheet object (`styleSheet` for IE < 9)
136 | extraSheet = extraSheet.sheet || extraSheet.styleSheet;
137 | }
138 |
139 | var index = (extraSheet.cssRules || extraSheet.rules).length;
140 | extraSheet.insertRule(css, index);
141 |
142 | return extraSheet;
143 | }
144 |
145 | },{}],7:[function(require,module,exports){
146 | 'use strict';
147 |
148 | /**
149 | * EVENT_NAME_MAP is used to determine which event fired when a
150 | * transition/animation ends, based on the style property used to
151 | * define that event.
152 | */
153 | var EVENT_NAME_MAP = {
154 | transitionend: {
155 | 'transition': 'transitionend',
156 | 'WebkitTransition': 'webkitTransitionEnd',
157 | 'MozTransition': 'mozTransitionEnd',
158 | 'OTransition': 'oTransitionEnd',
159 | 'msTransition': 'MSTransitionEnd'
160 | },
161 |
162 | animationend: {
163 | 'animation': 'animationend',
164 | 'WebkitAnimation': 'webkitAnimationEnd',
165 | 'MozAnimation': 'mozAnimationEnd',
166 | 'OAnimation': 'oAnimationEnd',
167 | 'msAnimation': 'MSAnimationEnd'
168 | }
169 | };
170 |
171 | var endEvents = [];
172 |
173 | function detectEvents() {
174 | var testEl = document.createElement('div');
175 | var style = testEl.style;
176 |
177 | // On some platforms, in particular some releases of Android 4.x,
178 | // the un-prefixed "animation" and "transition" properties are defined on the
179 | // style object but the events that fire will still be prefixed, so we need
180 | // to check if the un-prefixed events are useable, and if not remove them
181 | // from the map
182 | if (!('AnimationEvent' in window)) {
183 | delete EVENT_NAME_MAP.animationend.animation;
184 | }
185 |
186 | if (!('TransitionEvent' in window)) {
187 | delete EVENT_NAME_MAP.transitionend.transition;
188 | }
189 |
190 | for (var baseEventName in EVENT_NAME_MAP) {
191 | var baseEvents = EVENT_NAME_MAP[baseEventName];
192 | for (var styleName in baseEvents) {
193 | if (styleName in style) {
194 | endEvents.push(baseEvents[styleName]);
195 | break;
196 | }
197 | }
198 | }
199 | }
200 |
201 | if (typeof window !== 'undefined') {
202 | detectEvents();
203 | }
204 |
205 |
206 | // We use the raw {add|remove}EventListener() call because EventListener
207 | // does not know how to remove event listeners and we really should
208 | // clean up. Also, these events are not triggered in older browsers
209 | // so we should be A-OK here.
210 |
211 | function addEventListener(node, eventName, eventListener) {
212 | node.addEventListener(eventName, eventListener, false);
213 | }
214 |
215 | function removeEventListener(node, eventName, eventListener) {
216 | node.removeEventListener(eventName, eventListener, false);
217 | }
218 |
219 | module.exports = {
220 | addEndEventListener: function(node, eventListener) {
221 | if (endEvents.length === 0) {
222 | // If CSS transitions are not supported, trigger an "end animation"
223 | // event immediately.
224 | window.setTimeout(eventListener, 0);
225 | return;
226 | }
227 | endEvents.forEach(function(endEvent) {
228 | addEventListener(node, endEvent, eventListener);
229 | });
230 | },
231 |
232 | removeEndEventListener: function(node, eventListener) {
233 | if (endEvents.length === 0) {
234 | return;
235 | }
236 | endEvents.forEach(function(endEvent) {
237 | removeEventListener(node, endEvent, eventListener);
238 | });
239 | }
240 | };
241 |
242 | },{}],8:[function(require,module,exports){
243 | var modalFactory = require('./modalFactory');
244 | var insertKeyframesRule = require('domkit/insertKeyframesRule');
245 | var appendVendorPrefix = require('domkit/appendVendorPrefix');
246 |
247 | var animation = {
248 | show: {
249 | animationDuration: '0.4s',
250 | animationTimingFunction: 'cubic-bezier(0.7,0,0.3,1)'
251 | },
252 |
253 | hide: {
254 | animationDuration: '0.4s',
255 | animationTimingFunction: 'cubic-bezier(0.7,0,0.3,1)'
256 | },
257 |
258 | showModalAnimation: insertKeyframesRule({
259 | '0%': {
260 | opacity: 0,
261 | transform: 'translate3d(-50%, -300px, 0)'
262 | },
263 | '100%': {
264 | opacity: 1,
265 | transform: 'translate3d(-50%, -50%, 0)'
266 | }
267 | }),
268 |
269 | hideModalAnimation: insertKeyframesRule({
270 | '0%': {
271 | opacity: 1,
272 | transform: 'translate3d(-50%, -50%, 0)'
273 | },
274 | '100%': {
275 | opacity: 0,
276 | transform: 'translate3d(-50%, 100px, 0)'
277 | }
278 | }),
279 |
280 | showBackdropAnimation: insertKeyframesRule({
281 | '0%': {
282 | opacity: 0
283 | },
284 | '100%': {
285 | opacity: 0.9
286 | }
287 | }),
288 |
289 | hideBackdropAnimation: insertKeyframesRule({
290 | '0%': {
291 | opacity: 0.9
292 | },
293 | '100%': {
294 | opacity: 0
295 | }
296 | }),
297 |
298 | showContentAnimation: insertKeyframesRule({
299 | '0%': {
300 | opacity: 0,
301 | transform: 'translate3d(0, -20px, 0)'
302 | },
303 | '100%': {
304 | opacity: 1,
305 | transform: 'translate3d(0, 0, 0)'
306 | }
307 | }),
308 |
309 | hideContentAnimation: insertKeyframesRule({
310 | '0%': {
311 | opacity: 1,
312 | transform: 'translate3d(0, 0, 0)'
313 | },
314 | '100%': {
315 | opacity: 0,
316 | transform: 'translate3d(0, 50px, 0)'
317 | }
318 | })
319 | };
320 |
321 | var showAnimation = animation.show;
322 | var hideAnimation = animation.hide;
323 | var showModalAnimation = animation.showModalAnimation;
324 | var hideModalAnimation = animation.hideModalAnimation;
325 | var showBackdropAnimation = animation.showBackdropAnimation;
326 | var hideBackdropAnimation = animation.hideBackdropAnimation;
327 | var showContentAnimation = animation.showContentAnimation;
328 | var hideContentAnimation = animation.hideContentAnimation;
329 |
330 | module.exports = modalFactory({
331 | getRef: function(willHidden) {
332 | return 'modal';
333 | },
334 | getModalStyle: function(willHidden) {
335 | return appendVendorPrefix({
336 | position: "fixed",
337 | width: "500px",
338 | transform: "translate3d(-50%, -50%, 0)",
339 | top: "50%",
340 | left: "50%",
341 | backgroundColor: "white",
342 | zIndex: 1050,
343 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
344 | animationFillMode: 'forwards',
345 | animationName: willHidden ? hideModalAnimation : showModalAnimation,
346 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
347 | })
348 | },
349 | getBackdropStyle: function(willHidden) {
350 | return appendVendorPrefix({
351 | position: "fixed",
352 | top: 0,
353 | right: 0,
354 | bottom: 0,
355 | left: 0,
356 | zIndex: 1040,
357 | backgroundColor: "#373A47",
358 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
359 | animationFillMode: 'forwards',
360 | animationName: willHidden ? hideBackdropAnimation : showBackdropAnimation,
361 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
362 | });
363 | },
364 | getContentStyle: function(willHidden) {
365 | return appendVendorPrefix({
366 | margin: 0,
367 | opacity: 0,
368 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
369 | animationFillMode: 'forwards',
370 | animationDelay: '0.25s',
371 | animationName: showContentAnimation,
372 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
373 | })
374 | }
375 | });
376 |
377 | },{"./modalFactory":14,"domkit/appendVendorPrefix":1,"domkit/insertKeyframesRule":5}],9:[function(require,module,exports){
378 | var modalFactory = require('./modalFactory');
379 | var insertKeyframesRule = require('domkit/insertKeyframesRule');
380 | var appendVendorPrefix = require('domkit/appendVendorPrefix');
381 |
382 | var animation = {
383 | show: {
384 | animationDuration: '0.3s',
385 | animationTimingFunction: 'ease-out'
386 | },
387 | hide: {
388 | animationDuration: '0.3s',
389 | animationTimingFunction: 'ease-out'
390 | },
391 | showContentAnimation: insertKeyframesRule({
392 | '0%': {
393 | opacity: 0
394 | },
395 | '100%': {
396 | opacity: 1
397 | }
398 | }),
399 |
400 | hideContentAnimation: insertKeyframesRule({
401 | '0%': {
402 | opacity: 1
403 | },
404 | '100%': {
405 | opacity: 0
406 | }
407 | }),
408 |
409 | showBackdropAnimation: insertKeyframesRule({
410 | '0%': {
411 | opacity: 0
412 | },
413 | '100%': {
414 | opacity: 0.9
415 | },
416 | }),
417 |
418 | hideBackdropAnimation: insertKeyframesRule({
419 | '0%': {
420 | opacity: 0.9
421 | },
422 | '100%': {
423 | opacity: 0
424 | }
425 | })
426 | };
427 |
428 | var showAnimation = animation.show;
429 | var hideAnimation = animation.hide;
430 | var showContentAnimation = animation.showContentAnimation;
431 | var hideContentAnimation = animation.hideContentAnimation;
432 | var showBackdropAnimation = animation.showBackdropAnimation;
433 | var hideBackdropAnimation = animation.hideBackdropAnimation;
434 |
435 | module.exports = modalFactory({
436 | getRef: function(willHidden) {
437 | return 'content';
438 | },
439 | getModalStyle: function(willHidden) {
440 | return appendVendorPrefix({
441 | zIndex: 1050,
442 | position: "fixed",
443 | width: "500px",
444 | transform: "translate3d(-50%, -50%, 0)",
445 | top: "50%",
446 | left: "50%"
447 | })
448 | },
449 | getBackdropStyle: function(willHidden) {
450 | return appendVendorPrefix({
451 | position: "fixed",
452 | top: 0,
453 | right: 0,
454 | bottom: 0,
455 | left: 0,
456 | zIndex: 1040,
457 | backgroundColor: "#373A47",
458 | animationFillMode: 'forwards',
459 | animationDuration: '0.3s',
460 | animationName: willHidden ? hideBackdropAnimation : showBackdropAnimation,
461 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
462 | });
463 | },
464 | getContentStyle: function(willHidden) {
465 | return appendVendorPrefix({
466 | margin: 0,
467 | backgroundColor: "white",
468 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
469 | animationFillMode: 'forwards',
470 | animationName: willHidden ? hideContentAnimation : showContentAnimation,
471 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
472 | })
473 | }
474 | });
475 |
476 | },{"./modalFactory":14,"domkit/appendVendorPrefix":1,"domkit/insertKeyframesRule":5}],10:[function(require,module,exports){
477 | var modalFactory = require('./modalFactory');
478 | var insertKeyframesRule = require('domkit/insertKeyframesRule');
479 | var appendVendorPrefix = require('domkit/appendVendorPrefix');
480 |
481 | var animation = {
482 | show: {
483 | animationDuration: '0.5s',
484 | animationTimingFunction: 'ease-out'
485 | },
486 | hide: {
487 | animationDuration: '0.5s',
488 | animationTimingFunction: 'ease-out'
489 | },
490 | showContentAnimation: insertKeyframesRule({
491 |
492 | '0%': {
493 | opacity: 0,
494 | transform: 'translate3d(calc(-100vw - 50%), 0, 0)'
495 | },
496 | '50%': {
497 | opacity: 1,
498 | transform: 'translate3d(100px, 0, 0)'
499 | },
500 | '100%': {
501 | opacity: 1,
502 | transform: 'translate3d(0, 0, 0)'
503 | }
504 | }),
505 |
506 | hideContentAnimation: insertKeyframesRule({
507 |
508 | '0%': {
509 | opacity: 1,
510 | transform: 'translate3d(0, 0, 0)'
511 | },
512 | '50%': {
513 | opacity: 1,
514 | transform: 'translate3d(-100px, 0, 0) scale3d(1.1, 1.1, 1)'
515 | },
516 | '100%': {
517 | opacity: 0,
518 | transform: 'translate3d(calc(100vw + 50%), 0, 0)'
519 | },
520 | }),
521 |
522 | showBackdropAnimation: insertKeyframesRule({
523 | '0%': {
524 | opacity: 0
525 | },
526 | '100%': {
527 | opacity: 0.9
528 | },
529 | }),
530 |
531 | hideBackdropAnimation: insertKeyframesRule({
532 | '0%': {
533 | opacity: 0.9
534 | },
535 | '90%': {
536 | opactiy: 0.9
537 | },
538 | '100%': {
539 | opacity: 0
540 | }
541 | })
542 | };
543 |
544 | var showAnimation = animation.show;
545 | var hideAnimation = animation.hide;
546 | var showContentAnimation = animation.showContentAnimation;
547 | var hideContentAnimation = animation.hideContentAnimation;
548 | var showBackdropAnimation = animation.showBackdropAnimation;
549 | var hideBackdropAnimation = animation.hideBackdropAnimation;
550 |
551 | module.exports = modalFactory({
552 | getRef: function(willHidden) {
553 | return 'content';
554 | },
555 | getModalStyle: function(willHidden) {
556 | return appendVendorPrefix({
557 | zIndex: 1050,
558 | position: "fixed",
559 | width: "500px",
560 | transform: "translate3d(-50%, -50%, 0)",
561 | top: "50%",
562 | left: "50%"
563 | })
564 | },
565 | getBackdropStyle: function(willHidden) {
566 | return appendVendorPrefix({
567 | position: "fixed",
568 | top: 0,
569 | right: 0,
570 | bottom: 0,
571 | left: 0,
572 | zIndex: 1040,
573 | backgroundColor: "#373A47",
574 | animationFillMode: 'forwards',
575 | animationDuration: '0.3s',
576 | animationName: willHidden ? hideBackdropAnimation : showBackdropAnimation,
577 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
578 | });
579 | },
580 | getContentStyle: function(willHidden) {
581 | return appendVendorPrefix({
582 | margin: 0,
583 | backgroundColor: "white",
584 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
585 | animationFillMode: 'forwards',
586 | animationName: willHidden ? hideContentAnimation : showContentAnimation,
587 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
588 | })
589 | }
590 | });
591 |
592 | },{"./modalFactory":14,"domkit/appendVendorPrefix":1,"domkit/insertKeyframesRule":5}],11:[function(require,module,exports){
593 | var React = require('react');
594 | var modalFactory = require('./modalFactory');
595 | var insertKeyframesRule = require('domkit/insertKeyframesRule');
596 | var appendVendorPrefix = require('domkit/appendVendorPrefix');
597 |
598 | var animation = {
599 | show: {
600 | animationDuration: '0.8s',
601 | animationTimingFunction: 'cubic-bezier(0.6,0,0.4,1)'
602 | },
603 | hide: {
604 | animationDuration: '0.4s',
605 | animationTimingFunction: 'ease-out'
606 | },
607 | showContentAnimation: insertKeyframesRule({
608 | '0%': {
609 | opacity: 0,
610 | },
611 | '40%':{
612 | opacity: 0
613 | },
614 | '100%': {
615 | opacity: 1,
616 | }
617 | }),
618 |
619 | hideContentAnimation: insertKeyframesRule({
620 | '0%': {
621 | opacity: 1
622 | },
623 | '100%': {
624 | opacity: 0,
625 | }
626 | }),
627 |
628 | showBackdropAnimation: insertKeyframesRule({
629 | '0%': {
630 | opacity: 0
631 | },
632 | '100%': {
633 | opacity: 0.9
634 | },
635 | }),
636 |
637 | hideBackdropAnimation: insertKeyframesRule({
638 | '0%': {
639 | opacity: 0.9
640 | },
641 | '100%': {
642 | opacity: 0
643 | }
644 | })
645 | };
646 |
647 | var showAnimation = animation.show;
648 | var hideAnimation = animation.hide;
649 | var showContentAnimation = animation.showContentAnimation;
650 | var hideContentAnimation = animation.hideContentAnimation;
651 | var showBackdropAnimation = animation.showBackdropAnimation;
652 | var hideBackdropAnimation = animation.hideBackdropAnimation;
653 |
654 | module.exports = modalFactory({
655 | getRef: function(willHidden) {
656 | return 'content';
657 | },
658 | getSharp: function(willHidden) {
659 | var strokeDashLength = 1680;
660 |
661 | var showSharpAnimation = insertKeyframesRule({
662 | '0%': {
663 | 'stroke-dashoffset': strokeDashLength
664 | },
665 | '100%': {
666 | 'stroke-dashoffset': 0
667 | },
668 | });
669 |
670 |
671 | var sharpStyle = {
672 | position: 'absolute',
673 | width: 'calc(100%)',
674 | height: 'calc(100%)',
675 | zIndex: '-1'
676 | };
677 |
678 | var rectStyle = appendVendorPrefix({
679 | animationDuration: willHidden? '0.4s' :'0.8s',
680 | animationFillMode: 'forwards',
681 | animationName: willHidden? hideContentAnimation: showSharpAnimation,
682 | stroke: '#ffffff',
683 | strokeWidth: '2px',
684 | strokeDasharray: strokeDashLength
685 | });
686 |
687 | return React.createElement("div", {style: sharpStyle},
688 | React.createElement("svg", {
689 | xmlns: "http://www.w3.org/2000/svg",
690 | width: "100%",
691 | height: "100%",
692 | viewBox: "0 0 496 136",
693 | preserveAspectRatio: "none"},
694 | React.createElement("rect", {style: rectStyle,
695 | x: "2",
696 | y: "2",
697 | fill: "none",
698 | width: "492",
699 | height: "132"})
700 | )
701 | )
702 | },
703 | getModalStyle: function(willHidden) {
704 | return appendVendorPrefix({
705 | zIndex: 1050,
706 | position: "fixed",
707 | width: "500px",
708 | transform: "translate3d(-50%, -50%, 0)",
709 | top: "50%",
710 | left: "50%"
711 | })
712 | },
713 | getBackdropStyle: function(willHidden) {
714 | return appendVendorPrefix({
715 | position: "fixed",
716 | top: 0,
717 | right: 0,
718 | bottom: 0,
719 | left: 0,
720 | zIndex: 1040,
721 | backgroundColor: "#373A47",
722 | animationFillMode: 'forwards',
723 | animationDuration: '0.4s',
724 | animationName: willHidden ? hideBackdropAnimation : showBackdropAnimation,
725 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
726 | });
727 | },
728 | getContentStyle: function(willHidden) {
729 | return appendVendorPrefix({
730 | margin: 0,
731 | backgroundColor: "white",
732 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
733 | animationFillMode: 'forwards',
734 | animationName: willHidden ? hideContentAnimation : showContentAnimation,
735 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
736 | })
737 | }
738 | });
739 |
740 | },{"./modalFactory":14,"domkit/appendVendorPrefix":1,"domkit/insertKeyframesRule":5,"react":undefined}],12:[function(require,module,exports){
741 | var modalFactory = require('./modalFactory');
742 | var insertKeyframesRule = require('domkit/insertKeyframesRule');
743 | var appendVendorPrefix = require('domkit/appendVendorPrefix');
744 |
745 | var animation = {
746 | show: {
747 | animationDuration: '0.4s',
748 | animationTimingFunction: 'cubic-bezier(0.6,0,0.4,1)'
749 | },
750 | hide: {
751 | animationDuration: '0.4s',
752 | animationTimingFunction: 'ease-out'
753 | },
754 | showContentAnimation: insertKeyframesRule({
755 | '0%': {
756 | opacity: 0,
757 | transform: 'scale3d(0, 0, 1)'
758 | },
759 | '100%': {
760 | opacity: 1,
761 | transform: 'scale3d(1, 1, 1)'
762 | }
763 | }),
764 |
765 | hideContentAnimation: insertKeyframesRule({
766 | '0%': {
767 | opacity: 1
768 | },
769 | '100%': {
770 | opacity: 0,
771 | transform: 'scale3d(0.5, 0.5, 1)'
772 | }
773 | }),
774 |
775 | showBackdropAnimation: insertKeyframesRule({
776 | '0%': {
777 | opacity: 0
778 | },
779 | '100%': {
780 | opacity: 0.9
781 | },
782 | }),
783 |
784 | hideBackdropAnimation: insertKeyframesRule({
785 | '0%': {
786 | opacity: 0.9
787 | },
788 | '100%': {
789 | opacity: 0
790 | }
791 | })
792 | };
793 |
794 | var showAnimation = animation.show;
795 | var hideAnimation = animation.hide;
796 | var showContentAnimation = animation.showContentAnimation;
797 | var hideContentAnimation = animation.hideContentAnimation;
798 | var showBackdropAnimation = animation.showBackdropAnimation;
799 | var hideBackdropAnimation = animation.hideBackdropAnimation;
800 |
801 | module.exports = modalFactory({
802 | getRef: function(willHidden) {
803 | return 'content';
804 | },
805 | getModalStyle: function(willHidden) {
806 | return appendVendorPrefix({
807 | zIndex: 1050,
808 | position: "fixed",
809 | width: "500px",
810 | transform: "translate3d(-50%, -50%, 0)",
811 | top: "50%",
812 | left: "50%"
813 | })
814 | },
815 | getBackdropStyle: function(willHidden) {
816 | return appendVendorPrefix({
817 | position: "fixed",
818 | top: 0,
819 | right: 0,
820 | bottom: 0,
821 | left: 0,
822 | zIndex: 1040,
823 | backgroundColor: "#373A47",
824 | animationFillMode: 'forwards',
825 | animationDuration: '0.4s',
826 | animationName: willHidden ? hideBackdropAnimation : showBackdropAnimation,
827 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
828 | });
829 | },
830 | getContentStyle: function(willHidden) {
831 | return appendVendorPrefix({
832 | margin: 0,
833 | backgroundColor: "white",
834 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
835 | animationFillMode: 'forwards',
836 | animationName: willHidden ? hideContentAnimation : showContentAnimation,
837 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
838 | })
839 | }
840 | });
841 |
842 | },{"./modalFactory":14,"domkit/appendVendorPrefix":1,"domkit/insertKeyframesRule":5}],13:[function(require,module,exports){
843 | var modalFactory = require('./modalFactory');
844 | var insertKeyframesRule = require('domkit/insertKeyframesRule');
845 | var appendVendorPrefix = require('domkit/appendVendorPrefix');
846 |
847 | var animation = {
848 | show: {
849 | animationDuration: '1s',
850 | animationTimingFunction: 'linear'
851 | },
852 | hide: {
853 | animationDuration: '0.3s',
854 | animationTimingFunction: 'ease-out'
855 | },
856 | showContentAnimation: insertKeyframesRule({
857 | '0%': {
858 | opacity: 0,
859 | transform: 'matrix3d(0.7, 0, 0, 0, 0, 0.7, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
860 | },
861 | '2.083333%': {
862 | transform: 'matrix3d(0.75266, 0, 0, 0, 0, 0.76342, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
863 | },
864 | '4.166667%': {
865 | transform: 'matrix3d(0.81071, 0, 0, 0, 0, 0.84545, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
866 | },
867 | '6.25%': {
868 | transform: 'matrix3d(0.86808, 0, 0, 0, 0, 0.9286, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
869 | },
870 | '8.333333%': {
871 | transform: 'matrix3d(0.92038, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
872 | },
873 | '10.416667%': {
874 | transform: 'matrix3d(0.96482, 0, 0, 0, 0, 1.05202, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
875 | },
876 | '12.5%': {
877 | transform: 'matrix3d(1, 0, 0, 0, 0, 1.08204, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
878 | },
879 | '14.583333%': {
880 | transform: 'matrix3d(1.02563, 0, 0, 0, 0, 1.09149, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
881 | },
882 | '16.666667%': {
883 | transform: 'matrix3d(1.04227, 0, 0, 0, 0, 1.08453, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
884 | },
885 | '18.75%': {
886 | transform: 'matrix3d(1.05102, 0, 0, 0, 0, 1.06666, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
887 | },
888 | '20.833333%': {
889 | transform: 'matrix3d(1.05334, 0, 0, 0, 0, 1.04355, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
890 | },
891 | '22.916667%': {
892 | transform: 'matrix3d(1.05078, 0, 0, 0, 0, 1.02012, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
893 | },
894 | '25%': {
895 | transform: 'matrix3d(1.04487, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
896 | },
897 | '27.083333%': {
898 | transform: 'matrix3d(1.03699, 0, 0, 0, 0, 0.98534, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
899 | },
900 | '29.166667%': {
901 | transform: 'matrix3d(1.02831, 0, 0, 0, 0, 0.97688, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
902 | },
903 | '31.25%': {
904 | transform: 'matrix3d(1.01973, 0, 0, 0, 0, 0.97422, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
905 | },
906 | '33.333333%': {
907 | transform: 'matrix3d(1.01191, 0, 0, 0, 0, 0.97618, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
908 | },
909 | '35.416667%': {
910 | transform: 'matrix3d(1.00526, 0, 0, 0, 0, 0.98122, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
911 | },
912 | '37.5%': {
913 | transform: 'matrix3d(1, 0, 0, 0, 0, 0.98773, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
914 | },
915 | '39.583333%': {
916 | transform: 'matrix3d(0.99617, 0, 0, 0, 0, 0.99433, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
917 | },
918 | '41.666667%': {
919 | transform: 'matrix3d(0.99368, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
920 | },
921 | '43.75%': {
922 | transform: 'matrix3d(0.99237, 0, 0, 0, 0, 1.00413, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
923 | },
924 | '45.833333%': {
925 | transform: 'matrix3d(0.99202, 0, 0, 0, 0, 1.00651, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
926 | },
927 | '47.916667%': {
928 | transform: 'matrix3d(0.99241, 0, 0, 0, 0, 1.00726, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
929 | },
930 | '50%': {
931 | opacity: 1,
932 | transform: 'matrix3d(0.99329, 0, 0, 0, 0, 1.00671, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
933 | },
934 | '52.083333%': {
935 | transform: 'matrix3d(0.99447, 0, 0, 0, 0, 1.00529, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
936 | },
937 | '54.166667%': {
938 | transform: 'matrix3d(0.99577, 0, 0, 0, 0, 1.00346, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
939 | },
940 | '56.25%': {
941 | transform: 'matrix3d(0.99705, 0, 0, 0, 0, 1.0016, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
942 | },
943 | '58.333333%': {
944 | transform: 'matrix3d(0.99822, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
945 | },
946 | '60.416667%': {
947 | transform: 'matrix3d(0.99921, 0, 0, 0, 0, 0.99884, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
948 | },
949 | '62.5%': {
950 | transform: 'matrix3d(1, 0, 0, 0, 0, 0.99816, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
951 | },
952 | '64.583333%': {
953 | transform: 'matrix3d(1.00057, 0, 0, 0, 0, 0.99795, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
954 | },
955 | '66.666667%': {
956 | transform: 'matrix3d(1.00095, 0, 0, 0, 0, 0.99811, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
957 | },
958 | '68.75%': {
959 | transform: 'matrix3d(1.00114, 0, 0, 0, 0, 0.99851, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
960 | },
961 | '70.833333%': {
962 | transform: 'matrix3d(1.00119, 0, 0, 0, 0, 0.99903, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
963 | },
964 | '72.916667%': {
965 | transform: 'matrix3d(1.00114, 0, 0, 0, 0, 0.99955, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
966 | },
967 | '75%': {
968 | transform: 'matrix3d(1.001, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
969 | },
970 | '77.083333%': {
971 | transform: 'matrix3d(1.00083, 0, 0, 0, 0, 1.00033, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
972 | },
973 | '79.166667%': {
974 | transform: 'matrix3d(1.00063, 0, 0, 0, 0, 1.00052, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
975 | },
976 | '81.25%': {
977 | transform: 'matrix3d(1.00044, 0, 0, 0, 0, 1.00058, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
978 | },
979 | '83.333333%': {
980 | transform: 'matrix3d(1.00027, 0, 0, 0, 0, 1.00053, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
981 | },
982 | '85.416667%': {
983 | transform: 'matrix3d(1.00012, 0, 0, 0, 0, 1.00042, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
984 | },
985 | '87.5%': {
986 | transform: 'matrix3d(1, 0, 0, 0, 0, 1.00027, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
987 | },
988 | '89.583333%': {
989 | transform: 'matrix3d(0.99991, 0, 0, 0, 0, 1.00013, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
990 | },
991 | '91.666667%': {
992 | transform: 'matrix3d(0.99986, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
993 | },
994 | '93.75%': {
995 | transform: 'matrix3d(0.99983, 0, 0, 0, 0, 0.99991, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
996 | },
997 | '95.833333%': {
998 | transform: 'matrix3d(0.99982, 0, 0, 0, 0, 0.99985, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
999 | },
1000 | '97.916667%': {
1001 | transform: 'matrix3d(0.99983, 0, 0, 0, 0, 0.99984, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
1002 | },
1003 | '100%': {
1004 | opacity: 1,
1005 | transform: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
1006 | }
1007 | }),
1008 |
1009 | hideContentAnimation: insertKeyframesRule({
1010 | '0%': {
1011 | opacity: 1
1012 | },
1013 | '100%': {
1014 | opacity: 0,
1015 | transform: 'scale3d(0.8, 0.8, 1)'
1016 | },
1017 | }),
1018 |
1019 | showBackdropAnimation: insertKeyframesRule({
1020 | '0%': {
1021 | opacity: 0
1022 | },
1023 | '100%': {
1024 | opacity: 0.9
1025 | },
1026 | }),
1027 |
1028 | hideBackdropAnimation: insertKeyframesRule({
1029 | '0%': {
1030 | opacity: 0.9
1031 | },
1032 | '100%': {
1033 | opacity: 0
1034 | }
1035 | })
1036 | };
1037 |
1038 | var showAnimation = animation.show;
1039 | var hideAnimation = animation.hide;
1040 | var showContentAnimation = animation.showContentAnimation;
1041 | var hideContentAnimation = animation.hideContentAnimation;
1042 | var showBackdropAnimation = animation.showBackdropAnimation;
1043 | var hideBackdropAnimation = animation.hideBackdropAnimation;
1044 |
1045 | module.exports = modalFactory({
1046 | getRef: function(willHidden) {
1047 | return 'content';
1048 | },
1049 | getModalStyle: function(willHidden) {
1050 | return appendVendorPrefix({
1051 | zIndex: 1050,
1052 | position: "fixed",
1053 | width: "500px",
1054 | transform: "translate3d(-50%, -50%, 0)",
1055 | top: "50%",
1056 | left: "50%"
1057 | })
1058 | },
1059 | getBackdropStyle: function(willHidden) {
1060 | return appendVendorPrefix({
1061 | position: "fixed",
1062 | top: 0,
1063 | right: 0,
1064 | bottom: 0,
1065 | left: 0,
1066 | zIndex: 1040,
1067 | backgroundColor: "#373A47",
1068 | animationFillMode: 'forwards',
1069 | animationDuration: '0.3s',
1070 | animationName: willHidden ? hideBackdropAnimation : showBackdropAnimation,
1071 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
1072 | });
1073 | },
1074 | getContentStyle: function(willHidden) {
1075 | return appendVendorPrefix({
1076 | margin: 0,
1077 | backgroundColor: "white",
1078 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
1079 | animationFillMode: 'forwards',
1080 | animationName: willHidden ? hideContentAnimation : showContentAnimation,
1081 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
1082 | })
1083 | }
1084 | });
1085 |
1086 | },{"./modalFactory":14,"domkit/appendVendorPrefix":1,"domkit/insertKeyframesRule":5}],14:[function(require,module,exports){
1087 | var React = require('react');
1088 | var transitionEvents = require('domkit/transitionEvents');
1089 | var appendVendorPrefix = require('domkit/appendVendorPrefix');
1090 |
1091 | module.exports = function(animation){
1092 |
1093 | return React.createClass({
1094 | propTypes: {
1095 | className: React.PropTypes.string,
1096 | // Close the modal when esc is pressed? Defaults to true.
1097 | keyboard: React.PropTypes.bool,
1098 | onShow: React.PropTypes.func,
1099 | onHide: React.PropTypes.func,
1100 | animation: React.PropTypes.object,
1101 | backdrop: React.PropTypes.bool,
1102 | closeOnClick: React.PropTypes.bool,
1103 | modalStyle: React.PropTypes.object,
1104 | backdropStyle: React.PropTypes.object,
1105 | contentStyle: React.PropTypes.object,
1106 | },
1107 |
1108 | getDefaultProps: function() {
1109 | return {
1110 | className: "",
1111 | onShow: function(){},
1112 | onHide: function(){},
1113 | animation: animation,
1114 | keyboard: true,
1115 | backdrop: true,
1116 | closeOnClick: true,
1117 | modalStyle: {},
1118 | backdropStyle: {},
1119 | contentStyle: {},
1120 | };
1121 | },
1122 |
1123 | getInitialState: function(){
1124 | return {
1125 | willHidden: false,
1126 | hidden: true
1127 | }
1128 | },
1129 |
1130 | hasHidden: function(){
1131 | return this.state.hidden;
1132 | },
1133 |
1134 | addTransitionListener: function(node, handle){
1135 | if (node) {
1136 | var endListener = function(e) {
1137 | if (e && e.target !== node) {
1138 | return;
1139 | }
1140 | transitionEvents.removeEndEventListener(node, endListener);
1141 | handle();
1142 | };
1143 | transitionEvents.addEndEventListener(node, endListener);
1144 | }
1145 | },
1146 |
1147 | handleBackdropClick: function() {
1148 | if (this.props.closeOnClick) {
1149 | this.hide();
1150 | }
1151 | },
1152 |
1153 | render: function() {
1154 |
1155 | var hidden = this.hasHidden();
1156 | if (hidden) return null;
1157 |
1158 | var willHidden = this.state.willHidden;
1159 | var animation = this.props.animation;
1160 | var modalStyle = animation.getModalStyle(willHidden);
1161 | var backdropStyle = animation.getBackdropStyle(willHidden);
1162 | var contentStyle = animation.getContentStyle(willHidden);
1163 | var ref = animation.getRef(willHidden);
1164 | var sharp = animation.getSharp && animation.getSharp(willHidden);
1165 |
1166 | // Apply custom style properties
1167 | if (this.props.modalStyle) {
1168 | var prefixedModalStyle = appendVendorPrefix(this.props.modalStyle);
1169 | for (var style in prefixedModalStyle) {
1170 | modalStyle[style] = prefixedModalStyle[style];
1171 | }
1172 | }
1173 |
1174 | if (this.props.backdropStyle) {
1175 | var prefixedBackdropStyle = appendVendorPrefix(this.props.backdropStyle);
1176 | for (var style in prefixedBackdropStyle) {
1177 | backdropStyle[style] = prefixedBackdropStyle[style];
1178 | }
1179 | }
1180 |
1181 | if (this.props.contentStyle) {
1182 | var prefixedContentStyle = appendVendorPrefix(this.props.contentStyle);
1183 | for (var style in prefixedContentStyle) {
1184 | contentStyle[style] = prefixedContentStyle[style];
1185 | }
1186 | }
1187 |
1188 | var backdrop = this.props.backdrop? React.createElement("div", {style: backdropStyle, onClick: this.props.closeOnClick? this.handleBackdropClick: null}): undefined;
1189 |
1190 | if(willHidden) {
1191 | var node = this.refs[ref];
1192 | this.addTransitionListener(node, this.leave);
1193 | }
1194 |
1195 | return (React.createElement("span", null,
1196 | React.createElement("div", {ref: "modal", style: modalStyle, className: this.props.className},
1197 | sharp,
1198 | React.createElement("div", {ref: "content", tabIndex: "-1", style: contentStyle},
1199 | this.props.children
1200 | )
1201 | ),
1202 | backdrop
1203 | ))
1204 | ;
1205 | },
1206 |
1207 | leave: function(){
1208 | this.setState({
1209 | hidden: true
1210 | });
1211 | this.props.onHide();
1212 | },
1213 |
1214 | enter: function(){
1215 | this.props.onShow();
1216 | },
1217 |
1218 | show: function(){
1219 | if (!this.hasHidden()) return;
1220 |
1221 | this.setState({
1222 | willHidden: false,
1223 | hidden: false
1224 | });
1225 |
1226 | setTimeout(function(){
1227 | var ref = this.props.animation.getRef();
1228 | var node = this.refs[ref];
1229 | this.addTransitionListener(node, this.enter);
1230 | }.bind(this), 0);
1231 | },
1232 |
1233 | hide: function(){
1234 | if (this.hasHidden()) return;
1235 |
1236 | this.setState({
1237 | willHidden: true
1238 | });
1239 | },
1240 |
1241 | toggle: function(){
1242 | if (this.hasHidden())
1243 | this.show();
1244 | else
1245 | this.hide();
1246 | },
1247 |
1248 | listenKeyboard: function(event) {
1249 | if (this.props.keyboard &&
1250 | (event.key === "Escape" ||
1251 | event.keyCode === 27)) {
1252 | this.hide();
1253 | }
1254 | },
1255 |
1256 | componentDidMount: function(){
1257 | window.addEventListener("keydown", this.listenKeyboard, true);
1258 | },
1259 |
1260 | componentWillUnmount: function() {
1261 | window.removeEventListener("keydown", this.listenKeyboard, true);
1262 | }
1263 | });
1264 | }
1265 |
1266 | },{"domkit/appendVendorPrefix":1,"domkit/transitionEvents":7,"react":undefined}],"boron":[function(require,module,exports){
1267 | module.exports = {
1268 | DropModal: require('./DropModal'),
1269 | WaveModal: require('./WaveModal'),
1270 | FlyModal: require('./FlyModal'),
1271 | FadeModal: require('./FadeModal'),
1272 | ScaleModal: require('./ScaleModal'),
1273 | OutlineModal: require('./OutlineModal'),
1274 | }
1275 |
1276 | },{"./DropModal":8,"./FadeModal":9,"./FlyModal":10,"./OutlineModal":11,"./ScaleModal":12,"./WaveModal":13}]},{},[]);
1277 |
--------------------------------------------------------------------------------
/example/dist/codemirror.css:
--------------------------------------------------------------------------------
1 | /* BASICS */
2 |
3 | .CodeMirror {
4 | /* Set height, width, borders, and global font properties here */
5 | font-family: monospace;
6 | height: 300px;
7 | color: black;
8 | }
9 |
10 | /* PADDING */
11 |
12 | .CodeMirror-lines {
13 | padding: 4px 0; /* Vertical padding around content */
14 | }
15 | .CodeMirror pre {
16 | padding: 0 4px; /* Horizontal padding of content */
17 | }
18 |
19 | .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
20 | background-color: white; /* The little square between H and V scrollbars */
21 | }
22 |
23 | /* GUTTER */
24 |
25 | .CodeMirror-gutters {
26 | border-right: 1px solid #ddd;
27 | background-color: #f7f7f7;
28 | white-space: nowrap;
29 | }
30 | .CodeMirror-linenumbers {}
31 | .CodeMirror-linenumber {
32 | padding: 0 3px 0 5px;
33 | min-width: 20px;
34 | text-align: right;
35 | color: #999;
36 | white-space: nowrap;
37 | }
38 |
39 | .CodeMirror-guttermarker { color: black; }
40 | .CodeMirror-guttermarker-subtle { color: #999; }
41 |
42 | /* CURSOR */
43 |
44 | .CodeMirror-cursor {
45 | border-left: 1px solid black;
46 | border-right: none;
47 | width: 0;
48 | }
49 | /* Shown when moving in bi-directional text */
50 | .CodeMirror div.CodeMirror-secondarycursor {
51 | border-left: 1px solid silver;
52 | }
53 | .cm-fat-cursor .CodeMirror-cursor {
54 | width: auto;
55 | border: 0;
56 | background: #7e7;
57 | }
58 | .cm-fat-cursor div.CodeMirror-cursors {
59 | z-index: 1;
60 | }
61 |
62 | .cm-animate-fat-cursor {
63 | width: auto;
64 | border: 0;
65 | -webkit-animation: blink 1.06s steps(1) infinite;
66 | -moz-animation: blink 1.06s steps(1) infinite;
67 | animation: blink 1.06s steps(1) infinite;
68 | background-color: #7e7;
69 | }
70 | @-moz-keyframes blink {
71 | 0% {}
72 | 50% { background-color: transparent; }
73 | 100% {}
74 | }
75 | @-webkit-keyframes blink {
76 | 0% {}
77 | 50% { background-color: transparent; }
78 | 100% {}
79 | }
80 | @keyframes blink {
81 | 0% {}
82 | 50% { background-color: transparent; }
83 | 100% {}
84 | }
85 |
86 | /* Can style cursor different in overwrite (non-insert) mode */
87 | .CodeMirror-overwrite .CodeMirror-cursor {}
88 |
89 | .cm-tab { display: inline-block; text-decoration: inherit; }
90 |
91 | .CodeMirror-ruler {
92 | border-left: 1px solid #ccc;
93 | position: absolute;
94 | }
95 |
96 | /* DEFAULT THEME */
97 |
98 | .cm-s-default .cm-header {color: blue;}
99 | .cm-s-default .cm-quote {color: #090;}
100 | .cm-negative {color: #d44;}
101 | .cm-positive {color: #292;}
102 | .cm-header, .cm-strong {font-weight: bold;}
103 | .cm-em {font-style: italic;}
104 | .cm-link {text-decoration: underline;}
105 | .cm-strikethrough {text-decoration: line-through;}
106 |
107 | .cm-s-default .cm-keyword {color: #708;}
108 | .cm-s-default .cm-atom {color: #219;}
109 | .cm-s-default .cm-number {color: #164;}
110 | .cm-s-default .cm-def {color: #00f;}
111 | .cm-s-default .cm-variable,
112 | .cm-s-default .cm-punctuation,
113 | .cm-s-default .cm-property,
114 | .cm-s-default .cm-operator {}
115 | .cm-s-default .cm-variable-2 {color: #05a;}
116 | .cm-s-default .cm-variable-3 {color: #085;}
117 | .cm-s-default .cm-comment {color: #a50;}
118 | .cm-s-default .cm-string {color: #a11;}
119 | .cm-s-default .cm-string-2 {color: #f50;}
120 | .cm-s-default .cm-meta {color: #555;}
121 | .cm-s-default .cm-qualifier {color: #555;}
122 | .cm-s-default .cm-builtin {color: #30a;}
123 | .cm-s-default .cm-bracket {color: #997;}
124 | .cm-s-default .cm-tag {color: #170;}
125 | .cm-s-default .cm-attribute {color: #00c;}
126 | .cm-s-default .cm-hr {color: #999;}
127 | .cm-s-default .cm-link {color: #00c;}
128 |
129 | .cm-s-default .cm-error {color: #f00;}
130 | .cm-invalidchar {color: #f00;}
131 |
132 | .CodeMirror-composing { border-bottom: 2px solid; }
133 |
134 | /* Default styles for common addons */
135 |
136 | div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
137 | div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
138 | .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
139 | .CodeMirror-activeline-background {background: #e8f2ff;}
140 |
141 | /* STOP */
142 |
143 | /* The rest of this file contains styles related to the mechanics of
144 | the editor. You probably shouldn't touch them. */
145 |
146 | .CodeMirror {
147 | position: relative;
148 | overflow: hidden;
149 | background: white;
150 | }
151 |
152 | .CodeMirror-scroll {
153 | overflow: scroll !important; /* Things will break if this is overridden */
154 | /* 30px is the magic margin used to hide the element's real scrollbars */
155 | /* See overflow: hidden in .CodeMirror */
156 | margin-bottom: -30px; margin-right: -30px;
157 | padding-bottom: 30px;
158 | height: 100%;
159 | outline: none; /* Prevent dragging from highlighting the element */
160 | position: relative;
161 | }
162 | .CodeMirror-sizer {
163 | position: relative;
164 | border-right: 30px solid transparent;
165 | }
166 |
167 | /* The fake, visible scrollbars. Used to force redraw during scrolling
168 | before actuall scrolling happens, thus preventing shaking and
169 | flickering artifacts. */
170 | .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
171 | position: absolute;
172 | z-index: 6;
173 | display: none;
174 | }
175 | .CodeMirror-vscrollbar {
176 | right: 0; top: 0;
177 | overflow-x: hidden;
178 | overflow-y: scroll;
179 | }
180 | .CodeMirror-hscrollbar {
181 | bottom: 0; left: 0;
182 | overflow-y: hidden;
183 | overflow-x: scroll;
184 | }
185 | .CodeMirror-scrollbar-filler {
186 | right: 0; bottom: 0;
187 | }
188 | .CodeMirror-gutter-filler {
189 | left: 0; bottom: 0;
190 | }
191 |
192 | .CodeMirror-gutters {
193 | position: absolute; left: 0; top: 0;
194 | z-index: 3;
195 | }
196 | .CodeMirror-gutter {
197 | white-space: normal;
198 | height: 100%;
199 | display: inline-block;
200 | margin-bottom: -30px;
201 | /* Hack to make IE7 behave */
202 | *zoom:1;
203 | *display:inline;
204 | }
205 | .CodeMirror-gutter-wrapper {
206 | position: absolute;
207 | z-index: 4;
208 | background: none !important;
209 | border: none !important;
210 | }
211 | .CodeMirror-gutter-background {
212 | position: absolute;
213 | top: 0; bottom: 0;
214 | z-index: 4;
215 | }
216 | .CodeMirror-gutter-elt {
217 | position: absolute;
218 | cursor: default;
219 | z-index: 4;
220 | }
221 | .CodeMirror-gutter-wrapper {
222 | -webkit-user-select: none;
223 | -moz-user-select: none;
224 | user-select: none;
225 | }
226 |
227 | .CodeMirror-lines {
228 | cursor: text;
229 | min-height: 1px; /* prevents collapsing before first draw */
230 | }
231 | .CodeMirror pre {
232 | /* Reset some styles that the rest of the page might have set */
233 | -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
234 | border-width: 0;
235 | background: transparent;
236 | font-family: inherit;
237 | font-size: inherit;
238 | margin: 0;
239 | white-space: pre;
240 | word-wrap: normal;
241 | line-height: inherit;
242 | color: inherit;
243 | z-index: 2;
244 | position: relative;
245 | overflow: visible;
246 | -webkit-tap-highlight-color: transparent;
247 | }
248 | .CodeMirror-wrap pre {
249 | word-wrap: break-word;
250 | white-space: pre-wrap;
251 | word-break: normal;
252 | }
253 |
254 | .CodeMirror-linebackground {
255 | position: absolute;
256 | left: 0; right: 0; top: 0; bottom: 0;
257 | z-index: 0;
258 | }
259 |
260 | .CodeMirror-linewidget {
261 | position: relative;
262 | z-index: 2;
263 | overflow: auto;
264 | }
265 |
266 | .CodeMirror-widget {}
267 |
268 | .CodeMirror-code {
269 | outline: none;
270 | }
271 |
272 | /* Force content-box sizing for the elements where we expect it */
273 | .CodeMirror-scroll,
274 | .CodeMirror-sizer,
275 | .CodeMirror-gutter,
276 | .CodeMirror-gutters,
277 | .CodeMirror-linenumber {
278 | -moz-box-sizing: content-box;
279 | box-sizing: content-box;
280 | }
281 |
282 | .CodeMirror-measure {
283 | position: absolute;
284 | width: 100%;
285 | height: 0;
286 | overflow: hidden;
287 | visibility: hidden;
288 | }
289 |
290 | .CodeMirror-cursor { position: absolute; }
291 | .CodeMirror-measure pre { position: static; }
292 |
293 | div.CodeMirror-cursors {
294 | visibility: hidden;
295 | position: relative;
296 | z-index: 3;
297 | }
298 | div.CodeMirror-dragcursors {
299 | visibility: visible;
300 | }
301 |
302 | .CodeMirror-focused div.CodeMirror-cursors {
303 | visibility: visible;
304 | }
305 |
306 | .CodeMirror-selected { background: #d9d9d9; }
307 | .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
308 | .CodeMirror-crosshair { cursor: crosshair; }
309 | .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
310 | .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
311 |
312 | .cm-searching {
313 | background: #ffa;
314 | background: rgba(255, 255, 0, .4);
315 | }
316 |
317 | /* IE7 hack to prevent it from returning funny offsetTops on the spans */
318 | .CodeMirror span { *vertical-align: text-bottom; }
319 |
320 | /* Used to force a border model for a node */
321 | .cm-force-border { padding-right: .1px; }
322 |
323 | @media print {
324 | /* Hide the cursor when printing */
325 | .CodeMirror div.CodeMirror-cursors {
326 | visibility: hidden;
327 | }
328 | }
329 |
330 | /* See issue #2901 */
331 | .cm-tab-wrap-hack:after { content: ''; }
332 |
333 | /* Help users use markselection to safely style text background */
334 | span.CodeMirror-selectedtext { background: none; }
335 |
--------------------------------------------------------------------------------
/example/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Boron
6 |
7 |
8 |
9 |
10 |
11 |
77 |
78 |
79 |
86 |
87 |
88 |
89 |
90 | npm install boron
91 |
92 |
93 |
94 |
95 |
98 |
99 |
100 |
101 |
102 |
103 |
104 | Github
105 |
106 |
107 |
108 |
109 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/example/dist/javascript.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | // TODO actually recognize syntax of TypeScript constructs
5 |
6 | (function(mod) {
7 | if (typeof exports == "object" && typeof module == "object") // CommonJS
8 | mod(require("../../lib/codemirror"));
9 | else if (typeof define == "function" && define.amd) // AMD
10 | define(["../../lib/codemirror"], mod);
11 | else // Plain browser env
12 | mod(CodeMirror);
13 | })(function(CodeMirror) {
14 | "use strict";
15 |
16 | CodeMirror.defineMode("javascript", function(config, parserConfig) {
17 | var indentUnit = config.indentUnit;
18 | var statementIndent = parserConfig.statementIndent;
19 | var jsonldMode = parserConfig.jsonld;
20 | var jsonMode = parserConfig.json || jsonldMode;
21 | var isTS = parserConfig.typescript;
22 | var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
23 |
24 | // Tokenizer
25 |
26 | var keywords = function(){
27 | function kw(type) {return {type: type, style: "keyword"};}
28 | var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
29 | var operator = kw("operator"), atom = {type: "atom", style: "atom"};
30 |
31 | var jsKeywords = {
32 | "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
33 | "return": C, "break": C, "continue": C, "new": kw("new"), "delete": C, "throw": C, "debugger": C,
34 | "var": kw("var"), "const": kw("var"), "let": kw("var"),
35 | "function": kw("function"), "catch": kw("catch"),
36 | "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
37 | "in": operator, "typeof": operator, "instanceof": operator,
38 | "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
39 | "this": kw("this"), "class": kw("class"), "super": kw("atom"),
40 | "yield": C, "export": kw("export"), "import": kw("import"), "extends": C
41 | };
42 |
43 | // Extend the 'normal' keywords with the TypeScript language extensions
44 | if (isTS) {
45 | var type = {type: "variable", style: "variable-3"};
46 | var tsKeywords = {
47 | // object-like things
48 | "interface": kw("interface"),
49 | "extends": kw("extends"),
50 | "constructor": kw("constructor"),
51 |
52 | // scope modifiers
53 | "public": kw("public"),
54 | "private": kw("private"),
55 | "protected": kw("protected"),
56 | "static": kw("static"),
57 |
58 | // types
59 | "string": type, "number": type, "boolean": type, "any": type
60 | };
61 |
62 | for (var attr in tsKeywords) {
63 | jsKeywords[attr] = tsKeywords[attr];
64 | }
65 | }
66 |
67 | return jsKeywords;
68 | }();
69 |
70 | var isOperatorChar = /[+\-*&%=<>!?|~^]/;
71 | var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
72 |
73 | function readRegexp(stream) {
74 | var escaped = false, next, inSet = false;
75 | while ((next = stream.next()) != null) {
76 | if (!escaped) {
77 | if (next == "/" && !inSet) return;
78 | if (next == "[") inSet = true;
79 | else if (inSet && next == "]") inSet = false;
80 | }
81 | escaped = !escaped && next == "\\";
82 | }
83 | }
84 |
85 | // Used as scratch variables to communicate multiple values without
86 | // consing up tons of objects.
87 | var type, content;
88 | function ret(tp, style, cont) {
89 | type = tp; content = cont;
90 | return style;
91 | }
92 | function tokenBase(stream, state) {
93 | var ch = stream.next();
94 | if (ch == '"' || ch == "'") {
95 | state.tokenize = tokenString(ch);
96 | return state.tokenize(stream, state);
97 | } else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
98 | return ret("number", "number");
99 | } else if (ch == "." && stream.match("..")) {
100 | return ret("spread", "meta");
101 | } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
102 | return ret(ch);
103 | } else if (ch == "=" && stream.eat(">")) {
104 | return ret("=>", "operator");
105 | } else if (ch == "0" && stream.eat(/x/i)) {
106 | stream.eatWhile(/[\da-f]/i);
107 | return ret("number", "number");
108 | } else if (ch == "0" && stream.eat(/o/i)) {
109 | stream.eatWhile(/[0-7]/i);
110 | return ret("number", "number");
111 | } else if (ch == "0" && stream.eat(/b/i)) {
112 | stream.eatWhile(/[01]/i);
113 | return ret("number", "number");
114 | } else if (/\d/.test(ch)) {
115 | stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
116 | return ret("number", "number");
117 | } else if (ch == "/") {
118 | if (stream.eat("*")) {
119 | state.tokenize = tokenComment;
120 | return tokenComment(stream, state);
121 | } else if (stream.eat("/")) {
122 | stream.skipToEnd();
123 | return ret("comment", "comment");
124 | } else if (/^(?:operator|sof|keyword c|case|new|[\[{}\(,;:])$/.test(state.lastType)) {
125 | readRegexp(stream);
126 | stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);
127 | return ret("regexp", "string-2");
128 | } else {
129 | stream.eatWhile(isOperatorChar);
130 | return ret("operator", "operator", stream.current());
131 | }
132 | } else if (ch == "`") {
133 | state.tokenize = tokenQuasi;
134 | return tokenQuasi(stream, state);
135 | } else if (ch == "#") {
136 | stream.skipToEnd();
137 | return ret("error", "error");
138 | } else if (isOperatorChar.test(ch)) {
139 | stream.eatWhile(isOperatorChar);
140 | return ret("operator", "operator", stream.current());
141 | } else if (wordRE.test(ch)) {
142 | stream.eatWhile(wordRE);
143 | var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
144 | return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
145 | ret("variable", "variable", word);
146 | }
147 | }
148 |
149 | function tokenString(quote) {
150 | return function(stream, state) {
151 | var escaped = false, next;
152 | if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
153 | state.tokenize = tokenBase;
154 | return ret("jsonld-keyword", "meta");
155 | }
156 | while ((next = stream.next()) != null) {
157 | if (next == quote && !escaped) break;
158 | escaped = !escaped && next == "\\";
159 | }
160 | if (!escaped) state.tokenize = tokenBase;
161 | return ret("string", "string");
162 | };
163 | }
164 |
165 | function tokenComment(stream, state) {
166 | var maybeEnd = false, ch;
167 | while (ch = stream.next()) {
168 | if (ch == "/" && maybeEnd) {
169 | state.tokenize = tokenBase;
170 | break;
171 | }
172 | maybeEnd = (ch == "*");
173 | }
174 | return ret("comment", "comment");
175 | }
176 |
177 | function tokenQuasi(stream, state) {
178 | var escaped = false, next;
179 | while ((next = stream.next()) != null) {
180 | if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
181 | state.tokenize = tokenBase;
182 | break;
183 | }
184 | escaped = !escaped && next == "\\";
185 | }
186 | return ret("quasi", "string-2", stream.current());
187 | }
188 |
189 | var brackets = "([{}])";
190 | // This is a crude lookahead trick to try and notice that we're
191 | // parsing the argument patterns for a fat-arrow function before we
192 | // actually hit the arrow token. It only works if the arrow is on
193 | // the same line as the arguments and there's no strange noise
194 | // (comments) in between. Fallback is to only notice when we hit the
195 | // arrow, and not declare the arguments as locals for the arrow
196 | // body.
197 | function findFatArrow(stream, state) {
198 | if (state.fatArrowAt) state.fatArrowAt = null;
199 | var arrow = stream.string.indexOf("=>", stream.start);
200 | if (arrow < 0) return;
201 |
202 | var depth = 0, sawSomething = false;
203 | for (var pos = arrow - 1; pos >= 0; --pos) {
204 | var ch = stream.string.charAt(pos);
205 | var bracket = brackets.indexOf(ch);
206 | if (bracket >= 0 && bracket < 3) {
207 | if (!depth) { ++pos; break; }
208 | if (--depth == 0) break;
209 | } else if (bracket >= 3 && bracket < 6) {
210 | ++depth;
211 | } else if (wordRE.test(ch)) {
212 | sawSomething = true;
213 | } else if (/["'\/]/.test(ch)) {
214 | return;
215 | } else if (sawSomething && !depth) {
216 | ++pos;
217 | break;
218 | }
219 | }
220 | if (sawSomething && !depth) state.fatArrowAt = pos;
221 | }
222 |
223 | // Parser
224 |
225 | var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
226 |
227 | function JSLexical(indented, column, type, align, prev, info) {
228 | this.indented = indented;
229 | this.column = column;
230 | this.type = type;
231 | this.prev = prev;
232 | this.info = info;
233 | if (align != null) this.align = align;
234 | }
235 |
236 | function inScope(state, varname) {
237 | for (var v = state.localVars; v; v = v.next)
238 | if (v.name == varname) return true;
239 | for (var cx = state.context; cx; cx = cx.prev) {
240 | for (var v = cx.vars; v; v = v.next)
241 | if (v.name == varname) return true;
242 | }
243 | }
244 |
245 | function parseJS(state, style, type, content, stream) {
246 | var cc = state.cc;
247 | // Communicate our context to the combinators.
248 | // (Less wasteful than consing up a hundred closures on every call.)
249 | cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
250 |
251 | if (!state.lexical.hasOwnProperty("align"))
252 | state.lexical.align = true;
253 |
254 | while(true) {
255 | var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
256 | if (combinator(type, content)) {
257 | while(cc.length && cc[cc.length - 1].lex)
258 | cc.pop()();
259 | if (cx.marked) return cx.marked;
260 | if (type == "variable" && inScope(state, content)) return "variable-2";
261 | return style;
262 | }
263 | }
264 | }
265 |
266 | // Combinator utils
267 |
268 | var cx = {state: null, column: null, marked: null, cc: null};
269 | function pass() {
270 | for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
271 | }
272 | function cont() {
273 | pass.apply(null, arguments);
274 | return true;
275 | }
276 | function register(varname) {
277 | function inList(list) {
278 | for (var v = list; v; v = v.next)
279 | if (v.name == varname) return true;
280 | return false;
281 | }
282 | var state = cx.state;
283 | cx.marked = "def";
284 | if (state.context) {
285 | if (inList(state.localVars)) return;
286 | state.localVars = {name: varname, next: state.localVars};
287 | } else {
288 | if (inList(state.globalVars)) return;
289 | if (parserConfig.globalVars)
290 | state.globalVars = {name: varname, next: state.globalVars};
291 | }
292 | }
293 |
294 | // Combinators
295 |
296 | var defaultVars = {name: "this", next: {name: "arguments"}};
297 | function pushcontext() {
298 | cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
299 | cx.state.localVars = defaultVars;
300 | }
301 | function popcontext() {
302 | cx.state.localVars = cx.state.context.vars;
303 | cx.state.context = cx.state.context.prev;
304 | }
305 | function pushlex(type, info) {
306 | var result = function() {
307 | var state = cx.state, indent = state.indented;
308 | if (state.lexical.type == "stat") indent = state.lexical.indented;
309 | else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
310 | indent = outer.indented;
311 | state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
312 | };
313 | result.lex = true;
314 | return result;
315 | }
316 | function poplex() {
317 | var state = cx.state;
318 | if (state.lexical.prev) {
319 | if (state.lexical.type == ")")
320 | state.indented = state.lexical.indented;
321 | state.lexical = state.lexical.prev;
322 | }
323 | }
324 | poplex.lex = true;
325 |
326 | function expect(wanted) {
327 | function exp(type) {
328 | if (type == wanted) return cont();
329 | else if (wanted == ";") return pass();
330 | else return cont(exp);
331 | };
332 | return exp;
333 | }
334 |
335 | function statement(type, value) {
336 | if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
337 | if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
338 | if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
339 | if (type == "{") return cont(pushlex("}"), block, poplex);
340 | if (type == ";") return cont();
341 | if (type == "if") {
342 | if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
343 | cx.state.cc.pop()();
344 | return cont(pushlex("form"), expression, statement, poplex, maybeelse);
345 | }
346 | if (type == "function") return cont(functiondef);
347 | if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
348 | if (type == "variable") return cont(pushlex("stat"), maybelabel);
349 | if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
350 | block, poplex, poplex);
351 | if (type == "case") return cont(expression, expect(":"));
352 | if (type == "default") return cont(expect(":"));
353 | if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
354 | statement, poplex, popcontext);
355 | if (type == "class") return cont(pushlex("form"), className, poplex);
356 | if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
357 | if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
358 | return pass(pushlex("stat"), expression, expect(";"), poplex);
359 | }
360 | function expression(type) {
361 | return expressionInner(type, false);
362 | }
363 | function expressionNoComma(type) {
364 | return expressionInner(type, true);
365 | }
366 | function expressionInner(type, noComma) {
367 | if (cx.state.fatArrowAt == cx.stream.start) {
368 | var body = noComma ? arrowBodyNoComma : arrowBody;
369 | if (type == "(") return cont(pushcontext, pushlex(")"), commasep(pattern, ")"), poplex, expect("=>"), body, popcontext);
370 | else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
371 | }
372 |
373 | var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
374 | if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
375 | if (type == "function") return cont(functiondef, maybeop);
376 | if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
377 | if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop);
378 | if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
379 | if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
380 | if (type == "{") return contCommasep(objprop, "}", null, maybeop);
381 | if (type == "quasi") return pass(quasi, maybeop);
382 | if (type == "new") return cont(maybeTarget(noComma));
383 | return cont();
384 | }
385 | function maybeexpression(type) {
386 | if (type.match(/[;\}\)\],]/)) return pass();
387 | return pass(expression);
388 | }
389 | function maybeexpressionNoComma(type) {
390 | if (type.match(/[;\}\)\],]/)) return pass();
391 | return pass(expressionNoComma);
392 | }
393 |
394 | function maybeoperatorComma(type, value) {
395 | if (type == ",") return cont(expression);
396 | return maybeoperatorNoComma(type, value, false);
397 | }
398 | function maybeoperatorNoComma(type, value, noComma) {
399 | var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
400 | var expr = noComma == false ? expression : expressionNoComma;
401 | if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
402 | if (type == "operator") {
403 | if (/\+\+|--/.test(value)) return cont(me);
404 | if (value == "?") return cont(expression, expect(":"), expr);
405 | return cont(expr);
406 | }
407 | if (type == "quasi") { return pass(quasi, me); }
408 | if (type == ";") return;
409 | if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
410 | if (type == ".") return cont(property, me);
411 | if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
412 | }
413 | function quasi(type, value) {
414 | if (type != "quasi") return pass();
415 | if (value.slice(value.length - 2) != "${") return cont(quasi);
416 | return cont(expression, continueQuasi);
417 | }
418 | function continueQuasi(type) {
419 | if (type == "}") {
420 | cx.marked = "string-2";
421 | cx.state.tokenize = tokenQuasi;
422 | return cont(quasi);
423 | }
424 | }
425 | function arrowBody(type) {
426 | findFatArrow(cx.stream, cx.state);
427 | return pass(type == "{" ? statement : expression);
428 | }
429 | function arrowBodyNoComma(type) {
430 | findFatArrow(cx.stream, cx.state);
431 | return pass(type == "{" ? statement : expressionNoComma);
432 | }
433 | function maybeTarget(noComma) {
434 | return function(type) {
435 | if (type == ".") return cont(noComma ? targetNoComma : target);
436 | else return pass(noComma ? expressionNoComma : expression);
437 | };
438 | }
439 | function target(_, value) {
440 | if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
441 | }
442 | function targetNoComma(_, value) {
443 | if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
444 | }
445 | function maybelabel(type) {
446 | if (type == ":") return cont(poplex, statement);
447 | return pass(maybeoperatorComma, expect(";"), poplex);
448 | }
449 | function property(type) {
450 | if (type == "variable") {cx.marked = "property"; return cont();}
451 | }
452 | function objprop(type, value) {
453 | if (type == "variable" || cx.style == "keyword") {
454 | cx.marked = "property";
455 | if (value == "get" || value == "set") return cont(getterSetter);
456 | return cont(afterprop);
457 | } else if (type == "number" || type == "string") {
458 | cx.marked = jsonldMode ? "property" : (cx.style + " property");
459 | return cont(afterprop);
460 | } else if (type == "jsonld-keyword") {
461 | return cont(afterprop);
462 | } else if (type == "[") {
463 | return cont(expression, expect("]"), afterprop);
464 | } else if (type == "spread") {
465 | return cont(expression);
466 | }
467 | }
468 | function getterSetter(type) {
469 | if (type != "variable") return pass(afterprop);
470 | cx.marked = "property";
471 | return cont(functiondef);
472 | }
473 | function afterprop(type) {
474 | if (type == ":") return cont(expressionNoComma);
475 | if (type == "(") return pass(functiondef);
476 | }
477 | function commasep(what, end) {
478 | function proceed(type) {
479 | if (type == ",") {
480 | var lex = cx.state.lexical;
481 | if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
482 | return cont(what, proceed);
483 | }
484 | if (type == end) return cont();
485 | return cont(expect(end));
486 | }
487 | return function(type) {
488 | if (type == end) return cont();
489 | return pass(what, proceed);
490 | };
491 | }
492 | function contCommasep(what, end, info) {
493 | for (var i = 3; i < arguments.length; i++)
494 | cx.cc.push(arguments[i]);
495 | return cont(pushlex(end, info), commasep(what, end), poplex);
496 | }
497 | function block(type) {
498 | if (type == "}") return cont();
499 | return pass(statement, block);
500 | }
501 | function maybetype(type) {
502 | if (isTS && type == ":") return cont(typedef);
503 | }
504 | function maybedefault(_, value) {
505 | if (value == "=") return cont(expressionNoComma);
506 | }
507 | function typedef(type) {
508 | if (type == "variable") {cx.marked = "variable-3"; return cont();}
509 | }
510 | function vardef() {
511 | return pass(pattern, maybetype, maybeAssign, vardefCont);
512 | }
513 | function pattern(type, value) {
514 | if (type == "variable") { register(value); return cont(); }
515 | if (type == "spread") return cont(pattern);
516 | if (type == "[") return contCommasep(pattern, "]");
517 | if (type == "{") return contCommasep(proppattern, "}");
518 | }
519 | function proppattern(type, value) {
520 | if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
521 | register(value);
522 | return cont(maybeAssign);
523 | }
524 | if (type == "variable") cx.marked = "property";
525 | if (type == "spread") return cont(pattern);
526 | return cont(expect(":"), pattern, maybeAssign);
527 | }
528 | function maybeAssign(_type, value) {
529 | if (value == "=") return cont(expressionNoComma);
530 | }
531 | function vardefCont(type) {
532 | if (type == ",") return cont(vardef);
533 | }
534 | function maybeelse(type, value) {
535 | if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
536 | }
537 | function forspec(type) {
538 | if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
539 | }
540 | function forspec1(type) {
541 | if (type == "var") return cont(vardef, expect(";"), forspec2);
542 | if (type == ";") return cont(forspec2);
543 | if (type == "variable") return cont(formaybeinof);
544 | return pass(expression, expect(";"), forspec2);
545 | }
546 | function formaybeinof(_type, value) {
547 | if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
548 | return cont(maybeoperatorComma, forspec2);
549 | }
550 | function forspec2(type, value) {
551 | if (type == ";") return cont(forspec3);
552 | if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
553 | return pass(expression, expect(";"), forspec3);
554 | }
555 | function forspec3(type) {
556 | if (type != ")") cont(expression);
557 | }
558 | function functiondef(type, value) {
559 | if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
560 | if (type == "variable") {register(value); return cont(functiondef);}
561 | if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, statement, popcontext);
562 | }
563 | function funarg(type) {
564 | if (type == "spread") return cont(funarg);
565 | return pass(pattern, maybetype, maybedefault);
566 | }
567 | function className(type, value) {
568 | if (type == "variable") {register(value); return cont(classNameAfter);}
569 | }
570 | function classNameAfter(type, value) {
571 | if (value == "extends") return cont(expression, classNameAfter);
572 | if (type == "{") return cont(pushlex("}"), classBody, poplex);
573 | }
574 | function classBody(type, value) {
575 | if (type == "variable" || cx.style == "keyword") {
576 | if (value == "static") {
577 | cx.marked = "keyword";
578 | return cont(classBody);
579 | }
580 | cx.marked = "property";
581 | if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody);
582 | return cont(functiondef, classBody);
583 | }
584 | if (value == "*") {
585 | cx.marked = "keyword";
586 | return cont(classBody);
587 | }
588 | if (type == ";") return cont(classBody);
589 | if (type == "}") return cont();
590 | }
591 | function classGetterSetter(type) {
592 | if (type != "variable") return pass();
593 | cx.marked = "property";
594 | return cont();
595 | }
596 | function afterExport(_type, value) {
597 | if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
598 | if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
599 | return pass(statement);
600 | }
601 | function afterImport(type) {
602 | if (type == "string") return cont();
603 | return pass(importSpec, maybeFrom);
604 | }
605 | function importSpec(type, value) {
606 | if (type == "{") return contCommasep(importSpec, "}");
607 | if (type == "variable") register(value);
608 | if (value == "*") cx.marked = "keyword";
609 | return cont(maybeAs);
610 | }
611 | function maybeAs(_type, value) {
612 | if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
613 | }
614 | function maybeFrom(_type, value) {
615 | if (value == "from") { cx.marked = "keyword"; return cont(expression); }
616 | }
617 | function arrayLiteral(type) {
618 | if (type == "]") return cont();
619 | return pass(expressionNoComma, maybeArrayComprehension);
620 | }
621 | function maybeArrayComprehension(type) {
622 | if (type == "for") return pass(comprehension, expect("]"));
623 | if (type == ",") return cont(commasep(maybeexpressionNoComma, "]"));
624 | return pass(commasep(expressionNoComma, "]"));
625 | }
626 | function comprehension(type) {
627 | if (type == "for") return cont(forspec, comprehension);
628 | if (type == "if") return cont(expression, comprehension);
629 | }
630 |
631 | function isContinuedStatement(state, textAfter) {
632 | return state.lastType == "operator" || state.lastType == "," ||
633 | isOperatorChar.test(textAfter.charAt(0)) ||
634 | /[,.]/.test(textAfter.charAt(0));
635 | }
636 |
637 | // Interface
638 |
639 | return {
640 | startState: function(basecolumn) {
641 | var state = {
642 | tokenize: tokenBase,
643 | lastType: "sof",
644 | cc: [],
645 | lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
646 | localVars: parserConfig.localVars,
647 | context: parserConfig.localVars && {vars: parserConfig.localVars},
648 | indented: 0
649 | };
650 | if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
651 | state.globalVars = parserConfig.globalVars;
652 | return state;
653 | },
654 |
655 | token: function(stream, state) {
656 | if (stream.sol()) {
657 | if (!state.lexical.hasOwnProperty("align"))
658 | state.lexical.align = false;
659 | state.indented = stream.indentation();
660 | findFatArrow(stream, state);
661 | }
662 | if (state.tokenize != tokenComment && stream.eatSpace()) return null;
663 | var style = state.tokenize(stream, state);
664 | if (type == "comment") return style;
665 | state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
666 | return parseJS(state, style, type, content, stream);
667 | },
668 |
669 | indent: function(state, textAfter) {
670 | if (state.tokenize == tokenComment) return CodeMirror.Pass;
671 | if (state.tokenize != tokenBase) return 0;
672 | var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
673 | // Kludge to prevent 'maybelse' from blocking lexical scope pops
674 | if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
675 | var c = state.cc[i];
676 | if (c == poplex) lexical = lexical.prev;
677 | else if (c != maybeelse) break;
678 | }
679 | if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
680 | if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
681 | lexical = lexical.prev;
682 | var type = lexical.type, closing = firstChar == type;
683 |
684 | if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0);
685 | else if (type == "form" && firstChar == "{") return lexical.indented;
686 | else if (type == "form") return lexical.indented + indentUnit;
687 | else if (type == "stat")
688 | return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
689 | else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
690 | return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
691 | else if (lexical.align) return lexical.column + (closing ? 0 : 1);
692 | else return lexical.indented + (closing ? 0 : indentUnit);
693 | },
694 |
695 | electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
696 | blockCommentStart: jsonMode ? null : "/*",
697 | blockCommentEnd: jsonMode ? null : "*/",
698 | lineComment: jsonMode ? null : "//",
699 | fold: "brace",
700 | closeBrackets: "()[]{}''\"\"``",
701 |
702 | helperType: jsonMode ? "json" : "javascript",
703 | jsonldMode: jsonldMode,
704 | jsonMode: jsonMode
705 | };
706 | });
707 |
708 | CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
709 |
710 | CodeMirror.defineMIME("text/javascript", "javascript");
711 | CodeMirror.defineMIME("text/ecmascript", "javascript");
712 | CodeMirror.defineMIME("application/javascript", "javascript");
713 | CodeMirror.defineMIME("application/x-javascript", "javascript");
714 | CodeMirror.defineMIME("application/ecmascript", "javascript");
715 | CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
716 | CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
717 | CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
718 | CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
719 | CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
720 |
721 | });
722 |
--------------------------------------------------------------------------------
/example/src/app.js:
--------------------------------------------------------------------------------
1 | var React = require('react');
2 | var ReactDOM = require('react-dom');
3 |
4 | var selfCleaningTimeout = {
5 | componentDidUpdate: function() {
6 | clearTimeout(this.timeoutID);
7 | },
8 | setTimeout: function() {
9 | clearTimeout(this.timeoutID);
10 | this.timeoutID = setTimeout.apply(null, arguments);
11 | }
12 | };
13 |
14 | var ComponentPreview = React.createClass({
15 | propTypes: {
16 | code: React.PropTypes.string.isRequired
17 | },
18 |
19 | mixins: [selfCleaningTimeout],
20 |
21 | render: function() {
22 | return
;
23 | },
24 |
25 | componentDidMount: function() {
26 | this.executeCode();
27 | },
28 |
29 | componentDidUpdate: function(prevProps) {
30 | // execute code only when the state's not being updated by switching tab
31 | // this avoids re-displaying the error, which comes after a certain delay
32 | if (this.props.code !== prevProps.code) {
33 | this.executeCode();
34 | }
35 | },
36 |
37 | compileCode: function() {
38 | return JSXTransformer.transform(
39 | '(function() {' +
40 | this.props.code +
41 | '\n})();',
42 | { harmony: true }
43 | ).code;
44 | },
45 |
46 | executeCode: function() {
47 | var mountNode = this.refs.mount;
48 |
49 | try {
50 | ReactDOM.unmountComponentAtNode(mountNode);
51 | } catch (e) { }
52 |
53 | try {
54 | var compiledCode = this.compileCode();
55 | ReactDOM.render(eval(compiledCode), mountNode);
56 | } catch (err) {
57 |
58 | this.setTimeout(function() {
59 | ReactDOM.render(
60 | { err.stack || err.toString() }
,
61 | mountNode
62 | );
63 | }, 500);
64 | }
65 | }
66 | });
67 |
68 | var IS_MOBILE = (
69 | navigator.userAgent.match(/Android/i)
70 | || navigator.userAgent.match(/webOS/i)
71 | || navigator.userAgent.match(/iPhone/i)
72 | || navigator.userAgent.match(/iPad/i)
73 | || navigator.userAgent.match(/iPod/i)
74 | || navigator.userAgent.match(/BlackBerry/i)
75 | || navigator.userAgent.match(/Windows Phone/i)
76 | );
77 |
78 | var CodeMirrorEditor = React.createClass({
79 | componentDidMount: function() {
80 | if (IS_MOBILE) return;
81 |
82 | this.editor = CodeMirror.fromTextArea(this.refs.editor, {
83 | mode: 'javascript',
84 | //lineNumbers: true,
85 | viewportMargin: Infinity,
86 | lineWrapping: true,
87 | smartIndent: false, // javascript mode does bad things with jsx indents
88 | matchBrackets: true,
89 | readOnly: this.props.readOnly
90 | });
91 | this.editor.on('change', this.handleChange);
92 | },
93 |
94 | componentDidUpdate: function() {
95 | if (this.props.readOnly) {
96 | this.editor.setValue(this.props.codeText);
97 | }
98 | },
99 |
100 | handleChange: function() {
101 | if (!this.props.readOnly && this.props.onChange) {
102 | this.props.onChange(this.editor.getValue());
103 | }
104 | },
105 |
106 | render: function() {
107 | // wrap in a div to fully contain CodeMirror
108 | var editor;
109 |
110 | if (IS_MOBILE) {
111 | editor = {this.props.codeText} ;
112 | } else {
113 | editor = ;
114 | }
115 |
116 | return (
117 |
118 | {editor}
119 |
120 | );
121 | }
122 | });
123 |
124 | var ReactPlayground = React.createClass({
125 | propTypes: {
126 | codeText: React.PropTypes.string.isRequired
127 | },
128 |
129 | getInitialState: function() {
130 | return {
131 | code: this.props.codeText
132 | };
133 | },
134 |
135 | handleCodeChange: function(code) {
136 | this.setState({
137 | code: code
138 | });
139 | },
140 |
141 | changeTab: function(){
142 | if(this.state.tab == 'preview')
143 | this.setState({
144 | tab: 'edit'
145 | })
146 | else
147 | this.setState({
148 | tab: 'preview'
149 | })
150 | },
151 |
152 | render: function() {
153 |
154 | var tabText = this.state.tab == 'preview'? 'Live Preview': 'Live Edit';
155 | var code =
156 |
160 |
;
161 |
162 | var preview =
163 |
164 |
165 |
166 | return (
167 |
168 |
{tabText}
169 | {this.state.tab == 'preview'? code: preview}
170 |
171 | );
172 | }
173 | });
174 |
175 | for(var id=1; id<10; id++){
176 | var example = document.getElementById('example'+id);
177 | if(example){
178 | ReactDOM.render(
179 | ,
180 | example
181 | );
182 | }
183 | }
184 |
--------------------------------------------------------------------------------
/example/src/app.less:
--------------------------------------------------------------------------------
1 | *, *:before, *:after {
2 | -webkit-box-sizing: inherit;
3 | -moz-box-sizing: inherit;
4 | box-sizing: inherit;
5 | }
6 |
7 | html {
8 | -ms-text-size-adjust: 100%;
9 | -webkit-text-size-adjust: 100%;
10 | overflow-x: hidden;
11 | }
12 |
13 | body {
14 | background: #eee;
15 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
16 | margin: 0;
17 |
18 | line-height: 1.5;
19 | color: #2b303b;
20 |
21 | -webkit-box-sizing: border-box;
22 | -moz-box-sizing: border-box;
23 | box-sizing: border-box;
24 |
25 | -moz-osx-font-smoothing: grayscale;
26 | -webkit-font-smoothing: antialiased;
27 | }
28 |
29 | h1 {
30 | font-size: 2em;
31 | font-weight: 500;
32 | margin: 1em auto;
33 | text-align: center;
34 | }
35 |
36 | h2 {
37 | font-size: 32px;
38 | font-size: 2rem;
39 | }
40 |
41 | .center {
42 | text-align: center;
43 | }
44 |
45 | .example {
46 | margin-bottom: 20px;
47 | }
48 |
49 | .playground:after {
50 | content: "";
51 | display: table;
52 | clear: both;
53 | background: white;
54 | }
55 |
56 | .playgroundTab {
57 | border-bottom: none !important;
58 | border-radius: 3px 3px 0 0;
59 | padding: 6px 8px;
60 | font-size: 12px;
61 | font-weight: bold;
62 | color: #C94E50;
63 | display: inline-block;
64 | cursor: pointer;
65 | }
66 |
67 | .playgroundCode, .playgroundTab, .playgroundPreview {
68 | border: 1px solid rgba(16, 16, 16, 0.1);
69 | background: white;
70 | }
71 |
72 | .playgroundCode, .playgroundPreview {
73 | display: block;
74 | border-radius: 0 3px 3px 3px;
75 | }
76 |
77 | /* Layout */
78 | .container {
79 | margin: 0 auto;
80 | max-width: 960px;
81 | padding-left: 1em;
82 | padding-right: 1em;
83 | }
84 |
85 | .row {
86 | padding: 20px 0;
87 | padding: 1rem 0;
88 | }
89 |
90 | /* header */
91 | header {
92 | position: relative;
93 | padding-top: 36px;
94 | padding-bottom: 45px;
95 | margin-bottom: 3rem;
96 | }
97 |
98 | header:before {
99 | content: "";
100 | background: #C94E50;
101 | box-shadow: 0 15px 0 #B64042, 0 30px 0 #A33739, 0 45px 0 #942527;
102 | -webkit-transform: rotate(-5deg);
103 | -moz-transform: rotate(-5deg);
104 | transform: rotate(-5deg);
105 | margin-top: -170px;
106 |
107 | position: absolute;
108 | top: 0;
109 | right: -20%;
110 | left: -20%;
111 | bottom: 0;
112 | }
113 |
114 | .logo {
115 | font-size: 24px;
116 | font-size: 1.5rem;
117 | line-height: 1;
118 | height: 230px;
119 | margin: 0 auto;
120 | padding: 15px;
121 | position: relative;
122 | text-align: center;
123 | width: 230px;
124 | background: #C94E50;
125 | color: #fff;
126 | border: 22px solid #fff;
127 | text-rendering: optimizeLegibility;
128 | }
129 |
130 | .logo:before {
131 | content: "B";
132 | font-size: 140px;
133 | position: absolute;
134 | right: 0;
135 | bottom: 0;
136 | left: 0;
137 | line-height: 1;
138 | pointer-events: none;
139 | }
140 |
141 | main {
142 | padding-top: 36px;
143 | }
144 |
145 | .installer {
146 | display: inline-block;
147 | background: #2b303b;
148 | border: 1px solid #16191F;
149 | color: #fff;
150 | font-family: "Source Code Pro", monospace;
151 | font-size: 18px;
152 | line-height: 1.2;
153 | margin: 0 auto;
154 | padding: 16px 32px;
155 | }
156 |
157 | footer {
158 | background: #2b303b;
159 | color: #fff;
160 | }
161 |
162 | footer a {
163 | font-weight: 700;
164 | color: #C94E50;
165 | text-decoration: none;
166 | }
167 |
168 | footer a:hover,
169 | footer a:focus {
170 | color: #fff;
171 | }
172 |
173 | .CodeMirror {
174 | height: 800px;
175 | }
176 |
177 | .blur {
178 | -webkit-animation:blur 10s 3s ease-out infinite;
179 | }
180 |
181 | @-webkit-keyframes blur{
182 | from{
183 | transform: scaleX(1.1) scaleY(1.1);
184 | opacity: 0.8;
185 | }
186 | }
187 |
188 |
189 |
190 | .demo-enter {
191 | opacity: 0.01;
192 | height: 0px;
193 | padding: 0px 10px !important;
194 | transition: opacity 500ms ease-out,
195 | padding 500ms ease-out,
196 | height 500ms ease-out;
197 | }
198 | .demo-enter.demo-enter-active {
199 | opacity: 1;
200 | height: 16px;
201 | padding: 10px !important;
202 | }
203 | .demo-leave {
204 | opacity: 1;
205 | height: 16px;
206 | transition: opacity 500ms ease-out,
207 | padding 500ms ease-out,
208 | height 500ms ease-out;
209 | }
210 | .demo-leave.demo-leave-active {
211 | opacity: 0;
212 | height: 0px;
213 | padding: 0px 10px !important;
214 | }
215 |
--------------------------------------------------------------------------------
/example/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Boron
6 |
7 |
8 |
9 |
10 |
11 |
77 |
78 |
79 |
86 |
87 |
88 |
89 |
90 | npm install boron
91 |
92 |
93 |
94 |
95 |
98 |
99 |
100 |
101 |
102 |
103 |
104 | Github
105 |
106 |
107 |
108 |
109 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | var browserify = require('browserify'),
2 | shim = require('browserify-shim'),
3 | chalk = require('chalk'),
4 | del = require('del'),
5 | vinyPaths = require('vinyl-paths'),
6 | gulp = require('gulp'),
7 | bump = require('gulp-bump'),
8 | connect = require('gulp-connect'),
9 | deploy = require("gulp-gh-pages"),
10 | git = require("gulp-git"),
11 | less = require('gulp-less'),
12 | rename = require('gulp-rename'),
13 | streamify = require('gulp-streamify'),
14 | uglify = require('gulp-uglify'),
15 | gutil = require('gulp-util'),
16 | merge = require('merge-stream'),
17 | reactify = require('reactify'),
18 | react = require('gulp-react'),
19 | source = require('vinyl-source-stream'),
20 | watchify = require('watchify');
21 |
22 |
23 | /**
24 | * Constants
25 | */
26 |
27 | var SRC_PATH = 'src';
28 | var DIST_PATH = 'dist';
29 |
30 | var COMPONENT_NAME = 'Boron';
31 | var PACKAGE_FILE = COMPONENT_NAME + '.js';
32 | var PACKAGE_NAME = COMPONENT_NAME.toLowerCase();
33 |
34 | var DEPENDENCIES = ['react', 'react-dom'];
35 |
36 | var EXAMPLE_SRC_PATH = 'example/src';
37 | var EXAMPLE_DIST_PATH = 'example/dist';
38 |
39 | var EXAMPLE_APP = 'app.js';
40 | var EXAMPLE_COPY = [
41 | 'node_modules/codemirror/lib/codemirror.js',
42 | 'node_modules/codemirror/lib/codemirror.css',
43 | 'node_modules/codemirror/mode/javascript/javascript.js',
44 | 'node_modules/react/dist/JSXTransformer.js'
45 | ];
46 | var EXAMPLE_LESS = 'app.less';
47 | var EXAMPLE_FILES = [
48 | 'index.html'
49 | ];
50 |
51 |
52 | /**
53 | * Bundle helpers
54 | */
55 |
56 | function doBundle(target, name, dest) {
57 | return target.bundle()
58 | .on('error', function(e) {
59 | gutil.log('Browserify Error', e);
60 | })
61 | .pipe(source(name))
62 | .pipe(gulp.dest(dest))
63 | .pipe(connect.reload());
64 | }
65 |
66 | function watchBundle(target, name, dest) {
67 | return watchify(target)
68 | .on('update', function (scriptIds) {
69 | scriptIds = scriptIds
70 | .filter(function(i) { return i.substr(0,2) !== './' })
71 | .map(function(i) { return chalk.blue(i.replace(__dirname, '')) });
72 | if (scriptIds.length > 1) {
73 | gutil.log(scriptIds.length + ' Scripts updated:\n* ' + scriptIds.join('\n* ') + '\nrebuilding...');
74 | } else {
75 | gutil.log(scriptIds[0] + ' updated, rebuilding...');
76 | }
77 | doBundle(target, name, dest);
78 | })
79 | .on('time', function (time) {
80 | gutil.log(chalk.green(name + ' built in ' + (Math.round(time / 10) / 100) + 's'));
81 | });
82 | }
83 |
84 |
85 | /**
86 | * Prepare task for examples
87 | */
88 |
89 | gulp.task('clean:examples', function(done) {
90 | del([EXAMPLE_DIST_PATH], done);
91 | });
92 |
93 |
94 | /**
95 | * Build example files
96 | */
97 | gulp.task('build:example:files', function buildExampleFiles() {
98 | return gulp.src(EXAMPLE_FILES.map(function(i) { return EXAMPLE_SRC_PATH + '/' + i }))
99 | .pipe(gulp.dest(EXAMPLE_DIST_PATH))
100 | .pipe(connect.reload());
101 | });
102 |
103 |
104 | /**
105 | * Build example css from less
106 | */
107 | gulp.task('build:example:css', function buildExampleCSS() {
108 | return gulp.src(EXAMPLE_SRC_PATH + '/' + EXAMPLE_LESS)
109 | .pipe(less())
110 | .pipe(gulp.dest(EXAMPLE_DIST_PATH))
111 | .pipe(connect.reload());
112 | });
113 |
114 |
115 | /**
116 | * Build example scripts
117 | *
118 | * Returns a gulp task with watchify when in development mode
119 | */
120 |
121 | function buildExampleScripts(dev) {
122 |
123 | var dest = EXAMPLE_DIST_PATH;
124 |
125 | var opts = dev ? watchify.args : {};
126 | opts.debug = dev ? true : false;
127 | opts.hasExports = true;
128 |
129 | return function() {
130 |
131 | var common = browserify(opts),
132 | bundle = browserify(opts).require('./' + SRC_PATH + '/' + PACKAGE_FILE, { expose: PACKAGE_NAME }),
133 | example = browserify(opts).exclude(PACKAGE_NAME).add('./' + EXAMPLE_SRC_PATH + '/' + EXAMPLE_APP);
134 |
135 | DEPENDENCIES.forEach(function(pkg) {
136 | common.require(pkg);
137 | bundle.exclude(pkg);
138 | example.exclude(pkg);
139 | });
140 |
141 | if (dev) {
142 | watchBundle(common, 'common.js', dest);
143 | watchBundle(bundle, 'bundle.js', dest);
144 | watchBundle(example, 'app.js', dest);
145 | }
146 |
147 | return merge(
148 | doBundle(common, 'common.js', dest),
149 | doBundle(bundle, 'bundle.js', dest),
150 | doBundle(example, 'app.js', dest)
151 | );
152 |
153 | }
154 |
155 | };
156 |
157 |
158 | gulp.task('dev:build:example:scripts', buildExampleScripts(true));
159 | gulp.task('build:example:scripts', buildExampleScripts());
160 |
161 | gulp.task('build:example:copy', function(){
162 | return gulp.src(EXAMPLE_COPY)
163 | .pipe(gulp.dest(EXAMPLE_DIST_PATH))
164 | .pipe(connect.reload());
165 | });
166 |
167 | /**
168 | * Build examples
169 | */
170 | gulp.task('build:examples', [
171 | 'build:example:files',
172 | 'build:example:css',
173 | 'build:example:scripts',
174 | 'build:example:copy'
175 | ]);
176 |
177 | gulp.task('watch:examples', [
178 | 'build:example:files',
179 | 'build:example:css',
180 | 'dev:build:example:scripts',
181 | 'build:example:copy'
182 | ], function() {
183 | gulp.watch(EXAMPLE_FILES.map(function(i) { return EXAMPLE_SRC_PATH + '/' + i }), ['build:example:files']);
184 | gulp.watch([EXAMPLE_SRC_PATH + '/' + EXAMPLE_LESS], ['build:example:css']);
185 | });
186 |
187 |
188 | /**
189 | * Serve task for local development
190 | */
191 |
192 | gulp.task('dev:server', function() {
193 | connect.server({
194 | root: 'example/dist',
195 | port: 9999,
196 | livereload: true
197 | });
198 | });
199 |
200 | /**
201 | * Development task
202 | */
203 |
204 | gulp.task('dev', [
205 | 'dev:server',
206 | 'watch:examples'
207 | ]);
208 |
209 |
210 | /**
211 | * Build task
212 | */
213 |
214 | gulp.task('clean:dist', function(done) {
215 | del([DIST_PATH], done);
216 | });
217 |
218 | gulp.task('build:dist', function() {
219 |
220 | var standalone = browserify('./' + SRC_PATH + '/' + PACKAGE_FILE, {
221 | standalone: COMPONENT_NAME
222 | })
223 | .transform(reactify)
224 | .transform(shim);
225 |
226 | DEPENDENCIES.forEach(function(pkg) {
227 | standalone.exclude(pkg);
228 | });
229 |
230 | return standalone.bundle()
231 | .on('error', function(e) {
232 | gutil.log('Browserify Error', e);
233 | })
234 | .pipe(source(PACKAGE_NAME + '.js'))
235 | .pipe(gulp.dest(DIST_PATH))
236 | .pipe(rename(PACKAGE_NAME + '.min.js'))
237 | .pipe(streamify(uglify()))
238 | .pipe(gulp.dest(DIST_PATH));
239 |
240 | });
241 |
242 | gulp.task('build', [
243 | 'clean:dist',
244 | ], function(){
245 | gulp.start('build:dist', 'build:examples')
246 | });
247 |
248 |
249 | /**
250 | * Version bump tasks
251 | */
252 |
253 | function getBumpTask(type) {
254 | return function() {
255 | return gulp.src(['./package.json'])
256 | .pipe(bump({ type: type }))
257 | .pipe(gulp.dest('./'));
258 | };
259 | }
260 |
261 | gulp.task('bump', getBumpTask('patch'));
262 | gulp.task('bump:minor', getBumpTask('minor'));
263 | gulp.task('bump:major', getBumpTask('major'));
264 |
265 |
266 | /**
267 | * Git tag task
268 | * (version *must* be bumped first)
269 | */
270 |
271 | gulp.task('publish:tag', function(done) {
272 | var pkg = require('./package.json');
273 | var v = 'v' + pkg.version;
274 | var message = 'Release ' + v;
275 |
276 | git.tag(v, message, function (err) {
277 | if (err) throw err;
278 | git.push('origin', v, function (err) {
279 | if (err) throw err;
280 | done();
281 | });
282 | });
283 | });
284 |
285 |
286 |
287 | /**
288 | * npm publish task
289 | * * (version *must* be bumped first)
290 | */
291 | function buildToRoot(){
292 | return gulp.src(SRC_PATH + '/*.js')
293 | .pipe(react())
294 | .pipe(gulp.dest('./'))
295 | }
296 |
297 | gulp.task('build:npm', buildToRoot);
298 |
299 | gulp.task('publish:npm', ['build:npm'], function(done) {
300 |
301 | require('child_process')
302 | .spawn('npm', ['publish'], { stdio: 'inherit' })
303 | .on('close', done);
304 | });
305 |
306 | gulp.task('clean:npm', function () {
307 | buildToRoot().pipe(vinyPaths(del))
308 | })
309 |
310 | gulp.task('release:npm', ['publish:npm'], function(){
311 | gulp.start('clean:npm')
312 | });
313 |
314 |
315 | /**
316 | * Deploy tasks
317 | */
318 |
319 | gulp.task('publish:examples', ['build:examples'], function() {
320 | return gulp.src(EXAMPLE_DIST_PATH + '/**/*').pipe(deploy());
321 | });
322 |
323 | gulp.task('release', ['publish:tag', 'release:npm', 'publish:examples']);
324 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "boron",
3 | "version": "0.2.4",
4 | "description": "A collection of dialog animations with React.js",
5 | "main": "Boron.js",
6 | "author": "Yuanyan Cao",
7 | "license": "MIT",
8 | "repository": {
9 | "type": "git",
10 | "url": "https://github.com/yuanyan/boron.git"
11 | },
12 | "dependencies": {
13 | "domkit": "^0.0.1"
14 | },
15 | "peerDependencies": {
16 | "react": ">=0.14.0"
17 | },
18 | "devDependencies": {
19 | "react-dom": ">=0.14.0",
20 | "reactify": "^0.17.0",
21 | "browserify": "^6.3.3",
22 | "browserify-shim": "^3.8.0",
23 | "chalk": "^0.5.1",
24 | "codemirror": "^5.0.0",
25 | "del": "^0.1.3",
26 | "gulp": "^3.8.10",
27 | "gulp-bump": "^0.1.11",
28 | "gulp-connect": "^2.2.0",
29 | "gulp-gh-pages": "^0.4.0",
30 | "gulp-git": "^0.5.5",
31 | "gulp-less": "^1.3.6",
32 | "gulp-rename": "^1.2.0",
33 | "gulp-streamify": "^0.0.5",
34 | "gulp-uglify": "^1.0.1",
35 | "gulp-util": "^3.0.1",
36 | "merge-stream": "^0.1.6",
37 | "vinyl-paths": "^1.0.0",
38 | "vinyl-source-stream": "^1.0.0",
39 | "watchify": "^2.1.1",
40 | "gulp-react": "^3.0.1"
41 | },
42 | "browserify": {
43 | "transform": [
44 | "reactify"
45 | ]
46 | },
47 | "browserify-shim": {
48 | "react": "global:React"
49 | },
50 | "scripts": {
51 | "release": "gulp release"
52 | },
53 | "keywords": [
54 | "react",
55 | "react-component",
56 | "dialog",
57 | "modal"
58 | ]
59 | }
60 |
--------------------------------------------------------------------------------
/src/Boron.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | DropModal: require('./DropModal'),
3 | WaveModal: require('./WaveModal'),
4 | FlyModal: require('./FlyModal'),
5 | FadeModal: require('./FadeModal'),
6 | ScaleModal: require('./ScaleModal'),
7 | OutlineModal: require('./OutlineModal'),
8 | }
9 |
--------------------------------------------------------------------------------
/src/DropModal.js:
--------------------------------------------------------------------------------
1 | var modalFactory = require('./modalFactory');
2 | var insertKeyframesRule = require('domkit/insertKeyframesRule');
3 | var appendVendorPrefix = require('domkit/appendVendorPrefix');
4 |
5 | var animation = {
6 | show: {
7 | animationDuration: '0.4s',
8 | animationTimingFunction: 'cubic-bezier(0.7,0,0.3,1)'
9 | },
10 |
11 | hide: {
12 | animationDuration: '0.4s',
13 | animationTimingFunction: 'cubic-bezier(0.7,0,0.3,1)'
14 | },
15 |
16 | showModalAnimation: insertKeyframesRule({
17 | '0%': {
18 | opacity: 0,
19 | transform: 'translate(-50%, -300px)'
20 | },
21 | '100%': {
22 | opacity: 1,
23 | transform: 'translate(-50%, -50%)'
24 | }
25 | }),
26 |
27 | hideModalAnimation: insertKeyframesRule({
28 | '0%': {
29 | opacity: 1,
30 | transform: 'translate(-50%, -50%)'
31 | },
32 | '100%': {
33 | opacity: 0,
34 | transform: 'translate(-50%, 100px)'
35 | }
36 | }),
37 |
38 | showBackdropAnimation: insertKeyframesRule({
39 | '0%': {
40 | opacity: 0
41 | },
42 | '100%': {
43 | opacity: 0.9
44 | }
45 | }),
46 |
47 | hideBackdropAnimation: insertKeyframesRule({
48 | '0%': {
49 | opacity: 0.9
50 | },
51 | '100%': {
52 | opacity: 0
53 | }
54 | }),
55 |
56 | showContentAnimation: insertKeyframesRule({
57 | '0%': {
58 | opacity: 0,
59 | transform: 'translate(0, -20px)'
60 | },
61 | '100%': {
62 | opacity: 1,
63 | transform: 'translate(0, 0)'
64 | }
65 | }),
66 |
67 | hideContentAnimation: insertKeyframesRule({
68 | '0%': {
69 | opacity: 1,
70 | transform: 'translate(0, 0)'
71 | },
72 | '100%': {
73 | opacity: 0,
74 | transform: 'translate(0, 50px)'
75 | }
76 | })
77 | };
78 |
79 | var showAnimation = animation.show;
80 | var hideAnimation = animation.hide;
81 | var showModalAnimation = animation.showModalAnimation;
82 | var hideModalAnimation = animation.hideModalAnimation;
83 | var showBackdropAnimation = animation.showBackdropAnimation;
84 | var hideBackdropAnimation = animation.hideBackdropAnimation;
85 | var showContentAnimation = animation.showContentAnimation;
86 | var hideContentAnimation = animation.hideContentAnimation;
87 |
88 | module.exports = modalFactory({
89 | getRef: function(willHidden) {
90 | return 'modal';
91 | },
92 | getModalStyle: function(willHidden) {
93 | return appendVendorPrefix({
94 | position: "fixed",
95 | width: "500px",
96 | transform: "translate(-50%, -50%)",
97 | top: "50%",
98 | left: "50%",
99 | backgroundColor: "white",
100 | zIndex: 1050,
101 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
102 | animationFillMode: 'forwards',
103 | animationName: willHidden ? hideModalAnimation : showModalAnimation,
104 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
105 | })
106 | },
107 | getBackdropStyle: function(willHidden) {
108 | return appendVendorPrefix({
109 | position: "fixed",
110 | top: 0,
111 | right: 0,
112 | bottom: 0,
113 | left: 0,
114 | zIndex: 1040,
115 | backgroundColor: "#373A47",
116 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
117 | animationFillMode: 'forwards',
118 | animationName: willHidden ? hideBackdropAnimation : showBackdropAnimation,
119 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
120 | });
121 | },
122 | getContentStyle: function(willHidden) {
123 | return appendVendorPrefix({
124 | margin: 0,
125 | opacity: 0,
126 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
127 | animationFillMode: 'forwards',
128 | animationDelay: '0.25s',
129 | animationName: showContentAnimation,
130 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
131 | })
132 | }
133 | });
134 |
--------------------------------------------------------------------------------
/src/FadeModal.js:
--------------------------------------------------------------------------------
1 | var modalFactory = require('./modalFactory');
2 | var insertKeyframesRule = require('domkit/insertKeyframesRule');
3 | var appendVendorPrefix = require('domkit/appendVendorPrefix');
4 |
5 | var animation = {
6 | show: {
7 | animationDuration: '0.3s',
8 | animationTimingFunction: 'ease-out'
9 | },
10 | hide: {
11 | animationDuration: '0.3s',
12 | animationTimingFunction: 'ease-out'
13 | },
14 | showContentAnimation: insertKeyframesRule({
15 | '0%': {
16 | opacity: 0
17 | },
18 | '100%': {
19 | opacity: 1
20 | }
21 | }),
22 |
23 | hideContentAnimation: insertKeyframesRule({
24 | '0%': {
25 | opacity: 1
26 | },
27 | '100%': {
28 | opacity: 0
29 | }
30 | }),
31 |
32 | showBackdropAnimation: insertKeyframesRule({
33 | '0%': {
34 | opacity: 0
35 | },
36 | '100%': {
37 | opacity: 0.9
38 | },
39 | }),
40 |
41 | hideBackdropAnimation: insertKeyframesRule({
42 | '0%': {
43 | opacity: 0.9
44 | },
45 | '100%': {
46 | opacity: 0
47 | }
48 | })
49 | };
50 |
51 | var showAnimation = animation.show;
52 | var hideAnimation = animation.hide;
53 | var showContentAnimation = animation.showContentAnimation;
54 | var hideContentAnimation = animation.hideContentAnimation;
55 | var showBackdropAnimation = animation.showBackdropAnimation;
56 | var hideBackdropAnimation = animation.hideBackdropAnimation;
57 |
58 | module.exports = modalFactory({
59 | getRef: function(willHidden) {
60 | return 'content';
61 | },
62 | getModalStyle: function(willHidden) {
63 | return appendVendorPrefix({
64 | zIndex: 1050,
65 | position: "fixed",
66 | width: "500px",
67 | transform: "translate3d(-50%, -50%, 0)",
68 | top: "50%",
69 | left: "50%"
70 | })
71 | },
72 | getBackdropStyle: function(willHidden) {
73 | return appendVendorPrefix({
74 | position: "fixed",
75 | top: 0,
76 | right: 0,
77 | bottom: 0,
78 | left: 0,
79 | zIndex: 1040,
80 | backgroundColor: "#373A47",
81 | animationFillMode: 'forwards',
82 | animationDuration: '0.3s',
83 | animationName: willHidden ? hideBackdropAnimation : showBackdropAnimation,
84 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
85 | });
86 | },
87 | getContentStyle: function(willHidden) {
88 | return appendVendorPrefix({
89 | margin: 0,
90 | backgroundColor: "white",
91 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
92 | animationFillMode: 'forwards',
93 | animationName: willHidden ? hideContentAnimation : showContentAnimation,
94 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
95 | })
96 | }
97 | });
98 |
--------------------------------------------------------------------------------
/src/FlyModal.js:
--------------------------------------------------------------------------------
1 | var modalFactory = require('./modalFactory');
2 | var insertKeyframesRule = require('domkit/insertKeyframesRule');
3 | var appendVendorPrefix = require('domkit/appendVendorPrefix');
4 |
5 | var animation = {
6 | show: {
7 | animationDuration: '0.5s',
8 | animationTimingFunction: 'ease-out'
9 | },
10 | hide: {
11 | animationDuration: '0.5s',
12 | animationTimingFunction: 'ease-out'
13 | },
14 | showContentAnimation: insertKeyframesRule({
15 | '0%': {
16 | opacity: 0,
17 | transform: 'translate3d(calc(-100vw - 50%), 0, 0)'
18 | },
19 | '50%': {
20 | opacity: 1,
21 | transform: 'translate3d(100px, 0, 0)'
22 | },
23 | '100%': {
24 | opacity: 1,
25 | transform: 'translate3d(0, 0, 0)'
26 | }
27 | }),
28 |
29 | hideContentAnimation: insertKeyframesRule({
30 | '0%': {
31 | opacity: 1,
32 | transform: 'translate3d(0, 0, 0)'
33 | },
34 | '50%': {
35 | opacity: 1,
36 | transform: 'translate3d(-100px, 0, 0) scale3d(1.1, 1.1, 1)'
37 | },
38 | '100%': {
39 | opacity: 0,
40 | transform: 'translate3d(calc(100vw + 50%), 0, 0)'
41 | },
42 | }),
43 |
44 | showBackdropAnimation: insertKeyframesRule({
45 | '0%': {
46 | opacity: 0
47 | },
48 | '100%': {
49 | opacity: 0.9
50 | },
51 | }),
52 |
53 | hideBackdropAnimation: insertKeyframesRule({
54 | '0%': {
55 | opacity: 0.9
56 | },
57 | '90%': {
58 | opactiy: 0.9
59 | },
60 | '100%': {
61 | opacity: 0
62 | }
63 | })
64 | };
65 |
66 | var showAnimation = animation.show;
67 | var hideAnimation = animation.hide;
68 | var showContentAnimation = animation.showContentAnimation;
69 | var hideContentAnimation = animation.hideContentAnimation;
70 | var showBackdropAnimation = animation.showBackdropAnimation;
71 | var hideBackdropAnimation = animation.hideBackdropAnimation;
72 |
73 | module.exports = modalFactory({
74 | getRef: function(willHidden) {
75 | return 'content';
76 | },
77 | getModalStyle: function(willHidden) {
78 | return appendVendorPrefix({
79 | zIndex: 1050,
80 | position: "fixed",
81 | width: "500px",
82 | transform: "translate3d(-50%, -50%, 0)",
83 | top: "50%",
84 | left: "50%"
85 | })
86 | },
87 | getBackdropStyle: function(willHidden) {
88 | return appendVendorPrefix({
89 | position: "fixed",
90 | top: 0,
91 | right: 0,
92 | bottom: 0,
93 | left: 0,
94 | zIndex: 1040,
95 | backgroundColor: "#373A47",
96 | animationFillMode: 'forwards',
97 | animationDuration: '0.3s',
98 | animationName: willHidden ? hideBackdropAnimation : showBackdropAnimation,
99 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
100 | });
101 | },
102 | getContentStyle: function(willHidden) {
103 | return appendVendorPrefix({
104 | margin: 0,
105 | backgroundColor: "white",
106 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
107 | animationFillMode: 'forwards',
108 | animationName: willHidden ? hideContentAnimation : showContentAnimation,
109 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
110 | })
111 | }
112 | });
113 |
--------------------------------------------------------------------------------
/src/OutlineModal.js:
--------------------------------------------------------------------------------
1 | var React = require('react');
2 | var modalFactory = require('./modalFactory');
3 | var insertKeyframesRule = require('domkit/insertKeyframesRule');
4 | var appendVendorPrefix = require('domkit/appendVendorPrefix');
5 |
6 | var animation = {
7 | show: {
8 | animationDuration: '0.8s',
9 | animationTimingFunction: 'cubic-bezier(0.6,0,0.4,1)'
10 | },
11 | hide: {
12 | animationDuration: '0.4s',
13 | animationTimingFunction: 'ease-out'
14 | },
15 | showContentAnimation: insertKeyframesRule({
16 | '0%': {
17 | opacity: 0,
18 | },
19 | '40%':{
20 | opacity: 0
21 | },
22 | '100%': {
23 | opacity: 1,
24 | }
25 | }),
26 |
27 | hideContentAnimation: insertKeyframesRule({
28 | '0%': {
29 | opacity: 1
30 | },
31 | '100%': {
32 | opacity: 0,
33 | }
34 | }),
35 |
36 | showBackdropAnimation: insertKeyframesRule({
37 | '0%': {
38 | opacity: 0
39 | },
40 | '100%': {
41 | opacity: 0.9
42 | },
43 | }),
44 |
45 | hideBackdropAnimation: insertKeyframesRule({
46 | '0%': {
47 | opacity: 0.9
48 | },
49 | '100%': {
50 | opacity: 0
51 | }
52 | })
53 | };
54 |
55 | var showAnimation = animation.show;
56 | var hideAnimation = animation.hide;
57 | var showContentAnimation = animation.showContentAnimation;
58 | var hideContentAnimation = animation.hideContentAnimation;
59 | var showBackdropAnimation = animation.showBackdropAnimation;
60 | var hideBackdropAnimation = animation.hideBackdropAnimation;
61 |
62 | module.exports = modalFactory({
63 | getRef: function(willHidden) {
64 | return 'content';
65 | },
66 | getSharp: function(willHidden) {
67 | var strokeDashLength = 1680;
68 |
69 | var showSharpAnimation = insertKeyframesRule({
70 | '0%': {
71 | 'stroke-dashoffset': strokeDashLength
72 | },
73 | '100%': {
74 | 'stroke-dashoffset': 0
75 | },
76 | });
77 |
78 |
79 | var sharpStyle = {
80 | position: 'absolute',
81 | width: 'calc(100%)',
82 | height: 'calc(100%)',
83 | zIndex: '-1'
84 | };
85 |
86 | var rectStyle = appendVendorPrefix({
87 | animationDuration: willHidden? '0.4s' :'0.8s',
88 | animationFillMode: 'forwards',
89 | animationName: willHidden? hideContentAnimation: showSharpAnimation,
90 | stroke: '#ffffff',
91 | strokeWidth: '2px',
92 | strokeDasharray: strokeDashLength
93 | });
94 |
95 | return
96 |
102 |
108 |
109 |
110 | },
111 | getModalStyle: function(willHidden) {
112 | return appendVendorPrefix({
113 | zIndex: 1050,
114 | position: "fixed",
115 | width: "500px",
116 | transform: "translate3d(-50%, -50%, 0)",
117 | top: "50%",
118 | left: "50%"
119 | })
120 | },
121 | getBackdropStyle: function(willHidden) {
122 | return appendVendorPrefix({
123 | position: "fixed",
124 | top: 0,
125 | right: 0,
126 | bottom: 0,
127 | left: 0,
128 | zIndex: 1040,
129 | backgroundColor: "#373A47",
130 | animationFillMode: 'forwards',
131 | animationDuration: '0.4s',
132 | animationName: willHidden ? hideBackdropAnimation : showBackdropAnimation,
133 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
134 | });
135 | },
136 | getContentStyle: function(willHidden) {
137 | return appendVendorPrefix({
138 | margin: 0,
139 | backgroundColor: "white",
140 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
141 | animationFillMode: 'forwards',
142 | animationName: willHidden ? hideContentAnimation : showContentAnimation,
143 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
144 | })
145 | }
146 | });
147 |
--------------------------------------------------------------------------------
/src/ScaleModal.js:
--------------------------------------------------------------------------------
1 | var modalFactory = require('./modalFactory');
2 | var insertKeyframesRule = require('domkit/insertKeyframesRule');
3 | var appendVendorPrefix = require('domkit/appendVendorPrefix');
4 |
5 | var animation = {
6 | show: {
7 | animationDuration: '0.4s',
8 | animationTimingFunction: 'cubic-bezier(0.6,0,0.4,1)'
9 | },
10 | hide: {
11 | animationDuration: '0.4s',
12 | animationTimingFunction: 'ease-out'
13 | },
14 | showContentAnimation: insertKeyframesRule({
15 | '0%': {
16 | opacity: 0,
17 | transform: 'scale3d(0, 0, 1)'
18 | },
19 | '100%': {
20 | opacity: 1,
21 | transform: 'scale3d(1, 1, 1)'
22 | }
23 | }),
24 |
25 | hideContentAnimation: insertKeyframesRule({
26 | '0%': {
27 | opacity: 1
28 | },
29 | '100%': {
30 | opacity: 0,
31 | transform: 'scale3d(0.5, 0.5, 1)'
32 | }
33 | }),
34 |
35 | showBackdropAnimation: insertKeyframesRule({
36 | '0%': {
37 | opacity: 0
38 | },
39 | '100%': {
40 | opacity: 0.9
41 | },
42 | }),
43 |
44 | hideBackdropAnimation: insertKeyframesRule({
45 | '0%': {
46 | opacity: 0.9
47 | },
48 | '100%': {
49 | opacity: 0
50 | }
51 | })
52 | };
53 |
54 | var showAnimation = animation.show;
55 | var hideAnimation = animation.hide;
56 | var showContentAnimation = animation.showContentAnimation;
57 | var hideContentAnimation = animation.hideContentAnimation;
58 | var showBackdropAnimation = animation.showBackdropAnimation;
59 | var hideBackdropAnimation = animation.hideBackdropAnimation;
60 |
61 | module.exports = modalFactory({
62 | getRef: function(willHidden) {
63 | return 'content';
64 | },
65 | getModalStyle: function(willHidden) {
66 | return appendVendorPrefix({
67 | zIndex: 1050,
68 | position: "fixed",
69 | width: "500px",
70 | transform: "translate3d(-50%, -50%, 0)",
71 | top: "50%",
72 | left: "50%"
73 | })
74 | },
75 | getBackdropStyle: function(willHidden) {
76 | return appendVendorPrefix({
77 | position: "fixed",
78 | top: 0,
79 | right: 0,
80 | bottom: 0,
81 | left: 0,
82 | zIndex: 1040,
83 | backgroundColor: "#373A47",
84 | animationFillMode: 'forwards',
85 | animationDuration: '0.4s',
86 | animationName: willHidden ? hideBackdropAnimation : showBackdropAnimation,
87 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
88 | });
89 | },
90 | getContentStyle: function(willHidden) {
91 | return appendVendorPrefix({
92 | margin: 0,
93 | backgroundColor: "white",
94 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
95 | animationFillMode: 'forwards',
96 | animationName: willHidden ? hideContentAnimation : showContentAnimation,
97 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
98 | })
99 | }
100 | });
101 |
--------------------------------------------------------------------------------
/src/WaveModal.js:
--------------------------------------------------------------------------------
1 | var modalFactory = require('./modalFactory');
2 | var insertKeyframesRule = require('domkit/insertKeyframesRule');
3 | var appendVendorPrefix = require('domkit/appendVendorPrefix');
4 |
5 | var animation = {
6 | show: {
7 | animationDuration: '1s',
8 | animationTimingFunction: 'linear'
9 | },
10 | hide: {
11 | animationDuration: '0.3s',
12 | animationTimingFunction: 'ease-out'
13 | },
14 | showContentAnimation: insertKeyframesRule({
15 | '0%': {
16 | opacity: 0,
17 | transform: 'matrix3d(0.7, 0, 0, 0, 0, 0.7, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
18 | },
19 | '2.083333%': {
20 | transform: 'matrix3d(0.75266, 0, 0, 0, 0, 0.76342, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
21 | },
22 | '4.166667%': {
23 | transform: 'matrix3d(0.81071, 0, 0, 0, 0, 0.84545, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
24 | },
25 | '6.25%': {
26 | transform: 'matrix3d(0.86808, 0, 0, 0, 0, 0.9286, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
27 | },
28 | '8.333333%': {
29 | transform: 'matrix3d(0.92038, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
30 | },
31 | '10.416667%': {
32 | transform: 'matrix3d(0.96482, 0, 0, 0, 0, 1.05202, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
33 | },
34 | '12.5%': {
35 | transform: 'matrix3d(1, 0, 0, 0, 0, 1.08204, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
36 | },
37 | '14.583333%': {
38 | transform: 'matrix3d(1.02563, 0, 0, 0, 0, 1.09149, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
39 | },
40 | '16.666667%': {
41 | transform: 'matrix3d(1.04227, 0, 0, 0, 0, 1.08453, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
42 | },
43 | '18.75%': {
44 | transform: 'matrix3d(1.05102, 0, 0, 0, 0, 1.06666, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
45 | },
46 | '20.833333%': {
47 | transform: 'matrix3d(1.05334, 0, 0, 0, 0, 1.04355, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
48 | },
49 | '22.916667%': {
50 | transform: 'matrix3d(1.05078, 0, 0, 0, 0, 1.02012, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
51 | },
52 | '25%': {
53 | transform: 'matrix3d(1.04487, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
54 | },
55 | '27.083333%': {
56 | transform: 'matrix3d(1.03699, 0, 0, 0, 0, 0.98534, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
57 | },
58 | '29.166667%': {
59 | transform: 'matrix3d(1.02831, 0, 0, 0, 0, 0.97688, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
60 | },
61 | '31.25%': {
62 | transform: 'matrix3d(1.01973, 0, 0, 0, 0, 0.97422, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
63 | },
64 | '33.333333%': {
65 | transform: 'matrix3d(1.01191, 0, 0, 0, 0, 0.97618, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
66 | },
67 | '35.416667%': {
68 | transform: 'matrix3d(1.00526, 0, 0, 0, 0, 0.98122, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
69 | },
70 | '37.5%': {
71 | transform: 'matrix3d(1, 0, 0, 0, 0, 0.98773, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
72 | },
73 | '39.583333%': {
74 | transform: 'matrix3d(0.99617, 0, 0, 0, 0, 0.99433, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
75 | },
76 | '41.666667%': {
77 | transform: 'matrix3d(0.99368, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
78 | },
79 | '43.75%': {
80 | transform: 'matrix3d(0.99237, 0, 0, 0, 0, 1.00413, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
81 | },
82 | '45.833333%': {
83 | transform: 'matrix3d(0.99202, 0, 0, 0, 0, 1.00651, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
84 | },
85 | '47.916667%': {
86 | transform: 'matrix3d(0.99241, 0, 0, 0, 0, 1.00726, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
87 | },
88 | '50%': {
89 | opacity: 1,
90 | transform: 'matrix3d(0.99329, 0, 0, 0, 0, 1.00671, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
91 | },
92 | '52.083333%': {
93 | transform: 'matrix3d(0.99447, 0, 0, 0, 0, 1.00529, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
94 | },
95 | '54.166667%': {
96 | transform: 'matrix3d(0.99577, 0, 0, 0, 0, 1.00346, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
97 | },
98 | '56.25%': {
99 | transform: 'matrix3d(0.99705, 0, 0, 0, 0, 1.0016, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
100 | },
101 | '58.333333%': {
102 | transform: 'matrix3d(0.99822, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
103 | },
104 | '60.416667%': {
105 | transform: 'matrix3d(0.99921, 0, 0, 0, 0, 0.99884, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
106 | },
107 | '62.5%': {
108 | transform: 'matrix3d(1, 0, 0, 0, 0, 0.99816, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
109 | },
110 | '64.583333%': {
111 | transform: 'matrix3d(1.00057, 0, 0, 0, 0, 0.99795, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
112 | },
113 | '66.666667%': {
114 | transform: 'matrix3d(1.00095, 0, 0, 0, 0, 0.99811, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
115 | },
116 | '68.75%': {
117 | transform: 'matrix3d(1.00114, 0, 0, 0, 0, 0.99851, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
118 | },
119 | '70.833333%': {
120 | transform: 'matrix3d(1.00119, 0, 0, 0, 0, 0.99903, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
121 | },
122 | '72.916667%': {
123 | transform: 'matrix3d(1.00114, 0, 0, 0, 0, 0.99955, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
124 | },
125 | '75%': {
126 | transform: 'matrix3d(1.001, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
127 | },
128 | '77.083333%': {
129 | transform: 'matrix3d(1.00083, 0, 0, 0, 0, 1.00033, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
130 | },
131 | '79.166667%': {
132 | transform: 'matrix3d(1.00063, 0, 0, 0, 0, 1.00052, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
133 | },
134 | '81.25%': {
135 | transform: 'matrix3d(1.00044, 0, 0, 0, 0, 1.00058, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
136 | },
137 | '83.333333%': {
138 | transform: 'matrix3d(1.00027, 0, 0, 0, 0, 1.00053, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
139 | },
140 | '85.416667%': {
141 | transform: 'matrix3d(1.00012, 0, 0, 0, 0, 1.00042, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
142 | },
143 | '87.5%': {
144 | transform: 'matrix3d(1, 0, 0, 0, 0, 1.00027, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
145 | },
146 | '89.583333%': {
147 | transform: 'matrix3d(0.99991, 0, 0, 0, 0, 1.00013, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
148 | },
149 | '91.666667%': {
150 | transform: 'matrix3d(0.99986, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
151 | },
152 | '93.75%': {
153 | transform: 'matrix3d(0.99983, 0, 0, 0, 0, 0.99991, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
154 | },
155 | '95.833333%': {
156 | transform: 'matrix3d(0.99982, 0, 0, 0, 0, 0.99985, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
157 | },
158 | '97.916667%': {
159 | transform: 'matrix3d(0.99983, 0, 0, 0, 0, 0.99984, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
160 | },
161 | '100%': {
162 | opacity: 1,
163 | transform: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
164 | }
165 | }),
166 |
167 | hideContentAnimation: insertKeyframesRule({
168 | '0%': {
169 | opacity: 1
170 | },
171 | '100%': {
172 | opacity: 0,
173 | transform: 'scale3d(0.8, 0.8, 1)'
174 | },
175 | }),
176 |
177 | showBackdropAnimation: insertKeyframesRule({
178 | '0%': {
179 | opacity: 0
180 | },
181 | '100%': {
182 | opacity: 0.9
183 | },
184 | }),
185 |
186 | hideBackdropAnimation: insertKeyframesRule({
187 | '0%': {
188 | opacity: 0.9
189 | },
190 | '100%': {
191 | opacity: 0
192 | }
193 | })
194 | };
195 |
196 | var showAnimation = animation.show;
197 | var hideAnimation = animation.hide;
198 | var showContentAnimation = animation.showContentAnimation;
199 | var hideContentAnimation = animation.hideContentAnimation;
200 | var showBackdropAnimation = animation.showBackdropAnimation;
201 | var hideBackdropAnimation = animation.hideBackdropAnimation;
202 |
203 | module.exports = modalFactory({
204 | getRef: function(willHidden) {
205 | return 'content';
206 | },
207 | getModalStyle: function(willHidden) {
208 | return appendVendorPrefix({
209 | zIndex: 1050,
210 | position: "fixed",
211 | width: "500px",
212 | transform: "translate3d(-50%, -50%, 0)",
213 | top: "50%",
214 | left: "50%"
215 | })
216 | },
217 | getBackdropStyle: function(willHidden) {
218 | return appendVendorPrefix({
219 | position: "fixed",
220 | top: 0,
221 | right: 0,
222 | bottom: 0,
223 | left: 0,
224 | zIndex: 1040,
225 | backgroundColor: "#373A47",
226 | animationFillMode: 'forwards',
227 | animationDuration: '0.3s',
228 | animationName: willHidden ? hideBackdropAnimation : showBackdropAnimation,
229 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
230 | });
231 | },
232 | getContentStyle: function(willHidden) {
233 | return appendVendorPrefix({
234 | margin: 0,
235 | backgroundColor: "white",
236 | animationDuration: (willHidden ? hideAnimation : showAnimation).animationDuration,
237 | animationFillMode: 'forwards',
238 | animationName: willHidden ? hideContentAnimation : showContentAnimation,
239 | animationTimingFunction: (willHidden ? hideAnimation : showAnimation).animationTimingFunction
240 | })
241 | }
242 | });
243 |
--------------------------------------------------------------------------------
/src/modalFactory.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import transitionEvents from 'domkit/transitionEvents'
3 | import appendVendorPrefix from 'domkit/appendVendorPrefix'
4 |
5 | class modalFactory extends React.Component {
6 | propTypes: {
7 | className: React.PropTypes.string,
8 | // Close the modal when esc is pressed? Defaults to true.
9 | keyboard: React.PropTypes.bool,
10 | onShow: React.PropTypes.func,
11 | onHide: React.PropTypes.func,
12 | animation: React.PropTypes.object,
13 | backdrop: React.PropTypes.bool,
14 | closeOnClick: React.PropTypes.bool,
15 | modalStyle: React.PropTypes.object,
16 | backdropStyle: React.PropTypes.object,
17 | contentStyle: React.PropTypes.object,
18 | }
19 |
20 | getDefaultProps() {
21 | return {
22 | className: "",
23 | onShow: function(){},
24 | onHide: function(){},
25 | animation: animation,
26 | keyboard: true,
27 | backdrop: true,
28 | closeOnClick: true,
29 | modalStyle: {},
30 | backdropStyle: {},
31 | contentStyle: {},
32 | }
33 | }
34 |
35 | getInitialState(){
36 | return {
37 | willHidden: false,
38 | hidden: true
39 | }
40 | }
41 |
42 | hasHidden(){
43 | return this.state.hidden
44 | }
45 |
46 | addTransitionListener(node, handle){
47 | if (node) {
48 | var endListener = function(e) {
49 | if (e && e.target !== node) {
50 | return
51 | }
52 | transitionEvents.removeEndEventListener(node, endListener)
53 | handle()
54 | }
55 | transitionEvents.addEndEventListener(node, endListener)
56 | }
57 | }
58 |
59 | handleBackdropClick() {
60 | if (this.props.closeOnClick) {
61 | this.hide("backdrop")
62 | }
63 | }
64 |
65 | render() {
66 |
67 | var hidden = this.hasHidden()
68 | if (hidden) return null
69 |
70 | var willHidden = this.state.willHidden
71 | var animation = this.props.animation
72 | var modalStyle = animation.getModalStyle(willHidden)
73 | var backdropStyle = animation.getBackdropStyle(willHidden)
74 | var contentStyle = animation.getContentStyle(willHidden)
75 | var ref = animation.getRef(willHidden)
76 | var sharp = animation.getSharp && animation.getSharp(willHidden)
77 |
78 | // Apply custom style properties
79 | if (this.props.modalStyle) {
80 | var prefixedModalStyle = appendVendorPrefix(this.props.modalStyle)
81 | for (var style in prefixedModalStyle) {
82 | modalStyle[style] = prefixedModalStyle[style]
83 | }
84 | }
85 |
86 | if (this.props.backdropStyle) {
87 | var prefixedBackdropStyle = appendVendorPrefix(this.props.backdropStyle)
88 | for (var style in prefixedBackdropStyle) {
89 | backdropStyle[style] = prefixedBackdropStyle[style]
90 | }
91 | }
92 |
93 | if (this.props.contentStyle) {
94 | var prefixedContentStyle = appendVendorPrefix(this.props.contentStyle)
95 | for (var style in prefixedContentStyle) {
96 | contentStyle[style] = prefixedContentStyle[style]
97 | }
98 | }
99 |
100 | var backdrop = this.props.backdrop?
: undefined
101 |
102 | if(willHidden) {
103 | var node = this.refs[ref]
104 | this.addTransitionListener(node, this.leave)
105 | }
106 |
107 | return (
108 |
109 | {sharp}
110 |
111 | {this.props.children}
112 |
113 |
114 | {backdrop}
115 | )
116 |
117 | }
118 |
119 | leave(){
120 | this.setState({
121 | hidden: true
122 | })
123 | this.props.onHide(this.state.hideSource)
124 | }
125 |
126 | enter(){
127 | this.props.onShow()
128 | }
129 |
130 | show(){
131 | if (!this.hasHidden()) return
132 |
133 | this.setState({
134 | willHidden: false,
135 | hidden: false
136 | })
137 |
138 | setTimeout(function(){
139 | var ref = this.props.animation.getRef()
140 | var node = this.refs[ref]
141 | this.addTransitionListener(node, this.enter)
142 | }.bind(this), 0)
143 | }
144 |
145 | hide(source){
146 | if (this.hasHidden()) return
147 |
148 | if (!source) {
149 | source = "hide"
150 | }
151 |
152 | this.setState({
153 | hideSource: source,
154 | willHidden: true
155 | })
156 | }
157 |
158 | toggle(){
159 | if (this.hasHidden())
160 | this.show()
161 | else
162 | this.hide("toggle")
163 | }
164 |
165 | listenKeyboard(event) {
166 | (typeof(this.props.keyboard)=="function")
167 | ?this.props.keyboard(event)
168 | :this.closeOnEsc(event)
169 | }
170 |
171 | closeOnEsc(event){
172 | if (this.props.keyboard &&
173 | (event.key === "Escape" ||
174 | event.keyCode === 27)) {
175 | this.hide("keyboard")
176 | }
177 | }
178 |
179 | componentDidMount(){
180 | window.addEventListener("keydown", this.listenKeyboard, true)
181 | }
182 |
183 | componentWillUnmount() {
184 | window.removeEventListener("keydown", this.listenKeyboard, true)
185 | }
186 | }
187 |
188 | export default modalFactory
189 |
--------------------------------------------------------------------------------