diff --git a/api/prettier.config.js b/api/prettier.config.js new file mode 100644 index 000000000..406484074 --- /dev/null +++ b/api/prettier.config.js @@ -0,0 +1,8 @@ +module.exports = { + trailingComma: 'es5', + tabWidth: 2, + semi: true, + singleQuote: true, + arrowParen: 'avoid', + printWidth: 120, +}; diff --git a/web/prettier.config.js b/web/prettier.config.js new file mode 100644 index 000000000..406484074 --- /dev/null +++ b/web/prettier.config.js @@ -0,0 +1,8 @@ +module.exports = { + trailingComma: 'es5', + tabWidth: 2, + semi: true, + singleQuote: true, + arrowParen: 'avoid', + printWidth: 120, +}; diff --git a/web/src/App.js b/web/src/App.js index ddbb5b5a4..011d60963 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -1,13 +1,17 @@ import React from "react"; import useFetch from "./useFetch"; import "./index.css"; -import Screen from './Screen' - +import Screen from "./Screen"; +import {CurrentWidgetProvider} from "./widgets/useCurrentWidget"; function App() { const resp = useFetch("http://localhost:3000", {}); console.log("FETCH data", resp.data); - return ; + return ( + + + + ); } export default App; diff --git a/web/src/Screen.js b/web/src/Screen.js index b242d322a..3c20f7020 100644 --- a/web/src/Screen.js +++ b/web/src/Screen.js @@ -2,7 +2,7 @@ import React from "react"; import theme from "./theme"; import styled from "styled-components"; import FilesTabsPanel from "./FilesTabsPanel"; -import SideIconPanel from "./SideIconPanel"; +import WidgetIconPanel from "./widgets/WidgetIconPanel"; const BodyDiv = styled.div` position: fixed; @@ -54,7 +54,7 @@ export default function Screen({ children }) { return ( <> - + diff --git a/web/src/SideIconPanel.js b/web/src/SideIconPanel.js deleted file mode 100644 index db7d96f92..000000000 --- a/web/src/SideIconPanel.js +++ /dev/null @@ -1,47 +0,0 @@ -import React from "react"; -import theme from "./theme"; -import styled from "styled-components"; -import { FontIcon } from "./icons"; - -const IconWrapper = styled.div` - color: ${theme.widgetMenu.iconFontColor}; - font-size: ${theme.widgetMenu.iconFontSize}; - height: ${theme.widgetMenu.iconSize}px; - display: flex; - align-items: center; - justify-content: center; - &:hover { - background-color: ${theme.widgetMenu.backgroundHover}; - } - background-color: ${props => - props.isSelected ? theme.widgetMenu.backgroundSelected : "inherit"}; -`; - -export default function SideIconPanel() { - const widgets = [ - { - icon: "fa-database" - }, - { - icon: "fa-table", - isSelected: true - }, - { - icon: "fa-file-alt" - }, - { - icon: "fa-cog" - }, - { - icon: "fa-check" - } - ]; - - return widgets.map(({ icon, isSelected }) => ( - -
- -
-
- )); -} diff --git a/web/src/widgets/WidgetIconPanel.js b/web/src/widgets/WidgetIconPanel.js new file mode 100644 index 000000000..8cf3f06e9 --- /dev/null +++ b/web/src/widgets/WidgetIconPanel.js @@ -0,0 +1,52 @@ +import React from 'react'; +import theme from '../theme'; +import styled from 'styled-components'; +import { FontIcon } from '../icons'; +import useCurrentWidget, { useSetCurrentWidget } from './useCurrentWidget'; + +const IconWrapper = styled.div` + color: ${theme.widgetMenu.iconFontColor}; + font-size: ${theme.widgetMenu.iconFontSize}; + height: ${theme.widgetMenu.iconSize}px; + display: flex; + align-items: center; + justify-content: center; + background-color: ${props => (props.isSelected ? theme.widgetMenu.backgroundSelected : 'inherit')}; + &:hover { + background-color: ${theme.widgetMenu.backgroundHover}; + } +`; + +export default function WidgetIconPanel() { + const widgets = [ + { + icon: 'fa-database', + name: 'database', + }, + { + icon: 'fa-table', + name: 'table', + }, + { + icon: 'fa-file-alt', + name: 'file', + }, + { + icon: 'fa-cog', + name: 'settings', + }, + // { + // icon: 'fa-check', + // name: 'settings', + // }, + ]; + + const currentWidget = useCurrentWidget(); + const setCurrentWidget = useSetCurrentWidget(); + + return widgets.map(({ icon, name }) => ( + setCurrentWidget(name)}> + + + )); +} diff --git a/web/src/widgets/useCurrentWidget.js b/web/src/widgets/useCurrentWidget.js new file mode 100644 index 000000000..e5228af06 --- /dev/null +++ b/web/src/widgets/useCurrentWidget.js @@ -0,0 +1,20 @@ +import React from "react"; + +const CurrentWidgetProviderContext = React.createContext(); + +export function CurrentWidgetProvider({ children }) { + const [currentWidget, setCurrentWidget] = React.useState('database'); + return ( + + {children} + + ); +} + +export default function useCurrentWidget() { + return React.useContext(CurrentWidgetProviderContext)[0]; +} + +export function useSetCurrentWidget() { + return React.useContext(CurrentWidgetProviderContext)[1]; +}