MCPcopy Create free account
hub / github.com/codesandbox/sandpack / createClass

Function createClass

sandpack-react/src/utils/ansi-to-react.ts:35–54  ·  view source on GitHub ↗

* Create a class string. * @name createClass * @function * @param {AnserJsonEntry} bundle * @return {String} class name(s)

(bundle: AnserJsonEntry)

Source from the content-addressed store, hash-verified

33 * @return {String} class name(s)
34 */
35function createClass(bundle: AnserJsonEntry): string | null {
36 let classNames = "";
37
38 if (bundle.bg) {
39 classNames += `${bundle.bg}-bg `;
40 }
41 if (bundle.fg) {
42 classNames += `${bundle.fg}-fg `;
43 }
44 if (bundle.decoration) {
45 classNames += `ansi-${bundle.decoration} `;
46 }
47
48 if (classNames === "") {
49 return null;
50 }
51
52 classNames = classNames.substring(0, classNames.length - 1);
53 return classNames;
54}
55
56/**
57 * Create the style attribute.

Callers 1

convertBundleIntoReactFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected