Skip to content

Commit 4414e40

Browse files
committed
feat: add ShimmerText component with simplified API
- Create ShimmerText component that wraps any text with shimmer effect - Component inherits text size from parent (no size prop needed) - Rename all CSS from glimmer to shimmer - Add simple Storybook stories demonstrating usage
1 parent 1f43ef8 commit 4414e40

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// kilocode_change - new file
2+
import React from "react"
3+
import type { Meta, StoryObj } from "@storybook/react-vite"
4+
import { ShimmerText } from "../../../webview-ui/src/components/ui/shimmer-text"
5+
6+
const meta = {
7+
title: "Components/ShimmerText",
8+
component: ShimmerText,
9+
tags: ["autodocs"],
10+
argTypes: {
11+
children: {
12+
control: "text",
13+
description: "The text content to display with shimmer effect",
14+
},
15+
asChild: {
16+
control: "boolean",
17+
description: "Render as child element instead of wrapper span",
18+
},
19+
},
20+
args: {
21+
children: "API Request...",
22+
},
23+
decorators: [
24+
(Story) => (
25+
<div className="w-full max-w-4xl mx-auto bg-[var(--vscode-editor-background)] p-8">
26+
<Story />
27+
</div>
28+
),
29+
],
30+
} satisfies Meta<typeof ShimmerText>
31+
32+
export default meta
33+
type Story = StoryObj<typeof meta>
34+
35+
export const Default: Story = {
36+
args: {
37+
children: "API Request...",
38+
},
39+
}
40+
41+
export const Examples: Story = {
42+
render: () => (
43+
<div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>
44+
<div style={{ fontSize: "12px" }}>
45+
<ShimmerText>Small text with shimmer</ShimmerText>
46+
</div>
47+
<div style={{ fontSize: "16px" }}>
48+
<ShimmerText>Normal text with shimmer</ShimmerText>
49+
</div>
50+
<div style={{ fontSize: "24px" }}>
51+
<ShimmerText>Large text with shimmer</ShimmerText>
52+
</div>
53+
<ShimmerText>
54+
<span className="codicon codicon-loading" style={{ marginRight: "8px" }} />
55+
Loading with icon
56+
</ShimmerText>
57+
<ShimmerText>
58+
<span className="codicon codicon-sparkle" style={{ fontSize: "64px" }} />
59+
</ShimmerText>
60+
</div>
61+
),
62+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as React from "react"
2+
import { Slot } from "@radix-ui/react-slot"
3+
import { cn } from "@/lib/utils"
4+
5+
export interface ShimmerTextProps extends React.HTMLAttributes<HTMLSpanElement> {
6+
children: React.ReactNode
7+
asChild?: boolean
8+
}
9+
10+
const ShimmerText = React.forwardRef<HTMLSpanElement, ShimmerTextProps>(
11+
({ className, children, asChild = false, ...props }, ref) => {
12+
const Comp = asChild ? Slot : "span"
13+
14+
return (
15+
<Comp ref={ref} {...props} className={cn("shimmer-text", className)}>
16+
{children}
17+
</Comp>
18+
)
19+
},
20+
)
21+
ShimmerText.displayName = "ShimmerText"
22+
23+
export { ShimmerText }

webview-ui/src/kilocode.css

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,45 @@
6060
.animate-message-highlight {
6161
animation: message-highlight 1s ease-out forwards;
6262
}
63+
64+
/* Shimmer text animation - horizontal shimmer effect */
65+
@keyframes shimmer {
66+
0% {
67+
background-position: 200% center;
68+
}
69+
100% {
70+
background-position: -200% center;
71+
}
72+
}
73+
74+
@keyframes progress-indicator-spin {
75+
0% {
76+
transform: rotate(0deg);
77+
}
78+
100% {
79+
transform: rotate(360deg);
80+
}
81+
}
82+
83+
.shimmer-text {
84+
--shimmer-base: color-mix(in srgb, var(--vscode-descriptionForeground) 80%, black);
85+
--shimmer-highlight: color-mix(in srgb, var(--shimmer-base) 70%, white);
86+
87+
color: var(--shimmer-base);
88+
background: linear-gradient(
89+
90deg,
90+
var(--shimmer-base) 0%,
91+
var(--shimmer-base) 35%,
92+
var(--shimmer-highlight) 45%,
93+
var(--shimmer-highlight) 50%,
94+
var(--shimmer-highlight) 55%,
95+
var(--shimmer-base) 65%,
96+
var(--shimmer-base) 100%
97+
);
98+
background-size: 200% 100%;
99+
-webkit-background-clip: text;
100+
background-clip: text;
101+
-webkit-text-fill-color: transparent;
102+
display: inline-block;
103+
animation: shimmer 2.5s linear infinite;
104+
}

0 commit comments

Comments
 (0)