Skip to content

Commit

Permalink
Add new ShimmerBox component (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattias800 committed Sep 1, 2023
1 parent 04dd20e commit 220a61d
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.shimmerBox {
display: inline-block;
position: relative;
overflow: hidden;
background-color: #dddbdd;

&::after {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
transform: translateX(-100%);
background-image: linear-gradient(
90deg,
rgba(255, 255, 255, 0) 0,
rgba(255, 255, 255, 0.2) 20%,
rgba(255, 255, 255, 0.5) 60%,
rgba(255, 255, 255, 0)
);
animation: shimmer 2s infinite;
content: "";
}

@keyframes shimmer {
100% {
transform: translateX(100%);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Box, Column, Row, Space } from "@stenajs-webui/core";
import * as React from "react";
import { ShimmerBox } from "./ShimmerBox";

export default {
title: "elements/ShimmerBox",
component: ShimmerBox,
};

export const Demo = () => (
<Row width={"400px"} shadow={"box"}>
<Box flex={4} indent={2} spacing={2}>
<Column data-testid={"sailing-summary-cell"} alignItems={"flex-start"}>
<ShimmerBox height={"1.8rem"} width={"110px"} borderRadius={"8px"} />
<Space />
<ShimmerBox height={"1.4rem"} width={"50px"} borderRadius={"8px"} />
<Space />
<ShimmerBox height={"1.4rem"} width={"100px"} borderRadius={"8px"} />
</Column>
</Box>
<Box indent={2} spacing={2}>
<Column alignItems={"flex-end"} height={"76px"}>
<ShimmerBox width={"100px"} height={"2.0rem"} borderRadius={"8px"} />
</Column>
</Box>
</Row>
);
13 changes: 13 additions & 0 deletions packages/elements/src/components/ui/shimmer-box/ShimmerBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Box, BoxProps } from "@stenajs-webui/core";
import cx from "classnames";
import * as React from "react";
import styles from "./ShimmerBox.module.css";

export interface ShimmerBoxProps extends BoxProps {}

export const ShimmerBox: React.FC<ShimmerBoxProps> = ({
className,
...props
}) => {
return <Box className={cx(styles.shimmerBox, className)} {...props} />;
};
1 change: 1 addition & 0 deletions packages/elements/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ export * from "./components/ui/dialog/UseDialog";
export * from "./components/ui/dialog/UseDialogPromise";
export * from "./components/ui/dialog/drawer/UseDrawerDialog";
export * from "./components/ui/dialog/modal/UseModalDialog";
export * from "./components/ui/shimmer-box/ShimmerBox";

0 comments on commit 220a61d

Please sign in to comment.