Skip to content

Commit 92b89a9

Browse files
committed
demo page build
1 parent a39a3a5 commit 92b89a9

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

lib/SLDSModal/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ var _SLDSIcons = require('../SLDSIcons');
2323

2424
var _utils = require('../utils');
2525

26+
var _SLDSSettings = require('../SLDSSettings');
27+
28+
var _SLDSSettings2 = _interopRequireDefault(_SLDSSettings);
29+
2630
var _reactModal = require('react-modal');
2731

2832
var _reactModal2 = _interopRequireDefault(_reactModal);
@@ -70,6 +74,7 @@ module.exports = _react2['default'].createClass({
7074
componentDidMount: function componentDidMount() {
7175
var _this = this;
7276

77+
_reactModal2['default'].setAppElement(_SLDSSettings2['default'].getAppElement());
7378
console.log('!!! window.activeElement !!! ', document.activeElement);
7479
this.setState({ returnFocusTo: document.activeElement });
7580
if (!this.state.revealed) {

lib/SLDSSettings.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1212
'use strict';
1313

1414
var assetsPath = 'assets/';
15-
15+
var appRoot = undefined;
1616
module.exports = {
1717
setAssetsPath: function setAssetsPath(path) {
1818
if (path) {
@@ -21,5 +21,13 @@ module.exports = {
2121
},
2222
getAssetsPath: function getAssetsPath() {
2323
return String(assetsPath);
24+
},
25+
setAppElement: function setAppElement(el) {
26+
if (el) {
27+
appRoot = el;
28+
}
29+
},
30+
getAppElement: function getAppElement() {
31+
return appRoot;
2432
}
2533
};

lib/utils/CSSUtil.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
Copyright (c) 2015, salesforce.com, inc. All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
7+
Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
8+
9+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10+
*/
11+
12+
'use strict';
13+
14+
var addCSSRule = function addCSSRule(sheet, selector, rules, index) {
15+
console.log('selector: ', selector);
16+
console.log('rules: ', rules);
17+
if ('insertRule' in sheet) {
18+
console.log('insertRule: ');
19+
sheet.insertRule(selector + '{ ' + rules + ' }', index);
20+
} else if ('addRule' in sheet) {
21+
console.log('addRule: ');
22+
sheet.addRule(selector, rules.join(';'), index);
23+
}
24+
};
25+
26+
module.exports = {
27+
load: function load(cssClasses) {
28+
var sheet = (function () {
29+
var style = document.createElement("style");
30+
style.appendChild(document.createTextNode(""));
31+
document.head.appendChild(style);
32+
return style.sheet;
33+
})();
34+
cssClasses.forEach(function (cssClass) {
35+
var selector = cssClass.selector;
36+
var rules = cssClass.rules;
37+
addCSSRule(sheet, selector, rules.join(';'), 0);
38+
39+
// rules.forEach((rule)=>{
40+
// addCSSRule(sheet,selector,rule, 0);
41+
// });
42+
});
43+
}
44+
};

lib/utils/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ var _EventUtil = require('./EventUtil');
2121

2222
var _EventUtil2 = _interopRequireDefault(_EventUtil);
2323

24+
var _CSSUtil = require('./CSSUtil');
25+
26+
var _CSSUtil2 = _interopRequireDefault(_CSSUtil);
27+
2428
var _KEYS = require('./KEYS');
2529

2630
var _KEYS2 = _interopRequireDefault(_KEYS);
2731

2832
module.exports = {
2933
DateUtil: _DateUtil2['default'],
3034
EventUtil: _EventUtil2['default'],
35+
CSSUtil: _CSSUtil2['default'],
3136
KEYS: _KEYS2['default']
3237
};

0 commit comments

Comments
 (0)