Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making cards clickable in Ranking replies page (#1386)
* Make sortable clickable * remove forgotten bg * Make cypress test click on the left of a card * resolve conflicts * show 3 dots instead of 4 when shortened text ends with . * Remove unneeded check
- Loading branch information
Showing
3 changed files
with
70 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,10 @@ | ||
import { | ||
Button, | ||
Modal, | ||
ModalBody, | ||
ModalCloseButton, | ||
ModalContent, | ||
ModalHeader, | ||
ModalOverlay, | ||
Tooltip, | ||
useColorModeValue, | ||
useDisclosure, | ||
} from "@chakra-ui/react"; | ||
import React, { ReactNode } from "react"; | ||
|
||
const killEvent = (e) => e.stopPropagation(); | ||
|
||
export const CollapsableText = ({ | ||
text, | ||
maxLength = 220, | ||
isDisabled, | ||
}: { | ||
text: ReactNode; | ||
maxLength?: number; | ||
isDisabled?: boolean; | ||
}) => { | ||
const { isOpen, onOpen, onClose } = useDisclosure(); | ||
const finalRef = React.useRef(null); | ||
|
||
const moreButtonColor = useColorModeValue("gray.600", "gray.400"); | ||
import { ReactNode } from "react"; | ||
|
||
export const CollapsableText = ({ text, maxLength = 220 }: { text: ReactNode; maxLength?: number }) => { | ||
if (typeof text !== "string" || text.length <= maxLength) { | ||
return <>{text}</>; | ||
} else { | ||
return ( | ||
<> | ||
<span ref={finalRef}> | ||
{text.substring(0, maxLength - 3)} | ||
<Tooltip label={text} maxW="70vw"> | ||
<Button | ||
style={{ display: "inline" }} | ||
size={"xs"} | ||
variant={"solid"} | ||
bg={moreButtonColor} | ||
color={"white"} | ||
isDisabled={isDisabled} | ||
onClick={onOpen} | ||
> | ||
... | ||
</Button> | ||
</Tooltip> | ||
</span> | ||
<Modal | ||
finalFocusRef={finalRef} | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
size="xl" | ||
scrollBehavior={"inside"} | ||
isCentered | ||
> | ||
{/* we kill the event here to disable drag and drop, since it is in the same container */} | ||
<ModalOverlay onMouseDown={killEvent}> | ||
<ModalContent pb={5} alignItems="center"> | ||
<ModalHeader>Full Text</ModalHeader> | ||
<ModalCloseButton /> | ||
<ModalBody whiteSpace="pre-line">{text}</ModalBody> | ||
</ModalContent> | ||
</ModalOverlay> | ||
</Modal> | ||
</> | ||
); | ||
const visibleText = text.substring(0, maxLength - 3); | ||
return <span>{visibleText}...</span>; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters