File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "printWidth": 90,
3+ "tabWidth": 4
4+ }
Original file line number Diff line number Diff line change 11{
22 "name" : " react-card-stack-carousel" ,
3- "version" : " 0.2.1 " ,
3+ "version" : " 0.2.2 " ,
44 "description" : " A tiny configurable carousel component for React" ,
55 "main" : " dist/index.js" ,
66 "scripts" : {
Original file line number Diff line number Diff line change 11import React from "react" ;
2+ import { getMergedStyles } from "./getMergedStyles" ;
23
34export default React . memo ( function CarouselItem ( props ) {
45 const {
@@ -31,10 +32,15 @@ export default React.memo(function CarouselItem(props) {
3132 transform,
3233 zIndex,
3334 } ;
34- const mergedStyles = Object . assign ( { } , styleOverride , computedStyle ) ;
35+
36+ const [ className , inlineStyle ] = getMergedStyles (
37+ "rcsc-item" ,
38+ computedStyle ,
39+ styleOverride
40+ ) ;
3541
3642 return (
37- < div style = { mergedStyles } className = "rcsc-item" >
43+ < div style = { inlineStyle } className = { className } >
3844 { children }
3945 </ div >
4046 ) ;
Original file line number Diff line number Diff line change 11import { ArrowLeft , ArrowRight } from "./Icons" ;
2+ import { getMergedStyles } from "./getMergedStyles" ;
23
34export default function Navigation ( props ) {
45 const { onNext, onPrevious, styleOverrides } = props ;
56 const arrowSize = 16 ;
67
8+ const [ containerClassName , containerInlineStyle ] = getMergedStyles (
9+ "rcsc-nav-container" ,
10+ null ,
11+ styleOverrides . Navigation
12+ ) ;
13+ const [ iconClassName , iconInlineStyle ] = getMergedStyles (
14+ "rcsc-nav-icon" ,
15+ null ,
16+ styleOverrides . NavIcon
17+ ) ;
18+
719 return (
8- < nav style = { styleOverrides . Navigation } className = "rcsc-nav-container" >
9- < div
10- style = { styleOverrides . NavIcon }
11- onClick = { onPrevious }
12- className = "rcsc-nav-icon"
13- >
20+ < nav style = { containerInlineStyle } className = { containerClassName } >
21+ < div style = { iconInlineStyle } onClick = { onPrevious } className = { iconClassName } >
1422 < ArrowLeft color = "#fff" size = { arrowSize } />
1523 </ div >
16- < div
17- style = { styleOverrides . NavIcon }
18- onClick = { onNext }
19- className = "rcsc-nav-icon"
20- >
24+ < div style = { iconInlineStyle } onClick = { onNext } className = { iconClassName } >
2125 < ArrowRight color = "#fff" size = { arrowSize } />
2226 </ div >
2327 </ nav >
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import CarouselItem from "./CarouselItem";
33import Navigation from "./Navigation" ;
44import { useCardStackCarousel } from "./useCardStackCarousel" ;
55import { useRootHeight } from "./useRootHeight" ;
6+ import { getMergedStyles } from "./getMergedStyles" ;
67
78export function StackedCarousel ( props ) {
89 const {
@@ -50,11 +51,13 @@ export function StackedCarousel(props) {
5051 } ) ;
5152 } ;
5253
53- const { Root } = styleOverrides ;
54- const styles = Object . assign ( { } , Root , { height : rootHeight } ) ;
55-
54+ const [ className , inlineStyle ] = getMergedStyles (
55+ "rcsc-container" ,
56+ { height : rootHeight } ,
57+ styleOverrides . Root
58+ ) ;
5659 return (
57- < section className = "rcsc-container" style = { styles } >
60+ < section className = { className } style = { inlineStyle } >
5861 { renderCards ( ) }
5962
6063 < Navigation
Original file line number Diff line number Diff line change 1+ export const getMergedStyles = ( className , inlineStyle , styleOverride ) => {
2+ if ( styleOverride ) {
3+ if ( typeof styleOverride === "string" ) {
4+ const mergedClassName = `${ className } ${ styleOverride } ` ;
5+ return [ mergedClassName , inlineStyle ] ;
6+ } else {
7+ const mergedInlineStyle = Object . assign ( { } , styleOverride , inlineStyle ) ;
8+ return [ className , mergedInlineStyle ] ;
9+ }
10+ }
11+
12+ return [ className , inlineStyle ] ;
13+ } ;
Original file line number Diff line number Diff line change 1111
1212.rcsc-nav-container {
1313 position : absolute;
14- bottom : -40 px ;
14+ bottom : -44 px ;
1515 width : 100% ;
1616 display : flex;
1717 justify-content : center;
2525 width : 30px ;
2626 height : 30px ;
2727 border-radius : 50% ;
28- margin : 0 5 px ;
28+ margin : 0 6 px ;
2929 padding : 8px ;
3030 cursor : pointer;
3131 background-color : # 374151 ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ declare module "react-card-stack-carousel" {
22 import { ReactNode } from "react" ;
33
44 type StyleKeys = "Root" | "CarouselItem" | "Navigation" | "NavIcon" ;
5- type StyleOverrides = Record < StyleKeys , React . CSSProperties > ;
5+ type StyleOverrides = Record < StyleKeys , React . CSSProperties | string > ;
66
77 export interface StackedCarouselProps {
88 height : number | string ;
You can’t perform that action at this time.
0 commit comments