|
1 | 1 | 'use client' |
2 | 2 |
|
3 | | -import { Box, Center, Flex, Image, Text, VStack } from '@devup-ui/react' |
| 3 | +import { Box, Center, Flex, Grid, Image, Text, VStack } from '@devup-ui/react' |
4 | 4 | import { useState } from 'react' |
5 | 5 |
|
6 | 6 | import IconCode from '@/components/icons/IconCode' |
@@ -28,7 +28,7 @@ export default function MdxCardFooter({ |
28 | 28 | } |
29 | 29 |
|
30 | 30 | return ( |
31 | | - <VStack justifyContent="flex-end" maxH="600px" maxW="100%"> |
| 31 | + <VStack justifyContent="flex-end" maxW="100%"> |
32 | 32 | <Flex |
33 | 33 | borderTop="1px solid $border" |
34 | 34 | justifyContent="flex-end" |
@@ -56,52 +56,60 @@ export default function MdxCardFooter({ |
56 | 56 | <Text>Show Code</Text> |
57 | 57 | </Center> |
58 | 58 | </Flex> |
59 | | - {isOpen && ( |
60 | | - <> |
61 | | - <Box h="0" pos="relative" w="100%"> |
62 | | - <Center |
63 | | - _active={{ |
64 | | - borderColor: '$primary', |
65 | | - bg: '$menuActive', |
66 | | - }} |
67 | | - _hover={{ |
68 | | - borderColor: '$primary', |
69 | | - bg: '$menuHover', |
70 | | - }} |
71 | | - bg="$containerBackground" |
72 | | - border="1px solid transparent" |
73 | | - borderRadius="4px" |
74 | | - boxShadow="0 2px 6px 0 $shadow" |
75 | | - cursor="pointer" |
76 | | - gap="8px" |
77 | | - onClick={handleCopy} |
78 | | - p="8px" |
79 | | - pos="absolute" |
80 | | - right="16px" |
81 | | - top="16px" |
82 | | - transition="all 0.125s ease-in-out" |
83 | | - > |
84 | | - <Image |
85 | | - aspectRatio="1" |
86 | | - boxSize="20px" |
87 | | - src={copied ? '/icons/copied.svg' : '/icons/copy-code.svg'} |
88 | | - /> |
89 | | - <Text color="$captionBold" typography="caption"> |
90 | | - Copy |
91 | | - </Text> |
92 | | - </Center> |
93 | | - </Box> |
94 | | - <Box |
95 | | - borderTop="1px solid $border" |
96 | | - h="100%" |
97 | | - onWheel={(e) => e.stopPropagation()} |
98 | | - overflow="auto" |
99 | | - p={['12px', null, '24px']} |
100 | | - > |
101 | | - {children} |
102 | | - </Box> |
103 | | - </> |
104 | | - )} |
| 59 | + <Grid |
| 60 | + gridTemplateRows={isOpen ? '1fr' : '0fr'} |
| 61 | + maxH="600px" |
| 62 | + pos="relative" |
| 63 | + transition="grid-template-rows 0.3s ease-in-out" |
| 64 | + > |
| 65 | + {isOpen && ( |
| 66 | + <> |
| 67 | + <Box pos="absolute" w="100%"> |
| 68 | + <Center |
| 69 | + _active={{ |
| 70 | + borderColor: '$primary', |
| 71 | + bg: '$menuActive', |
| 72 | + }} |
| 73 | + _hover={{ |
| 74 | + borderColor: '$primary', |
| 75 | + bg: '$menuHover', |
| 76 | + }} |
| 77 | + bg="$containerBackground" |
| 78 | + border="1px solid transparent" |
| 79 | + borderRadius="4px" |
| 80 | + boxShadow="0 2px 6px 0 $shadow" |
| 81 | + cursor="pointer" |
| 82 | + gap="8px" |
| 83 | + onClick={handleCopy} |
| 84 | + p="8px" |
| 85 | + pos="absolute" |
| 86 | + right="16px" |
| 87 | + top="16px" |
| 88 | + transition="all 0.125s ease-in-out" |
| 89 | + > |
| 90 | + <Image |
| 91 | + aspectRatio="1" |
| 92 | + boxSize="20px" |
| 93 | + src={copied ? '/icons/copied.svg' : '/icons/copy-code.svg'} |
| 94 | + /> |
| 95 | + <Text color="$captionBold" typography="caption"> |
| 96 | + Copy |
| 97 | + </Text> |
| 98 | + </Center> |
| 99 | + </Box> |
| 100 | + </> |
| 101 | + )} |
| 102 | + <Box |
| 103 | + borderTop={isOpen ? '1px solid $border' : 'none'} |
| 104 | + h="100%" |
| 105 | + onWheel={(e) => e.stopPropagation()} |
| 106 | + overflow="auto" |
| 107 | + p={isOpen ? ['12px', null, '24px'] : '0'} |
| 108 | + transition="padding 0.2s ease-in-out" |
| 109 | + > |
| 110 | + {children} |
| 111 | + </Box> |
| 112 | + </Grid> |
105 | 113 | </VStack> |
106 | 114 | ) |
107 | 115 | } |
0 commit comments