Skip to content

Commit

Permalink
fix: gradient component
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardocasares committed Nov 1, 2020
1 parent 3eda767 commit 3bbf388
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/components/Gradient/index.ts

This file was deleted.

24 changes: 24 additions & 0 deletions src/components/Gradient/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { FC } from "react";
import gradient from "random-gradient";

export type Gradient = {
hash?: string;
direction?: "radial" | "vertical" | "horizontal";
};

export const Gradient: FC<Gradient> = ({
hash,
direction = "vertical",
...props
}) => (
<div
style={{
minWidth: "100%",
minHeight: "120px",
background: gradient(ensureHash(hash), direction),
}}
{...props}
/>
);

const ensureHash = (hash?: string) => hash || Math.random();

0 comments on commit 3bbf388

Please sign in to comment.