Skip to content

Commit ce330fb

Browse files
committed
Made files structures and some styling
1 parent 803f8fe commit ce330fb

File tree

14 files changed

+484
-193
lines changed

14 files changed

+484
-193
lines changed

src/App.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Footer from "./layouts/Footer";
2+
import Header from "./layouts/Header";
3+
import Sidebar from "./layouts/Sidebar";
4+
import SnippetList from "./layouts/SnippetList";
5+
6+
const App = () => {
7+
return (
8+
<div className="container">
9+
<Header />
10+
<div className="heading">
11+
<h1 className="main-title">
12+
Made to save your <span className="text-highlight">time.</span>
13+
</h1>
14+
<p>
15+
Find the necessary snippet in seconds, across multiple languages. Just
16+
search and copy!
17+
</p>
18+
</div>
19+
<main>
20+
<Sidebar />
21+
<SnippetList />
22+
</main>
23+
<hr className="divider" />
24+
<Footer />
25+
</div>
26+
);
27+
};
28+
29+
export default App;

src/components/Button.tsx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,42 @@ type ButtonProps = {
44
as?: "button" | "link";
55
href?: string;
66
children: ReactNode;
7+
className?: string;
78
};
89

9-
const Button = ({ as = "button", href, children, ...props }: ButtonProps) => {
10+
type IconButtonProps = {
11+
children: ReactNode;
12+
className?: string;
13+
};
14+
15+
const Button = ({
16+
as = "button",
17+
href,
18+
className,
19+
children,
20+
...props
21+
}: ButtonProps) => {
1022
return as === "button" ? (
11-
<button className="button" {...props}>
23+
<button className={`button ${className}`} {...props}>
1224
{children}
1325
</button>
1426
) : (
15-
<a className="button" href={href} {...props}>
27+
<a className={`button ${className}`} href={href} {...props}>
1628
{children}
1729
</a>
1830
);
1931
};
2032

33+
export const IconButton = ({
34+
className,
35+
children,
36+
...props
37+
}: IconButtonProps) => {
38+
return (
39+
<button className={`button--icon ${className}`} {...props}>
40+
{children}
41+
</button>
42+
);
43+
};
44+
2145
export default Button;

src/components/Category.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { CategoryProps } from "../types";
2+
3+
const Category = ({ title }: CategoryProps) => {
4+
return (
5+
<li>
6+
<a href="#">{title}</a>
7+
</li>
8+
);
9+
};
10+
11+
export default Category;

src/components/CategoryList.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { CategoryProps } from "../types";
2+
import Category from "./Category";
3+
4+
const CategoryList = () => {
5+
const sampleData: CategoryProps[] = [
6+
{
7+
title: "DOM Manipulation",
8+
},
9+
{
10+
title: "API Requests",
11+
},
12+
{
13+
title: "Local Storage",
14+
},
15+
{
16+
title: "Performance Optimization",
17+
},
18+
{
19+
title: "Date and Time",
20+
},
21+
];
22+
23+
return (
24+
<ul role="list">
25+
{sampleData.map((category) => (
26+
<Category {...category} />
27+
))}
28+
</ul>
29+
);
30+
};
31+
32+
export default CategoryList;

src/components/Icons.tsx

Lines changed: 169 additions & 112 deletions
Large diffs are not rendered by default.

src/components/LanguageSwitch.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import slugify from "../utils/slugify";
2+
3+
const LanguageSwitch = () => {
4+
const sampleData = ["JavaScript", "Python", "Java"];
5+
6+
return (
7+
<select id="languages">
8+
{sampleData.map((lan) => (
9+
<option value={slugify(lan)}>{lan}</option>
10+
))}
11+
</select>
12+
);
13+
};
14+
15+
export default LanguageSwitch;

src/components/SnippetCard.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { SnippetCardProps } from "../types";
2+
import { IconButton } from "./Button";
3+
import { CopyIcon, ExpandIcon } from "./Icons";
4+
5+
const SnippetCard = ({ title }: SnippetCardProps) => {
6+
return (
7+
<li className="snippet">
8+
<div className="snippet__preview">
9+
<IconButton className="snippet__copy">
10+
<CopyIcon />
11+
</IconButton>
12+
</div>
13+
<div className="snippet__content">
14+
<h3>{title}</h3>
15+
<IconButton>
16+
<ExpandIcon />
17+
</IconButton>
18+
</div>
19+
</li>
20+
);
21+
};
22+
23+
export default SnippetCard;

src/layouts/Header.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import Button from "../ui/Button";
2-
import { GitHubIcon } from "../ui/Icons";
3-
import Logo from "../ui/Logo";
4-
import SearchInput from "../ui/SearchInput";
1+
import Button from "../components/Button";
2+
import { GitHubIcon } from "../components/Icons";
3+
import Logo from "../components/Logo";
4+
import SearchInput from "../components/SearchInput";
55

66
const Header = () => {
77
return (

src/layouts/Sidebar.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import CategoryList from "../components/CategoryList";
2+
import LanguageSwitch from "../components/LanguageSwitch";
3+
4+
const Sidebar = () => {
5+
return (
6+
<aside>
7+
<LanguageSwitch />
8+
<CategoryList />
9+
</aside>
10+
);
11+
};
12+
13+
export default Sidebar;

src/layouts/SnippetList.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import SnippetCard from "../components/SnippetCard";
2+
import { SnippetCardProps } from "../types";
3+
4+
const SnippetList = () => {
5+
const sampleData: SnippetCardProps[] = [
6+
{
7+
title: "GET Request",
8+
},
9+
{
10+
title: "POST Request",
11+
},
12+
];
13+
14+
return (
15+
<section>
16+
<h2>API Requests</h2>
17+
<ul role="list">
18+
{sampleData.map((snippet) => (
19+
<SnippetCard {...snippet} />
20+
))}
21+
</ul>
22+
</section>
23+
);
24+
};
25+
26+
export default SnippetList;

0 commit comments

Comments
 (0)