Skip to content

Commit 22a44d1

Browse files
Merge pull request #161 from gridaco/solid
Initial SolidJS support - with styled components
2 parents 885f65f + c14a455 commit 22a44d1

File tree

70 files changed

+1239
-357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1239
-357
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ export function CodeOptionsControl(props: CodeOptionsControlProps) {
7777
value: "reactnative_with_inline_style",
7878
description: "with inline-style",
7979
},
80+
{
81+
name: "Solid",
82+
value: "solid_default",
83+
description: "solid-js",
84+
},
8085
{
8186
name: "Flutter",
8287
value: "flutter_default",
@@ -162,6 +167,7 @@ export function CodeOptionsControl(props: CodeOptionsControlProps) {
162167
const fields_config = {
163168
react: [platform_field_config, lang_field_config, react_style_field_config],
164169
"react-native": [platform_field_config, lang_field_config],
170+
"solid-js": [platform_field_config, lang_field_config],
165171
flutter: [platform_field_config, lang_field_config],
166172
vanilla: [platform_field_config, lang_field_config],
167173
};

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export type ReactNativeStylingStrategy =
1818
| "styled-components"
1919
| "inline-style";
2020

21+
export type SolidStylingStrategy =
22+
| "css"
23+
//
24+
| "styled-components"
25+
| "inline-css";
26+
2127
export interface FlutterOption {
2228
framework: Framework.flutter;
2329
language: Language.dart;
@@ -35,6 +41,12 @@ export interface ReactNativeOption {
3541
styling: ReactNativeStylingStrategy;
3642
}
3743

44+
export interface SolidOption {
45+
framework: Framework.solid;
46+
language: Language.jsx | Language.tsx;
47+
styling: SolidStylingStrategy;
48+
}
49+
3850
export interface VanillaOption {
3951
framework: Framework.vanilla;
4052
language: Language.html;
@@ -44,6 +56,7 @@ export type FrameworkOption =
4456
| ReactOption
4557
| ReactNativeOption
4658
| FlutterOption
59+
| SolidOption
4760
| VanillaOption;
4861

4962
export const react_presets = {
@@ -99,6 +112,24 @@ export const flutter_presets = {
99112
},
100113
};
101114

115+
export const solid_presets = {
116+
solid_default: <SolidOption>{
117+
framework: Framework.solid,
118+
language: Language.tsx,
119+
styling: "styled-components",
120+
},
121+
solid_with_styled_components: <SolidOption>{
122+
framework: Framework.solid,
123+
language: Language.tsx,
124+
styling: "styled-components",
125+
},
126+
solid_with_inline_css: <SolidOption>{
127+
framework: Framework.solid,
128+
language: Language.tsx,
129+
styling: "inline-css",
130+
},
131+
};
132+
102133
export const vanilla_presets = {
103134
vanilla_default: <VanillaOption>{
104135
framework: Framework.vanilla,
@@ -111,6 +142,7 @@ export const presets = {
111142
reactnative: reactnative_presets,
112143
flutter: flutter_presets,
113144
vanilla: vanilla_presets,
145+
solid: solid_presets,
114146
};
115147

116148
export const all_preset_options__prod = [
@@ -121,6 +153,7 @@ export const all_preset_options__prod = [
121153
react_presets.react_with_css_module,
122154
reactnative_presets.reactnative_default,
123155
vanilla_presets.vanilla_default,
156+
solid_presets.solid_default,
124157
// react_with_css // NOT ON PRODUCTION
125158
];
126159

@@ -133,19 +166,27 @@ export const all_preset_options_map__prod = {
133166
react_with_styled_components: react_presets.react_with_styled_components,
134167
react_with_inline_css: react_presets.react_with_inline_css,
135168
react_with_css_module: react_presets.react_with_css_module,
169+
"react-native": reactnative_presets.reactnative_default,
170+
reactnative: reactnative_presets.reactnative_default,
136171
reactnative_default: reactnative_presets.reactnative_default,
137172
reactnative_with_styled_components:
138173
reactnative_presets.reactnative_with_styled_components,
139174
reactnative_with_inline_style:
140175
reactnative_presets.reactnative_with_inline_style,
176+
vanilla: vanilla_presets.vanilla_default,
141177
vanilla_default: vanilla_presets.vanilla_default,
178+
solid: solid_presets.solid_default,
179+
solid_default: solid_presets.solid_default,
180+
solid_with_inline_css: solid_presets.solid_with_inline_css,
181+
solid_with_styled_components: solid_presets.solid_with_styled_components,
142182
// react_with_css // NOT ON PRODUCTION
143183
};
144184

145185
export const lang_by_framework = {
146186
flutter: [Language.dart],
147187
react: [Language.jsx, Language.tsx],
148188
"react-native": [Language.jsx, Language.tsx],
189+
"solid-js": [Language.jsx, Language.tsx],
149190
vanilla: [Language.html],
150191
};
151192

editor/config/scripting-enabled-frameworks.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export const scripting_and_preview_framework_config: {
3434
nativeScripting: false,
3535
enabled: false,
3636
},
37+
"solid-js": {
38+
nativePreview: false,
39+
nativeScripting: false,
40+
enabled: false,
41+
},
3742
preview: null,
3843
} as const;
3944

editor/next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const withTM = require("next-transpile-modules")([
1919
"@designto/sanitized",
2020
"@designto/token",
2121
"@designto/flutter",
22+
"@designto/solid-js",
2223
"@designto/web",
2324
"@designto/vanilla",
2425
"@designto/react",
@@ -85,6 +86,8 @@ const withTM = require("next-transpile-modules")([
8586
// region web builders
8687
"@web-builder/nodejs",
8788
"@web-builder/core",
89+
"@web-builder/module-es",
90+
"@web-builder/solid-js",
8891
"@web-builder/vanilla",
8992
"@web-builder/react-core",
9093
"@web-builder/react",

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
reactnative_presets,
44
flutter_presets,
55
vanilla_presets,
6+
solid_presets,
67
} from "@grida/builder-config-preset";
78
import { ParsedUrlQuery } from "querystring";
89
import { FrameworkConfig } from "@designto/config";
@@ -49,7 +50,9 @@ export function get_framework_config(framework: string) {
4950
return reactnative_presets.reactnative_with_styled_components;
5051
case "react-native-with-inline-style":
5152
return reactnative_presets.reactnative_with_inline_style;
52-
case "flutter":
53+
case "solid_with_styled_components":
54+
case "solid-with-styled-components":
55+
return solid_presets.solid_with_styled_components;
5356
case "flutter_default":
5457
case "flutter-default":
5558
case "flutter.default":
@@ -59,6 +62,10 @@ export function get_framework_config(framework: string) {
5962
case "vanilla.default":
6063
return vanilla_presets.vanilla_default;
6164
default:
65+
console.warn(
66+
'no matching framework preset found for "' + framework + '"',
67+
"fallback to react preset"
68+
);
6269
return react_presets.react_default;
6370
}
6471
}

editor/scaffolds/code/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ export function CodeSegment() {
174174
}
175175
break;
176176
}
177+
case "solid-js": {
178+
switch (o.styling) {
179+
case "styled-components":
180+
c = get_framework_config("solid-with-styled-components");
181+
break;
182+
}
183+
break;
184+
}
177185
case "flutter":
178186
c = get_framework_config(o.framework);
179187
break;

packages/builder-config-preset/index.ts

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { config, react } from "@designto/config";
22
import { Framework, Language } from "@grida/builder-platform-types";
33

4-
const _react_component_declaration_style = {
4+
const _jsx_component_declaration_style = {
55
exporting_style: {
66
type: "export-named-functional-component",
77
exporting_position: "with-declaration",
@@ -18,7 +18,7 @@ export const react_presets = {
1818
type: "styled-components",
1919
module: "@emotion/styled",
2020
},
21-
component_declaration_style: _react_component_declaration_style,
21+
component_declaration_style: _jsx_component_declaration_style,
2222
},
2323
react_with_styled_components: <config.ReactFrameworkConfig>{
2424
framework: Framework.react,
@@ -27,7 +27,7 @@ export const react_presets = {
2727
type: "styled-components",
2828
module: "styled-components",
2929
},
30-
component_declaration_style: _react_component_declaration_style,
30+
component_declaration_style: _jsx_component_declaration_style,
3131
},
3232
react_with_emotion_styled: <config.ReactFrameworkConfig>{
3333
framework: Framework.react,
@@ -36,15 +36,15 @@ export const react_presets = {
3636
type: "styled-components",
3737
module: "@emotion/styled",
3838
},
39-
component_declaration_style: _react_component_declaration_style,
39+
component_declaration_style: _jsx_component_declaration_style,
4040
},
4141
react_with_inline_css: <config.ReactFrameworkConfig>{
4242
framework: Framework.react,
4343
language: Language.tsx,
4444
styling: {
4545
type: "inline-css",
4646
},
47-
component_declaration_style: _react_component_declaration_style,
47+
component_declaration_style: _jsx_component_declaration_style,
4848
},
4949
react_with_css_module: <config.ReactFrameworkConfig>{
5050
framework: Framework.react,
@@ -55,14 +55,14 @@ export const react_presets = {
5555
importDefault: "styles",
5656
loader: "css-loader",
5757
},
58-
component_declaration_style: _react_component_declaration_style,
58+
component_declaration_style: _jsx_component_declaration_style,
5959
},
6060
react_with_css: <config.ReactFrameworkConfig>{
6161
framework: Framework.react,
6262
language: Language.tsx,
6363
styling: { type: "css" },
6464
},
65-
component_declaration_style: _react_component_declaration_style,
65+
component_declaration_style: _jsx_component_declaration_style,
6666
};
6767

6868
export const reactnative_presets = {
@@ -75,7 +75,7 @@ export const reactnative_presets = {
7575
type: "react-native-stylesheet",
7676
module: "react-native",
7777
},
78-
component_declaration_style: _react_component_declaration_style,
78+
component_declaration_style: _jsx_component_declaration_style,
7979
},
8080
reactnative_with_style_sheet: <config.ReactNativeFrameworkConfig>{
8181
framework: Framework.reactnative,
@@ -86,7 +86,7 @@ export const reactnative_presets = {
8686
type: "react-native-stylesheet",
8787
module: "react-native",
8888
},
89-
component_declaration_style: _react_component_declaration_style,
89+
component_declaration_style: _jsx_component_declaration_style,
9090
},
9191
reactnative_with_styled_components: <config.ReactNativeFrameworkConfig>{
9292
framework: Framework.reactnative,
@@ -97,7 +97,7 @@ export const reactnative_presets = {
9797
type: "styled-components",
9898
module: "styled-components/native",
9999
},
100-
component_declaration_style: _react_component_declaration_style,
100+
component_declaration_style: _jsx_component_declaration_style,
101101
},
102102
reactnative_with_inline_style: <config.ReactNativeFrameworkConfig>{
103103
framework: Framework.reactnative,
@@ -107,7 +107,28 @@ export const reactnative_presets = {
107107
styling: {
108108
type: "inline-style",
109109
},
110-
component_declaration_style: _react_component_declaration_style,
110+
component_declaration_style: _jsx_component_declaration_style,
111+
},
112+
};
113+
114+
export const solid_presets = {
115+
solid_with_styled_components: <config.SolidFrameworkConfig>{
116+
framework: Framework.solid,
117+
language: Language.tsx,
118+
styling: {
119+
type: "styled-components",
120+
module: "solid-styled-components",
121+
},
122+
component_declaration_style: _jsx_component_declaration_style,
123+
},
124+
solid_default: <config.SolidFrameworkConfig>{
125+
framework: Framework.solid,
126+
language: Language.tsx,
127+
styling: {
128+
type: "styled-components",
129+
module: "solid-styled-components",
130+
},
131+
component_declaration_style: _jsx_component_declaration_style,
111132
},
112133
};
113134

packages/builder-config/configure/framework-config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import type { Language } from "@grida/builder-platform-types";
22
import type { ReactFrameworkConfig } from "../framework-react";
33
import type { ReactNativeFrameworkConfig } from "../framework-reactnative";
4+
import type { SolidFrameworkConfig } from "../framework-solid";
45
import type { VanillaFrameworkConfig } from "../framework-vanilla";
56
import type { VanillaPreviewFrameworkConfig } from "../framework-vanilla-preview";
67

78
export type FrameworkConfig =
89
| ReactFrameworkConfig
910
| ReactNativeFrameworkConfig
11+
| SolidFrameworkConfig
1012
| FlutterFrameworkConfig
1113
| VanillaFrameworkConfig
1214
| VanillaPreviewFrameworkConfig;
1315

1416
export type { ReactFrameworkConfig };
1517
export type { ReactNativeFrameworkConfig };
18+
export type { SolidFrameworkConfig };
1619
export type { VanillaFrameworkConfig };
1720
export type { VanillaPreviewFrameworkConfig };
1821

0 commit comments

Comments
 (0)