improved responsivness of the screen

pull/470/head
Tim Pechersky 2021-11-29 12:41:48 +00:00
rodzic 0f3f4886e6
commit c37132ab81
3 zmienionych plików z 344 dodań i 160 usunięć

Wyświetl plik

@ -14,7 +14,7 @@ import {
import { AiOutlinePlusCircle } from "react-icons/ai";
import OverlayContext from "../src/core/providers/OverlayProvider/context";
import { MODAL_TYPES } from "../src/core/providers/OverlayProvider/constants";
import Scrollable from "../src/components/Scrollable";
const Subscriptions = () => {
const { subscriptionsCache } = useSubscriptions();
const modal = useContext(OverlayContext);
@ -37,6 +37,7 @@ const Subscriptions = () => {
modal.toggleModal({ type: MODAL_TYPES.NEW_SUBSCRIPTON });
};
return (
<Scrollable>
<Box w="100%" px="7%" pt={2}>
{subscriptionsCache.isLoading ? (
<Center>
@ -95,6 +96,7 @@ const Subscriptions = () => {
</ScaleFade>
)}
</Box>
</Scrollable>
);
};

Wyświetl plik

@ -11,8 +11,10 @@ import {
import { BiCopy } from "react-icons/bi";
const CopyButton = (props) => {
console.log(props.copyString);
const children = props.children ? props.children : "";
const copyString = props.prefix ? props.prefix + children : children;
const copyString =
props.copyString ?? (props.prefix ? props.prefix + children : children);
const { onCopy } = useClipboard(copyString);
@ -31,7 +33,7 @@ const CopyButton = (props) => {
icon={<BiCopy />}
colorScheme="orange"
variant="ghost"
size="sm"
size={props.size ?? "sm"}
/>
</PopoverTrigger>
<PopoverContent

Wyświetl plik

@ -13,6 +13,17 @@ import {
Image,
EditablePreview,
Button,
useMediaQuery,
Accordion,
AccordionItem,
AccordionButton,
AccordionPanel,
AccordionIcon,
Box,
Flex,
Text,
Spacer,
Stack,
} from "@chakra-ui/react";
import { CheckIcon, DeleteIcon } from "@chakra-ui/icons";
import moment from "moment";
@ -29,6 +40,7 @@ const mapper = {
};
const SubscriptionsList = ({ emptyCTA }) => {
const [isLargerThan530px] = useMediaQuery(["(min-width: 530px)"]);
const overlay = useContext(OverlayContext);
const {
subscriptionsCache,
@ -44,11 +56,17 @@ const SubscriptionsList = ({ emptyCTA }) => {
updateSubscription.mutate(data);
};
const cellProps = {
px: ["16px", "8px", "16px"],
};
if (
subscriptionsCache.data &&
subscriptionsCache.data.subscriptions.length > 0
) {
return (
<>
{isLargerThan530px && (
<Table
borderColor="gray.200"
borderWidth="1px"
@ -63,13 +81,13 @@ const SubscriptionsList = ({ emptyCTA }) => {
>
<Thead>
<Tr>
<Th>Token</Th>
<Th>Label</Th>
<Th>Address</Th>
<Th>abi</Th>
<Th>Color</Th>
<Th>Date Created</Th>
<Th>Actions</Th>
<Th {...cellProps}>Token</Th>
<Th {...cellProps}>Label</Th>
<Th {...cellProps}>Address</Th>
<Th {...cellProps}>abi</Th>
<Th {...cellProps}>Color</Th>
<Th {...cellProps}>Date Created</Th>
<Th {...cellProps}>Actions</Th>
</Tr>
</Thead>
<Tbody>
@ -78,12 +96,16 @@ const SubscriptionsList = ({ emptyCTA }) => {
subscriptionTypeIcons[subscription.subscription_type_id];
return (
<Tr key={`token-row-${subscription.id}`}>
<Td>
<Td {...cellProps}>
<Tooltip label="Ethereum blockchain" fontSize="md">
<Image h="32px" src={iconLink} alt="pool icon" />
<Image
h={["32px", "16px", "32px", null]}
src={iconLink}
alt="pool icon"
/>
</Tooltip>
</Td>
<Td py={0}>
<Td py={0} {...cellProps} wordBreak="break-word">
<Editable
colorScheme="blue"
placeholder="enter note here"
@ -102,14 +124,14 @@ const SubscriptionsList = ({ emptyCTA }) => {
<EditableInput maxW="40rem" />
</Editable>
</Td>
<Td mr={4} p={0}>
<Td mr={4} p={0} wordBreak="break-word" {...cellProps}>
{subscription.address?.startsWith("tag") ? (
<CopyButton>{mapper[subscription.address]}</CopyButton>
) : (
<CopyButton>{subscription.address}</CopyButton>
)}
</Td>
<Td mr={4} p={0}>
<Td mr={4} p={0} {...cellProps}>
{subscription.abi ? (
<CheckIcon />
) : (
@ -129,7 +151,7 @@ const SubscriptionsList = ({ emptyCTA }) => {
</Button>
)}
</Td>
<Td>
<Td {...cellProps}>
<ColorSelector
// subscriptionId={subscription.id}
initialColor={subscription.color}
@ -138,13 +160,17 @@ const SubscriptionsList = ({ emptyCTA }) => {
}
/>
</Td>
<Td py={0}>{moment(subscription.created_at).format("L")}</Td>
<Td py={0} {...cellProps} wordBreak="break-word">
{moment(subscription.created_at).format("L")}
</Td>
<Td py={0}>
<Td py={0} {...cellProps}>
<ConfirmationRequest
bodyMessage={"please confirm"}
header={"Delete subscription"}
onConfirm={() => deleteSubscription.mutate(subscription.id)}
onConfirm={() =>
deleteSubscription.mutate(subscription.id)
}
>
<IconButton
size="sm"
@ -159,6 +185,160 @@ const SubscriptionsList = ({ emptyCTA }) => {
})}
</Tbody>
</Table>
)}
{!isLargerThan530px && (
<Accordion>
{subscriptionsCache.data.subscriptions.map((subscription) => {
const iconLink =
subscriptionTypeIcons[subscription.subscription_type_id];
return (
<AccordionItem key={`token-row-${subscription.id}`}>
<h2>
<AccordionButton>
<Stack
direction="row"
textAlign="left"
alignItems="center"
>
<Tooltip label="Ethereum blockchain" fontSize="md">
<Image
h={["32px", "16px", "32px", null]}
src={iconLink}
alt="pool icon"
/>
</Tooltip>
<Editable
colorScheme="blue"
placeholder="enter note here"
defaultValue={subscription.label}
onSubmit={(nextValue) =>
updateCallback({
id: subscription.id,
label: nextValue,
})
}
>
<EditablePreview
maxW="40rem"
_placeholder={{ color: "black" }}
/>
<EditableInput maxW="40rem" />
</Editable>
</Stack>
<AccordionIcon />
</AccordionButton>
</h2>
<AccordionPanel pb={4}>
<Stack>
<Flex
fontSize="sm"
placeContent="center"
h="min-content"
alignItems="center"
pr={8}
>
<Text>Address:</Text>
<Spacer />
{subscription.address?.startsWith("tag") ? (
<CopyButton
size="xs"
copyString={subscription.address}
>
{mapper[subscription.address]}
</CopyButton>
) : (
<CopyButton
size="xs"
copyString={subscription.address}
>
<Text isTruncated>{subscription.address}</Text>
</CopyButton>
)}
</Flex>
<Flex
fontSize="sm"
placeContent="center"
h="min-content"
alignItems="center"
pr={8}
>
<Text>Abi:</Text>
<Spacer />
{subscription.abi ? (
<CheckIcon />
) : (
<Button
colorScheme="orange"
size="xs"
py={2}
disabled={!subscription.address}
onClick={() =>
overlay.toggleModal({
type: MODAL_TYPES.UPLOAD_ABI,
props: { id: subscription.id },
})
}
>
Upload
</Button>
)}
</Flex>
<Flex
fontSize="sm"
placeContent="center"
h="min-content"
pr={8}
>
<Spacer />
<ConfirmationRequest
bodyMessage={"please confirm"}
header={"Delete subscription"}
onConfirm={() =>
deleteSubscription.mutate(subscription.id)
}
>
<Button
colorScheme="red"
size="xs"
py={2}
disabled={!subscription.address}
onClick={() =>
overlay.toggleModal({
type: MODAL_TYPES.UPLOAD_ABI,
props: { id: subscription.id },
})
}
leftIcon={<DeleteIcon />}
>
Delete
</Button>
</ConfirmationRequest>
</Flex>
</Stack>
</AccordionPanel>
</AccordionItem>
);
})}
<AccordionItem>
<h2>
<AccordionButton>
<Box flex="1" textAlign="left">
Section 2 title
</Box>
<AccordionIcon />
</AccordionButton>
</h2>
<AccordionPanel pb={4}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat.
</AccordionPanel>
</AccordionItem>
</Accordion>
)}
</>
);
} else if (
subscriptionsCache.data &&