Skip to content

Commit

Permalink
[RSN-43] - Implemented card component with variants (to refactor) (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
wzarek authored Jun 6, 2024
1 parent d1ca7f0 commit 15a9c31
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Client/reasn-client/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["prettier-plugin-tailwindcss"]
}
1 change: 1 addition & 0 deletions Client/reasn-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"jest-fetch-mock": "^3.0.3",
"lint-staged": "^15.2.2",
"prettier": "^3.1.1",
"prettier-plugin-tailwindcss": "^0.6.1",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"turbo": "latest"
Expand Down
123 changes: 123 additions & 0 deletions Client/reasn-client/packages/ui/src/components/Card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import React from "react";

const MOCK_IMG_URL =
"https://res.klook.com/images/fl_lossy.progressive,q_65/c_fill,w_1200,h_630/w_80,x_15,y_15,g_south_west,l_Klook_water_br_trans_yhcmh3/activities/tsah7c9evnal289z5fig/IMG%20Worlds%20of%20Adventure%20Admission%20Ticket%20in%20Dubai%20-%20Klook.jpg";

export enum CardVariant {
Big,
Tile,
List,
}

export interface CardProps {
variant: CardVariant;
event: string; // todo: add event after RSN-9
}

export const Card = (props: Readonly<CardProps>) => {
const { variant, event } = props;
return (
<div>
{variant === CardVariant.Big && <CardBig event={event} />}
{variant === CardVariant.Tile && <CardTile event={event} />}
{variant === CardVariant.List && <CardList event={event} />}
</div>
);
};

const CardBig = ({ event }: { event: string }) => {
return (
<div className="relative h-[30vh] w-[30vw] overflow-hidden rounded-3xl">
<img
src={MOCK_IMG_URL}
alt=""
className="absolute left-0 top-0 -z-10 w-full"
/>
<div className="flex h-[45%] w-full flex-col gap-2 bg-[#232326ee] p-4 text-[#F7F8F8]">
<div className="flex gap-2 text-xs text-[#cacaca]">
<p className="rounded-md bg-[#4b4e52] px-[5px] py-[1px]">#abcd</p>
<p className="rounded-md bg-[#4b4e52] px-[5px] py-[1px]">#abcd</p>
<p className="rounded-md bg-[#4b4e52] px-[5px] py-[1px]">#abcd</p>
<p className="rounded-md bg-[#4b4e52] px-[5px] py-[1px]">#abcd</p>
</div>
<h2 className="w-1/2 break-words text-2xl font-semibold">
Koncert fagaty na PWR w C-16
</h2>
</div>
<div className="absolute right-4 top-0 flex h-[45%] flex-col justify-center gap-2 py-4">
<span className="flex h-8 w-8 cursor-pointer items-center justify-center rounded-full bg-[#0f0f0f80] p-2 font-semibold text-green-500 duration-300 hover:bg-[#0f0f0f]">
+
</span>
<span className="flex h-8 w-8 cursor-pointer items-center justify-center rounded-full bg-[#0f0f0f80] p-2 font-semibold text-blue-400 duration-300 hover:bg-[#0f0f0f]">
?
</span>
</div>
</div>
);
};

const CardTile = ({ event }: { event: string }) => {
return (
<div className="group relative h-64 w-48 overflow-clip rounded-3xl">
<img
src={MOCK_IMG_URL}
alt=""
className="absolute left-0 top-0 -z-10 h-full object-cover"
/>
<div className="relative flex h-1/2 w-full flex-col gap-2 bg-[#232326ee] p-4 text-[#F7F8F8]">
<div className="flex flex-wrap gap-1 text-xs text-[#cacaca]">
<p className="rounded-md bg-[#4b4e52] px-[5px] py-[1px]">#abcd</p>
<p className="rounded-md bg-[#4b4e52] px-[5px] py-[1px]">#abcd</p>
<p className="rounded-md bg-[#4b4e52] px-[5px] py-[1px]">#abcd</p>
<p className="rounded-md bg-[#4b4e52] px-[5px] py-[1px]">#abcd</p>
</div>
<h2 className="w-4/5 break-words text-base font-semibold">
Koncert fagaty na PWR w C-16
</h2>
</div>
<div className="absolute bottom-0 left-0 hidden w-full flex-row justify-center gap-2 bg-[#232326ee] py-2 group-hover:flex">
<span className="flex h-6 w-6 cursor-pointer items-center justify-center rounded-full bg-[#0f0f0f80] p-1 text-sm font-semibold text-green-500 duration-300 hover:bg-[#0f0f0f]">
+
</span>
<span className="flex h-6 w-6 cursor-pointer items-center justify-center rounded-full bg-[#0f0f0f80] p-1 text-sm font-semibold text-blue-400 duration-300 hover:bg-[#0f0f0f]">
?
</span>
</div>
</div>
);
};

