From b194fc1c9d7623b03dd4022c997569c6235acb3e Mon Sep 17 00:00:00 2001 From: Martin Bruun Michaelsen Date: Wed, 26 Apr 2023 22:51:50 +0200 Subject: [PATCH 1/5] Small changes --- .env | 1 + src/WholeApp.js | 10 ++-- src/components/menu/Share.js | 31 ++---------- src/components/menu/ShareLink.js | 68 ++++++++++---------------- src/components/menu/TopMenu.js | 2 +- src/styles/02_components/Overlay.scss | 2 +- src/styles/03_layout/svg/notation.scss | 2 +- 7 files changed, 36 insertions(+), 80 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..4f79a0f --- /dev/null +++ b/.env @@ -0,0 +1 @@ +GENERATE_SOURCEMAP=false \ No newline at end of file diff --git a/src/WholeApp.js b/src/WholeApp.js index e5328d8..02ced05 100644 --- a/src/WholeApp.js +++ b/src/WholeApp.js @@ -264,7 +264,7 @@ class WholeApp extends Component { // //this.setState({ [selectedElement]: selectedValue }); // } - saveSessionToDB = () => { + saveSessionToDB = async () => { // console.log("saveSessionToDB"); const { octave, @@ -283,7 +283,8 @@ class WholeApp extends Component { videoActive, activeVideoTab, } = this.state; - db.collection("sessions") + console.log("START SAVE"); + return await db.collection("sessions") .add({ octave: octave, scale: scale, @@ -301,10 +302,7 @@ class WholeApp extends Component { videoActive: videoActive, activeVideoTab: activeVideoTab, }) - .then((docRef) => { - // console.log("Session written with ID: ", docRef.id); - this.setState({ sessionID: docRef.id }); - }) + .then((docRef) => docRef.id) .catch((error) => { console.error("Error adding document: ", error); this.setState({ sessionError: error }); diff --git a/src/components/menu/Share.js b/src/components/menu/Share.js index 5485206..3397651 100644 --- a/src/components/menu/Share.js +++ b/src/components/menu/Share.js @@ -1,42 +1,17 @@ -import React, { useEffect, useState } from "react"; +import React from "react"; import ShareLink from "./ShareLink"; import Overlay from "./../OverlayPlugins/Overlay"; import { Tabs, Tab } from "react-bootstrap"; const Share = (props) => { - // const [activeTab, setActiveTab] = useState("playlist"); - // const activeTab = "share"; - const [sessionId, setSessionId] = useState(props.sessionID); - - useEffect(() => { - if (sessionId !== props.sessionID) { - setSessionId(props.sessionID); - } - }, [props.sessionID, sessionId]); - - // handleSelectTab = (key) => { - // // A bit dummy but need to control tabs after submit (cf handleSumbit()) - // if (key === "share") this.setState({ activeTab: "share" }); - // }; - - // console.log("Share"); - // console.log(sessionId); - // const { url, playing } = this.state; return (
- {/* */} - +
- -
-
- - -
- +
diff --git a/src/components/menu/ShareLink.js b/src/components/menu/ShareLink.js index b49bde3..6d82451 100644 --- a/src/components/menu/ShareLink.js +++ b/src/components/menu/ShareLink.js @@ -1,51 +1,33 @@ import React, { useState } from "react"; const ShareLink = (props) => { - const [hasCopied, setHasCopied] = useState(false); + const [url, setUrl] = useState(""); - if (props.sessionID) { - const url = "/shared/" + props.sessionID; - const fullUrl = window.location.host + url; + const copyToClipBoard = (fullUrl) => { + console.log("COPY"); + navigator.clipboard.writeText(fullUrl); + }; - const copyToClipBoard = () => { - navigator.clipboard.writeText(fullUrl); - }; - - return ( -
-

Share

-

Share your stored setup:

- - {fullUrl} + return ( + - ); - } else if (props.saveSessionToDB) { - return ( -
-

Share

-

Share your current setup:

- - The link has been copied - will store online and create a new link for sharing -
- ); - } else { - return ( -
-

Share

-

Create a Share link on the create links tab

-
- ); - } +
+ ) }; - + export default ShareLink; diff --git a/src/components/menu/TopMenu.js b/src/components/menu/TopMenu.js index c59e912..2625161 100644 --- a/src/components/menu/TopMenu.js +++ b/src/components/menu/TopMenu.js @@ -26,7 +26,7 @@ import NotationImg from "../../assets/img/Notation"; import clefs from "../../data/clefs"; import tooltipText from "../../data/tooltipText"; -import SoundFontLibraryNames from "data/SoundFontLibraryNames"; +//import SoundFontLibraryNames from "data/SoundFontLibraryNames"; // import CustomScaleSelector from "./CustomScaleSelector"; class TopMenu extends Component { diff --git a/src/styles/02_components/Overlay.scss b/src/styles/02_components/Overlay.scss index 076e1bd..6517e1d 100644 --- a/src/styles/02_components/Overlay.scss +++ b/src/styles/02_components/Overlay.scss @@ -14,7 +14,7 @@ // display: flex; overflow: hidden; // flex: 1 1; - background-color: rgb(0, 0, 0); + background-color: rgb(31, 28, 28); position: absolute; transform: scale(96%, 96%); padding: 5px; diff --git a/src/styles/03_layout/svg/notation.scss b/src/styles/03_layout/svg/notation.scss index 325d805..a7f558f 100644 --- a/src/styles/03_layout/svg/notation.scss +++ b/src/styles/03_layout/svg/notation.scss @@ -1,6 +1,6 @@ .notationSVG { // background-color: yellow; - max-height: 3vh; + max-height: 4.5vh; min-height: 2vh; min-width: 90%; width: 5vw; From 7363b70dcda3da185669feed21a9885e1f2c0e46 Mon Sep 17 00:00:00 2001 From: Martin Bruun Michaelsen Date: Wed, 26 Apr 2023 23:14:00 +0200 Subject: [PATCH 2/5] Remove console.logs --- src/WholeApp.js | 1 - src/components/menu/ShareLink.js | 4 ---- 2 files changed, 5 deletions(-) diff --git a/src/WholeApp.js b/src/WholeApp.js index 02ced05..0c86c9a 100644 --- a/src/WholeApp.js +++ b/src/WholeApp.js @@ -283,7 +283,6 @@ class WholeApp extends Component { videoActive, activeVideoTab, } = this.state; - console.log("START SAVE"); return await db.collection("sessions") .add({ octave: octave, diff --git a/src/components/menu/ShareLink.js b/src/components/menu/ShareLink.js index 6d82451..b456cdc 100644 --- a/src/components/menu/ShareLink.js +++ b/src/components/menu/ShareLink.js @@ -4,7 +4,6 @@ const ShareLink = (props) => { const [url, setUrl] = useState(""); const copyToClipBoard = (fullUrl) => { - console.log("COPY"); navigator.clipboard.writeText(fullUrl); }; @@ -13,10 +12,7 @@ const ShareLink = (props) => {

Share

Share your current setup:

+ if(url === ""){ + let dbId = await props.saveSessionToDB(); + let url = "/shared/" + dbId; + setUrl(url); + setFullUrl(window.location.host + url); + } + copyToClipBoard(fullUrl);}}>Create Share Link Store your current setup and share it with a link. The link is copied to your clipboard and can be sent to others to open the same setup - { window.location.host + url} + { fullUrl }
) From 2d9c3ce3403df143e379467fa193af716884deda Mon Sep 17 00:00:00 2001 From: saxjax Date: Thu, 27 Apr 2023 00:19:42 +0200 Subject: [PATCH 4/5] simplified html --- src/components/menu/ShareLink.js | 44 +++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/components/menu/ShareLink.js b/src/components/menu/ShareLink.js index ca89e87..c0a7cd6 100644 --- a/src/components/menu/ShareLink.js +++ b/src/components/menu/ShareLink.js @@ -12,21 +12,35 @@ const ShareLink = (props) => {

Share

Share your current setup:

- - Store your current setup and share it with a link. - The link is copied to your clipboard and can be sent to others to open the same setup - - { fullUrl } - + + {fullUrl} + +

+ + + Store your current setup and share it with a link. + + + The link is copied to your clipboard and can be sent to others to open the same setup +
- ) + ); }; - + export default ShareLink; From 0be790619f1995a785021e27773d61c8f910303c Mon Sep 17 00:00:00 2001 From: saxjax Date: Thu, 27 Apr 2023 00:32:54 +0200 Subject: [PATCH 5/5] simplified html --- src/components/menu/ShareLink.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/menu/ShareLink.js b/src/components/menu/ShareLink.js index c0a7cd6..3302a84 100644 --- a/src/components/menu/ShareLink.js +++ b/src/components/menu/ShareLink.js @@ -33,11 +33,11 @@ const ShareLink = (props) => { }}> {url ? "Copy to clipboard" : "Create Share Link"} - - Store your current setup and share it with a link. - - - The link is copied to your clipboard and can be sent to others to open the same setup +

+ + {url + ? "The link is copied to your clipboard and can be sent to others to open the same setup" + : "Store your current setup and share it with a link."} );