-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kitu' of https://github.com/mdgspace/activity-leaderboard…
… into kitu
- Loading branch information
Showing
42 changed files
with
1,043 additions
and
583 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.modal-footer { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 0.5rem; | ||
font-weight: 600; | ||
a { | ||
text-decoration: none; | ||
} | ||
} | ||
|
||
.firstvisit-btn { | ||
background-color: #402aa4; | ||
border: none; | ||
color: white; | ||
padding: 0.5rem 1rem; | ||
border-radius: 5rem; | ||
border: 1px solid #402aa4; | ||
font-size: 1rem; | ||
} | ||
|
||
.firstvisit-btn:hover { | ||
background-color: whitesmoke; | ||
border: none; | ||
color: #402aa4; | ||
padding: 0.5rem 1rem; | ||
border-radius: 5rem; | ||
border: 1px solid #402aa4; | ||
font-size: 1rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useEffect, useState } from 'react'; | ||
import Popup from '../popup'; | ||
import './index.scss'; | ||
|
||
export default function FirstVisit() { | ||
const [show, setShow] = useState(false); | ||
useEffect(() => { | ||
const visit = localStorage.getItem('visit'); | ||
if (visit !== 'true') { | ||
localStorage.setItem('visit', 'true'); | ||
|
||
setShow(true); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<> | ||
{show && ( | ||
<Popup | ||
title={'Welcome to Activity Leaderboard!'} | ||
onClose={() => setShow(false)} | ||
footer={ | ||
<div className='modal-footer'> | ||
<h1> | ||
Google Summer of Code is a global, online program focused on | ||
bringing new contributors into open source software development. | ||
</h1> | ||
<a | ||
href='https://summerofcode.withgoogle.com/' | ||
target='blank' | ||
className='firstvisit-btn' | ||
> | ||
Visit GSOC | ||
</a> | ||
</div> | ||
} | ||
popup_zindex={{ overlay: 3000, modal: 4000 }} | ||
/> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
.popup-overlay { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
} | ||
|
||
.popup-modal { | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
background-color: white; | ||
border-radius: 10px; | ||
max-width: 500px; | ||
width: 100%; | ||
max-height: 67vh; | ||
overflow-y: auto; | ||
color: black; | ||
} | ||
|
||
.popup-title { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
border-bottom: 1px solid black; | ||
padding: 0.5em 1em 0.5em 1em; | ||
background-color: #402aa4; | ||
color: white; | ||
} | ||
|
||
.popup-body { | ||
text-align: center; | ||
padding: 0.5em 1em 0.5em 1em; | ||
} | ||
|
||
.popup-footer { | ||
display: flex; | ||
flex-direction: row-reverse; | ||
margin: 0.6em; | ||
} | ||
|
||
.close-btn { | ||
background: none; | ||
border: none; | ||
padding: 0.1em; | ||
color: white; | ||
} | ||
|
||
.modal-btn { | ||
width: 30px; | ||
height: 30px; | ||
background-color: transparent; | ||
border: none; | ||
color: white; | ||
border: 1px solid white; | ||
border-radius: 50%; | ||
} | ||
|
||
.modal-btn:hover { | ||
width: 30px; | ||
height: 30px; | ||
background-color: white; | ||
border: none; | ||
color: #402aa4; | ||
border: 1px solid #402aa4; | ||
border-radius: 50%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import './index.scss'; | ||
import ReactPortal from '../reactPortal'; | ||
import { ReactNode } from 'react'; | ||
type _POPUP_PROPS = { | ||
onClose?: () => void; | ||
onSubmit?: () => void; | ||
title: string | ReactNode; | ||
type?: 'success' | 'error'; | ||
submit?: string; | ||
content?: string | ReactNode; | ||
footer?: ReactNode; | ||
popup_zindex?: { | ||
overlay: number; | ||
modal: number; | ||
}; | ||
}; | ||
|
||
const Popup = ({ | ||
title, | ||
content, | ||
type, | ||
onClose, | ||
onSubmit, | ||
submit, | ||
footer, | ||
popup_zindex, | ||
}: _POPUP_PROPS) => { | ||
return ( | ||
<ReactPortal> | ||
<div | ||
className='popup-overlay' | ||
style={{ zIndex: popup_zindex?.overlay ?? 1000 }} | ||
/> | ||
<div | ||
className='popup-modal' | ||
style={{ zIndex: popup_zindex?.modal ?? 2000 }} | ||
> | ||
<div className='popup-title'> | ||
{typeof title === 'string' ? ( | ||
<span>{title}</span> | ||
) : ( | ||
<div>{title}</div> | ||
)} | ||
{onClose && ( | ||
<button type='button' className='modal-btn' onClick={onClose}> | ||
<svg | ||
className='h-5 w-5' | ||
fill='none' | ||
viewBox='0 0 24 24' | ||
stroke='currentColor' | ||
aria-hidden='true' | ||
> | ||
<path | ||
strokeLinecap='round' | ||
strokeLinejoin='round' | ||
strokeWidth='3' | ||
d='M6 18L18 6M6 6l12 12' | ||
/> | ||
</svg> | ||
</button> | ||
)} | ||
</div> | ||
{content && <div className='popup-body'>{content}</div>} | ||
<div className='popup-footer'> | ||
{onSubmit && ( | ||
<button | ||
className='modal-btn' | ||
style={ | ||
type && { | ||
backgroundColor: type === 'success' ? 'green' : 'red', | ||
} | ||
} | ||
onClick={onSubmit} | ||
> | ||
{submit ?? 'Okay'} | ||
</button> | ||
)} | ||
<div>{footer}</div> | ||
</div> | ||
</div> | ||
</ReactPortal> | ||
); | ||
}; | ||
|
||
export default Popup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ReactNode, useEffect, useState } from 'react'; | ||
import { createPortal } from 'react-dom'; | ||
|
||
/** | ||
* Ensures that document.body is available | ||
*/ | ||
export default function ReactPortal({ children }: { children: ReactNode }) { | ||
const [mounted, setMounted] = useState(false); | ||
useEffect(() => { | ||
setMounted(true); | ||
}, []); | ||
|
||
return <>{mounted && createPortal(<>{children}</>, document.body)}</>; | ||
} |
Oops, something went wrong.