Skip to content

Commit 4a05757

Browse files
add styled-components support for react-native (styled-components/native | @emotion/native)
1 parent d9b0313 commit 4a05757

14 files changed

Lines changed: 329 additions & 9 deletions

File tree

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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ export function CodeOptionsControl(props: CodeOptionsControlProps) {
6767
value: "reactnative_default",
6868
description: "react-native",
6969
},
70+
{
71+
name: "React Native",
72+
value: "reactnative_with_styled_components",
73+
description: "with styled-components",
74+
},
7075
{
7176
name: "Flutter",
7277
value: "flutter_default",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ export const all_preset_options_map__prod = {
127127
react_with_inline_css: react_presets.react_with_inline_css,
128128
react_with_css_module: react_presets.react_with_css_module,
129129
reactnative_default: reactnative_presets.reactnative_default,
130+
reactnative_with_styled_components:
131+
reactnative_presets.reactnative_with_styled_components,
130132
vanilla_default: vanilla_presets.vanilla_default,
131133
// react_with_css // NOT ON PRODUCTION
132134
};

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export function get_framework_config(framework: string) {
4343
return react_presets.react_with_css_module;
4444
case "react-native":
4545
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;
4650
case "flutter":
4751
case "flutter_default":
4852
case "flutter-default":

editor/scaffolds/code/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,16 @@ export function CodeSegment() {
137137
break;
138138
}
139139
case "react-native": {
140-
c = get_framework_config("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+
}
141150
break;
142151
}
143152
case "flutter":

externals/coli

Submodule coli updated from e2035df to 0b2bf9c

packages/builder-config-preset/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,28 @@ export const reactnative_presets = {
7777
},
7878
component_declaration_style: _react_component_declaration_style,
7979
},
80+
reactnative_with_style_sheet: <config.ReactNativeFrameworkConfig>{
81+
framework: Framework.reactnative,
82+
language: Language.tsx,
83+
svg: null, // TODO:
84+
gradient: null, // TODO:
85+
styling: {
86+
type: "react-native-stylesheet",
87+
module: "react-native",
88+
},
89+
component_declaration_style: _react_component_declaration_style,
90+
},
91+
reactnative_with_styled_components: <config.ReactNativeFrameworkConfig>{
92+
framework: Framework.reactnative,
93+
language: Language.tsx,
94+
svg: null, // TODO:
95+
gradient: null, // TODO:
96+
styling: {
97+
type: "styled-components",
98+
module: "styled-components/native",
99+
},
100+
component_declaration_style: _react_component_declaration_style,
101+
},
80102
};
81103

82104
export const vanilla_presets = {

packages/builder-react-native/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from "./rn-widgets";
33

44
// building strategies
55
export * from "./rn-build-stylesheet-widget";
6+
export * from "./rn-build-styled-component-widget";
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { JsxWidget } from "@web-builder/core";
2+
import { ReactComponentExportResult } from "@web-builder/react-core";
3+
import {
4+
reactnative as rn_config,
5+
react as react_config,
6+
} from "@designto/config";
7+
import { ReactNativeStyledComponentsModuleBuilder } from "./rn-styled-components-module-builder";
8+
9+
/**
10+
* standard `StyleSheet.create` pattern for react-native
11+
* @todo - this is not fully implemented
12+
* @param entry
13+
* @returns
14+
*/
15+
export function finalizeReactNativeWidget_StyledComponents(
16+
entry: JsxWidget,
17+
{
18+
styling,
19+
exporting,
20+
}: {
21+
styling: rn_config.ReactNativeStyledComponentsConfig;
22+
exporting: react_config.ReactComponentExportingCofnig;
23+
}
24+
): ReactComponentExportResult {
25+
const builder = new ReactNativeStyledComponentsModuleBuilder({
26+
entry,
27+
config: styling,
28+
});
29+
return builder.asExportableModule().finalize(exporting);
30+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./from-static-widget-tree";

0 commit comments

Comments
 (0)