Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added card component #219

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions content-scripts/components/Card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import jsx from "texsaur";
import Button from "./Button";

interface CardProps {
title: string;
description?: string;
imgSrc?: string;
subtitles?: string[];
button: string;
}

const Card: JSX.Component<CardProps> = ({ title, description, imgSrc, subtitles, button }) => {
let finalClassName = "se_card";

if (imgSrc && !subtitles && !description) {
finalClassName += " imgonly";
return(<div className={finalClassName} id="container">
{imgSrc && <img src={imgSrc} alt = "Card Image" />}
<div className="card__details">
<h2 className= "title">{title}</h2>
</div>
{button && (
<Button color= "primary" size="lg" title= {button}>
</Button>
)}
</div>);
} else if (!imgSrc && !subtitles && !description) {
finalClassName += " titlebutton";
return (<div className={finalClassName} id="container">
<div className="card_details">
<h2 className="title">{title}</h2>
</div>
{button && (
<Button color= "primary" size="lg" title= {button}>
</Button>
)}
</div>);
} else {
finalClassName += " default";
return (
<div className={finalClassName} id="container">
{imgSrc && <img src={imgSrc} alt="Card Image" />}
<div className="card__details">
<h2 className="title">{title}</h2>
{subtitles && subtitles.length > 0 && (
<div className="subtitles">
{subtitles[0]}
</div>
)}
{description && <p>{description}</p>}
</div>
{button && (
<Button color= "primary" size="lg" title= {button}>
</Button>
)}
</div>
);
}
};

export default Card;
37 changes: 36 additions & 1 deletion content-scripts/pages/components_page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import jsx from "texsaur";
import Button from "../components/Button";
import { Table } from "../components/Table";
import Icon from "../components/Icon";
import Card from "../components/Card";

const components = ["Icon", "Button", "Table"];
const components = ["Icon", "Button", "Table", "Cards"];

export function createComponentsPage() {
// TODO: remove this check
Expand Down Expand Up @@ -208,8 +209,42 @@ export function createComponentsPage() {
]}
/>
</Component>
{/* Card */}
<Component
name= "Card"
description="Our card component, that allows the creation of cards with different styles."
code={`
<Card
title="Default Card"
description="I have all attributes possible (i.e; image, title, description, subtitles and a button)"
subtitles={["Subtitle"]}
imgSrc="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcThD4or2R-Tpyokw8NzJyn-LXt6R8YK9Sih5w&s"
button="Click Me"
/>
`}>
<Card
title="Default Card"
description="I have all attributes possible (i.e; image, title, description, subtitles and a button)"
subtitles={["Subtitle"]}
imgSrc="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcThD4or2R-Tpyokw8NzJyn-LXt6R8YK9Sih5w&s"
button="Click Me"
/>
{/* <Card */}
{/* title ="Image Only" */}
{/* imgSrc="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcThD4or2R-Tpyokw8NzJyn-LXt6R8YK9Sih5w&s" */}
{/* button = "Click me" */}
{/* /> */}
{/* <Card */}
{/* title ="Title Button Card" */}
{/* button = "Click me" */}
{/* /> */}

</Component>

</div>

</div>

);

document.body.appendChild(page);
Expand Down
106 changes: 99 additions & 7 deletions css/card.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,102 @@
.se-card {
background-color: #f4f4f4;
border-radius: 8px;
padding: 0.5em 1em;
margin: 2em 0em;
.se_card {
background-color: #eeeeee;
padding: 8px;
border-radius: 12px;
border: 1px solid #eeeeee;
}

.se-card :is(h2, h3, h4) {
margin: 0;
#container {
max-width: 300px;
margin: 0 auto;
margin-top: 20vh;
}

.card__details {
padding: 16px 8px 8px 8px;
}

button:focus,
button:hover {
background-color: #F6F6F6;
color: #8C2D19;
}

button {
border: none;
padding: 12px 24px;
border-radius: 50px;
font-weight: 600;
color: #F6F6F6;
background-color: #8C2D19;
margin: 0 auto;
display: block;
transition: all 200ms ease-in-out;
cursor: pointer;
}

/* Default State */
.se_card.default .title {
font-size: 24px;
font-weight: 600;
color: #8C2D19;
margin-top: 16px;
}

.se_card.default .subtitles {
padding: 4px 8px;
border: 1px solid #8C2D19;
border-radius: 50px;
font-size: 12px;
font-weight: 600;
color: #000000;
}

.se_card.default p {
font-size: 14px;
color: #000000;
line-height: 150%;
}

.se_card.default img {
width: 100%;
border-radius: 12px;
height: 214px;
object-fit: cover;
}

/* Image-Only State */
.se_card.imgonly {
display: flex;
flex-direction: column;
align-items: center;
}

.se_card.imgonly img {
width: 100%;
border-radius: 12px;
height: 214px;
object-fit: cover;
}

.se_card.imgonly .title {
font-size: 24px;
font-weight: 600;
color: #8C2D19;
margin-top: 16px;
text-align: center;
}

/* Title + Button State */
.se_card.titlebutton {
display: flex;
flex-direction: column;
align-items: center;
}

.se_card.titlebutton .title {
font-size: 24px;
font-weight: 600;
color: #8C2D19;
margin-top: 16px;
text-align: center;
}
97 changes: 97 additions & 0 deletions css/components.css
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,100 @@
}
}
}


/* Card */
.se_card {
background-color: #eeeeee;
padding: 8px;
border-radius: 12px;
border: 1px solid #eeeeee;
}

#container {
max-width: 300px;
margin: 0 auto;
margin-top: 20vh;
}

.card__details {
padding: 16px 8px 8px 8px;
}



/* Default Card*/
.se_card.default .title {
font-size: 24px;
font-weight: 600;
color: #8C2D19;
margin-top: 16px;
}

.se_card.default .subtitles {
padding: 0;
border: 1px solid #8C2D19;
border-radius: 50px;
font-size: 14px;
font-weight: 600;
color: #000000;
display: inline-block;
white-space: nowrap;
}


.se_card.default p {
font-size: 14px;
color: #000000;
line-height: 150%;
}

.se_card.default img {
width: 100%;
border-radius: 12px;
height: 214px;
object-fit: cover;
}

/* Image-Only Card*/

.se_card.imgonly {
display: flex;
flex-direction: column;
align-items: center;
max-height: 400px;
overflow: hidden;
}

.se_card.imgonly img {
width: 100%;
border-radius: 12px;
height: 214px;
object-fit: cover;
}

.se_card.imgonly .title {
font-size: 24px;
font-weight: 600;
color: #8C2D19;
margin-top: 16px;
text-align: center;
}

/* Title + Button Card */
.se_card.titlebutton {
display: flex;
flex-direction: column;
align-items: center;
max-height: 110px;
overflow: hidden;
}

.se_card.titlebutton .title {
font-size: 5px;
font-weight: 200;
color: #8C2D19;
margin-top: 20px;
text-align: center;
}