From 7736ab55336c710d99708806596a870292bcba8b Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Fri, 9 Sep 2022 18:46:36 +0200 Subject: [PATCH] Prima release --- .gitignore | 3 + package.json | 1 + pnpm-lock.yaml | 6 + public/logo-circuit-board.svg | 87 +++++++++++++ src/components/ComboBox.jsx | 25 ++-- src/components/CompoundButton.jsx | 16 +++ src/components/HamburgerMenu.jsx | 27 +++- src/components/Icon.jsx | 6 +- src/components/Popup.jsx | 17 +++ src/components/Toolbar.jsx | 99 ++++++--------- src/main.jsx | 195 +++++++++++++++++++++------- src/styles/main.scss | 202 +++++++++++++++++++++++++++--- src/utils.jsx | 7 ++ vite.config.js | 21 +++- 14 files changed, 568 insertions(+), 144 deletions(-) create mode 100644 public/logo-circuit-board.svg create mode 100644 src/components/CompoundButton.jsx create mode 100644 src/components/Popup.jsx create mode 100644 src/utils.jsx diff --git a/.gitignore b/.gitignore index 93a61dc..c82b61e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ dist/ node_modules/ *.local* + +.env +.env.production diff --git a/package.json b/package.json index f90d9f9..fb5bcca 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "dependencies": { "date-fns": "^2.29.2", "lodash": "^4.17.21", + "lodash-es": "^4.17.21", "preact": "^10.10.6", "sass": "^1.54.8", "vite": "^3.0.9" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 31fd7e1..a0c038f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,7 @@ specifiers: '@preact/preset-vite': ^2.3.0 date-fns: ^2.29.2 lodash: ^4.17.21 + lodash-es: ^4.17.21 preact: ^10.10.6 sass: ^1.54.8 vite: ^3.0.9 @@ -12,6 +13,7 @@ specifiers: dependencies: date-fns: 2.29.2 lodash: 4.17.21 + lodash-es: 4.17.21 preact: 10.10.6 sass: 1.54.8 vite: 3.0.9_sass@1.54.8 @@ -777,6 +779,10 @@ packages: resolution: {integrity: sha512-lxpCM3HTvquGxKGzHeknB/sUjuVoUElLlfYnXZT73K8geR9jQbroGlSCFBax9/0mpGoD3kzcMLnOlGQPJJNyqQ==} dev: true + /lodash-es/4.17.21: + resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} + dev: false + /lodash/4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} dev: false diff --git a/public/logo-circuit-board.svg b/public/logo-circuit-board.svg new file mode 100644 index 0000000..1e65c1c --- /dev/null +++ b/public/logo-circuit-board.svg @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/ComboBox.jsx b/src/components/ComboBox.jsx index e7edfaa..7abf13d 100644 --- a/src/components/ComboBox.jsx +++ b/src/components/ComboBox.jsx @@ -1,19 +1,28 @@ -import { useRef } from 'preact/hooks' +import { useRef, useState } from 'preact/hooks' import { Icon } from './Icon.jsx' -export const ComboBox = ({ selected, options }) => { +let ids = 0 + +function generateId() { + return 'combo-id-' + ids++ +} + +export const ComboBox = ({ options, value, setValue }) => { + const [uid] = useState(() => generateId()) const selectRef = useRef() return ( -
selectRef.current?.click()}> - setValue(e.target.value)}> + {options.map(option => ( + ))} - +
) } diff --git a/src/components/CompoundButton.jsx b/src/components/CompoundButton.jsx new file mode 100644 index 0000000..11612ea --- /dev/null +++ b/src/components/CompoundButton.jsx @@ -0,0 +1,16 @@ +import { withClasses } from '../utils.jsx' + +export const CompoundButton = ({ options, value, setValue }) => { + return ( +
+ {options.map(option => ( + + ))} +
+ ) +} diff --git a/src/components/HamburgerMenu.jsx b/src/components/HamburgerMenu.jsx index 2a083d3..beaa598 100644 --- a/src/components/HamburgerMenu.jsx +++ b/src/components/HamburgerMenu.jsx @@ -1,7 +1,7 @@ import { ComboBox } from './ComboBox.jsx' import { Icon } from './Icon.jsx' -export const HamburgerMenu = ({ onClose }) => { +export const HamburgerMenu = ({ onClose, mode, setMode, source, setSource }) => { return (