Completed
Push — main ( f6d4a8...a4cb90 )
by Cataldo
02:41
created

src/app/utils.ts   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 30
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 18
mnd 1
bc 1
fnc 0
dl 0
loc 30
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
ccs 7
cts 7
cp 1
rs 10
1
import { ThemeField } from "./types";
2
3
/**
4
 * Utility function to add CSS in multiple passes.
5
 *
6
 * @param {string} styleString
7
 */
8 1
export const addStyle = (styleString: string) => {
9 3
  const style = document.createElement("style");
10 3
  style.textContent = styleString;
11 3
  document.head.append(style);
12
};
13
14
/*istanbul ignore next */
15 1
export const printDev = (output: any) => {
16
  if (process.env.NODE_ENV === "development") {
17
    console.log(output);
18
  }
19
};
20
21 1
export const parseThemeField = (
22
  themeField: Partial<ThemeField>,
23
  defaultThemeField: ThemeField
24
): ThemeField => {
25 8
  return {
26
    className: themeField.className,
27
    style: themeField.style || defaultThemeField.style,
28
  };
29
};
30