From 7c3513b9df8005a0a8edd4ed72da3a48b9e167bc Mon Sep 17 00:00:00 2001 From: Benja Kugler Date: Sat, 2 Jan 2021 13:13:48 -0300 Subject: [PATCH] feat: browse libraries styles fixed (#2694) * feat: browse libraries styles fixed * simplify jsx & css * remove justify-content * fix padding/margin * Update src/components/LayerUI.scss Co-authored-by: benjamin.kugler Co-authored-by: dwelle --- src/components/LayerUI.scss | 22 +++++++--- src/components/LayerUI.tsx | 80 +++++++++++++++++-------------------- 2 files changed, 53 insertions(+), 49 deletions(-) diff --git a/src/components/LayerUI.scss b/src/components/LayerUI.scss index e4aa9029..494d3ba2 100644 --- a/src/components/LayerUI.scss +++ b/src/components/LayerUI.scss @@ -7,11 +7,23 @@ align-items: center; justify-content: center; - .browse-libraries { - position: absolute; - right: 12px; - top: 16px; - white-space: nowrap; + .layer-ui__library-header { + display: flex; + align-items: center; + width: 100%; + margin: 2px 0; + + button { + // 2px from the left to account for focus border of left-most button + margin: 0 2px; + } + + a { + margin-left: auto; + // 17px for scrollbar (needed for overlay scrollbars on Big Sur?) + 1px extra + padding-right: 18px; + white-space: nowrap; + } } } diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx index ec3b17e9..5a806e82 100644 --- a/src/components/LayerUI.tsx +++ b/src/components/LayerUI.tsx @@ -124,9 +124,42 @@ const LibraryMenuItems = ({ let addedPendingElements = false; rows.push( - <> +
+ { + importLibraryFromJSON() + .then(() => { + // Maybe we should close and open the menu so that the items get updated. + // But for now we just close the menu. + setAppState({ isLibraryOpen: false }); + }) + .catch(muteFSAbortError) + .catch((error) => { + setAppState({ errorMessage: error.message }); + }); + }} + /> + { + saveLibraryAsJSON() + .catch(muteFSAbortError) + .catch((error) => { + setAppState({ errorMessage: error.message }); + }); + }} + /> + { @@ -135,48 +168,7 @@ const LibraryMenuItems = ({ > {t("labels.libraries")} - - - { - importLibraryFromJSON() - .then(() => { - // Maybe we should close and open the menu so that the items get updated. - // But for now we just close the menu. - setAppState({ isLibraryOpen: false }); - }) - .catch(muteFSAbortError) - .catch((error) => { - setAppState({ errorMessage: error.message }); - }); - }} - /> - { - saveLibraryAsJSON() - .catch(muteFSAbortError) - .catch((error) => { - setAppState({ errorMessage: error.message }); - }); - }} - /> - - , +
, ); for (let row = 0; row < numRows; row++) {