Skip to content

Commit

Permalink
Hello world
Browse files Browse the repository at this point in the history
  • Loading branch information
baptadn committed Jan 28, 2020
1 parent 7ed3b29 commit c62c367
Show file tree
Hide file tree
Showing 61 changed files with 4,743 additions and 299 deletions.
5 changes: 5 additions & 0 deletions config-overrides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { override } = require("customize-cra");
const { addReactRefresh } = require("customize-cra-react-refresh");

/* config-overrides.js */
module.exports = override(addReactRefresh({ disableRefreshCheck: true }));
37 changes: 32 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,36 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@chakra-ui/core": "^0.5.2",
"@emotion/core": "^10.0.27",
"@emotion/styled": "^10.0.27",
"@mdx-js/react": "^1.5.5",
"@reach/combobox": "^0.7.3",
"@rehooks/local-storage": "^2.1.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"codesandbox": "^2.1.11",
"coloreact": "^0.3.1",
"emotion-theming": "^10.0.27",
"lodash": "^4.17.15",
"lodash-es": "^4.17.15",
"prism-react-renderer": "^1.0.2",
"react": "^16.12.0",
"react-color": "^2.18.0",
"react-color-picker": "^4.0.2",
"react-dnd": "^10.0.2",
"react-dnd-html5-backend": "^10.0.2",
"react-dom": "^16.12.0",
"react-scripts": "3.3.0"
"react-icons": "^3.8.0",
"react-scripts": "3.3.0",
"react-split-pane": "^0.1.89",
"typescript": "^3.7.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -30,5 +48,14 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@types/lodash": "^4.14.149",
"@types/prettier": "^1.19.0",
"@types/react-color": "^3.0.1",
"customize-cra": "^0.9.1",
"customize-cra-react-refresh": "^1.0.1",
"prettier": "^1.19.1",
"react-app-rewired": "^2.1.5"
}
}
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Open Chakra - Chakra UI drag and drop editor for developers</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
38 changes: 0 additions & 38 deletions src/App.css

This file was deleted.

26 changes: 0 additions & 26 deletions src/App.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/App.test.js

This file was deleted.

55 changes: 55 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from "react";
import { Flex, Box } from "@chakra-ui/core";
import { DndProvider } from "react-dnd";
import Backend from "react-dnd-html5-backend";
import Editor from "./components/editor/Editor";
import Inspector from "./components/inspector/Inspector";
import Sidebar from "./components/sidebar/Sidebar";
import Header from "./components/Header";
import { Global } from "@emotion/core";

export const COMPONENTS: ComponentType[] = [
"Box",
"Checkbox",
"Button",
"Image",
"Badge",
"Icon",
"Text",
"Avatar",
"AvatarGroup",
"AvatarBadge"
];

const App = () => (
<DndProvider backend={Backend}>
<Global
styles={() => ({
"*": { borderBox: "box-sizing" }
})}
/>

<Header />

<Flex minHeight="calc(100vh - 3rem)">
<Box bg="white" flex={1} zIndex={10} position="relative">
<Editor />
</Box>

<Sidebar />

<Box
maxH="calc(100vh - 3rem)"
flex="0 0 15rem"
roundedRight={10}
bg="#f7fafc"
overflowY="scroll"
borderLeft="1px solid #cad5de"
>
<Inspector />
</Box>
</Flex>
</DndProvider>
);

export default App;
65 changes: 65 additions & 0 deletions src/components/CodePanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React from "react";
import { useBuilderContext } from "../contexts/BuilderContext";
import Highlight, { defaultProps } from "prism-react-renderer";
import { Box, Button, useClipboard } from "@chakra-ui/core";
import { generateCode } from "../utils/code";
import theme from "prism-react-renderer/themes/nightOwl";

const CodePanel = () => {
const { components, showCode } = useBuilderContext();
const code = generateCode(components);

const { onCopy, hasCopied } = useClipboard(code);

if (!showCode) {
return null;
}

return (
<Box
p={4}
fontSize="sm"
backgroundColor="#011627"
overflow="scroll"
position="absolute"
top={0}
bottom={0}
left={0}
right={0}
>
{showCode && (
<>
<Button
onClick={onCopy}
size="sm"
position="absolute"
textTransform="uppercase"
variantColor="teal"
fontSize="xs"
height="24px"
top={4}
right="1.25em"
>
{hasCopied ? "copied" : "copy"}
</Button>

<Highlight {...defaultProps} theme={theme} code={code} language="jsx">
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre className={className} style={style}>
{tokens.map((line, i) => (
<div {...getLineProps({ line, key: i })}>
{line.map((token, key) => (
<span {...getTokenProps({ token, key })} />
))}
</div>
))}
</pre>
)}
</Highlight>
</>
)}
</Box>
);
};

export default CodePanel;
Loading

0 comments on commit c62c367

Please sign in to comment.