File tree 3 files changed +33
-4
lines changed
3 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,23 @@ import { Marquee } from "./marquee";
3
3
4
4
export default {
5
5
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
+ } ,
6
21
} ;
7
22
8
- export const Standard = ( ) => < Marquee > Hello there 👋</ Marquee > ;
23
+ export const Standard = ( { text, ...props } ) => (
24
+ < Marquee { ...props } > { text } </ Marquee >
25
+ ) ;
Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
+ import clsx from "clsx" ;
2
3
3
4
type Props = {
4
5
children : React . ReactNode ;
6
+ speed ?: "slow" | "medium" ;
5
7
separator ?: string | React . ReactNode ;
6
8
} ;
7
9
8
- export const Marquee = ( { children, separator = "/" } : Props ) => (
10
+ export const Marquee = ( {
11
+ children,
12
+ speed = "medium" ,
13
+ separator = "/" ,
14
+ } : Props ) => (
9
15
< 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
+ >
11
22
< div className = "inline-block whitespace-nowrap" > { children } </ div >
12
23
13
24
{ new Array ( 20 ) . fill ( null ) . map ( ( _ , index ) => (
Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ module.exports = {
40
40
} ,
41
41
extend : {
42
42
animation : {
43
- marquee : "marquee 20s linear infinite" ,
43
+ "marquee-slow" : "marquee 60s linear infinite" ,
44
+ "marquee-medium" : "marquee 20s linear infinite" ,
44
45
} ,
45
46
keyframes : {
46
47
marquee : {
You can’t perform that action at this time.
0 commit comments