Skip to content

Commit b910efc

Browse files
committed
LCS-81: Adds how-to-use modal on navbar
1 parent 433cb54 commit b910efc

File tree

1 file changed

+65
-1
lines changed
  • leetcode-srs/src/containers/SharedItems/NavBar

1 file changed

+65
-1
lines changed

leetcode-srs/src/containers/SharedItems/NavBar/Navbar.js

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useState, useEffect} from 'react'
1+
import React, {useState, useEffect, Fragment} from 'react'
22
import {NavLink} from 'react-router-dom'
33
import PropTypes from 'prop-types'
44
import classes from './Navbar.module.css'
@@ -18,6 +18,8 @@ Provide links to:
1818
const Navbar = props => {
1919
// State for the login modal
2020
const [loginOpen, setLoginOpen] = useState(false)
21+
// State for the help/how-to-use modal
22+
const [helpOpen, setHelpOpen] = useState(false)
2123

2224
// On reload, close Modal if it was open and we auth'd
2325
useEffect(() => {
@@ -35,10 +37,72 @@ const Navbar = props => {
3537
setLoginOpen(false)
3638
}
3739

40+
// Open/Close How-To-Use modal
41+
const openHelp = (event) => {
42+
event.preventDefault()
43+
setHelpOpen(true)
44+
}
45+
const closeHelp = () => {
46+
setHelpOpen(false)
47+
}
48+
3849
// JSX
50+
51+
const helpText = (
52+
<div className='text-center'>
53+
<p><strong>How to Use</strong></p>
54+
<ul>
55+
<li>First, make an account by clicking the login/register page on the navigation bar.</li>
56+
</ul>
57+
<p>You will be redirected to the main page, where you will be prompted to visit the manage lists page, which you can access from the prompt or by selecting Manage Lists in the navigation bar.</p>
58+
<ul>
59+
<li>From here, create a new list, which is private by default (explained below).</li>
60+
</ul>
61+
<p>Your new list will auto-populate in the drop-down list selector, and new options will appear - the ability to edit your list, change the name, or set public (if created as a private list).</p>
62+
<ul>
63+
<li><p>Select Edit List, and the list editor will appear, where you can add/remove problems from your list. By default, the first 50 LeetCode problems are shown, but you can search for problems based on their title. Once you have added problems, click the Save Changes button.</p>
64+
</li>
65+
<li><p>After your changes have been saved, return to the main page by clicking the &#39;LeetCode SRS&#39; title on the top of the page, in the center of the navbar.</p>
66+
</li>
67+
</ul>
68+
<p>Two drop downs will appear - one for your lists, and one for the problems in your selected list.</p>
69+
<ul>
70+
<li><p>Problems in the drop down list will be color-coded based on when you should do them - problems &quot;due&quot; within the next 3 days are red, within the next week yellow, and after a week in green.</p>
71+
</li>
72+
<li><p>After you have selected the problem you wish to attempt, click Start Problem.</p>
73+
</li>
74+
<li><p>A LeetCode link will appear, and as that page loads, a form and a timer will also appear on the LeetCodeSRS site. Once you complete your LeetCode problem, fill in the form with the results of your submission - whether you were successful or not, what your submitted code was, LeetCode&#39;s reported memory used and execution time, and the time you spent doing the problem. The time spent can be auto-filled based on the state of the timer - click the &quot;Finish Recording&quot; button and the current time shown is auto-filled into the form. If this sounds like too much work for you, don&#39;t worry - the only two fields required are the time spent and if you were successful or not.</p>
75+
</li>
76+
<li><p>After you&#39;ve filled the form to your satisfaction, click Submit, and the page will refresh, and the next problem to do will be automatically selected in the problem drop-down.</p>
77+
</li>
78+
<li><p>After you have attempted some problems, you can go back and view your submissions for the problems you have done by visiting the &quot;Submission History&quot; link in the navbar. Once here, all problems that you have attempted (between all your lists) are presented, and you may view your submission results in table format, including your submitted code.</p>
79+
</li>
80+
</ul>
81+
<p>One final feature to note is that of public versus private lists - public lists are, as the name implies, public - anyone can see the list by name, and the problems contained within them. They may only be edited by you, but a public list cannot be set back to private. All public lists are visible via the &#39;View Public Lists&#39; link on the navbar. There, in addition to viewing the lists, users may also clone the list in its current state to their collection of private lists, where the user may edit it as they please.</p>
82+
</div>
83+
)
84+
85+
const helpModal = (
86+
<Fragment>
87+
<Button btnType="Success" clicked={openHelp}>How-to-Use</Button>
88+
<Modal
89+
isOpen={helpOpen}
90+
onAfterOpen={null}
91+
onRequestClose={closeHelp}
92+
contentLabel="Help Modal"
93+
>
94+
<div>
95+
<Button btnType="Success" clicked={closeHelp}>Back to Home</Button>
96+
</div>
97+
{helpText}
98+
</Modal>
99+
</Fragment>
100+
)
101+
39102
return (
40103
<div className={classes.Navbar}>
41104
<div className={classes.Left}>
105+
{helpModal}
42106
<NavLink className={classes.NavLink} to='/view-public-lists'>View Public Lists</NavLink>
43107
</div>
44108
<div className={classes.Center}>

0 commit comments

Comments
 (0)