@builder.io/sdk-solid 0.0.8-13 → 0.0.8-14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-solid",
3
- "version": "0.0.8-13",
3
+ "version": "0.0.8-14",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./src/solid-index.jsx",
@@ -27,9 +27,7 @@ function Image(props) {
27
27
  fontSize: "0"
28
28
  })} style={{
29
29
  "padding-top": props.aspectRatio * 100 + "%"
30
- }}>
31
- {" "}
32
- </div>
30
+ }}></div>
33
31
  </Show>
34
32
  <Show when={props.builderBlock?.children?.length && props.fitContent}>
35
33
  {props.children}
@@ -4,6 +4,8 @@ import { TARGET } from "../../constants/target.js";
4
4
  import BuilderContext from "../../context/builder.context";
5
5
  import { getProcessedBlock } from "../../functions/get-processed-block.js";
6
6
  import RenderInlinedStyles from "../render-inlined-styles.jsx";
7
+ import { convertStyleMaptoCSS } from "../../helpers/css.js";
8
+ import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
7
9
 
8
10
  function BlockStyles(props) {
9
11
  const state = createMutable({
@@ -15,35 +17,25 @@ function BlockStyles(props) {
15
17
  });
16
18
  },
17
19
 
18
- camelToKebabCase(string) {
19
- return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
20
- },
21
-
22
20
  get css() {
23
- // TODO: media queries
24
- const styleObject = state.useBlock.responsiveStyles?.large;
25
-
26
- if (!styleObject) {
27
- return "";
28
- }
29
-
30
- let str = `.${state.useBlock.id} {`;
31
-
32
- for (const key in styleObject) {
33
- const value = styleObject[key];
34
-
35
- if (typeof value === "string") {
36
- str += `${state.camelToKebabCase(key)}: ${value};`;
37
- }
38
- }
39
-
40
- str += "}";
41
- return str;
21
+ const styles = state.useBlock.responsiveStyles;
22
+ const largeStyles = styles?.large;
23
+ const mediumStyles = styles?.medium;
24
+ const smallStyles = styles?.small;
25
+ return `
26
+ ${largeStyles ? `.${state.useBlock.id} {${convertStyleMaptoCSS(largeStyles)}}` : ""}
27
+ ${mediumStyles ? `${getMaxWidthQueryForSize("medium")} {
28
+ .${state.useBlock.id} {${convertStyleMaptoCSS(mediumStyles)}}
29
+ }` : ""}
30
+ ${smallStyles ? `${getMaxWidthQueryForSize("small")} {
31
+ .${state.useBlock.id} {${convertStyleMaptoCSS(smallStyles)}}
32
+ }` : ""}
33
+ }`;
42
34
  }
43
35
 
44
36
  });
45
37
  const builderContext = useContext(BuilderContext);
46
- return <Show when={TARGET === "vue" || TARGET === "svelte"}>
38
+ return <Show when={TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte"}>
47
39
  <RenderInlinedStyles styles={state.css}></RenderInlinedStyles>
48
40
  </Show>;
49
41
  }
@@ -1,10 +1,4 @@
1
- const sizeNames = ["xsmall", "small", "medium", "large"];
2
- const sizes = {
3
- xsmall: {
4
- min: 0,
5
- default: 0,
6
- max: 0
7
- },
1
+ const SIZES = {
8
2
  small: {
9
3
  min: 320,
10
4
  default: 321,
@@ -19,21 +13,9 @@ const sizes = {
19
13
  min: 990,
20
14
  default: 991,
21
15
  max: 1200
22
- },
23
- getWidthForSize(size) {
24
- return this[size].default;
25
- },
26
- getSizeForWidth(width) {
27
- for (const size of sizeNames) {
28
- const value = this[size];
29
- if (width <= value.max) {
30
- return size;
31
- }
32
- }
33
- return "large";
34
16
  }
35
17
  };
18
+ const getMaxWidthQueryForSize = (size) => `@media (max-width: ${SIZES[size].max}px)`;
36
19
  export {
37
- sizeNames,
38
- sizes
20
+ getMaxWidthQueryForSize
39
21
  };
@@ -0,0 +1,4 @@
1
+ const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
2
+ export {
3
+ camelToKebabCase
4
+ };
@@ -0,0 +1,12 @@
1
+ import { camelToKebabCase } from "../functions/camel-to-kebab-case";
2
+ const convertStyleMaptoCSS = (style) => {
3
+ const cssProps = Object.entries(style).map(([key, value]) => {
4
+ if (typeof value === "string") {
5
+ return `${camelToKebabCase(key)}: ${value};`;
6
+ }
7
+ });
8
+ return cssProps.join("\n");
9
+ };
10
+ export {
11
+ convertStyleMaptoCSS
12
+ };
@@ -1,5 +0,0 @@
1
- function ErrorBoundary(props) {
2
- return <></>;
3
- }
4
-
5
- export default ErrorBoundary;