Skip to content

Commit 87259c7

Browse files
Merge pull request #119 from linked-planet/dev
new component: SlideOpen, slightly improved TruncatedText one
2 parents 66850df + 28e0ff9 commit 87259c7

File tree

8 files changed

+386
-177
lines changed

8 files changed

+386
-177
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import type { CSSProperties, RefObject } from "react"
2+
import { twMerge } from "tailwind-merge"
3+
4+
export function SlideOpen({
5+
children,
6+
containerClassName,
7+
containerStyle,
8+
contentStyle,
9+
contentClassName,
10+
open,
11+
ref,
12+
}: {
13+
children: React.ReactNode
14+
containerClassName?: string
15+
containerStyle?: CSSProperties
16+
contentClassName?: string
17+
contentStyle?: CSSProperties
18+
open: boolean
19+
ref?: RefObject<HTMLDivElement>
20+
}) {
21+
return (
22+
<div
23+
className={twMerge(
24+
"grid relative p-0 m-0 box-border overflow-hidden ease-in-out min-h-0 transition-all data-[open=true]:grid-rows-[1fr] data-[open=false]:grid-rows-[0fr]",
25+
containerClassName,
26+
)}
27+
style={containerStyle}
28+
data-open={open}
29+
ref={ref}
30+
>
31+
<div
32+
className={twMerge(
33+
"relative bottom-0 min-h-0 data-[open=false]:p-0 data-[open=false]:border-0 m-0 box-border transition-all",
34+
contentClassName,
35+
)}
36+
style={contentStyle}
37+
data-open={open}
38+
>
39+
{children}
40+
</div>
41+
</div>
42+
)
43+
}

library/src/components/TruncatedText.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const TruncatedText = ({
1515
moreButtonStyle,
1616
className,
1717
style,
18-
testId,
1918
duration = 150,
2019
}: {
2120
children: React.ReactNode
@@ -29,7 +28,6 @@ const TruncatedText = ({
2928
moreButtonStyle?: React.CSSProperties
3029
className?: string
3130
style?: React.CSSProperties
32-
testId?: string
3331
duration?: number
3432
}) => {
3533
const ref = useRef<HTMLParagraphElement>(null)
@@ -56,7 +54,6 @@ const TruncatedText = ({
5654
className,
5755
)}
5856
style={style}
59-
data-testid={testId}
6057
>
6158
<div
6259
className={`transition-[grid-template-rows] ease-in-out ${
@@ -75,12 +72,15 @@ const TruncatedText = ({
7572
<div
7673
style={{
7774
...textStyle,
78-
display: open || animating ? "block" : "-webkit-box",
75+
display: open ? "block" : "-webkit-box",
76+
//display: "-webkit-box",
7977
WebkitLineClamp: lines,
8078
WebkitBoxOrient: "vertical",
8179
overflow: "hidden",
8280
textOverflow: "ellipsis",
8381
whiteSpace: "normal",
82+
lineClamp: lines,
83+
minHeight: `${lines + 0.5}rem`,
8484
}}
8585
ref={ref}
8686
className={textClassName}

library/src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ export * from "./tour"
3838
export * from "./form"
3939
export * from "./EventList"
4040
export * from "./HighlightedText"
41+
export * from "./SlideOpen"

0 commit comments

Comments
 (0)