Skip to content

Commit

Permalink
pass styles directly to trailed elements
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesmac committed Jan 2, 2025
1 parent fd85441 commit c016ed8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/animation/src/Trail.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import type { BoxProps } from '@mui/material'
import { Box } from '@mui/material'
import { a, useTrail } from '@react-spring/web'
import type { CSSProperties } from 'react'
import React, { isValidElement } from 'react'

export interface TrailProps extends BoxProps {
fullWidth?: boolean
open: boolean
trailStyles?: CSSProperties
}

export const Trail: React.FC<TrailProps> = ({
fullWidth, open, children, ...props
fullWidth, open, trailStyles, children, ...props
}) => {
// Ensure children is an array for iteration
const childArray = isValidElement(children) ? [children] : (children as React.ReactNode[])
Expand All @@ -32,7 +34,9 @@ export const Trail: React.FC<TrailProps> = ({
<a.div
className={`trail-${index}`}
key={childArrayWithKey[index].key}
style={{ ...style, display: 'flex' }}
style={{
...trailStyles, ...style, display: 'flex',
}}
>
{childArrayWithKey[index].child}
</a.div>
Expand Down

0 comments on commit c016ed8

Please sign in to comment.