Skip to content

Commit b9e8d34

Browse files
✨ - feat: add Placeholder component
1 parent 204ca84 commit b9e8d34

File tree

5 files changed

+60
-0
lines changed

5 files changed

+60
-0
lines changed

src/components/typography/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ export * from "./h2";
55
export * from "./h3";
66
export * from "./hr";
77
export * from "./p";
8+
export * from "./placeholder";
9+
export * from "./ul";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./placeholder";
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.mykn-placeholder {
2+
--mykn-placeholder-color-dark: var(--typography-color-border);
3+
--mykn-placeholder-color-light: var(--typography-color-background-alt);
4+
5+
animation: shift-background var(--animation-duration-slow) infinite
6+
var(--animation-timing-function) reverse;
7+
background: linear-gradient(
8+
90deg,
9+
var(--mykn-placeholder-color-dark),
10+
var(--mykn-placeholder-color-light),
11+
var(--mykn-placeholder-color-dark)
12+
);
13+
background-size: 200% 100%;
14+
border: none;
15+
border-radius: 1em;
16+
display: inline-block;
17+
height: 1em;
18+
margin: 0;
19+
overflow: hidden;
20+
position: relative;
21+
width: 100%;
22+
}
23+
24+
@keyframes shift-background {
25+
0% {
26+
background-position: 0% 0%;
27+
}
28+
100% {
29+
background-position: 200% 0%;
30+
}
31+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
3+
import { Placeholder } from "./placeholder";
4+
5+
const meta: Meta<typeof Placeholder> = {
6+
title: "Typography/Placeholder",
7+
component: Placeholder,
8+
};
9+
10+
export default meta;
11+
type Story = StoryObj<typeof meta>;
12+
13+
export const PlaceholderComponent: Story = {};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import clsx from "clsx";
2+
import React from "react";
3+
4+
import "./placeholder.scss";
5+
6+
export type PlaceholderProps = React.ComponentProps<"hr">;
7+
8+
/**
9+
* Placeholder component, indicates that content is loading.
10+
*/
11+
export const Placeholder: React.FC<PlaceholderProps> = ({ ...props }) => (
12+
<hr className={clsx("mykn-placeholder")} aria-hidden={true} {...props} />
13+
);

0 commit comments

Comments
 (0)