-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Activities bar - added carousel (#287)
> Closes: #225 --- ### Implement a carousel component --- ### _What was done:_ - Creating a responsive carousel component for the activities card - Added packages: `react-slick, ver. ^0.30.2` | `@types/react-slick: "^0.23.13"` React-slick is a carousel component built with React. It is a react port of a slick carousel: https://kenwheeler.github.io/slick/. The first release was in 2015, the last release - 2 weeks ago. Based on MIT license. Weekly downloads: 1,071,550 Unpacked Size only: 815 kB Stars on GitHub: 11.5k Docs: https://react-slick.neostack.com/ More details: https://www.npmjs.com/package/react-slick Repository: https://github.com/akiran/react-slick - Changed file structure of ActivityBar - Added SimpleGrid area to OverviewPage - Separating DocsButton in OverviewPage. --- ### _Preview:_ <img width="1569" alt="activities-carousel" src="https://github.com/thesis/acre/assets/28560653/90ddde69-7f11-4c97-901f-16b2c024e23e"> --- ### _Additional info:_ - If there are fewer cards, the carousel arrows are hidden. - If the user removes a card, the carousel component is refreshed in the background for correct width conversion. - If the last element is removed, the carousel is moved to the previous element to improve user experience. - The activity details page will be changed in another story, according to the design we are waiting for.
- Loading branch information
Showing
27 changed files
with
607 additions
and
123 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
66 changes: 66 additions & 0 deletions
66
dapp/src/assets/icons/animated/ArrowUpRightAnimatedIcon.tsx
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from "react" | ||
import { ArrowUpRight } from "#/assets/icons" | ||
import { Box, Icon } from "@chakra-ui/react" | ||
import { Variants, motion } from "framer-motion" | ||
import { chakraUnitToPx } from "#/theme/utils" | ||
|
||
const arrowUpVariants: Variants = { | ||
initial: { | ||
x: 0, | ||
y: -5, | ||
}, | ||
animate: (boxSizePx: number) => ({ | ||
x: [0, boxSizePx], | ||
y: [-5, -boxSizePx], | ||
transition: { | ||
duration: 0.4, | ||
ease: "easeInOut", | ||
}, | ||
}), | ||
} | ||
|
||
const arrowBottomVariants: Variants = { | ||
initial: (boxSizePx: number) => ({ | ||
x: -boxSizePx, | ||
y: boxSizePx, | ||
}), | ||
animate: (boxSizePx: number) => ({ | ||
x: [-boxSizePx, 0], | ||
y: [boxSizePx, -5], | ||
transition: { | ||
duration: 0.4, | ||
ease: "easeInOut", | ||
}, | ||
}), | ||
} | ||
|
||
type ArrowUpRightAnimatedIconProps = { | ||
boxSize?: number | ||
color?: string | ||
} | ||
|
||
export function ArrowUpRightAnimatedIcon({ | ||
boxSize = 4, | ||
color = "brand.400", | ||
}: ArrowUpRightAnimatedIconProps) { | ||
const boxSizePx = chakraUnitToPx(boxSize) | ||
return ( | ||
<Box pos="relative" boxSize={boxSize} overflow="hidden"> | ||
{[ | ||
{ id: "arrow-up", variants: arrowUpVariants }, | ||
{ id: "arrow-bottom", variants: arrowBottomVariants }, | ||
].map(({ id, variants }) => ( | ||
<Box | ||
key={id} | ||
pos="absolute" | ||
as={motion.div} | ||
boxSize={boxSize} | ||
custom={boxSizePx} | ||
variants={variants} | ||
> | ||
<Icon as={ArrowUpRight} boxSize={boxSize} color={color} /> | ||
</Box> | ||
))} | ||
</Box> | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./ArrowUpRightAnimatedIcon" |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./ActivityCard" |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { forwardRef } from "react" | ||
import { FlexProps, Flex } from "@chakra-ui/react" | ||
import Slider, { Settings as SliderProps } from "react-slick" | ||
|
||
const carouselSettings: SliderProps = { | ||
dots: false, | ||
infinite: false, | ||
draggable: false, | ||
variableWidth: true, | ||
speed: 500, | ||
slidesToShow: 12, | ||
slidesToScroll: 1, | ||
} | ||
|
||
type CarouselProps = FlexProps & | ||
SliderProps & { | ||
children: React.ReactNode | ||
} | ||
|
||
export const Carousel = forwardRef<HTMLInputElement, CarouselProps>( | ||
(props, ref) => ( | ||
<Flex | ||
as={Slider} | ||
ref={ref} | ||
// overflow="hidden" is required to hide the items outside the viewport. | ||
overflow="hidden" | ||
{...carouselSettings} | ||
{...props} | ||
> | ||
{props.children} | ||
</Flex> | ||
), | ||
) |
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
Oops, something went wrong.