Skip to content

Commit 93318b2

Browse files
Merge branch 'staging' of https://github.com/gridaco/designto-code into staging
2 parents 2c29a8b + b09c45f commit 93318b2

152 files changed

Lines changed: 6147 additions & 2635 deletions

File tree

Some content is hidden

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

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,65 @@ yarn editor
2525

2626
update pulling - `git submodule update --init --recursive`
2727

28+
## Platforms / Frameworks
29+
30+
| **Frameworks** | |
31+
| ------------------ | :---: |
32+
| ReactJS ||
33+
| Flutter ||
34+
| React Native ||
35+
| Vanilla (html/css) ||
36+
| Vue | (wip) |
37+
38+
| **ReactJS** | |
39+
| ------------------- | :---: |
40+
| `styled-components` ||
41+
| `@emotion/styled` ||
42+
| css-modules ||
43+
| inline-css ||
44+
| `@mui/material` | (wip) |
45+
| breakpoints | (wip) |
46+
| components | (wip) |
47+
48+
| **ReactNative** | |
49+
| ------------------------------ | :---: |
50+
| `StyleSheet` ||
51+
| `styled-components/native` ||
52+
| `@emotion/native` ||
53+
| `react-native-linear-gradient` | (wip) |
54+
| `react-native-svg` | (wip) |
55+
| `expo` | (wip) |
56+
57+
| **Vanilla** | |
58+
| ----------- | :-----------: |
59+
| reflect-ui | right-aligned |
60+
| css ||
61+
| scss | are neat |
62+
63+
| **Flutter** | |
64+
| ----------- | :---: |
65+
| material ||
66+
| cupertino | (wip) |
67+
| reflect-ui | (wip) |
68+
69+
| **Svelte** | |
70+
| ------------------- | :---: |
71+
| `styled-components` ||
72+
| `@mui/material` | (wip) |
73+
74+
| **Vue** | |
75+
| ------------------- | :---: |
76+
| `styled-components` ||
77+
| `@mui/material` | (wip) |
78+
79+
| **iOS** | |
80+
| ------- | :---: |
81+
| SwiftUI | (wip) |
82+
83+
| **Android** | |
84+
| --------------- | :---: |
85+
| Jetpack Compose | (wip) |
86+
2887
## What does it mean?
2988

3089
### By "design". What does it mean?

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
react_styles,
1414
} from "./framework-options";
1515
import styled from "@emotion/styled";
16+
import assert from "assert";
1617

1718
type DesigntoCodeUserOptions = FrameworkOption;
1819

@@ -31,6 +32,8 @@ export function CodeOptionsControl(props: CodeOptionsControlProps) {
3132
all_preset_options_map__prod[__presetname]
3233
);
3334

