Skip to content

Commit

Permalink
Merge pull request #119 from linked-planet/dev
Browse files Browse the repository at this point in the history
new component: SlideOpen, slightly improved TruncatedText one
  • Loading branch information
marcus-wishes authored Jan 30, 2025
2 parents 66850df + 28e0ff9 commit 87259c7
Show file tree
Hide file tree
Showing 8 changed files with 386 additions and 177 deletions.
43 changes: 43 additions & 0 deletions library/src/components/SlideOpen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { CSSProperties, RefObject } from "react"
import { twMerge } from "tailwind-merge"

export function SlideOpen({
children,
containerClassName,
containerStyle,
contentStyle,
contentClassName,
open,
ref,
}: {
children: React.ReactNode
containerClassName?: string
containerStyle?: CSSProperties
contentClassName?: string
contentStyle?: CSSProperties
open: boolean
ref?: RefObject<HTMLDivElement>
}) {
return (
<div
className={twMerge(
"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]",
containerClassName,
)}
style={containerStyle}
data-open={open}
ref={ref}
>
<div
className={twMerge(
"relative bottom-0 min-h-0 data-[open=false]:p-0 data-[open=false]:border-0 m-0 box-border transition-all",
contentClassName,
)}
style={contentStyle}
data-open={open}
>
{children}
</div>
</div>
)
}
8 changes: 4 additions & 4 deletions library/src/components/TruncatedText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const TruncatedText = ({
moreButtonStyle,
className,
style,
testId,
duration = 150,
}: {
children: React.ReactNode
Expand All @@ -29,7 +28,6 @@ const TruncatedText = ({
moreButtonStyle?: React.CSSProperties
className?: string
style?: React.CSSProperties
testId?: string
duration?: number
}) => {
const ref = useRef<HTMLParagraphElement>(null)
Expand All @@ -56,7 +54,6 @@ const TruncatedText = ({
className,
)}
style={style}
data-testid={testId}
>
<div
className={`transition-[grid-template-rows] ease-in-out ${
Expand All @@ -75,12 +72,15 @@ const TruncatedText = ({
<div
style={{
...textStyle,
display: open || animating ? "block" : "-webkit-box",
display: open ? "block" : "-webkit-box",
//display: "-webkit-box",
WebkitLineClamp: lines,
WebkitBoxOrient: "vertical",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "normal",
lineClamp: lines,
minHeight: `${lines + 0.5}rem`,
}}
ref={ref}
className={textClassName}
Expand Down
1 change: 1 addition & 0 deletions library/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ export * from "./tour"
export * from "./form"
export * from "./EventList"
export * from "./HighlightedText"
export * from "./SlideOpen"
Loading

0 comments on commit 87259c7

Please sign in to comment.