1- import React from "react" ;
1+ import React , { useRef } from "react" ;
22import styled from "styled-components" ;
33import Spine , { VariantProp , variantColor } from "./spine" ;
44export type { VariantProp } ;
@@ -17,6 +17,9 @@ const Wrapper = styled.div<SideProp>`
1717const StyledTitle = styled . h2 `` ;
1818const StyledParty = styled . p `` ;
1919const StyledSubtitle = styled . small `` ;
20+ const PartyElementWrapper = styled . div `
21+ display: inline-flex;
22+ ` ;
2023
2124const TextContainer = styled . div < SideProp & VariantProp & { isLast : boolean } > `
2225 margin-${ ( { rightSided } ) => ( rightSided ? "left" : "right" ) } : 20px;
@@ -49,6 +52,12 @@ const TextContainer = styled.div<SideProp & VariantProp & { isLast: boolean }>`
4952 line-height: 19px;
5053 color: ${ variantColor } ;
5154 }
55+
56+ & ${ PartyElementWrapper } {
57+ order: ${ ( { rightSided } ) => ( rightSided ? 2 : 1 ) } ;
58+ max-height: 32px;
59+ overflow: hidden;
60+ }
5261
5362 & ${ StyledSubtitle } {
5463 ${ small }
@@ -60,6 +69,8 @@ const TextContainer = styled.div<SideProp & VariantProp & { isLast: boolean }>`
6069
6170const PartyTitleContainer = styled . div < SideProp > `
6271 display: flex;
72+ position: relative;
73+ align-items: center;
6374 flex-direction: row;
6475 flex-wrap: wrap;
6576 gap: 4px 8px;
@@ -69,7 +80,7 @@ const PartyTitleContainer = styled.div<SideProp>`
6980
7081interface BulletProps extends VariantProp , SideProp {
7182 title : string ;
72- party : string ;
83+ party : string | React . ReactElement ;
7384 subtitle : string ;
7485 active ?: boolean ;
7586 Icon ?: React . FC < React . SVGAttributes < SVGElement > > ;
@@ -81,14 +92,21 @@ const Bullet: React.FC<BulletProps> = (props) => {
8192 const { title, party, subtitle, ...restProps } = props ;
8293 const { rightSided, variant, line, Icon, isLast, ...wrapperProps } =
8394 restProps ;
95+ const titleRef = useRef < HTMLHeadingElement > ( null ) ;
8496
8597 return (
8698 < Wrapper { ...{ rightSided } } { ...wrapperProps } >
87- < Spine { ...{ variant, line, Icon } } />
99+ < Spine { ...{ variant, line, Icon, titleRef } } />
88100 < TextContainer { ...{ variant, rightSided, isLast } } >
89101 < PartyTitleContainer { ...{ rightSided } } >
90- < StyledTitle > { title } </ StyledTitle >
91- < StyledParty > { party } </ StyledParty >
102+ < StyledTitle ref = { titleRef } > { title } </ StyledTitle >
103+ { typeof party === `string` ? (
104+ < StyledParty > { party } </ StyledParty >
105+ ) : (
106+ < PartyElementWrapper className = "party-wrapper" >
107+ { party }
108+ </ PartyElementWrapper >
109+ ) }
92110 </ PartyTitleContainer >
93111 < StyledSubtitle > { subtitle } </ StyledSubtitle >
94112 </ TextContainer >
0 commit comments