Skip to content

Commit 3dffae7

Browse files
committed
Create grid-syste,
1 parent 03f3904 commit 3dffae7

File tree

13 files changed

+83
-340
lines changed

13 files changed

+83
-340
lines changed

.prettierrc

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
semi: true,
3-
trailingComma: 'es5',
4-
singleQuote: true,
5-
tabWidth: 2,
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"tabWidth": 2
66
}

src/App.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ html {
4949

5050
@media (max-width: 350px) {
5151
.App {
52-
width: 90%
52+
width: 95%
5353
}
5454
}
5555

src/components/Card/index.tsx

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
import React from 'react';
1+
import React, { useEffect, useState, useRef, ReactChild } from 'react';
2+
23
import './styles.scss';
3-
import '../../constants/colors.scss';
44

55
interface CardProps {
6-
title?: string;
7-
logo?: string;
8-
link?: string;
9-
color?: string;
10-
newTab?: boolean;
6+
children?: ReactChild;
7+
style?: object;
118
}
129

13-
const Card: React.FC<CardProps> = ({ title, logo, link, color, newTab }: CardProps) => {
14-
const isNewTab = newTab ? '_blank' : '_self';
15-
const className = 'card ' + color;
10+
const Card: React.FC<CardProps> = ({children, style}: CardProps) => {
11+
const [height, setHeight] = useState(0);
12+
const containerRef = useRef<HTMLDivElement>(null);
13+
14+
15+
useEffect(() => {
16+
const updateSquare = () => {
17+
const current = containerRef.current;
18+
setHeight(height => current ? current.offsetWidth : height);
19+
}
20+
updateSquare();
21+
window.addEventListener("resize", () => updateSquare());
22+
23+
return (() => window.removeEventListener("resize", () => updateSquare()));
24+
}, [])
1625

1726
return (
18-
<a href={link} className="cardLink" target={isNewTab}>
19-
<div className={className}>
20-
<div className="imageView">
21-
<span className="material-icons-round md-48">{logo}</span>
22-
</div>
23-
<div className="label">{title}</div>
24-
</div>
25-
</a>
27+
<div
28+
className="box"
29+
ref={containerRef}
30+
style={{...style, ...{height: height}}}
31+
>
32+
{children}
33+
</div>
2634
);
27-
};
28-
29-
Card.defaultProps = {
30-
title: '',
31-
logo: 'help_outline',
32-
link: 'smu.edu.sg',
33-
color: 'red',
34-
newTab: false,
35-
};
35+
}
3636

3737
export default Card;

src/components/Card/styles.scss

+5-90
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,5 @@
1-
.card {
2-
border-radius: 16px;
3-
width: 230px;
4-
text-decoration: none;
5-
6-
display: flex;
7-
align-items: center;
8-
justify-content: flex-start;
9-
10-
transition: filter 200ms ease-in;
11-
}
12-
13-
.card:hover {
14-
filter: brightness(125%);
15-
}
16-
17-
.cardLink {
18-
border-radius: 16px;
19-
text-decoration: none;
20-
}
21-
22-
.imageView {
23-
display: flex;
24-
align-items: center;
25-
justify-content: center;
26-
width: 90px;
27-
height: 90px;
28-
}
29-
30-
.material-icons-round {
31-
font-size: 52px;
32-
color: white;
33-
}
34-
35-
.label {
36-
font-size: 24px;
37-
font-weight: 600;
38-
color: white;
39-
}
40-
41-
/* Mobile Friendly */
42-
43-
@media (max-width: 750px) {
44-
.card {
45-
border-radius: 12px;
46-
width: 90%;
47-
padding-bottom: 8px;
48-
padding-top: 8px;
49-
}
50-
51-
.imageView {
52-
display: flex;
53-
width: 60px;
54-
height: 60px;
55-
}
56-
57-
.label {
58-
font-size: 16px;
59-
padding-right: 8px;;
60-
}
61-
62-
.material-icons-round {
63-
font-size: 36px;
64-
}
65-
}
66-
67-
@media (max-width: 480px) {
68-
.card {
69-
border-radius: 12px;
70-
width: 100%;
71-
flex-direction: row;
72-
align-items: center;
73-
justify-content: flex-start;
74-
width: 90%;
75-
padding-left: 8px;
76-
padding-bottom: 8px;
77-
padding-top: 8px;
78-
}
79-
80-
.imageView {
81-
display: flex;
82-
justify-content: flex-start;
83-
width: 50px;
84-
height: 50px;
85-
}
86-
87-
.label {
88-
font-size: 16px;
89-
}
90-
}
1+
.box {
2+
border: 3px solid #0A0A0A;
3+
box-sizing: border-box;
4+
width: 100%;
5+
}

src/components/CardList/index.tsx

-46
This file was deleted.

src/components/CardList/styles.scss

-53
This file was deleted.

src/components/Footer/index.tsx

-22
This file was deleted.

src/components/Footer/styles.scss

-69
This file was deleted.

src/components/NavBar/styles.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// background-color: pink;
88

9-
@media screen and (max-width: 650px) {
9+
@media screen and (max-width: 720px) {
1010
justify-content: center;
1111
}
1212

0 commit comments

Comments
 (0)