-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathfrom-reusable-widget-tree.ts
56 lines (52 loc) · 1.35 KB
/
from-reusable-widget-tree.ts
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
////
//// LEGACY
////
import {
InstanceMetaToken,
InstanceWidget,
} from "@code-features/component/tokens/token-instance";
import { MasterComponentWidget } from "@code-features/component/tokens/token-master-component";
import { buildWebWidgetFromTokens } from "@designto/web";
import { ReactStyledComponentsModuleBuilder } from "./react-styled-components-module-builder";
/**
* @deprecated wip
* @param param0
* @returns
* @experimental
*/
export function finalizeReactReusable_StyledComponents__Experimental({
tree,
components,
}: {
tree: InstanceWidget;
components: MasterComponentWidget[];
}) {
const hanlde = (token) => {
if (token instanceof InstanceMetaToken) {
const children = token.master["children"]?.map(hanlde);
return {
...token.master,
children,
};
} else {
return token;
}
};
const token = hanlde(tree);
const webwi = buildWebWidgetFromTokens(token, {});
const builder = new ReactStyledComponentsModuleBuilder({
entry: webwi,
config: {
type: "styled-components",
module: "@emotion/styled",
},
});
const code = builder.asExportableModule().finalize({
type: "export-named-functional-component",
exporting_position: "with-declaration",
export_declaration_syntax_choice: "export",
declaration_syntax_choice: "function",
});
//
return code;
}