Skip to content

Commit 0cd320c

Browse files
safinsinghraad1masumrjawesomeaaditgupta21
committed
new icons, copy, zoomed post
Co-authored-by: Raadwan Masum <[email protected]> Co-authored-by: Rohan Juneja <[email protected]> Co-authored-by: Aadit Gupta <[email protected]>
1 parent 78b07ae commit 0cd320c

File tree

12 files changed

+166
-33
lines changed

12 files changed

+166
-33
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"jsx-a11y/anchor-is-valid": 0,
3838
"jsx-a11y/no-static-element-interactions": 0,
3939
"jsx-a11y/click-events-have-key-events": 0,
40-
"no-alert": 0
40+
"no-alert": 0,
41+
"jsx-a11y/no-noninteractive-element-interactions": 0
4142
}
4243
}

components/UI/Card.tsx

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,76 @@ import { CardProps } from '../../lib/types'
44
import style from '../../styles/UI/Card.module.scss'
55

66
const Card = (props: CardProps) => {
7-
const { media, name, id, profilePic } = props
7+
const { media, name, id, profilePic, isZoomed } = props
88
const router = useRouter()
99

1010
return (
11-
<div className={style.cardWrapper}>
12-
<div className={style.card} onClick={() => router.push(`/post/${id}`)}>
13-
<div>
14-
<div className={style.profilePic}>
11+
<div
12+
className={
13+
isZoomed
14+
? `${style.cardWrapper} ${style.zoomedCardWrapper}`
15+
: style.cardWrapper
16+
}
17+
>
18+
<div
19+
className={isZoomed ? `${style.card} ${style.cardZoomed}` : style.card}
20+
>
21+
<div
22+
className={
23+
isZoomed
24+
? `${style.cardBar} ${style.zoomedCardBar}`
25+
: style.cardBar
26+
}
27+
>
28+
<div
29+
className={
30+
isZoomed
31+
? `${style.profilePic} ${style.zoomedProfilePic}`
32+
: style.profilePic
33+
}
34+
>
1535
<img
1636
src={profilePic}
1737
alt={`${name}'s profile`}
1838
className={style.profilePicImg}
1939
/>
2040
<h1>{name}</h1>
41+
<img
42+
src="/copy.svg"
43+
alt="copy to clipboard"
44+
className={style.copy}
45+
onClick={() => {
46+
navigator.clipboard.writeText(
47+
`https://webshare.team3749.org/post/${id}`
48+
)
49+
alert('Copied post link to clipboard!')
50+
}}
51+
/>
2152
</div>
2253
<h2>{media.title}</h2>
2354
</div>
2455
<img
2556
src={media.image}
2657
alt={`${name}'s post: ${media.title}`}
27-
className={style.cardImage}
58+
className={
59+
isZoomed
60+
? `${style.cardImage} ${style.zoomedCardImage}`
61+
: style.cardImage
62+
}
63+
onClick={() => router.push(`/post/${id}`)}
2864
/>
29-
<div className={style.tagCollection}>
65+
<div
66+
className={
67+
isZoomed
68+
? `${style.tagCollection} ${style.zoomedTagCollection}`
69+
: style.profilePic
70+
}
71+
>
3072
{media.tags.map((tag) => (
31-
<div className={style.tag}>
73+
<div
74+
className={style.tag}
75+
onClick={() => router.push(`/?tag=${tag}`)}
76+
>
3277
<div className={style.circle} />
3378
<p>{tag.replace('_', ' ')}</p>
3479
</div>

components/UI/Nav.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Image from 'next/image'
22
import Link from 'next/link'
3+
import { useRouter } from 'next/router'
34

45
import { logOut, useAuthState } from '../../lib/firebase'
56
import theme from '../../lib/theme'
@@ -9,11 +10,19 @@ import style from '../../styles/UI/Nav.module.scss'
910
const Nav = (props: NavProps) => {
1011
const { active } = props
1112
const [user, loading] = useAuthState()
13+
const router = useRouter()
1214

1315
return (
1416
<div className={style.nav}>
1517
<div>
16-
<Image src="/icon.png" alt="Site Icon" width={30} height={30} />
18+
<Image
19+
src="/icon.png"
20+
alt="Site Icon"
21+
width={30}
22+
height={30}
23+
className={style.button}
24+
onClick={() => router.push('/')}
25+
/>
1726
</div>
1827
<div>
1928
<Link href="/" passHref>

lib/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface CardProps {
99
tags: string[]
1010
}
1111
date: number
12+
isZoomed?: boolean
1213
}
1314

1415
export interface GridProps {

pages/index.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { useRouter } from 'next/router'
33
import Meta from '../components/SEO/Meta'
44
import Grid from '../components/UI/Grid'
55
import Nav from '../components/UI/Nav'
6-
import { getPosts, logOut, usePosts } from '../lib/firebase'
6+
import { getPosts, usePosts } from '../lib/firebase'
77
import { GridProps } from '../lib/types'
8-
import style from '../styles/UI/Index.module.scss'
98

109
export const getServerSideProps = async () => {
1110
const cards = await getPosts()
@@ -16,22 +15,19 @@ const Index = (props: GridProps) => {
1615
const { cards } = props
1716

1817
const router = useRouter()
19-
const posts = usePosts(cards)
18+
const rawPosts = usePosts(cards)
19+
20+
const realCards = !router.query.tag
21+
? rawPosts
22+
: rawPosts.filter((card) =>
23+
card.media.tags.includes(router.query.tag as string)
24+
)
2025

2126
return (
2227
<>
2328
<Meta />
2429
<Nav active="posts" />
25-
<Grid cards={posts} />
26-
<button
27-
onClick={async () => {
28-
await logOut()
29-
router.push('/login')
30-
}}
31-
type="button"
32-
>
33-
<img className={style.logOut} src="/logout.png" alt="Log Out" />
34-
</button>
30+
<Grid cards={realCards} />
3531
</>
3632
)
3733
}

pages/post/[slug].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const Slug = (props: CardPropsProp) => {
3535
<>
3636
<Meta />
3737
<Nav active="posts" />
38-
<Card {...trueCard} />
38+
<Card {...trueCard} isZoomed />
3939
</>
4040
)
4141
}

public/copy.svg

Lines changed: 1 addition & 0 deletions
Loading

public/vercel.svg

Lines changed: 0 additions & 4 deletions
This file was deleted.

styles/Globals.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,22 @@ textarea:focus,
2626
button:focus {
2727
outline: none !important;
2828
}
29+
30+
::selection {
31+
color: #0fbea7;
32+
background-color: #0fbea73a;
33+
}
34+
35+
::-webkit-scrollbar {
36+
width: 10px;
37+
}
38+
39+
::-webkit-scrollbar-thumb {
40+
border-radius: 3px;
41+
transition: all 0.2s;
42+
background: #0fbea793;
43+
}
44+
45+
::-webkit-scrollbar-thumb:hover {
46+
background: rgba(15, 190, 167, 0.808);
47+
}

styles/UI/Card.module.scss

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
height: 100%;
44
display: flex;
55
justify-content: center;
6+
word-wrap: break-all !important;
67
}
78

89
.profilePic {
910
display: flex;
11+
align-items: center;
12+
margin-bottom: 0.5rem;
1013
}
1114

1215
.profilePicImg {
@@ -27,28 +30,31 @@
2730
flex-direction: column;
2831
justify-content: space-between;
2932
align-items: flex-start;
30-
cursor: pointer;
33+
word-break: break-all !important;
3134

3235
&:hover {
3336
box-shadow: 0 2.5px 3.2px rgba(0, 0, 0, 0.048),
3437
0 8.3px 10.7px rgba(0, 0, 0, 0.072), 0 37px 48px rgba(0, 0, 0, 0.12);
3538
}
3639

40+
&:hover .copy {
41+
opacity: 1 !important;
42+
}
43+
3744
h1 {
3845
color: #111212;
39-
font-weight: 600;
40-
margin-bottom: 0.5rem;
4146
}
4247

4348
h2 {
4449
color: #111212;
4550
margin-bottom: 0.2rem;
51+
word-break: break-all !important;
4652
font-weight: 300;
4753
}
4854

49-
img {
50-
color: #111212;
55+
.cardImage {
5156
width: 100%;
57+
cursor: pointer;
5258
border-radius: 3px;
5359
}
5460

@@ -80,10 +86,64 @@
8086

8187
.tagCollection {
8288
display: flex;
89+
align-items: flex-end;
8390
width: 100%;
8491

8592
&:first-child {
8693
margin-right: 0.5rem;
8794
}
95+
96+
&:hover {
97+
cursor: pointer;
98+
}
99+
}
100+
}
101+
102+
.copy {
103+
opacity: 0;
104+
height: 19px;
105+
cursor: pointer;
106+
order: 2;
107+
margin-left: auto;
108+
}
109+
110+
.cardBar {
111+
width: 100%;
112+
}
113+
114+
.zoomedCardImage {
115+
max-width: 400px !important;
116+
}
117+
118+
.cardZoomed {
119+
box-shadow: none !important;
120+
.copy {
121+
display: none !important;
122+
}
123+
& > * {
124+
margin: 0.5rem;
88125
}
126+
align-items: center;
127+
justify-content: center;
128+
}
129+
130+
.zoomedCardBar {
131+
align-items: center;
132+
justify-content: center;
133+
text-align: center;
134+
margin: 0 auto;
135+
}
136+
137+
.zoomedProfilePic {
138+
align-items: center;
139+
justify-content: center;
140+
text-align: center;
141+
margin: 0 auto;
142+
}
143+
144+
.zoomedTagCollection {
145+
align-items: center;
146+
justify-content: center;
147+
text-align: center;
148+
margin: 0 auto;
89149
}

0 commit comments

Comments
 (0)