From db8b2b683090053c810625f5f10115089feb3678 Mon Sep 17 00:00:00 2001 From: Marco van Dijk Date: Sat, 23 Apr 2022 22:57:21 +0200 Subject: [PATCH] orch description now becomes a popup if it is too big to fit --- src/components/OrchInfoViewer.js | 44 ++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/src/components/OrchInfoViewer.js b/src/components/OrchInfoViewer.js index 507b6d5..a67536f 100644 --- a/src/components/OrchInfoViewer.js +++ b/src/components/OrchInfoViewer.js @@ -1,9 +1,10 @@ -import React from "react"; +import React, { useState, useEffect } from 'react'; import Stat from "./statViewer"; import Address from "./OrchAddressViewer"; import { useSelector } from 'react-redux'; import { Text } from "@mantine/core"; import ScrollContainer from "react-indiana-drag-scroll"; +import { Popover } from '@mantine/core'; function updateClipboard(newClip) { navigator.clipboard.writeText(newClip).then( @@ -27,6 +28,7 @@ function copyLink(addr) { } const OrchInfoViewer = (obj) => { + const [opened, setOpened] = useState(false); const livepeer = useSelector((state) => state.livepeerstate); let hasENS = false; let hasThreeBox = false; @@ -130,7 +132,7 @@ const OrchInfoViewer = (obj) => { } } else if (hasThreeBox) { if (thisInfo.description) { - ensDescription = thisInfo.description + ensDescription = thisInfo.description; } if (thisInfo.website) { if (!thisInfo.website.startsWith('http')) { @@ -147,6 +149,34 @@ const OrchInfoViewer = (obj) => { } } + let descriptionObj; + if (ensDescription) { + if (ensDescription.length < 200) { + descriptionObj = +

+ {ensDescription} +

+ } else { + descriptionObj = + setOpened(false)} + target={ +

setOpened((o) => !o)}> + {ensDescription.substring(0, 200)}... +

+ } + width={260} + position="right" + withArrow + > +

+ {ensDescription} +

+
+ } + } + return (
@@ -157,15 +187,7 @@ const OrchInfoViewer = (obj) => {
{ensUrl}
-
- -
-

- {ensDescription} -

-
-
-
+ {descriptionObj}