Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81155 views
1
/**
2
* Copyright 2013-2014, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule cx
10
*/
11
12
/**
13
* This function is used to mark string literals representing CSS class names
14
* so that they can be transformed statically. This allows for modularization
15
* and minification of CSS class names.
16
*
17
* In static_upstream, this function is actually implemented, but it should
18
* eventually be replaced with something more descriptive, and the transform
19
* that is used in the main stack should be ported for use elsewhere.
20
*
21
* @param string|object className to modularize, or an object of key/values.
22
* In the object case, the values are conditions that
23
* determine if the className keys should be included.
24
* @param [string ...] Variable list of classNames in the string case.
25
* @return string Renderable space-separated CSS className.
26
*/
27
function cx(classNames) {
28
if (typeof classNames == 'object') {
29
return Object.keys(classNames).filter(function(className) {
30
return classNames[className];
31
}).join(' ');
32
} else {
33
return Array.prototype.join.call(arguments, ' ');
34
}
35
}
36
37
module.exports = cx;
38
39