Skip to content

Commit

Permalink
feat: firstVisit popup
Browse files Browse the repository at this point in the history
Signed-off-by: Karthik Ayangar <[email protected]>
  • Loading branch information
kituuu committed Feb 16, 2024
1 parent bd5531f commit e47eca0
Show file tree
Hide file tree
Showing 40 changed files with 958 additions and 556 deletions.
6 changes: 3 additions & 3 deletions src/app/api/githubData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export interface OrgRank {
contributors: Contributors;
}

export interface ProjectStats{
contributors: Contributors
export interface ProjectStats {
contributors: Contributors;
}

// Contributors==project issues commits pull
Expand Down Expand Up @@ -71,7 +71,7 @@ export const getProjectGithubData = async (
orgName: string,
projectName: string,
monthly: boolean
) : Promise<AxiosResponse<ProjectStats>>=> {
): Promise<AxiosResponse<ProjectStats>> => {
const url =
BACKEND_URL +
'/api/protected/github/' +
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const changeOrgMembersStatus = async (
orgName: string,
orgMemberStatus: { [key: string]: string }
) => {
const url = BACKEND_URL + '/api/protected/org/changeMembersStatus/'+orgName;
const url = BACKEND_URL + '/api/protected/org/changeMembersStatus/' + orgName;
const respnse = await axios.put(
url,
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface GetProject {
id: number;
name: string;
description: string;
link: string
link: string;
}

export interface Member {
Expand Down
39 changes: 24 additions & 15 deletions src/app/components/buttonBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,36 @@ import TimeRangeSwitch from 'app/components/timeRangeSwitch';
import './index.scss';
import { GetProject } from 'app/api/project';
import { useNavigate } from 'react-router-dom';
interface Props{
weekly: boolean,
setWeekly: (week:boolean)=>void
project: GetProject | null
workspaceName: string | undefined

interface Props {
weekly: boolean;
setWeekly: (week: boolean) => void;
project: GetProject | null;
workspaceName: string | undefined;
}
const ButtonBar:React.FC<Props> = ({weekly, setWeekly, project, workspaceName}) => {
const navigate= useNavigate()
const ButtonBar: React.FC<Props> = ({
weekly,
setWeekly,
project,
workspaceName,
}) => {
const navigate = useNavigate();
return (
<div className='project-upper-cont'>
<div className='button-bar'>
<button className='back-btn' onClick={()=>navigate(`/workspace/${workspaceName}`)} >&larr; Back</button>
<button
className='back-btn'
onClick={() => navigate(`/workspace/${workspaceName}`)}
>
&larr; Back
</button>
<TimeRangeSwitch weekly={weekly} setWeekly={setWeekly} />
</div>
{ project&&<>
<h1>{project.name}</h1>
<p>
{project.description}
</p>
</>}
{project && (
<>
<h1>{project.name}</h1>
<p>{project.description}</p>
</>
)}
</div>
);
};
Expand Down
32 changes: 32 additions & 0 deletions src/app/components/firstVisit/index.scss
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;
}
42 changes: 42 additions & 0 deletions src/app/components/firstVisit/index.tsx
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 }}
/>
)}
</>
);
}
70 changes: 70 additions & 0 deletions src/app/components/popup/index.scss
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%;
}
82 changes: 82 additions & 0 deletions src/app/components/popup/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
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;
14 changes: 14 additions & 0 deletions src/app/components/reactPortal/index.tsx
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)}</>;
}
8 changes: 4 additions & 4 deletions src/app/components/timeRangeSwitch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ interface Props {
const TimeRangeSwitch: React.FC<Props> = ({ weekly, setWeekly }) => {
// const dispatch = useDispatch();
// const isWeekly = useSelector((state: timeRangeModel) => state.isWeekly.value);
useEffect(()=>{
console.log(weekly)
},[weekly, setWeekly])
useEffect(() => {
console.log(weekly);
}, [weekly, setWeekly]);
return (
<div className='timerange-cont'>
<button
onClick={() => setWeekly(true)}
className={weekly ? 'active' :''}
className={weekly ? 'active' : ''}
// className={'active'}
>
Weekly{' '}
Expand Down
Loading

0 comments on commit e47eca0

Please sign in to comment.