├── .gitignore ├── README.md ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt ├── src ├── AddComponentModal.tsx ├── App.css ├── App.test.tsx ├── App.tsx ├── ComponentItem.tsx ├── Editor.tsx ├── FontLoaderModal.tsx ├── MotionBox.tsx ├── PaletteModal.tsx ├── ThemeManager.ts ├── evaluate.ts ├── fonts.ts ├── index.css ├── index.tsx ├── logo.svg ├── react-app-env.d.ts ├── reportWebVitals.ts ├── setupTests.ts ├── types.ts └── useTheme.tsx ├── tsconfig.json └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Chakra Theme Tool 2 | 3 | This is a tool to help build chakra-ui themes. It's designed to let you see all of your themed components in one place and to let you iterate on your theme in a holistic way. Chakra theme tool lets you easily experiment with global and component-level styles side-by-side. 4 | 5 | Check it out at [https://malerba118.github.io/chakra-theme-tool/](https://malerba118.github.io/chakra-theme-tool/) 6 | 7 | ![chakra-theme-tool](https://user-images.githubusercontent.com/5760059/114793787-673a1d00-9d48-11eb-9c93-2d5ce9dbf083.gif) 8 | 9 | # Getting Started with Create React App 10 | 11 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 12 | 13 | ## Available Scripts 14 | 15 | In the project directory, you can run: 16 | 17 | ### `yarn start` 18 | 19 | Runs the app in the development mode.\ 20 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 21 | 22 | The page will reload if you make edits.\ 23 | You will also see any lint errors in the console. 24 | 25 | ### `yarn test` 26 | 27 | Launches the test runner in the interactive watch mode.\ 28 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 29 | 30 | ### `yarn build` 31 | 32 | Builds the app for production to the `build` folder.\ 33 | It correctly bundles React in production mode and optimizes the build for the best performance. 34 | 35 | The build is minified and the filenames include the hashes.\ 36 | Your app is ready to be deployed! 37 | 38 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 39 | 40 | ### `yarn eject` 41 | 42 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 43 | 44 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 45 | 46 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 47 | 48 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 49 | 50 | ## Learn More 51 | 52 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 53 | 54 | To learn React, check out the [React documentation](https://reactjs.org/). 55 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chakra-theme-tool", 3 | "version": "0.1.0", 4 | "private": true, 5 | "homepage": "https://malerba118.github.io/chakra-theme-tool", 6 | "dependencies": { 7 | "@babel/standalone": "^7.13.14", 8 | "@chakra-ui/react": "^1.4.2", 9 | "@emotion/react": "^11", 10 | "@emotion/styled": "^11", 11 | "@testing-library/jest-dom": "^5.11.4", 12 | "@testing-library/react": "^11.1.0", 13 | "@testing-library/user-event": "^12.1.10", 14 | "@types/jest": "^26.0.15", 15 | "@types/node": "^12.0.0", 16 | "@types/react": "^17.0.0", 17 | "@types/react-dom": "^17.0.0", 18 | "axios": "^0.21.1", 19 | "chroma-js": "^2.1.1", 20 | "codemirror": "^5.60.0", 21 | "focus-visible": "^5.2.0", 22 | "framer-motion": "^4", 23 | "javascript-stringify": "^2.1.0", 24 | "js-file-download": "^0.4.12", 25 | "js-to-string": "^0.4.8", 26 | "jsx-to-string": "^1.4.0", 27 | "lodash": "^4.17.21", 28 | "mobx": "^6.1.8", 29 | "mobx-react-lite": "^3.2.0", 30 | "react": "^17.0.2", 31 | "react-codemirror2": "^7.2.1", 32 | "react-color": "^2.19.3", 33 | "react-dom": "^17.0.2", 34 | "react-error-boundary": "^3.1.1", 35 | "react-icons": "^4.2.0", 36 | "react-scripts": "4.0.3", 37 | "safer-eval": "^1.3.6", 38 | "typescript": "^4.1.2", 39 | "web-vitals": "^1.0.1", 40 | "webfontloader": "^1.6.28" 41 | }, 42 | "scripts": { 43 | "start": "react-scripts start", 44 | "build": "react-scripts build", 45 | "test": "react-scripts test", 46 | "eject": "react-scripts eject", 47 | "predeploy": "npm run build", 48 | "deploy": "gh-pages -d build" 49 | }, 50 | "eslintConfig": { 51 | "extends": [ 52 | "react-app", 53 | "react-app/jest" 54 | ] 55 | }, 56 | "browserslist": { 57 | "production": [ 58 | ">0.2%", 59 | "not dead", 60 | "not op_mini all" 61 | ], 62 | "development": [ 63 | "last 1 chrome version", 64 | "last 1 firefox version", 65 | "last 1 safari version" 66 | ] 67 | }, 68 | "devDependencies": { 69 | "@types/babel__standalone": "^7.1.3", 70 | "@types/chroma-js": "^2.1.3", 71 | "@types/codemirror": "^0.0.108", 72 | "@types/lodash": "^4.14.168", 73 | "@types/react-color": "^3.0.4", 74 | "@types/webfontloader": "^1.6.32", 75 | "gh-pages": "^3.1.0" 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malerba118/chakra-theme-tool/0cc846ac9a502d4521259c8cc4c6ecac2defd115/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 19 | 23 | 32 | Chakra Theme Tool 33 | 34 | 35 | 36 |
37 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malerba118/chakra-theme-tool/0cc846ac9a502d4521259c8cc4c6ecac2defd115/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malerba118/chakra-theme-tool/0cc846ac9a502d4521259c8cc4c6ecac2defd115/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/AddComponentModal.tsx: -------------------------------------------------------------------------------- 1 | import React, { FC, useState, useRef } from "react"; 2 | import Hue from "react-color/lib/components/hue/Hue"; 3 | import manager from "./ThemeManager"; 4 | import { 5 | Modal, 6 | ModalOverlay, 7 | ModalContent, 8 | ModalHeader, 9 | ModalCloseButton, 10 | ModalBody, 11 | ModalFooter, 12 | Button, 13 | Box, 14 | Flex, 15 | Stack, 16 | Code, 17 | Spacer, 18 | Input, 19 | FormHelperText, 20 | FormLabel, 21 | FormControl, 22 | } from "@chakra-ui/react"; 23 | import { observer } from "mobx-react-lite"; 24 | 25 | const AddComponentModal: FC = observer(({ isOpen, onClose, onSubmit }) => { 26 | const nameEl = useRef(null); 27 | const [name, setName] = useState(""); 28 | const [key, setKey] = useState(""); 29 | 30 | const keyAlreadyExists = !!manager.components[key]; 31 | 32 | const isValid = !!name && !!key && !key.includes(" ") && !keyAlreadyExists; 33 | 34 | return ( 35 | 42 | 43 | 44 |
e.preventDefault()}> 45 | Add a Component 46 | 47 | 48 | 49 | Component Name 50 | setName(e.target.value)} 54 | placeholder="eg: Example Form" 55 | /> 56 | 57 | Component Key 58 | setKey(e.target.value)} 61 | placeholder="eg: Form" 62 | /> 63 | 64 | This will point to theme.components[component_key] 65 | 66 | 67 | 68 | 69 | 78 | 81 | 82 | 83 |
84 |
85 | ); 86 | }); 87 | 88 | export default AddComponentModal; 89 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render, screen } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | render(); 7 | const linkElement = screen.getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /src/App.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState, FC } from "react"; 2 | import { 3 | Flex, 4 | Box, 5 | IconButton, 6 | SimpleGrid, 7 | ChakraProvider, 8 | useDisclosure, 9 | CloseButton, 10 | Stack, 11 | Text, 12 | theme as DEFAULT_THEME, 13 | extendTheme, 14 | useColorMode, 15 | Center, 16 | Switch, 17 | useColorModeValue, 18 | FormControl, 19 | FormLabel, 20 | Tooltip, 21 | } from "@chakra-ui/react"; 22 | import { 23 | IoMdCode as CodeIcon, 24 | IoMdClose as CloseIcon, 25 | IoMdColorPalette as ColorIcon, 26 | IoMdAddCircleOutline as AddIcon, 27 | } from "react-icons/io"; 28 | import { 29 | BiFontFamily as FontIcon, 30 | BiDownload as DownloadIcon, 31 | } from "react-icons/bi"; 32 | import "./App.css"; 33 | import { AnimatePresence, motion, MotionConfig } from "framer-motion"; 34 | import MotionBox from "./MotionBox"; 35 | import ComponentItem from "./ComponentItem"; 36 | import manager from "./ThemeManager"; 37 | import { observer } from "mobx-react-lite"; 38 | import { Editor } from "./Editor"; 39 | import { autorun } from "mobx"; 40 | import PaletteModal from "./PaletteModal"; 41 | import AddComponentModal from "./AddComponentModal"; 42 | import downloadFile from "js-file-download"; 43 | 44 | import * as fonts from "./fonts"; 45 | import FontLoaderModal from "./FontLoaderModal"; 46 | 47 | const variants = { 48 | menu: { 49 | open: { 50 | transition: { 51 | staggerChildren: 0.05, 52 | staggerDirection: 1, 53 | }, 54 | }, 55 | closed: { 56 | transition: { 57 | staggerChildren: 0.05, 58 | staggerDirection: -1, 59 | }, 60 | }, 61 | }, 62 | menuItem: { 63 | open: { 64 | opacity: 1, 65 | x: 0, 66 | }, 67 | closed: { 68 | opacity: 0, 69 | x: 36, 70 | }, 71 | }, 72 | }; 73 | 74 | const CodeMenu: FC = ({ 75 | onClick, 76 | onColorsClick, 77 | onFontsClick, 78 | onDownloadClick, 79 | isOpen, 80 | ...otherProps 81 | }) => { 82 | return ( 83 | 84 | 85 | : } 93 | /> 94 | 95 | 96 | {isOpen && ( 97 | 104 | 108 | 109 | } 117 | /> 118 | 119 | 120 | 124 | 125 | } 133 | /> 134 | 135 | 136 | 140 | 141 | } 149 | /> 150 | 151 | 152 | 153 | )} 154 | 155 | 156 | ); 157 | }; 158 | 159 | // save to local storage 160 | autorun( 161 | () => { 162 | localStorage.setItem("data", JSON.stringify(manager.data)); 163 | }, 164 | { 165 | delay: 3000, 166 | } 167 | ); 168 | 169 | const App = observer(() => { 170 | const [sidebarOpen, setSidebarOpen] = useState(true); 171 | const modals = { 172 | color: useDisclosure(), 173 | component: useDisclosure(), 174 | font: useDisclosure(), 175 | }; 176 | const { colorMode, toggleColorMode } = useColorMode(); 177 | const theme = manager.theme; 178 | const cardBg = useColorModeValue("whiteAlpha.800", "whiteAlpha.50"); 179 | 180 | return ( 181 | 182 | 183 | 184 | 195 | 196 | Chakra Theme Tool 197 | 198 | 199 | 207 | 208 | Dark Mode 209 | 210 | { 215 | toggleColorMode(); 216 | }} 217 | /> 218 | 219 | 220 | 221 | 227 | {manager.componentKeys.map((componentKey) => ( 228 | manager.setSelected(componentKey)} 236 | transition="all .25s" 237 | _hover={{ transform: "scale(1.015)", boxShadow: "md" }} 238 | boxShadow={"sm"} 239 | > 240 | 248 | 249 | ))} 250 | 261 |
262 | 263 | Add a Component 264 | 265 | 266 |
267 |
268 |
269 | {manager.getSelected() && ( 270 | 280 | 284 | manager.setSelected(null)} 289 | /> 290 | 291 | )} 292 |
293 |
294 | 303 | 304 | 305 |
306 | 310 | 314 | { 318 | manager.addComponent(data); 319 | modals.component.onClose(); 320 | }} 321 | /> 322 | setSidebarOpen((p) => !p)} 324 | onColorsClick={modals.color.onOpen} 325 | onFontsClick={modals.font.onOpen} 326 | onDownloadClick={() => { 327 | downloadFile(manager.themeStr, "theme.js"); 328 | }} 329 | isOpen={sidebarOpen} 330 | pos="fixed" 331 | top={"12px"} 332 | right={"12px"} 333 | zIndex={100} 334 | /> 335 |
336 | ); 337 | }); 338 | 339 | export default App; 340 | -------------------------------------------------------------------------------- /src/ComponentItem.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState, FC, useMemo } from "react"; 2 | import { 3 | Accordion, 4 | AccordionItem, 5 | Box, 6 | Heading, 7 | HStack, 8 | Stack, 9 | Wrap, 10 | AccordionButton, 11 | AccordionIcon, 12 | AccordionPanel, 13 | ChakraProvider, 14 | useColorModeValue, 15 | useColorModePreference, 16 | } from "@chakra-ui/react"; 17 | import { ComponentData } from "./types"; 18 | import manager from "./ThemeManager"; 19 | import { observer } from "mobx-react-lite"; 20 | import { motion, Variants } from "framer-motion"; 21 | import MotionBox from "./MotionBox"; 22 | import evaluate from "./evaluate"; 23 | import { ErrorBoundary } from "react-error-boundary"; 24 | 25 | const ErrorFallback: FC = ({ error, resetErrorBoundary }) => { 26 | return ( 27 |
28 |

Something went wrong:

29 |
{error.message}
30 | 31 |
32 | ); 33 | }; 34 | 35 | interface ComponentItemProps { 36 | mode: "grid-item" | "list-item" | "expanded"; 37 | componentKey: string; 38 | } 39 | 40 | // interface SizeVariant { 41 | // size: string | undefined; 42 | // variant: string | undefined; 43 | // } 44 | 45 | // const enumerateSizeVariants = ( 46 | // sizes: Array, 47 | // variants: Array 48 | // ): SizeVariant[] => { 49 | // let sizeVariants: SizeVariant[] = []; 50 | // sizes.forEach((size) => { 51 | // variants.forEach((variant) => { 52 | // sizeVariants.push({ 53 | // size, 54 | // variant, 55 | // }); 56 | // }); 57 | // }); 58 | // return sizeVariants; 59 | // }; 60 | 61 | const getSizes = (theme: any, componentKey: string) => { 62 | let sizes: Array = Object.keys( 63 | theme.components[componentKey]?.sizes || {} 64 | ); 65 | sizes.push(undefined); 66 | return sizes; 67 | }; 68 | 69 | const getVariants = (theme: any, componentKey: string) => { 70 | let sizes: Array = Object.keys( 71 | theme.components[componentKey]?.variants || {} 72 | ); 73 | sizes.push(undefined); 74 | return sizes; 75 | }; 76 | 77 | const animationVariants: any = { 78 | expanded: { 79 | transform: "scale(1)", 80 | }, 81 | "grid-item": { 82 | transform: "scale(.75)", 83 | }, 84 | }; 85 | 86 | const ComponentItem: FC = observer( 87 | ({ mode, componentKey }) => { 88 | const component = manager.components[componentKey]; 89 | const theme = manager.theme; 90 | const variants = getVariants(theme, component.key); 91 | const sizes = getSizes(theme, component.key); 92 | 93 | const rendererStr = manager.getRawComponentRenderer(componentKey); 94 | 95 | const Renderer = useMemo(() => { 96 | return evaluate(rendererStr); 97 | }, [rendererStr]); 98 | 99 | return ( 100 | { 103 | // reset the state of your app so the error doesn't happen again 104 | }} 105 | > 106 | 113 | 114 | {component.name} 115 | 116 | {mode === "grid-item" && ( 117 | 118 | {variants.map((variant) => ( 119 | 124 | {Renderer && } 125 | 126 | ))} 127 | 128 | )} 129 | {mode === "expanded" && ( 130 | 131 | {sizes.map((size) => ( 132 | 133 | 134 | 135 | {size || "default"} 136 | 137 | 138 | 139 | 140 | 141 | {variants.map((variant) => ( 142 | 147 | 148 | {Renderer && ( 149 | 150 | )} 151 | 152 | 153 | ))} 154 | 155 | 156 | 157 | ))} 158 | 159 | )} 160 | 161 | 162 | ); 163 | } 164 | ); 165 | 166 | export default ComponentItem; 167 | 168 | const Card: FC = ({ title, children, ...otherProps }) => { 169 | const styles = useColorModeValue( 170 | { 171 | borderColor: "blackAlpha.400", 172 | bg: "white", 173 | }, 174 | { 175 | borderColor: "whiteAlpha.400", 176 | bg: "gray.700", 177 | } 178 | ); 179 | 180 | return ( 181 | 187 | 188 | {title} 189 | 190 | {children} 191 | 192 | ); 193 | }; 194 | -------------------------------------------------------------------------------- /src/Editor.tsx: -------------------------------------------------------------------------------- 1 | import React, { useRef, useState, FC, useEffect } from "react"; 2 | import "codemirror/lib/codemirror.css"; 3 | import "codemirror/mode/javascript/javascript.js"; 4 | import "codemirror/mode/jsx/jsx.js"; 5 | import "codemirror/mode/css/css.js"; 6 | import "codemirror/theme/material-darker.css"; 7 | import { UnControlled as Codemirror } from "react-codemirror2"; 8 | import { Editor as CodeMirrorEditor, EditorConfiguration } from "codemirror"; 9 | import { Box, Flex, Tabs, Tab, TabList } from "@chakra-ui/react"; 10 | import { observer } from "mobx-react-lite"; 11 | import manager from "./ThemeManager"; 12 | import debounce from "lodash/debounce"; 13 | 14 | const debounced = { 15 | setRawGlobalOverrides: debounce( 16 | (val) => manager.setRawGlobalOverrides(val), 17 | 1000 18 | ), 19 | setRawComponentOverrides: debounce( 20 | (componentKey, val) => manager.setRawComponentOverrides(componentKey, val), 21 | 1000 22 | ), 23 | setRawComponentRenderer: debounce( 24 | (componentKey, val) => manager.setRawComponentRenderer(componentKey, val), 25 | 1000 26 | ), 27 | }; 28 | 29 | interface EditorProps {} 30 | 31 | const value = manager.getRawGlobalOverrides(); 32 | 33 | export const Editor: FC = observer(() => { 34 | const editorRef = useRef(); 35 | const value = manager.getRawGlobalOverrides(); 36 | const componentKey = manager.getSelected(); 37 | const [selectedTab, setSelectedTab] = useState("global"); 38 | 39 | const tabs = ["global"]; 40 | if (componentKey) { 41 | tabs.push(componentKey); 42 | tabs.push("render"); 43 | } 44 | 45 | useEffect(() => { 46 | setSelectedTab(componentKey || "global"); 47 | }, [componentKey]); 48 | 49 | let editorVals: any = {}; 50 | 51 | if (selectedTab === "global") { 52 | editorVals.value = manager.getRawGlobalOverrides(); 53 | editorVals.setValue = debounced.setRawGlobalOverrides; 54 | } else if (selectedTab === componentKey) { 55 | editorVals.value = manager.getRawComponentOverrides(componentKey); 56 | editorVals.setValue = (val: string) => 57 | debounced.setRawComponentOverrides(componentKey, val); 58 | } else if (selectedTab === "render") { 59 | editorVals.value = manager.getRawComponentRenderer(componentKey); 60 | editorVals.setValue = (val: string) => 61 | debounced.setRawComponentRenderer(componentKey, val); 62 | } 63 | 64 | return ( 65 | 66 | 72 | setSelectedTab(tabs[index])} 79 | > 80 | 81 | {tabs.map((tab) => ( 82 | 93 | {tab} 94 | 95 | ))} 96 | 97 | 98 | 99 | 100 | { 103 | editorRef.current = editor; 104 | editor.setSize("100%", "100%"); 105 | // Hacky, but needed to get editor 106 | // to size properly after mount 107 | setTimeout(() => { 108 | editor.refresh(); 109 | }, 0); 110 | }} 111 | options={{ 112 | theme: "material-darker", 113 | mode: "jsx", 114 | lineNumbers: true, 115 | tabSize: 2, 116 | }} 117 | className="editor" 118 | detach 119 | value={editorVals.value} 120 | onChange={(_, __, val) => editorVals.setValue(val)} 121 | /> 122 | 123 | 124 | ); 125 | }); 126 | -------------------------------------------------------------------------------- /src/FontLoaderModal.tsx: -------------------------------------------------------------------------------- 1 | import React, { FC, useState, useRef, useEffect } from "react"; 2 | import Hue from "react-color/lib/components/hue/Hue"; 3 | import manager from "./ThemeManager"; 4 | import { 5 | Modal, 6 | ModalOverlay, 7 | ModalContent, 8 | ModalHeader, 9 | ModalCloseButton, 10 | ModalBody, 11 | ModalFooter, 12 | Button, 13 | Stack, 14 | Checkbox, 15 | Tag, 16 | TagLabel, 17 | TagCloseButton, 18 | Wrap, 19 | useClipboard, 20 | Input, 21 | } from "@chakra-ui/react"; 22 | import { observer } from "mobx-react-lite"; 23 | import * as fontService from "./fonts"; 24 | import { autorun } from "mobx"; 25 | import { SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG } from "constants"; 26 | 27 | autorun(() => { 28 | const selectedFonts = manager.getSelectedFonts(); 29 | if (selectedFonts.length) { 30 | fontService.load(manager.getSelectedFonts()); 31 | } 32 | }); 33 | 34 | const FontLoaderModal: FC = observer(({ isOpen, onClose, onSubmit }) => { 35 | const nameEl = useRef(null); 36 | const [fonts, setFonts] = useState([]); 37 | const [search, setSearch] = useState(""); 38 | 39 | useEffect(() => { 40 | fontService.list().then(setFonts); 41 | }, []); 42 | 43 | const selectedFonts = manager.getSelectedFonts(); 44 | 45 | const fontFamiliesStr = selectedFonts.reduce( 46 | (str: string, fontFamily: string, i: number) => { 47 | str += `'${fontFamily}'`; 48 | if (i < selectedFonts.length - 1) { 49 | str += ", "; 50 | } 51 | return str; 52 | }, 53 | "" 54 | ); 55 | 56 | const { hasCopied, onCopy } = useClipboard( 57 | JSON.stringify( 58 | { 59 | body: fontFamiliesStr, 60 | heading: fontFamiliesStr, 61 | mono: fontFamiliesStr, 62 | }, 63 | null, 64 | 2 65 | ) 66 | ); 67 | 68 | return ( 69 | 76 | 77 | 78 | Manage Loaded Fonts 79 | 80 | 81 | 82 | setSearch(e.target.value)} 86 | /> 87 | 88 | {selectedFonts.map((fontFamily) => ( 89 | 96 | {fontFamily} 97 | manager.unselectFont(fontFamily)} 99 | /> 100 | 101 | ))} 102 | 103 | 104 | {fonts 105 | .filter((font: any) => 106 | font.family.toLowerCase().includes(search.toLowerCase()) 107 | ) 108 | .slice(0, 250) 109 | .map((font: any) => ( 110 | { 113 | if (e.target.checked) { 114 | manager.selectFont(font.family); 115 | } else { 116 | manager.unselectFont(font.family); 117 | } 118 | }} 119 | > 120 | {font.family} 121 | 122 | ))} 123 | 124 | 125 | 126 | 127 | 130 | 133 | 134 | 135 | 136 | ); 137 | }); 138 | 139 | export default FontLoaderModal; 140 | -------------------------------------------------------------------------------- /src/MotionBox.tsx: -------------------------------------------------------------------------------- 1 | import { HTMLChakraProps, chakra } from "@chakra-ui/react"; 2 | import { motion, HTMLMotionProps } from "framer-motion"; 3 | 4 | type Merge = Omit & T; 5 | type MotionBoxProps = Merge, HTMLMotionProps<"div">>; 6 | const MotionBox: React.FC = motion(chakra.div); 7 | 8 | export default MotionBox; 9 | -------------------------------------------------------------------------------- /src/PaletteModal.tsx: -------------------------------------------------------------------------------- 1 | import React, { FC, useState } from "react"; 2 | import Hue from "react-color/lib/components/hue/Hue"; 3 | import { 4 | Modal, 5 | ModalOverlay, 6 | ModalContent, 7 | ModalHeader, 8 | ModalCloseButton, 9 | ModalBody, 10 | ModalFooter, 11 | Button, 12 | Box, 13 | Flex, 14 | Stack, 15 | Text, 16 | useClipboard, 17 | useColorModeValue, 18 | } from "@chakra-ui/react"; 19 | import * as chroma from "chroma-js"; 20 | import { ChromePicker } from "react-color"; 21 | import _ from "lodash"; 22 | 23 | const Color: FC = ({ color }) => { 24 | return ; 25 | }; 26 | 27 | const SATURATIONS = [0.32, 0.16, 0.08, 0.04, 0, 0, 0.04, 0.08, 0.16, 0.32]; 28 | const LIGHTNESSES = [ 29 | 0.95, 30 | 0.85, 31 | 0.75, 32 | 0.65, 33 | 0.55, 34 | 0.45, 35 | 0.35, 36 | 0.25, 37 | 0.15, 38 | 0.05, 39 | ]; 40 | 41 | const PaletteModal: FC = ({ isOpen, onClose }) => { 42 | const [hex, setHex] = useState("#A600FF"); 43 | 44 | const styles = useColorModeValue( 45 | { 46 | bg: "blackAlpha.100", 47 | }, 48 | { 49 | bg: "whiteAlpha.100", 50 | } 51 | ); 52 | 53 | const selectedColor = chroma.hex(hex); 54 | 55 | const targetLightness = _.minBy(LIGHTNESSES, (lightness) => 56 | Math.abs(lightness - selectedColor.get("hsl.l")) 57 | ) as number; 58 | 59 | const colorIndex = LIGHTNESSES.indexOf(targetLightness); 60 | 61 | const colors = LIGHTNESSES.map((lightness, i) => { 62 | const color = selectedColor.set("hsl.l", lightness); 63 | const delta = SATURATIONS[i] - SATURATIONS[colorIndex]; 64 | return delta >= 0 65 | ? color.saturate(delta).hex() 66 | : color.desaturate(-delta).hex(); 67 | }); 68 | 69 | const scale = colors.reduce((obj, color, index) => { 70 | if (index === 0) { 71 | obj[50] = color; 72 | } else { 73 | obj[index * 100] = color; 74 | } 75 | return obj; 76 | }, {} as any); 77 | 78 | const { hasCopied, onCopy } = useClipboard(JSON.stringify(scale, null, 2)); 79 | 80 | return ( 81 | 82 | 83 | 84 | Create a Color Scale 85 | 86 | 87 | 88 | e.preventDefault()} 90 | borderRadius="md" 91 | overflow="hidden" 92 | border="none" 93 | bg={styles.bg} 94 | > 95 | setHex(hex)} 99 | disableAlpha 100 | /> 101 | 102 | 103 | {Object.keys(scale).map((colorKey) => ( 104 | 105 | 106 | 107 | ))} 108 | 109 | 110 | 111 | 112 | 115 | 118 | 119 | 120 | 121 | ); 122 | }; 123 | 124 | export default PaletteModal; 125 | -------------------------------------------------------------------------------- /src/ThemeManager.ts: -------------------------------------------------------------------------------- 1 | import { computed, observable } from "mobx"; 2 | import { theme, extendTheme, ChakraTheme } from "@chakra-ui/react"; 3 | import { ComponentData } from "./types"; 4 | import { mapValues } from "lodash"; 5 | import evaluate from "./evaluate"; 6 | // @ts-ignore 7 | import { stringify } from "javascript-stringify"; 8 | 9 | const getDefaultRenderer = ( 10 | componentKey: string 11 | ) => `// Specify what to render for each size and variant 12 | ({ size, variant }) => { 13 | const sx = useStyleConfig('${componentKey}', { size, variant }) 14 | 15 | return ( 16 | 17 | Hello 18 | 19 | ) 20 | }`; 21 | const DEFAULT_COMPONENT_THEME = `// Specify theme overrides for this component 22 | { 23 | // style object for base or default style 24 | baseStyle: {}, 25 | // styles for different sizes ("sm", "md", "lg") 26 | sizes: {}, 27 | // styles for different visual variants ("outline", "solid") 28 | variants: {}, 29 | // override default props on this component 30 | defaultProps: { 31 | size: "md", 32 | colorScheme: "brand" 33 | }, 34 | }`; 35 | const DEFAULT_GLOBAL_THEME = `// Specify global theme overrides 36 | { 37 | colors: { 38 | brand: { 39 | 50: '#f5e3ff', 40 | 100: '#d8b2ff', 41 | 200: '#bd80ff', 42 | 300: '#a34dff', 43 | 400: '#881bfe', 44 | 500: '#6f02e5', 45 | 600: '#5600b3', 46 | 700: '#3e0081', 47 | 800: '#25004f', 48 | 900: '#0e001f', 49 | }, 50 | gray: { 51 | 50: "#f1f3fb", 52 | 100: "#d3d5dc", 53 | 200: "#b6b8be", 54 | 300: "#9a9ba1", 55 | 400: "#7f8084", 56 | 500: "#656669", 57 | 600: "#4c4c4f", 58 | 700: "#343536", 59 | 800: "#1e1e1f", 60 | 900: "#030304" 61 | } 62 | }, 63 | fonts: { 64 | body: "Inconsolata, sans-serif", 65 | heading: "Inconsolata, serif", 66 | mono: "Inconsolata, monospace", 67 | }, 68 | styles: { 69 | global: ({ colorMode }) => ({ 70 | body: { 71 | bg: colorMode === "dark" ? "gray.800" : "gray.50" 72 | }, 73 | _focusVisible: { 74 | boxShadow: "0 0 0 3px #d8b2ff !important" 75 | } 76 | }), 77 | }, 78 | fontSizes: {}, 79 | fontWeights: {}, 80 | lineHeights: {}, 81 | letterSpacings: {}, 82 | }`; 83 | 84 | const DEFAULT_COMPONENTS: Record = { 85 | Alert: { 86 | render: `({ size, variant }) => ( 87 | 88 | 89 | Hello! 90 | Just saying hi. 91 | 92 | )`, 93 | overrides: DEFAULT_COMPONENT_THEME, 94 | key: "Alert", 95 | name: "Alerts", 96 | }, 97 | Badge: { 98 | render: `({ size, variant }) => ( 99 | 103 | Hello 104 | 105 | )`, 106 | overrides: DEFAULT_COMPONENT_THEME, 107 | key: "Badge", 108 | name: "Badges", 109 | }, 110 | Button: { 111 | render: `({ size, variant }) => ( 112 | 118 | )`, 119 | overrides: DEFAULT_COMPONENT_THEME, 120 | key: "Button", 121 | name: "Buttons", 122 | }, 123 | Checkbox: { 124 | render: `({ size, variant }) => ( 125 | 129 | )`, 130 | overrides: DEFAULT_COMPONENT_THEME, 131 | key: "Checkbox", 132 | name: "Checkboxes", 133 | }, 134 | Heading: { 135 | render: `({ size, variant }) => ( 136 | 140 | Hello 141 | 142 | )`, 143 | overrides: DEFAULT_COMPONENT_THEME, 144 | key: "Heading", 145 | name: "Headings", 146 | }, 147 | Input: { 148 | render: `({ size, variant }) => ( 149 | 154 | )`, 155 | overrides: DEFAULT_COMPONENT_THEME, 156 | key: "Input", 157 | name: "Inputs", 158 | }, 159 | Spinner: { 160 | render: `({ size, variant }) => ( 161 | 167 | )`, 168 | overrides: `// Specify theme overrides for this component 169 | { 170 | // style object for base or default style 171 | baseStyle: { 172 | color: "brand.300" 173 | }, 174 | // styles for different sizes ("sm", "md", "lg") 175 | sizes: {}, 176 | // styles for different visual variants ("outline", "solid") 177 | variants: {}, 178 | // override default props on this component 179 | defaultProps: { 180 | size: "md", 181 | }, 182 | }`, 183 | key: "Spinner", 184 | name: "Spinners", 185 | }, 186 | Tabs: { 187 | render: `({ size, variant }) => ( 188 | 189 | 190 | One 191 | Two 192 | Three 193 | 194 | 195 | )`, 196 | overrides: DEFAULT_COMPONENT_THEME, 197 | key: "Tabs", 198 | name: "Tabs", 199 | }, 200 | Tag: { 201 | render: `({ size, variant }) => ( 202 | 206 | Hello 207 | 208 | )`, 209 | overrides: DEFAULT_COMPONENT_THEME, 210 | key: "Tag", 211 | name: "Tags", 212 | }, 213 | }; 214 | 215 | class ThemeManager { 216 | global = observable({ 217 | overrides: DEFAULT_GLOBAL_THEME, 218 | }); 219 | components = observable>(DEFAULT_COMPONENTS); 220 | selected = observable({ 221 | componentKey: null, 222 | }); 223 | fonts = observable(["Inconsolata"]); 224 | 225 | constructor({ global, components, fonts }: any = {}) { 226 | if (global) { 227 | this.global = observable(global); 228 | } 229 | if (components) { 230 | this.components = observable(components); 231 | } 232 | if (fonts) { 233 | this.fonts = observable(fonts); 234 | } 235 | } 236 | 237 | @computed 238 | get data() { 239 | return { 240 | global: this.global, 241 | components: this.components, 242 | fonts: this.fonts, 243 | }; 244 | } 245 | 246 | addComponent = ({ 247 | key, 248 | name, 249 | render = getDefaultRenderer(key), 250 | overrides = DEFAULT_COMPONENT_THEME, 251 | }: ComponentData) => { 252 | this.components[key] = { 253 | key, 254 | name, 255 | render, 256 | overrides, 257 | }; 258 | }; 259 | 260 | removeComponent(componentKey: string) { 261 | delete this.components[componentKey]; 262 | } 263 | 264 | get componentKeys() { 265 | return Object.keys(this.components); 266 | } 267 | 268 | setRawComponentOverrides(componentKey: string, overrides: string) { 269 | this.components[componentKey].overrides = overrides; 270 | } 271 | getRawComponentOverrides(componentKey: string): string { 272 | return this.components[componentKey].overrides; 273 | } 274 | getComponentOverrides(componentKey: string): any { 275 | const val = evaluate(this.components[componentKey].overrides); 276 | return val; 277 | } 278 | 279 | getGlobalOverrides() { 280 | return evaluate(this.global.overrides) || {}; 281 | } 282 | getRawGlobalOverrides() { 283 | return this.global.overrides; 284 | } 285 | setRawGlobalOverrides(overrides: string) { 286 | this.global.overrides = overrides; 287 | } 288 | 289 | @computed 290 | get theme(): ChakraTheme { 291 | const components = mapValues(this.components, (data) => 292 | this.getComponentOverrides(data.key) 293 | ); 294 | return extendTheme( 295 | { 296 | ...this.getGlobalOverrides(), 297 | components, 298 | }, 299 | theme 300 | ); 301 | } 302 | 303 | @computed 304 | get themeStr(): string { 305 | const components = mapValues(this.components, (data) => 306 | this.getComponentOverrides(data.key) 307 | ); 308 | const obj = { 309 | ...this.getGlobalOverrides(), 310 | components, 311 | }; 312 | let result = ""; 313 | try { 314 | result = "export const theme = " + stringify(obj, null, 2) || ""; 315 | } catch (err) { 316 | console.error("Unable to export theme file", err); 317 | } 318 | return result; 319 | } 320 | 321 | setRawComponentRenderer(componentKey: string, renderer: string) { 322 | this.components[componentKey].render = renderer; 323 | } 324 | 325 | getRawComponentRenderer(componentKey: string) { 326 | return this.components[componentKey]?.render || ""; 327 | } 328 | 329 | getComponentRenderer(componentKey: string) { 330 | return evaluate(this.components[componentKey].render); 331 | } 332 | 333 | setSelected(componentKey: string | null) { 334 | this.selected.componentKey = componentKey; 335 | } 336 | 337 | getSelected() { 338 | return this.selected.componentKey; 339 | } 340 | 341 | selectFont(font: string) { 342 | this.fonts.push(font); 343 | } 344 | 345 | unselectFont(font: string) { 346 | this.fonts.splice(this.fonts.indexOf(font), 1); 347 | } 348 | 349 | getSelectedFonts() { 350 | return this.fonts; 351 | } 352 | } 353 | 354 | const data = localStorage.getItem("data"); 355 | 356 | export default new ThemeManager(data ? JSON.parse(data) : {}); 357 | -------------------------------------------------------------------------------- /src/evaluate.ts: -------------------------------------------------------------------------------- 1 | import * as Chakra from "@chakra-ui/react"; 2 | import * as Babel from "@babel/standalone"; 3 | import * as React from "react"; 4 | // @ts-ignore 5 | import safeEval from "safer-eval/lib/browser"; 6 | 7 | const evaluate = (code: string) => { 8 | "use strict"; 9 | code = `(${code})`; 10 | try { 11 | let transpiled = Babel.transform(code, { 12 | presets: ["env", "react"], 13 | sourceType: "script", 14 | }).code; 15 | const result = transpiled 16 | ? safeEval(transpiled, { ...Chakra, Chakra, React, window }) 17 | : null; 18 | return result; 19 | } catch (err) { 20 | console.log(err); 21 | return null; 22 | } 23 | }; 24 | 25 | export default evaluate; 26 | -------------------------------------------------------------------------------- /src/fonts.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import * as WebFont from "webfontloader"; 3 | 4 | const API_KEY = "AIzaSyDNOXY-FJ0rMylNSR0W1HtssQXQzZx3cfE"; 5 | 6 | export const list = async () => { 7 | const res = await axios.get( 8 | `https://www.googleapis.com/webfonts/v1/webfonts?key=${API_KEY}&sort=popularity` 9 | ); 10 | return res.data.items; 11 | }; 12 | 13 | export const load = async (families: string[]) => { 14 | WebFont.load({ 15 | google: { 16 | families, 17 | }, 18 | }); 19 | }; 20 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | html { 2 | height: -webkit-fill-available; 3 | } 4 | 5 | body { 6 | margin: 0; 7 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 8 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 9 | sans-serif; 10 | -webkit-font-smoothing: antialiased; 11 | -moz-osx-font-smoothing: grayscale; 12 | height: 100vh; 13 | height: -webkit-fill-available; 14 | overflow: hidden; 15 | } 16 | 17 | code { 18 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 19 | monospace; 20 | } 21 | 22 | #root { 23 | height: 100%; 24 | overflow: auto; 25 | } 26 | 27 | .editor { 28 | height: 100%; 29 | } 30 | 31 | .colorpicker { 32 | width: 100% !important; 33 | box-shadow: none !important; 34 | background: transparent !important; 35 | } 36 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { FC, useEffect } from "react"; 2 | import ReactDOM from "react-dom"; 3 | import "./index.css"; 4 | import App from "./App"; 5 | import { 6 | ChakraProvider, 7 | ColorModeScript, 8 | useToast, 9 | Box, 10 | Code, 11 | Button, 12 | } from "@chakra-ui/react"; 13 | import reportWebVitals from "./reportWebVitals"; 14 | import "focus-visible/dist/focus-visible"; 15 | import manager from "./ThemeManager"; 16 | import { observer } from "mobx-react-lite"; 17 | import { ErrorBoundary } from "react-error-boundary"; 18 | 19 | const ErrorToast: FC = ({ error, resetErrorBoundary }) => { 20 | const toast = useToast(); 21 | 22 | useEffect(() => { 23 | // alert("maybe"); 24 | // toast({ 25 | // description: 26 | // "Oops, it looks like there's an error in your theme. Now using a fallback theme. Please fix the code and refresh.", 27 | // status: "error", 28 | // }); 29 | const toastId = toast({ 30 | duration: 100000, 31 | isClosable: false, 32 | render: () => ( 33 | 34 | Oops, encountered an error in your theme:{" "} 35 | {error.message}. Using a 36 | fallback theme instead. Please fix and{" "} 37 | 44 | 45 | ), 46 | }); 47 | 48 | return () => { 49 | if (toastId) toast.close(toastId); 50 | }; 51 | }, []); 52 | 53 | return null; 54 | }; 55 | 56 | const ErrorFallback: FC = ({ error, resetErrorBoundary }) => { 57 | return ( 58 | 59 | 60 | 61 | 62 | ); 63 | }; 64 | 65 | const ThemedApp = observer(() => { 66 | const theme = manager.theme; 67 | return ( 68 | 69 | 70 | 71 | 72 | 73 | ); 74 | }); 75 | 76 | ReactDOM.render( 77 | 78 | 79 | 80 | , 81 | document.getElementById("root") 82 | ); 83 | 84 | // If you want to start measuring performance in your app, pass a function 85 | // to log results (for example: reportWebVitals(console.log)) 86 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 87 | reportWebVitals(); 88 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | export interface ComponentData { 2 | render: string; 3 | overrides: string; 4 | name: string; 5 | key: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/useTheme.tsx: -------------------------------------------------------------------------------- 1 | import React, { createContext, useState, useContext, FC } from "react"; 2 | import { 3 | theme as DEFAULT_THEME, 4 | extendTheme as chakraExtendTheme, 5 | ChakraProvider, 6 | ChakraTheme, 7 | } from "@chakra-ui/react"; 8 | 9 | const ThemeContext = createContext(null); 10 | 11 | export const ThemeProvider: FC = ({ children }) => { 12 | const [theme, setTheme] = useState(DEFAULT_THEME); 13 | 14 | const extendTheme = (overrides: any) => { 15 | setTheme(chakraExtendTheme(overrides, theme)); 16 | }; 17 | 18 | return ( 19 | 20 | 21 | {children} 22 | 23 | 24 | ); 25 | }; 26 | 27 | export const useTheme = () => { 28 | return useContext(ThemeContext); 29 | }; 30 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "esModuleInterop": true, 8 | "allowSyntheticDefaultImports": true, 9 | "strict": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "noFallthroughCasesInSwitch": true, 12 | "module": "esnext", 13 | "moduleResolution": "node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react", 18 | "experimentalDecorators": true 19 | }, 20 | "include": ["src"] 21 | } 22 | --------------------------------------------------------------------------------