Skip to content

Event popup #11

Open
JCSnap wants to merge 7 commits into
mainfrom
add-event-popup
Open

Event popup #11
JCSnap wants to merge 7 commits into
mainfrom
add-event-popup

Conversation

@JCSnap

@JCSnap JCSnap commented Feb 11, 2023

Copy link
Copy Markdown

Added EventPopup under components to display events with a popup window
Added a placeholder SignUpButton under components for the popup

Added a placeholder SignUpButton under components for the popup
@JCSnap JCSnap requested a review from marcus-ong-qy February 11, 2023 12:18
by deleted "import EventPopup...." statement which was used for testing

@JCSnap JCSnap left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed accidental changes

@woowenjun99 woowenjun99 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi I have left some general comments for your code

@@ -0,0 +1,84 @@
import React from 'react'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try removing this line and see if it works?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old habits die hard; there is now no need to write this default import on every page in Next.js now (unless you're explicitely using the React object)

Suggested change
import React from 'react'

@@ -0,0 +1,24 @@
import React from 'react'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try removing this line and see if it works?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import React from 'react'

import React from 'react'
import styled from 'styled-components'

const SignUpButtonContainer = styled.button`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this component can be better renamed as a button as it seems to fulfil the functions of a button?

Suggested change
const SignUpButtonContainer = styled.button`
const SignUpButton = styled.button`

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm it conflicts with the function name if I name it as SignUpButton, is there any way around this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const SignUpButtonContainer = styled.button`
const StyledButton = styled.button`

Name it like this instead. Also, there's no need to make an exclusive button just for signups. Instead make a generic button component that can be customised (i.e. take in params that set its display text, onClick function etc.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

mb for not mentioning earlier during the meeting, but i've placed some codes in the sample-rhdevs-websites subfolders, which contains codes that might be useful, so do refer to them if you're unsure of how to make for e.g. a button, or u can just copy them if they work!

`

type Props = {
image: any

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid the use of the type any here. Judging from the use, it seemed to be a string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
image: any
image: string

yeap, since it's a URL, it's a string. Try to avoid using any

{isActive && (
<EventPopupContainer>
<CloseButton onClick={closePopup}>x</CloseButton>
<PopupImage src={defaultProps.image} alt="Event Image" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing the use of the img tag and use the <Image /> component from Next/Image instead.

Documentation
Reference Link

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap

Comment on lines +74 to +76
<PopupImage src={defaultProps.image} alt="Event Image" />
<PopupTitle>{defaultProps.title}</PopupTitle>
<PopupContent>{defaultProps.content}</PopupContent>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be

Suggested change
<PopupImage src={defaultProps.image} alt="Event Image" />
<PopupTitle>{defaultProps.title}</PopupTitle>
<PopupContent>{defaultProps.content}</PopupContent>
<PopupImage src={props.image} alt="Event Image" />
<PopupTitle>{props.title}</PopupTitle>
<PopupContent>{props.content}</PopupContent>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea I'm just using this as a placeholder for testing haha since I think they haven't confirmed the details of how the information will be passed

`

type Props = {
image: any

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using the any type in typescript

@@ -0,0 +1,84 @@
import React from 'react'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can consider removing this line

@marcus-ong-qy marcus-ong-qy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to visualise your component, and it seems good so far! But do remember for future PRs do include images of whatever you have done ya (e.g. below)

Also I've left some comment for you, do review them. Good job!

It'll be great if you could document your code as well: guide

image

Comment on lines +10 to +12
margin-top: 100px;
margin-left: 20%;
margin-right: 20%;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these can be all expressed in one line i.e. margin: .... Go and find out how to use CSS shorthands :)

}
`

const PopupImage = styled.img`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Next.js Image component instead, as wen jun has mentioned as well

Comment on lines +33 to +34
padding-top: 30px;
padding-bottom: 50px;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, use CSS shorthand

Comment on lines +54 to +61
const defaultProps = {
image:
'https://images.unsplash.com/photo-1481349518771-20055b2a7b24?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8NHx8cmFuZG9tfGVufDB8fDB8fA%3D%3D&w=1000&q=80',
title: 'Valentines Day Event',
content:
"Still thinking of what to get your friends or that special someone for VALENTINES DAY? RVC SP got you!!! With a wide assortment of gifts from fresh flowers and preserved flowers , there's bound to be something for everyone! As all stocks are limited, fill up the pre order form HERE to get FIRST DIBS on your items! P.S. Due to unforeseen circumstances, our crochet flowers will not be sold anymore but fret not! The other options are still available so faster PREORDER NOWWWWAll profits will be channelled to support the welfare of our beneficiaries so DONT WAIT ANYMORE!!! Show your love to your friends/ boo and do a good deed today!",
isActive: true,
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rmb to remove these ya

Comment on lines +11 to +12
margin-top: 50px;
margin-left: auto;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorthand

JCSnap and others added 4 commits February 16, 2023 19:59
1. Removed import react
2. Changed SignUpButton to generic button that takes in onClick function
3. Changed img to using <Image /> from Next
4. Changed img type to String
5. Added documentation for EventPopUp
6. Deleted defaultProps placeholder
7. Changed CSS to use shorthands
2. Made the Popup container more responsive by reducing
   left and right margins for smaller screens
@JCSnap JCSnap requested a review from marcus-ong-qy February 17, 2023 04:13

@marcus-ong-qy marcus-ong-qy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much better! just work on writing the documrntation, and a few more comments

Comment thread components/EventPopup.tsx
Comment on lines +58 to +62
/**
*
* @returns A popup that displays the event details and sign up button
*
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread components/EventPopup.tsx
Comment on lines +71 to +81
<div>
{isActive && (
<EventPopupContainer>
<CloseButton onClick={closePopup}>x</CloseButton>
<PopupImage src={props.image} alt="Event Image" />
<PopupTitle>{props.title}</PopupTitle>
<PopupContent>{props.content}</PopupContent>
<SignUpButton />
</EventPopupContainer>
)}
</div>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div>
{isActive && (
<EventPopupContainer>
<CloseButton onClick={closePopup}>x</CloseButton>
<PopupImage src={props.image} alt="Event Image" />
<PopupTitle>{props.title}</PopupTitle>
<PopupContent>{props.content}</PopupContent>
<SignUpButton />
</EventPopupContainer>
)}
</div>
<>
{isActive && (
<EventPopupContainer>
<CloseButton onClick={closePopup}>x</CloseButton>
<PopupImage src={props.image} alt="Event Image" />
<PopupTitle>{props.title}</PopupTitle>
<PopupContent>{props.content}</PopupContent>
<SignUpButton />
</EventPopupContainer>
)}
</>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if outermost div is not styled (i.e. dummy div), then can just use a blank tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants