File tree Expand file tree Collapse file tree 6 files changed +117
-0
lines changed
app/components/Home/components/Section/components/SectionHero/components/Carousel Expand file tree Collapse file tree 6 files changed +117
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,17 @@ export const Carousel = styled.div`
35
35
${ mediaTabletUp } {
36
36
height: ${ CAROUSEL_HEIGHT } px;
37
37
}
38
+
39
+ .MuiIconButton-root {
40
+ opacity: 0;
41
+ transition: opacity 150ms ease-in-out;
42
+ }
43
+
44
+ &:hover {
45
+ > .MuiIconButton-root {
46
+ opacity: 1;
47
+ }
48
+ }
38
49
` ;
39
50
40
51
export const StyledBullets = styled ( Bullets ) `
Original file line number Diff line number Diff line change
1
+ import { SWIPE_ACTION } from "../../../../../../../../hooks/useSwipeInteraction/common/entities" ;
1
2
import {
2
3
Carousel as CarouselCards ,
3
4
CarouselView ,
4
5
StyledBullets ,
5
6
} from "./carousel.styles" ;
7
+ import { Arrow } from "./components/Arrow/arrow" ;
6
8
import { Cards } from "./components/Cards/cards" ;
7
9
import { useInteractiveCarousel } from "./hooks/useInteractiveCarousel" ;
8
10
@@ -13,11 +15,20 @@ export const Carousel = (): JSX.Element => {
13
15
interactiveCards,
14
16
interactiveIndexes,
15
17
onSetActiveIndex,
18
+ onSetSwipeAction,
16
19
} = useInteractiveCarousel ( ) ;
17
20
return (
18
21
< CarouselView >
19
22
< CarouselCards { ...interactiveAction } >
23
+ < Arrow
24
+ onClick = { ( ) : void => onSetSwipeAction ( SWIPE_ACTION . SWIPE_BACKWARD ) }
25
+ swipeAction = { SWIPE_ACTION . SWIPE_BACKWARD }
26
+ />
20
27
< Cards activeIndex = { activeIndex } cards = { interactiveCards } />
28
+ < Arrow
29
+ onClick = { ( ) : void => onSetSwipeAction ( SWIPE_ACTION . SWIPE_FORWARD ) }
30
+ swipeAction = { SWIPE_ACTION . SWIPE_FORWARD }
31
+ />
21
32
< StyledBullets
22
33
activeBullet = { activeIndex }
23
34
bullets = { interactiveIndexes }
Original file line number Diff line number Diff line change @@ -9,3 +9,4 @@ export const CAROUSEL_HEIGHT_SM =
9
9
MAX_CARD_HEIGHT_SM + MAX_DECK_SIZE * CARD_OFFSET_Y ;
10
10
export const TRANSITION_DELAY = 100 ;
11
11
export const TRANSITION_DURATION = 100 ;
12
+ export const ARROW_OFFSET_Y = ( CARD_OFFSET_Y * MAX_DECK_SIZE ) / 2 ;
Original file line number Diff line number Diff line change
1
+ import { SWIPE_ACTION } from "../../../../../../../../../hooks/useSwipeInteraction/common/entities" ;
1
2
import {
3
+ ARROW_OFFSET_Y ,
2
4
CARD_OFFSET_Y ,
3
5
CARD_SCALE_X ,
4
6
MAX_CARD_WIDTH ,
@@ -7,6 +9,17 @@ import {
7
9
TRANSITION_DURATION ,
8
10
} from "./constants" ;
9
11
12
+ /**
13
+ * Returns the arrow's transform scaleX and translateY.
14
+ * @param swipeAction - Swipe action.
15
+ * @returns arrow's transform.
16
+ */
17
+ export function getArrowTransform ( swipeAction : SWIPE_ACTION ) : string {
18
+ return swipeAction === SWIPE_ACTION . SWIPE_FORWARD
19
+ ? `translate(24px, calc(${ ARROW_OFFSET_Y } px - 50%)) scaleX(-1)`
20
+ : `translate(-24px, calc(${ ARROW_OFFSET_Y } px - 50%))` ;
21
+ }
22
+
10
23
/**
11
24
* Returns the carousel card's position in the deck.
12
25
* @param index - Card index.
Original file line number Diff line number Diff line change
1
+ import { mediaTabletDown } from "@databiosphere/findable-ui/lib/styles/common/mixins/breakpoints" ;
2
+ import {
3
+ inkMain ,
4
+ smokeDark ,
5
+ smokeLightest ,
6
+ white ,
7
+ } from "@databiosphere/findable-ui/lib/styles/common/mixins/colors" ;
8
+ import { black08 } from "@databiosphere/findable-ui/lib/theme/common/palette" ;
9
+ import { css } from "@emotion/react" ;
10
+ import styled from "@emotion/styled" ;
11
+ import { IconButton as MIconButton } from "@mui/material" ;
12
+ import {
13
+ SwipeAction ,
14
+ SWIPE_ACTION ,
15
+ } from "../../../../../../../../../../hooks/useSwipeInteraction/common/entities" ;
16
+ import { MAX_DECK_SIZE } from "../../common/constants" ;
17
+ import { getArrowTransform } from "../../common/utils" ;
18
+
19
+ interface Props {
20
+ swipeAction : SwipeAction ;
21
+ }
22
+
23
+ export const IconButton = styled ( MIconButton , {
24
+ shouldForwardProp : ( props ) => props !== "swipeAction" ,
25
+ } ) < Props > `
26
+ & {
27
+ background-color: ${ white } ;
28
+ border-radius: 50%;
29
+ box-shadow: inset 0 0 0 1px ${ smokeDark } , 0 1px 0 0 ${ black08 } ;
30
+ color: ${ inkMain } ;
31
+ position: absolute;
32
+ top: 50%;
33
+ transform: ${ ( { swipeAction } ) => getArrowTransform ( swipeAction ) } ;
34
+ z-index: ${ MAX_DECK_SIZE + 1 } ;
35
+
36
+ &:hover {
37
+ background-color: ${ smokeLightest } ;
38
+ }
39
+
40
+ &:active {
41
+ box-shadow: inset 0 0 0 1px ${ smokeDark } ;
42
+ }
43
+
44
+ ${ mediaTabletDown } {
45
+ display: none;
46
+ }
47
+ }
48
+
49
+ ${ ( { swipeAction } ) =>
50
+ swipeAction === SWIPE_ACTION . SWIPE_BACKWARD &&
51
+ css `
52
+ left : 0 ;
53
+ ` }
54
+
55
+ ${ ( { swipeAction } ) =>
56
+ swipeAction === SWIPE_ACTION . SWIPE_FORWARD &&
57
+ css `
58
+ right : 0 ;
59
+ ` }
60
+ ` ;
Original file line number Diff line number Diff line change
1
+ import { SouthIcon } from "@databiosphere/findable-ui/lib/components/common/CustomIcon/components/SouthIcon/southIcon" ;
2
+ import { SwipeAction } from "../../../../../../../../../../hooks/useSwipeInteraction/common/entities" ;
3
+ import { IconButton } from "./arrow.styles" ;
4
+
5
+ interface ArrowProps {
6
+ onClick : ( ) => void ;
7
+ swipeAction : SwipeAction ;
8
+ }
9
+
10
+ export const Arrow = ( { onClick, swipeAction } : ArrowProps ) : JSX . Element => {
11
+ return (
12
+ < IconButton
13
+ color = "secondary"
14
+ onClick = { onClick }
15
+ size = "large"
16
+ swipeAction = { swipeAction }
17
+ >
18
+ < SouthIcon fontSize = "small" />
19
+ </ IconButton >
20
+ ) ;
21
+ } ;
You can’t perform that action at this time.
0 commit comments