Skip to content

Commit d52d4d1

Browse files
authored
Add support for multiple speeds for Marquee (#18)
1 parent 0aa7cee commit d52d4d1

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

src/marquee/marquee.stories.tsx

+18-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@ import { Marquee } from "./marquee";
33

44
export default {
55
title: "Marquee",
6+
argTypes: {
7+
text: {
8+
defaultValue: "Hello there 👋",
9+
control: {
10+
type: "text",
11+
},
12+
},
13+
speed: {
14+
defaultValue: "medium",
15+
control: {
16+
type: "select",
17+
options: ["slow", "medium"],
18+
},
19+
},
20+
},
621
};
722

8-
export const Standard = () => <Marquee>Hello there 👋</Marquee>;
23+
export const Standard = ({ text, ...props }) => (
24+
<Marquee {...props}>{text}</Marquee>
25+
);

src/marquee/marquee.tsx

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
import React from "react";
2+
import clsx from "clsx";
23

34
type Props = {
45
children: React.ReactNode;
6+
speed?: "slow" | "medium";
57
separator?: string | React.ReactNode;
68
};
79

8-
export const Marquee = ({ children, separator = "/" }: Props) => (
10+
export const Marquee = ({
11+
children,
12+
speed = "medium",
13+
separator = "/",
14+
}: Props) => (
915
<div className="overflow-hidden w-full">
10-
<div className="motion-safe:animate-marquee p-8 text-3xl whitespace-nowrap">
16+
<div
17+
className={clsx("p-8 text-3xl whitespace-nowrap", {
18+
"motion-safe:animate-marquee-slow": speed === "slow",
19+
"motion-safe:animate-marquee-medium": speed === "medium",
20+
})}
21+
>
1122
<div className="inline-block whitespace-nowrap">{children}</div>
1223

1324
{new Array(20).fill(null).map((_, index) => (

tailwind.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ module.exports = {
4040
},
4141
extend: {
4242
animation: {
43-
marquee: "marquee 20s linear infinite",
43+
"marquee-slow": "marquee 60s linear infinite",
44+
"marquee-medium": "marquee 20s linear infinite",
4445
},
4546
keyframes: {
4647
marquee: {

0 commit comments

Comments
 (0)