Skip to content

Commit

Permalink
feat: gradient component
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardocasares committed Oct 30, 2020
1 parent 6050134 commit 5265099
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/components/Card/style.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from "@emotion/styled";
import gradient from "random-gradient";
import { Gradient } from "@/components/Gradient";

export const Container = styled.div`
border-radius: var(--sz1);
Expand All @@ -9,14 +9,10 @@ export type Cover = {
hash: string;
};

export const Cover = styled.div<Cover>`
export const Cover = styled(Gradient)`
display: grid;
place-items: center;
min-width: 100%;
min-height: 120px;
border-top-left-radius: var(--sz1);
border-top-right-radius: var(--sz1);
background: ${({ hash }) => gradient(hash, "vertical")};
border-radius: var(--sz2) var(--sz2) 0 0;
`;

export const Title = styled.h3`
Expand Down
14 changes: 14 additions & 0 deletions src/components/Gradient/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import styled from "@emotion/styled";
import gradient from "random-gradient";

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

export const Gradient = styled.div<Gradient>`
min-width: 100%;
min-height: 120px;
background: ${({ hash, direction = "vertical" }) =>
gradient(hash, direction)};
`;

0 comments on commit 5265099

Please sign in to comment.