Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix event box content clipping and improve animation #463

Merged
merged 3 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#463](https://github.com/alleslabs/celatone-frontend/pull/463) Fix event box content clipping and improve animation
- [#462](https://github.com/alleslabs/celatone-frontend/pull/462) Fix validator query dependencies
- [#460](https://github.com/alleslabs/celatone-frontend/pull/460) Fix icns names and contract address alignment
- [#459](https://github.com/alleslabs/celatone-frontend/pull/459) Fix contract txs by using contract account id instead of contract address
Expand Down
8 changes: 7 additions & 1 deletion src/lib/components/tx/TxReceiptRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ export const TxReceiptRender = ({
variant = "packed",
gap = 2,
keyPrefix = "",
...containerProps
}: TxReceiptRenderProps) => (
<Flex direction="column" gap={gap} sx={variantStyle[variant]}>
<Flex
direction="column"
gap={gap}
sx={variantStyle[variant]}
{...containerProps}
>
{receipts.map((receipt, idx) => (
<ReceiptRow
key={keyPrefix + idx.toString() + receipt.title + receipt.value}
Expand Down
55 changes: 30 additions & 25 deletions src/lib/pages/tx-details/components/tx-message/EventBox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Box, Flex } from "@chakra-ui/react";
import { Box, Flex, chakra, shouldForwardProp } from "@chakra-ui/react";
import type { Event } from "@cosmjs/stargate";
import { isValidMotionProp, motion } from "framer-motion";
import type { ReactNode } from "react";
import { useCallback, useState } from "react";
import { useState } from "react";

import { useGetAddressType } from "lib/app-provider";
import type { LinkType } from "lib/components/ExplorerLink";
Expand All @@ -13,6 +14,11 @@ import { AmpTrackExpand } from "lib/services/amplitude";
import type { TxReceipt } from "lib/types";
import { jsonPrettify, jsonValidate } from "lib/utils";

const MotionBox = chakra(motion.div, {
shouldForwardProp: (prop) =>
isValidMotionProp(prop) || shouldForwardProp(prop),
});

interface EventBoxProps {
event: Event;
msgIndex: number;
Expand All @@ -21,15 +27,6 @@ interface EventBoxProps {
export const EventBox = ({ event, msgIndex }: EventBoxProps) => {
const getAddressType = useGetAddressType();
const [expand, setExpand] = useState(true);
const [receiptHeight, setReceiptHeight] = useState(0);

const measuredRef = useCallback((node: HTMLDivElement | null) => {
if (node !== null) {
setTimeout(() => {
setReceiptHeight(node.clientHeight);
}, 100);
}
}, []);

const receipts = event.attributes.map<TxReceipt>(({ key, value }) => {
const addrType = getAddressType(value);
Expand Down Expand Up @@ -108,7 +105,6 @@ export const EventBox = ({ event, msgIndex }: EventBoxProps) => {
position="relative"
direction="column"
borderRadius="8px"
transition="all .25s ease-in-out"
backgroundColor="gray.900"
_hover={{ backgroundColor: "gray.800" }}
>
Expand Down Expand Up @@ -139,21 +135,30 @@ export const EventBox = ({ event, msgIndex }: EventBoxProps) => {
m={0}
/>
</Flex>
<Box
<MotionBox
display="flex"
flexDir="column"
variants={{
expanded: { opacity: 1, height: "auto" },
collapsed: { opacity: 0, height: 0 },
}}
overflow="hidden"
h={expand ? `${receiptHeight}px` : 0}
transition="all .25s ease-in-out"
initial="collapsed"
animate={expand ? "expanded" : "collapsed"}
transition={{
duration: "0.25",
ease: "easeInOut",
}}
>
<Flex direction="column" p={4} pt={0} ref={measuredRef}>
<Box mb={4} h="1px" bgColor="gray.700" />
<TxReceiptRender
keyPrefix={msgIndex.toString() + event.type}
variant="tx-page"
receipts={receipts}
gap={3}
/>
</Flex>
</Box>
<Box borderTop="1px solid var(--chakra-colors-gray-700)" mx={4} />
<TxReceiptRender
keyPrefix={msgIndex.toString() + event.type}
variant="tx-page"
receipts={receipts}
gap={3}
p={4}
/>
</MotionBox>
</Flex>
);
};
Loading