-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprototypes.jsx
More file actions
29 lines (22 loc) · 864 Bytes
/
prototypes.jsx
File metadata and controls
29 lines (22 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import * as style_library from './styles/index.module.scss';
import * as icons from './static/icons/devjk/style.module.scss';
const is_production = process.env.NODE_ENV === 'production'
String.prototype.classNames = function (style) {
let dump = '';
let cls = this.split(' '); // Split multiples by space
cls = cls.map((c) => c.trim()); // Trim leading and trailing slashes
cls = cls.filter((c) => c); // Remove empty strings
// Apply dynamic classes
cls = cls.map((c) => {
let source = style || (c.indexOf('jcon') > -1 ? icons : style_library);
// Log if the class not found
if (!source[c]) {
dump += ' ' + c;
}
return (source[c] || '') + (!is_production ? ' ' + '__' + c : '');
});
if (dump) {
console.warn('Unresolved Class: ' + dump);
}
return cls.join(' ') + ' '; // Join back to single string and include raw. Then return.
};