const CardList = ({ event }: { event: string }) => {
return (
<div className="group relative h-36 w-full overflow-hidden rounded-3xl">
<img
src={MOCK_IMG_URL}
alt=""
className="absolute left-0 top-0 -z-10 w-full"
/>
<div className="flex h-full w-2/3 flex-col gap-2 bg-[#232326ee] p-4 text-[#F7F8F8]">
<div className="flex gap-2 text-xs text-[#cacaca]">
<p className="rounded-md bg-[#4b4e52] px-[5px] py-[1px]">#abcd</p>
<p className="rounded-md bg-[#4b4e52] px-[5px] py-[1px]">#abcd</p>
<p className="rounded-md bg-[#4b4e52] px-[5px] py-[1px]">#abcd</p>
<p className="rounded-md bg-[#4b4e52] px-[5px] py-[1px]">#abcd</p>
</div>
<h2 className="w-4/5 break-words text-2xl font-semibold">
Koncert fagaty na PWR w C-16
</h2>
<p className="text-sm text-[#cacaca]">
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Architecto
et saepe, iste sequi deleniti ducimus est
</p>
</div>
<div className="absolute right-0 top-0 hidden h-full flex-col justify-center gap-2 bg-[#232326ee] px-4 group-hover:flex">
<span className="flex h-8 w-8 cursor-pointer items-center justify-center rounded-full bg-[#0f0f0f80] p-2 font-semibold text-green-500 duration-300 hover:bg-[#0f0f0f]">
+
</span>
<span className="flex h-8 w-8 cursor-pointer items-center justify-center rounded-full bg-[#0f0f0f80] p-2 font-semibold text-blue-400 duration-300 hover:bg-[#0f0f0f]">
?
</span>
</div>
</div>
);
};
1 change: 1 addition & 0 deletions Client/reasn-client/packages/ui/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { Button, type ButtonProps } from "./button";
export { Card, type CardProps, CardVariant } from "./components/Card";
56 changes: 56 additions & 0 deletions Client/reasn-client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14195,6 +14195,61 @@ __metadata:
languageName: node
linkType: hard

"prettier-plugin-tailwindcss@npm:^0.6.1":
version: 0.6.1
resolution: "prettier-plugin-tailwindcss@npm:0.6.1"
peerDependencies:
"@ianvs/prettier-plugin-sort-imports": "*"
"@prettier/plugin-pug": "*"
"@shopify/prettier-plugin-liquid": "*"
"@trivago/prettier-plugin-sort-imports": "*"
"@zackad/prettier-plugin-twig-melody": "*"
prettier: ^3.0
prettier-plugin-astro: "*"
prettier-plugin-css-order: "*"
prettier-plugin-import-sort: "*"
prettier-plugin-jsdoc: "*"
prettier-plugin-marko: "*"
prettier-plugin-organize-attributes: "*"
prettier-plugin-organize-imports: "*"
prettier-plugin-sort-imports: "*"
prettier-plugin-style-order: "*"
prettier-plugin-svelte: "*"
peerDependenciesMeta:
"@ianvs/prettier-plugin-sort-imports":
optional: true
"@prettier/plugin-pug":
optional: true
"@shopify/prettier-plugin-liquid":
optional: true
"@trivago/prettier-plugin-sort-imports":
optional: true
"@zackad/prettier-plugin-twig-melody":
optional: true
prettier-plugin-astro:
optional: true
prettier-plugin-css-order:
optional: true
prettier-plugin-import-sort:
optional: true
prettier-plugin-jsdoc:
optional: true
prettier-plugin-marko:
optional: true
prettier-plugin-organize-attributes:
optional: true
prettier-plugin-organize-imports:
optional: true
prettier-plugin-sort-imports:
optional: true
prettier-plugin-style-order:
optional: true
prettier-plugin-svelte:
optional: true
checksum: 10c0/533006f456e4b4da43e7fc7d5218e464a3d9f32ae47deb2d654e51436cf3d3956ccf4e3b7ccacb71f47ab5b271668907c1f018ba9e5afa615d94c056d68c8630
languageName: node
linkType: hard

"prettier@npm:^3.1.1":
version: 3.1.1
resolution: "prettier@npm:3.1.1"
Expand Down Expand Up @@ -14700,6 +14755,7 @@ __metadata:
lint-staged: "npm:^15.2.2"
postcss: "npm:^8.4.38"
prettier: "npm:^3.1.1"
prettier-plugin-tailwindcss: "npm:^0.6.1"
tailwindcss: "npm:^3.4.3"
ts-jest: "npm:^29.1.2"
ts-node: "npm:^10.9.2"
Expand Down

0 comments on commit 15a9c31

Please sign in to comment.