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

feat(components): created components #6

Merged
merged 2 commits into from
Jan 12, 2024
Merged
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
5 changes: 5 additions & 0 deletions public/assets/close-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions src/components/Modal/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from "react";
import clsx from "clsx";

import closeIcon from "../../../public/assets/close-icon.svg";

export interface IModal {
close(): void;
isOpen: boolean;
externalStyles: string;
content: React.ReactNode;
}

export const Modal = ({ isOpen, content, close, externalStyles }: IModal) => {
return (
<div>
{isOpen && (
<div className={clsx(externalStyles, "modal-dialog")}>
<div className="header-container">
<img
onClick={close}
src={closeIcon}
alt="Close icon"
className="close"
/>
</div>
{content}
</div>
)}
{isOpen && <div onClick={close} className="drawer-container" />}
</div>
);
};
20 changes: 20 additions & 0 deletions src/components/Pill/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import clsx from "clsx";

export interface IPill {
label: string;
color: string;
bgColor: string;
externalStyles: string;
}

export const Pill = ({ label, color, bgColor, externalStyles }: IPill) => {
return (
<div
className={clsx(externalStyles, "container-pill")}
style={{ backgroundColor: bgColor }}
>
<span style={{ color: color }}>{label}</span>
</div>
);
};
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "./scss/styles.scss";

export * from "./components/Pill";
export * from "./components/Modal";
export * from "./components/Button";
export * from "./components/Sidebar";
export * from "./components/Container";
Expand Down
29 changes: 29 additions & 0 deletions src/scss/components/Modal/_modal.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.modal-dialog {
top: 50%;
left: 50%;
z-index: 1000;
padding: 24px;
position: fixed;
min-width: 210px;
background-color: #fff;
transform: translate(-50%, -50%);
}

.header-container {
display: flex;
justify-content: end;
}

.drawer-container {
top: 0;
left: 0;
z-index: 999;
width: 100vw;
height: 100vh;
position: fixed;
background-color: rgba(0, 0, 0, 0.5);
}

.close {
cursor: pointer;
}
9 changes: 9 additions & 0 deletions src/scss/components/Pill/_pill.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.container-pill {
display: flex;
padding: 8px 16px;
width: max-content;
align-items: center;
border-radius: 16px;
justify-content: center;
background-color: #F2F2F2;
}
2 changes: 2 additions & 0 deletions src/scss/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
@import "./base/palette";

// Components
@import "./components/Pill/pill";
@import "./components/Modal/modal";
@import "./components/Button/button";
@import "./components/Sidebar/sidebar";
@import "./components/Container/container";
Expand Down
28 changes: 28 additions & 0 deletions src/stories/Modal.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { useState } from "react";
import { Story } from "@storybook/react";

import { Modal, IModal } from "../components/Modal";

export default {
title: "Modal",
component: Modal,
};

const Template: Story<IModal> = (args) => {
const [open, setOpen] = useState(true);

const handleClose = () => {
setOpen(false);
};

return <Modal {...args} isOpen={open} close={handleClose} />;
};

export const ModalItem = Template.bind({});
ModalItem.args = {
content: (
<div style={{ height: 100 }}>
<span>Modal example</span>
</div>
),
};
16 changes: 16 additions & 0 deletions src/stories/Pill.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import { Story } from "@storybook/react";

import { Pill, IPill } from "../components/Pill";

export default {
title: "Pill",
component: Pill,
};

const Template: Story<IPill> = (args) => <Pill {...args} />;

export const PillItem = Template.bind({});
PillItem.args = {
label: "Pill example",
};