Skip to content

Commit aed0877

Browse files
committed
Support setting transition-delay in Slider
This can be used to defer the exit animation. The initial use case is the moderation list, where we want annotations to be briefly visible with their new moderation status after being moderated, before being hidden.
1 parent 1c012eb commit aed0877

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

src/components/transition/Slider.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const Slider: TransitionComponent = ({
66
children,
77
direction = 'in',
88
onTransitionEnd,
9+
delay,
910
}) => {
1011
const visible = direction === 'in';
1112
const containerRef = useRef<HTMLDivElement | null>(null);
@@ -93,6 +94,8 @@ const Slider: TransitionComponent = ({
9394
// are visible.
9495
overflow: isFullyVisible ? 'visible' : 'hidden',
9596
transition: `height 0.15s ease-in`,
97+
98+
transitionDelay: delay,
9699
}}
97100
>
98101
{children}

src/pattern-library/components/patterns/UsingComponentsPage.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,21 @@ export default function UsingComponentsPage() {
268268
</Library.Link>
269269
</p>
270270
<Library.Section title="API" id="transition-components-api">
271+
<Library.SectionL3 title="delay">
272+
<Library.Info>
273+
<Library.InfoItem label="description">
274+
Sets delay before transitions begin. See the{' '}
275+
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/transition-delay">
276+
transition-delay
277+
</a>{' '}
278+
CSS property.
279+
</Library.InfoItem>
280+
<Library.InfoItem label="type">
281+
<code>string | undefined</code>
282+
</Library.InfoItem>
283+
</Library.Info>
284+
</Library.SectionL3>
285+
271286
<Library.SectionL3 title="direction">
272287
<Library.Info>
273288
<Library.InfoItem label="description">

src/pattern-library/components/patterns/transition/SliderPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default function SliderPage() {
7272

7373
<Library.SectionL2 title="Component API">
7474
<p>
75-
<code>Button</code> accepts{' '}
75+
<code>Slider</code> accepts{' '}
7676
<Library.Link href="/using-components#transition-components-api">
7777
transition component props
7878
</Library.Link>

src/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,17 @@ export type IconComponent = FunctionComponent<JSX.SVGAttributes<SVGSVGElement>>;
5555
* animate the mounting and unmounting of a child component.
5656
*/
5757
export type TransitionComponent = FunctionComponent<{
58+
/** Whether the children should be revealed ("in") or hidden ("out"). */
5859
direction?: 'in' | 'out';
60+
61+
/** Callback invoked when transition ends. */
5962
onTransitionEnd?: (direction: 'in' | 'out') => void;
63+
64+
/**
65+
* Delay before transitions begin. This corresponds to the `transition-delay`
66+
* CSS property.
67+
*/
68+
delay?: string;
6069
}>;
6170

6271
export type OrderDirection = 'ascending' | 'descending';

0 commit comments

Comments
 (0)