MCPcopy
hub / github.com/lumapps/lumX / getClasses

Function getClasses

components/button/js/button_directive.js:102–180  ·  view source on GitHub ↗

* Get button classes. * * @return {Array} The list of button classes.

()

Source from the content-addressed store, hash-verified

100 * @return {Array} The list of button classes.
101 */
102 function getClasses() {
103 const classes = [];
104
105 if (angular.isUndefined(lx.color) || !lx.color) {
106 if (angular.isDefined(lx.theme) && lx.theme && !_isDefaultEmphasis()) {
107 const buttonColor = lx.theme === 'light' ? 'dark' : 'light';
108 classes.push(`${CSS_PREFIX}-button--color-${buttonColor}`);
109 } else {
110 const defaultColor = _isDefaultEmphasis() ? 'primary' : 'dark';
111 classes.push(`${CSS_PREFIX}-button--color-${defaultColor}`);
112 }
113
114 // Backward compatibility.
115 classes.push('btn--primary');
116 } else {
117 classes.push(`${CSS_PREFIX}-button--color-${lx.color}`);
118
119 // Backward compatibility.
120 classes.push(`btn--${lx.color}`);
121 }
122
123 if (angular.isUndefined(lx.emphasis) || !lx.emphasis) {
124 if (angular.isDefined(lx.type) && lx.type) {
125 classes.push(`${CSS_PREFIX}-button--emphasis-${_EMPHASIS_FALLBACK[lx.type]}`);
126 } else {
127 classes.push(`${CSS_PREFIX}-button--emphasis-${_DEFAULT_PROPS.emphasis}`);
128 }
129 } else {
130 classes.push(`${CSS_PREFIX}-button--emphasis-${lx.emphasis}`);
131 }
132
133 if (lx.isSelected) {
134 classes.push(`${CSS_PREFIX}-button--is-selected`);
135 }
136
137 if (angular.isUndefined(lx.size) || !lx.size) {
138 classes.push(`${CSS_PREFIX}-button--size-${_DEFAULT_PROPS.size}`);
139
140 // Backward compatibility.
141 classes.push('btn--m');
142 } else {
143 classes.push(`${CSS_PREFIX}-button--size-${_SIZE_FALLBACK[lx.size]}`);
144
145 // Backward compatibility.
146 classes.push(`btn--${lx.size}`);
147 }
148
149 if (_isDefaultEmphasis()) {
150 if (angular.isUndefined(lx.theme) || !lx.theme) {
151 classes.push(`${CSS_PREFIX}-button--theme-${_DEFAULT_PROPS.theme}`);
152 } else {
153 classes.push(`${CSS_PREFIX}-button--theme-${lx.theme}`);
154 }
155 }
156
157 if (angular.isUndefined(lx.variant) || !lx.variant) {
158 if (angular.isDefined(lx.type) && lx.type) {
159 classes.push(`${CSS_PREFIX}-button--variant-${_VARIANT_FALLBACK[lx.type]}`);

Callers

nothing calls this directly

Calls 1

_isDefaultEmphasisFunction · 0.85

Tested by

no test coverage detected