-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updating Animated text * fixing linting * Update sparkle/src/components/AnimatedText.tsx Co-authored-by: Philippe Rolet <[email protected]> * cleaning --------- Co-authored-by: Philippe Rolet <[email protected]>
- Loading branch information
1 parent
1b4a665
commit a5c9aa0
Showing
6 changed files
with
106 additions
and
69 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { cva, VariantProps } from "class-variance-authority"; | ||
import { ReactNode } from "react"; | ||
import React from "react"; | ||
|
||
import { cn } from "@sparkle/lib/utils"; | ||
|
||
const animVariants = cva( | ||
"s-relative s-mx-auto s-max-w-md s-text-black/0 s-animate-shiny-text s-bg-clip-text s-bg-no-repeat [background-position:0_0] [background-size:50%_100%] s-bg-gradient-to-r", | ||
{ | ||
variants: { | ||
variant: { | ||
muted: | ||
"s-from-transparent s-via-primary-950/80 s-via-50% s-to-transparent", | ||
highlight: | ||
"s-from-highlight s-via-highlight-800 s-via-50% s-to-highlight", | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: "muted", | ||
}, | ||
} | ||
); | ||
|
||
const textVariants = cva("s-absolute s-inset-0", { | ||
variants: { | ||
variant: { | ||
muted: "s-text-muted-foreground", | ||
highlight: "s-text-highlight", | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: "muted", | ||
}, | ||
}); | ||
|
||
interface AnimatedShinyTextProps { | ||
children: ReactNode; | ||
variant?: VariantProps<typeof textVariants>["variant"]; | ||
className?: string; | ||
} | ||
|
||
export function AnimatedText({ | ||
children, | ||
variant, | ||
className, | ||
}: AnimatedShinyTextProps) { | ||
return ( | ||
<span className={cn("s-relative s-inline-block", className)}> | ||
<span className={textVariants({ variant })}>{children}</span> | ||
<span className={animVariants({ variant })}>{children}</span> | ||
</span> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Meta } from "@storybook/react"; | ||
import React from "react"; | ||
|
||
import { AnimatedText } from "../index_with_tw_base"; | ||
|
||
const meta = { | ||
title: "Primitives/AnimatedText", | ||
component: AnimatedText, | ||
} satisfies Meta<typeof AnimatedText>; | ||
|
||
export default meta; | ||
|
||
export function AnimatedShinyTextDemo() { | ||
return ( | ||
<div className="s-flex s-gap-3"> | ||
<div className="s-z-10 s-flex s-min-h-64 s-flex-col s-items-center s-justify-center s-gap-4"> | ||
<div className="s-rounded-2xl s-bg-muted s-p-4"> | ||
<AnimatedText>Thinking...</AnimatedText> | ||
</div> | ||
|
||
<div className="s-rounded-2xl s-bg-muted s-p-4"> | ||
<AnimatedText>Thinking a long time</AnimatedText> | ||
</div> | ||
|
||
<div className="s-rounded-2xl s-bg-muted s-p-4"> | ||
<AnimatedText>Thinking a long long long long time</AnimatedText> | ||
</div> | ||
</div> | ||
<div className="s-z-10 s-flex s-min-h-64 s-flex-col s-items-center s-justify-center s-gap-4"> | ||
<div className="s-rounded-2xl s-bg-highlight-50 s-p-4"> | ||
<AnimatedText variant="highlight">Thinking...</AnimatedText> | ||
</div> | ||
|
||
<div className="s-rounded-2xl s-bg-highlight-50 s-p-4"> | ||
<AnimatedText variant="highlight">Thinking a long time</AnimatedText> | ||
</div> | ||
|
||
<div className="s-rounded-2xl s-bg-highlight-50 s-p-4"> | ||
<AnimatedText variant="highlight"> | ||
Thinking a long long long long time | ||
</AnimatedText> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters