- )
-}
+ );
+};
CardTop.craft = {
rules: {
- canMoveIn: (incomingNode) => incomingNode.data.type == Text
+ canMoveIn: incomingNode => incomingNode.data.type === Text
}
-}
+};
-export const CardBottom = ({children}) => {
- const { connectors: {connect} } = useNode();
+export const CardBottom = ({ children }) => {
+ const {
+ connectors: { connect }
+ } = useNode();
return (
-
+
{children}
- )
-}
+ );
+};
CardBottom.craft = {
rules: {
- canMoveIn : (incomingNode) => incomingNode.data.type == Button
+ canMoveIn: incomingNode => incomingNode.data.type === Button
}
-}
+};
-export const Card = ({background, padding = 20}) => {
+export const Card = ({ background, padding = 20 }) => {
return (
- )
-}
+ );
+};
Card.craft = {
defaultProps: ContainerDefaultProps,
related: {
settings: ContainerSettings
}
-}
\ No newline at end of file
+};
diff --git a/packages/examples/basic/components/user/Container.js b/packages/examples/basic/components/user/Container.js
index b138de58c..5eb4dba90 100644
--- a/packages/examples/basic/components/user/Container.js
+++ b/packages/examples/basic/components/user/Container.js
@@ -1,19 +1,22 @@
-import React from "react";
-import {Card as MaterialCard, CardContent, Slider} from "@material-ui/core";
-import Text from "./Text";
-import Button from "./Button";
-import { Canvas, useNode } from "@craftjs/core";
-import {Paper, FormControl, FormLabel, RadioGroup,Radio, FormControlLabel} from "@material-ui/core";
-import ColorPicker from 'material-ui-color-picker'
+import React from "react";
+import { Slider } from "@material-ui/core";
+import { useNode } from "@craftjs/core";
+import { Paper, FormControl, FormLabel } from "@material-ui/core";
+import ColorPicker from "material-ui-color-picker";
-export const Container = ({background, padding, children}) => {
- const { connectors: {connect, drag} } = useNode();
+export const Container = ({ background, padding, children }) => {
+ const {
+ connectors: { connect, drag }
+ } = useNode();
return (
-
connect(drag(ref))} style={{margin: "5px 0", background, padding: `${padding}px`}}>
+ connect(drag(ref))}
+ style={{ margin: "5px 0", background, padding: `${padding}px` }}
+ >
{children}
- )
-}
+ );
+};
export const ContainerSettings = () => {
const { background, padding, setProp } = useNode(node => ({
@@ -25,20 +28,26 @@ export const ContainerSettings = () => {
Background
- {
- setProp(props => props.background = color)
- }} />
+ {
+ setProp(props => (props.background = color));
+ }}
+ />
Padding
- setProp(props => props.padding = value)} />
+ setProp(props => (props.padding = value))}
+ />
- )
-}
+ );
+};
export const ContainerDefaultProps = {
- background : "#ffffff",
+ background: "#ffffff",
padding: 3
};
@@ -47,4 +56,4 @@ Container.craft = {
related: {
settings: ContainerSettings
}
-}
\ No newline at end of file
+};
diff --git a/packages/examples/basic/components/user/Text.js b/packages/examples/basic/components/user/Text.js
index 333a03ba1..af410f0f6 100644
--- a/packages/examples/basic/components/user/Text.js
+++ b/packages/examples/basic/components/user/Text.js
@@ -1,42 +1,47 @@
-import React, {useState, useEffect} from "react";
+import React, { useState, useEffect } from "react";
import { useNode } from "@craftjs/core";
-import ContentEditable from 'react-contenteditable'
-import {Slider, FormControl, FormLabel} from "@material-ui/core";
+import ContentEditable from "react-contenteditable";
+import { Slider, FormControl, FormLabel } from "@material-ui/core";
-export const Text= ({text, fontSize, textAlign}) => {
- const { connectors: {connect, drag}, selected, setProp } = useNode((state) => ({
+export const Text = ({ text, fontSize, textAlign }) => {
+ const {
+ connectors: { connect, drag },
+ selected,
+ setProp
+ } = useNode(state => ({
selected: state.events.selected,
dragged: state.events.dragged
}));
const [editable, setEditable] = useState(false);
- useEffect(() => {!selected && setEditable(false)}, [selected]);
+ useEffect(() => {
+ !selected && setEditable(false);
+ }, [selected]);
return (
- connect(drag(ref))}
- onClick={e => selected && setEditable(true)}
+ onClick={e => selected && setEditable(true)}
>
- setProp(props =>
- props.text = e.target.value.replace(/<\/?[^>]+(>|$)/g, "")
+ onChange={e =>
+ setProp(
+ props =>
+ (props.text = e.target.value.replace(/<\/?[^>]+(>|$)/g, ""))
)
- }
+ }
tagName="p"
- style={{fontSize: `${fontSize}px`, textAlign}}
+ style={{ fontSize: `${fontSize}px`, textAlign }}
/>
-
- )
-}
-
+ );
+};
const TextSettings = () => {
- const { setProp, fontSize } = useNode((node) => ({
+ const { setProp, fontSize } = useNode(node => ({
text: node.data.props.text,
fontSize: node.data.props.fontSize
}));
@@ -51,13 +56,13 @@ const TextSettings = () => {
min={1}
max={50}
onChange={(_, value) => {
- setProp(props => props.fontSize = value);
+ setProp(props => (props.fontSize = value));
}}
/>
>
- )
-}
+ );
+};
export const TextDefaultProps = {
text: "Hi",
@@ -66,7 +71,7 @@ export const TextDefaultProps = {
Text.craft = {
defaultProps: TextDefaultProps,
- related : {
+ related: {
settings: TextSettings
}
-}
\ No newline at end of file
+};
diff --git a/packages/examples/basic/next.config.js b/packages/examples/basic/next.config.js
index 882e6151b..3b10623a4 100644
--- a/packages/examples/basic/next.config.js
+++ b/packages/examples/basic/next.config.js
@@ -1,22 +1,19 @@
-const withPlugins = require('next-compose-plugins');
-const withTM = require('next-transpile-modules')
-const withCSS = require('@zeit/next-css')
+const withPlugins = require("next-compose-plugins");
+const withTM = require("next-transpile-modules");
+const withCSS = require("@zeit/next-css");
-
-let plugins = [
- [withCSS]
-];
+let plugins = [[withCSS]];
/** For development purposes */
-if ( process.env.NODE_ENV != "production" ) {
- plugins.push(
- [withTM, {
- transpileModules: ['@craftjs/core', '@craftjs/utils']
- }]
- )
+if (process.env.NODE_ENV !== "production") {
+ plugins.push([
+ withTM,
+ {
+ transpileModules: ["@craftjs/core", "@craftjs/utils"]
+ }
+ ]);
}
-
module.exports = withPlugins(plugins, {
- assetPrefix: process.env.NODE_ENV === 'production' ? '/examples/basic' : '',
-});
\ No newline at end of file
+ assetPrefix: process.env.NODE_ENV === "production" ? "/examples/basic" : ""
+});
diff --git a/packages/examples/basic/pages/_app.js b/packages/examples/basic/pages/_app.js
index dd776d9e7..9d9e7d120 100644
--- a/packages/examples/basic/pages/_app.js
+++ b/packages/examples/basic/pages/_app.js
@@ -1,14 +1,14 @@
-import React from 'react';
-import App from 'next/app';
-import Head from 'next/head';
-import { ThemeProvider } from '@material-ui/core/styles';
-import CssBaseline from '@material-ui/core/CssBaseline';
-import theme from '../src/theme';
+import React from "react";
+import App from "next/app";
+import Head from "next/head";
+import { ThemeProvider } from "@material-ui/core/styles";
+import CssBaseline from "@material-ui/core/CssBaseline";
+import theme from "../src/theme";
export default class MyApp extends App {
componentDidMount() {
// Remove the server-side injected CSS.
- const jssStyles = document.querySelector('#jss-server-side');
+ const jssStyles = document.querySelector("#jss-server-side");
if (jssStyles) {
jssStyles.parentElement.removeChild(jssStyles);
}
diff --git a/packages/examples/basic/pages/_document.js b/packages/examples/basic/pages/_document.js
index 05473eab3..72cfde4e9 100644
--- a/packages/examples/basic/pages/_document.js
+++ b/packages/examples/basic/pages/_document.js
@@ -1,7 +1,7 @@
-import React from 'react';
-import Document, { Head, Main, NextScript } from 'next/document';
-import { ServerStyleSheets } from '@material-ui/core/styles';
-import theme from '../src/theme';
+import React from "react";
+import Document, { Head, Main, NextScript } from "next/document";
+import { ServerStyleSheets } from "@material-ui/core/styles";
+import theme from "../src/theme";
export default class MyDocument extends Document {
render() {
@@ -58,7 +58,7 @@ MyDocument.getInitialProps = async ctx => {
ctx.renderPage = () =>
originalRenderPage({
- enhanceApp: App => props => sheets.collect(),
+ enhanceApp: App => props => sheets.collect()
});
const initialProps = await Document.getInitialProps(ctx);
@@ -66,6 +66,9 @@ MyDocument.getInitialProps = async ctx => {
return {
...initialProps,
// Styles fragment is rendered after the app and page rendering finish.
- styles: [...React.Children.toArray(initialProps.styles), sheets.getStyleElement()],
+ styles: [
+ ...React.Children.toArray(initialProps.styles),
+ sheets.getStyleElement()
+ ]
};
};
diff --git a/packages/examples/basic/pages/about.js b/packages/examples/basic/pages/about.js
index 536f80b12..3fa59f761 100644
--- a/packages/examples/basic/pages/about.js
+++ b/packages/examples/basic/pages/about.js
@@ -1,21 +1,21 @@
-import React from 'react';
-import Container from '@material-ui/core/Container';
-import Typography from '@material-ui/core/Typography';
-import Box from '@material-ui/core/Box';
-import MuiLink from '@material-ui/core/Link';
-import Button from '@material-ui/core/Button';
-import ProTip from '../src/ProTip';
-import Link from '../src/Link';
+import React from "react";
+import Container from "@material-ui/core/Container";
+import Typography from "@material-ui/core/Typography";
+import Box from "@material-ui/core/Box";
+import MuiLink from "@material-ui/core/Link";
+import Button from "@material-ui/core/Button";
+import ProTip from "../src/ProTip";
+import Link from "../src/Link";
function Copyright() {
return (
- {'Copyright © '}
+ {"Copyright © "}
Your Website
- {' '}
+ {" "}
{new Date().getFullYear()}
- {'.'}
+ {"."}
);
}
@@ -27,7 +27,13 @@ export default function About() {
Next.js example
-