35+
assert(useroption, "option must be specified");
36+
3437
useEffect(() => {
3538
// trigger initial value
3639
props.onUseroptionChange(useroption);
@@ -54,6 +57,26 @@ export function CodeOptionsControl(props: CodeOptionsControlProps) {
5457
value: "react_with_inline_css",
5558
description: "with inline-css",
5659
},
60+
{
61+
name: "React",
62+
value: "react_with_css_module",
63+
description: "with css-module",
64+
},
65+
{
66+
name: "React Native",
67+
value: "reactnative_default",
68+
description: "react-native",
69+
},
70+
{
71+
name: "React Native",
72+
value: "reactnative_with_styled_components",
73+
description: "with styled-components",
74+
},
75+
{
76+
name: "React Native",
77+
value: "reactnative_with_inline_style",
78+
description: "with inline-style",
79+
},
5780
{
5881
name: "Flutter",
5982
value: "flutter_default",
@@ -89,12 +112,12 @@ export function CodeOptionsControl(props: CodeOptionsControlProps) {
89112
const getreactstyle = (frameworkPreset: string) => {
90113
const preset = getpreset(frameworkPreset) as ReactOption;
91114
const selected_styling = preset.styling;
92-
const sorted_langs = [
115+
const sorted_styles = [
93116
selected_styling,
94117
/* remove target item // - https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/splice */
95118
...react_styles.splice(1, 0, selected_styling),
96119
];
97-
return sorted_langs;
120+
return sorted_styles;
98121
};
99122

100123
const react_style_field_config: IField = {
@@ -138,6 +161,7 @@ export function CodeOptionsControl(props: CodeOptionsControlProps) {
138161

139162
const fields_config = {
140163
react: [platform_field_config, lang_field_config, react_style_field_config],
164+
"react-native": [platform_field_config, lang_field_config],
141165
flutter: [platform_field_config, lang_field_config],
142166
vanilla: [platform_field_config, lang_field_config],
143167
};

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

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

10-
export type ReactStylingStrategy = "css" | "styled-components" | "inline-css";
10+
export type ReactStylingStrategy =
11+
| "css"
12+
| "styled-components"
13+
| "inline-css"
14+
| "css-module";
15+
16+
export type ReactNativeStylingStrategy =
17+
| "style-sheet"
18+
| "styled-components"
19+
| "inline-style";
1120

1221
export interface FlutterOption {
1322
framework: Framework.flutter;
@@ -20,12 +29,22 @@ export interface ReactOption {
2029
styling: ReactStylingStrategy;
2130
}
2231

32+
export interface ReactNativeOption {
33+
framework: Framework.reactnative;
34+
language: Language.jsx | Language.tsx;
35+
styling: ReactNativeStylingStrategy;
36+
}
37+
2338
export interface VanillaOption {
2439
framework: Framework.vanilla;
2540
language: Language.html;
2641
}
2742

28-
export type FrameworkOption = ReactOption | FlutterOption | VanillaOption;
43+
export type FrameworkOption =
44+
| ReactOption
45+
| ReactNativeOption
46+
| FlutterOption
47+
| VanillaOption;
2948

3049
export const react_presets = {
3150
react_default: <ReactOption>{
@@ -43,13 +62,36 @@ export const react_presets = {
4362
language: Language.tsx,
4463
styling: "inline-css",
4564
},
65+
react_with_css_module: <ReactOption>{
66+
framework: Framework.react,
67+
language: Language.tsx,
68+
styling: "css-module",
69+
},
4670
react_with_css: <ReactOption>{
4771
framework: Framework.react,
4872
language: Language.tsx,
4973
styling: "css",
5074
},
5175
};
5276

77+
export const reactnative_presets = {
78+
reactnative_default: <ReactNativeOption>{
79+
framework: Framework.reactnative,
80+
language: Language.tsx,
81+
styling: "style-sheet",
82+
},
83+
reactnative_with_styled_components: <ReactNativeOption>{
84+
framework: Framework.reactnative,
85+
language: Language.tsx,
86+
styling: "styled-components",
87+
},
88+
reactnative_with_inline_style: <ReactNativeOption>{
89+
framework: Framework.reactnative,
90+
language: Language.tsx,
91+
styling: "inline-style",
92+
},
93+
};
94+
5395
export const flutter_presets = {
5496
flutter_default: <FlutterOption>{
5597
framework: Framework.flutter,
@@ -66,6 +108,7 @@ export const vanilla_presets = {
66108

67109
export const presets = {
68110
react: react_presets,
111+
reactnative: reactnative_presets,
69112
flutter: flutter_presets,
70113
vanilla: vanilla_presets,
71114
};
@@ -75,6 +118,8 @@ export const all_preset_options__prod = [
75118
react_presets.react_default,
76119
react_presets.react_with_styled_components,
77120
react_presets.react_with_inline_css,
121+
react_presets.react_with_css_module,
122+
reactnative_presets.reactnative_default,
78123
vanilla_presets.vanilla_default,
79124
// react_with_css // NOT ON PRODUCTION
80125
];
@@ -85,19 +130,27 @@ export const all_preset_options_map__prod = {
85130
react_default: react_presets.react_default,
86131
react_with_styled_components: react_presets.react_with_styled_components,
87132
react_with_inline_css: react_presets.react_with_inline_css,
133+
react_with_css_module: react_presets.react_with_css_module,
134+
reactnative_default: reactnative_presets.reactnative_default,
135+
reactnative_with_styled_components:
136+
reactnative_presets.reactnative_with_styled_components,
137+
reactnative_with_inline_style:
138+
reactnative_presets.reactnative_with_inline_style,
88139
vanilla_default: vanilla_presets.vanilla_default,
89140
// react_with_css // NOT ON PRODUCTION
90141
};
91142

92143
export const lang_by_framework = {
93144
flutter: [Language.dart],
94145
react: [Language.jsx, Language.tsx],
146+
"react-native": [Language.jsx, Language.tsx],
95147
vanilla: [Language.html],
96148
};
97149

98150
export const react_styles: ReactStylingStrategy[] = [
99151
"styled-components",
100152
"inline-css",
153+
"css-module",
101154
"css",
102155
];
103156

@@ -115,6 +168,8 @@ export const getDefaultPresetNameByFramework = (frameowrk: Framework) => {
115168
return "flutter_default";
116169
case Framework.react:
117170
return "react_default";
171+
case Framework.reactnative:
172+
return "reactnative_default";
118173
case Framework.vanilla:
119174
return "vanilla_default";
120175
}

editor/next.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const withTM = require("next-transpile-modules")([
2222
"@designto/web",
2323
"@designto/vanilla",
2424
"@designto/react",
25+
"@designto/react-native",
2526

2627
"@code-features/assets",
2728
"@code-features/component",
@@ -82,10 +83,12 @@ const withTM = require("next-transpile-modules")([
8283
// region builders - part of designto-code / coli
8384

8485
// region web builders
85-
"@coli.codes/nodejs-builder",
86+
"@web-builder/nodejs",
8687
"@web-builder/core",
8788
"@web-builder/vanilla",
89+
"@web-builder/react-core",
8890
"@web-builder/react",
91+
"@web-builder/react-native",
8992
"@web-builder/reflect-ui",
9093
"@web-builder/styled",
9194
"@web-builder/styles",

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
react_presets,
3+
reactnative_presets,
34
flutter_presets,
45
vanilla_presets,
56
} from "@grida/builder-config-preset";
@@ -37,6 +38,17 @@ export function get_framework_config(framework: string) {
3738
case "react_with_inline_css":
3839
case "react-with-inline-css":
3940
return react_presets.react_with_inline_css;
41+
case "react_with_css_module":
42+
case "react-with-css-module":
43+
return react_presets.react_with_css_module;
44+
case "react-native":
45+
return reactnative_presets.reactnative_default;
46+
case "react-native-with-style-sheet":
47+
return reactnative_presets.reactnative_with_style_sheet;
48+
case "react-native-with-styled-components":
49+
return reactnative_presets.reactnative_with_styled_components;
50+
case "react-native-with-inline-style":
51+
return reactnative_presets.reactnative_with_inline_style;
4052
case "flutter":
4153
case "flutter_default":
4254
case "flutter-default":

editor/scaffolds/code/index.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { utils_dart } from "utils";
1414
import type { ReflectSceneNode } from "@design-sdk/core";
1515

1616
import { utils as _design_utils } from "@design-sdk/core";
17+
import assert from "assert";
1718
const designq = _design_utils.query;
1819

1920
export function CodeSegment() {
@@ -120,25 +121,46 @@ export function CodeSegment() {
120121
switch (o.framework) {
121122
case "react": {
122123
switch (o.styling) {
124+
case "styled-components":
125+
c = get_framework_config("react-with-styled-components");
126+
break;
123127
case "inline-css":
124128
c = get_framework_config("react-with-inline-css");
125129
break;
126-
case "styled-components":
127-
c = get_framework_config("react-with-styled-components");
130+
case "css-module":
131+
c = get_framework_config("react-with-css-module");
128132
break;
129133
case "css":
130134
// TODO:
131135
break;
132136
}
133137
break;
134138
}
139+
case "react-native": {
140+
switch (o.styling) {
141+
case "style-sheet":
142+
c = get_framework_config("react-native-with-style-sheet");
143+
break;
144+
case "styled-components":
145+
c = get_framework_config(
146+
"react-native-with-styled-components"
147+
);
148+
break;
149+
case "inline-style":
150+
c = get_framework_config("react-native-with-inline-style");
151+
break;
152+
}
153+
break;
154+
}
135155
case "flutter":
136156
c = get_framework_config(o.framework);
137157
break;
138158
case "vanilla":
139159
c = get_framework_config(o.framework);
140160
break;
141161
}
162+
163+
assert(c);
142164
set_framework_config(c);
143165
}}
144166
/>

externals/reflect-core

0 commit comments

Comments
 (0)