Skip to content

Commit e373d03

Browse files
Merge pull request #118 from gridaco/support-css-in-js
React Inline CSS Support
2 parents c45d530 + 6022a79 commit e373d03

32 files changed

Lines changed: 623 additions & 429 deletions

File tree

editor-packages/editor-canvas/math/center-of.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ export function centerOf(
5555
vbcenter[1] - boxcenter[1] * scale,
5656
];
5757

58-
console.log(translate, scale);
59-
6058
return {
6159
box: box,
6260
center: boxcenter,

editor/components/codeui-code-options-control/code-options-control.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export function CodeOptionsControl(props: CodeOptionsControlProps) {
4949
value: "react_with_styled_components",
5050
description: "with styled-component",
5151
},
52+
{
53+
name: "React",
54+
value: "react_with_inline_css",
55+
description: "with inline-css",
56+
},
5257
{
5358
name: "Flutter",
5459
value: "flutter_default",

editor/components/codeui-code-options-control/framework-options.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export enum Language {
77
html = "html",
88
}
99

10-
export type ReactStylingStrategy = "css" | "styled-components" | "css-in-jsx";
10+
export type ReactStylingStrategy = "css" | "styled-components" | "inline-css";
1111

1212
export interface FlutterOption {
1313
framework: Framework.flutter;
@@ -38,10 +38,10 @@ export const react_presets = {
3838
language: Language.tsx,
3939
styling: "styled-components",
4040
},
41-
react_with_css_in_jsx: <ReactOption>{
41+
react_with_inline_css: <ReactOption>{
4242
framework: Framework.react,
4343
language: Language.tsx,
44-
styling: "css-in-jsx",
44+
styling: "inline-css",
4545
},
4646
react_with_css: <ReactOption>{
4747
framework: Framework.react,
@@ -74,8 +74,8 @@ export const all_preset_options__prod = [
7474
flutter_presets.flutter_default,
7575
react_presets.react_default,
7676
react_presets.react_with_styled_components,
77+
react_presets.react_with_inline_css,
7778
vanilla_presets.vanilla_default,
78-
// react_with_css_in_jsx // NOT ON PRODUCTION
7979
// react_with_css // NOT ON PRODUCTION
8080
];
8181

@@ -84,8 +84,8 @@ export const all_preset_options_map__prod = {
8484
flutter_default: flutter_presets.flutter_default,
8585
react_default: react_presets.react_default,
8686
react_with_styled_components: react_presets.react_with_styled_components,
87+
react_with_inline_css: react_presets.react_with_inline_css,
8788
vanilla_default: vanilla_presets.vanilla_default,
88-
// react_with_css_in_jsx // NOT ON PRODUCTION
8989
// react_with_css // NOT ON PRODUCTION
9090
};
9191

@@ -97,7 +97,7 @@ export const lang_by_framework = {
9797

9898
export const react_styles: ReactStylingStrategy[] = [
9999
"styled-components",
100-
"css-in-jsx",
100+
"inline-css",
101101
"css",
102102
];
103103

editor/pages/figma/to-flutter.tsx

Lines changed: 0 additions & 112 deletions
This file was deleted.

editor/pages/figma/to-react.tsx

Lines changed: 0 additions & 132 deletions
This file was deleted.

editor/query/to-code-options-from-query.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ export function get_framework_config(framework: string) {
3030
case "react.default":
3131
return react_presets.react_default;
3232
case "react-with-styled-components":
33+
case "react_with_styled_components":
3334
return react_presets.react_with_styled_components;
3435
case "react-with-emotion-styled":
3536
return react_presets.react_with_emotion_styled;
37+
case "react_with_inline_css":
38+
case "react-with-inline-css":
39+
return react_presets.react_with_inline_css;
3640
case "flutter":
3741
case "flutter_default":
3842
case "flutter-default":

editor/scaffolds/code/index.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,37 @@ export function CodeSegment() {
109109
}, [targetted?.id, framework_config]);
110110

111111
const { code, scaffold, name: componentName } = result ?? {};
112-
113112
return (
114113
<CodeEditorContainer>
115114
<EditorAppbarFragments.CodeEditor />
116115
<CodeOptionsControl
117116
initialPreset={router.query.framework as string}
118117
fallbackPreset="react_default"
119118
onUseroptionChange={(o) => {
120-
set_framework_config(get_framework_config(o.framework));
119+
let c;
120+
switch (o.framework) {
121+
case "react": {
122+
switch (o.styling) {
123+
case "inline-css":
124+
c = get_framework_config("react-with-inline-css");
125+
break;
126+
case "styled-components":
127+
c = get_framework_config("react-with-styled-components");
128+
break;
129+
case "css":
130+
// TODO:
131+
break;
132+
}
133+
break;
134+
}
135+
case "flutter":
136+
c = get_framework_config(o.framework);
137+
break;
138+
case "vanilla":
139+
c = get_framework_config(o.framework);
140+
break;
141+
}
142+
set_framework_config(c);
121143
}}
122144
/>
123145
<CodeEditor

externals/design-sdk

0 commit comments

Comments
 (0)