-
Notifications
You must be signed in to change notification settings - Fork 7
Startingmodal #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
CalebLItalien
wants to merge
16
commits into
CherokeeLanguage:main
Choose a base branch
from
CalebLItalien:startingmodal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Startingmodal #85
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0d53597
starter code for new onboarding workflow
CharlieMcVicker 34b38ac
oop
CharlieMcVicker 9d2ea5f
oops pt2
CharlieMcVicker b960c45
Phonetics Preference Implementation (#64)
CharlieMcVicker 02760a7
keep state in wizard state; use radio buttons; implement default phon…
CharlieMcVicker a4465c7
Added a step to add a starting collection
07596be
edited formatting of intro steps
e56a23f
Merge pull request #65 from fiabot/union-team/jan-23-starter-code
CharlieMcVicker 784b452
Merge branch 'main' into union-team/jan-23-starter-code
CalebLItalien 617f18d
changes to the starting modal
CalebLItalien 3bb1237
refactored getting started modal
CalebLItalien b7d7bf7
pushing branch
CalebLItalien 1e2f3b7
changes to starting modal. not all issues resolved, some to work out
CalebLItalien b5cf5b7
Changes to getting started modal
CalebLItalien 02e9d30
small change
CalebLItalien cd386e2
PWA
CalebLItalien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Empty file.
This file contains hidden or 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 hidden or 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,111 @@ | ||
| import { ChangeEvent, FormEvent, ReactElement, useEffect , useState} from "react"; | ||
| import { NavigationButtons, Step, StepProps } from "."; | ||
| import { Button } from "../Button"; | ||
| import { | ||
| isPhoneticsPreference, | ||
| PhoneticsPreference, | ||
| PREFERENCE_LITERATES, | ||
| } from "../../state/reducers/phoneticsPreference"; | ||
| import { GROUPS, isGroupId } from "../../state/reducers/groupId"; | ||
| import { SectionHeading } from "../SectionHeading"; | ||
| import { CollectionDetails } from "../CollectionDetails"; | ||
|
|
||
| import { collections, VocabSet } from "../../data/vocabSets"; | ||
| import { useUserStateContext } from "../../providers/UserStateProvider"; | ||
| import { TermsByProficiencyLevelChart } from "../TermsByProficiencyLevelChart"; | ||
|
|
||
| export const ChooseSetStep: Step = { | ||
| title: "Choose your first set", | ||
| commitState: ({ collectionId }, {setUpstreamCollection}) => { | ||
| if (collectionId !== undefined){ | ||
| setUpstreamCollection(collectionId); | ||
| } | ||
| }, | ||
| Component: ChooseStepComponent, | ||
| }; | ||
|
|
||
| function ChooseStepComponent({ | ||
| wizardState: { collectionId, groupId }, | ||
| setWizardState, | ||
| goToNextStep, | ||
| goToPreviousStep, | ||
| }: StepProps): ReactElement { | ||
| let canGoToNextStep = collectionId !== undefined; | ||
| function setWizardStateCollectionId( | ||
| newCollectionId: string | ||
| ) { | ||
| setWizardState((s) => ({ | ||
| ...s, | ||
| collectionId: newCollectionId, | ||
| })); | ||
| } | ||
| function onRadioChanged(e: ChangeEvent<HTMLInputElement>) { | ||
| const collectionId = e.target.value; | ||
| setWizardStateCollectionId(collectionId); | ||
| canGoToNextStep = true; | ||
| } | ||
| function onSubmit(e: FormEvent<HTMLFormElement>) { | ||
| e.preventDefault(); | ||
| if (collectionId && goToNextStep) goToNextStep(); | ||
| } | ||
|
|
||
|
|
||
| function totalTerms(vocab: VocabSet[]){ | ||
| var t = 0; | ||
|
|
||
| vocab.map((vocabSet) => ( | ||
| t += vocabSet.terms.length | ||
| )) | ||
|
|
||
| return t; | ||
| } | ||
|
|
||
| useEffect(() => { | ||
| if (!collectionId) { | ||
| const defaultCollectionId = | ||
| groupId && isGroupId(groupId) | ||
| ? GROUPS[groupId].defaultCollectionId | ||
| : undefined; | ||
| if (defaultCollectionId) { | ||
| setWizardStateCollectionId(defaultCollectionId) | ||
| canGoToNextStep = true; | ||
| } | ||
| } | ||
| }, [collectionId]); | ||
|
|
||
| return ( | ||
| <div> | ||
|
|
||
| <p></p> | ||
|
|
||
| <form onSubmit={onSubmit}> | ||
| <fieldset> | ||
| <legend>Select a collection</legend> | ||
|
|
||
| {Object.values(collections).map((collection, idx) => ( | ||
| <div key={idx}> | ||
|
|
||
| <input | ||
| name = {collection.title} | ||
| type = "radio" | ||
| value = {collection.id} | ||
| id = {collection.id} | ||
| onChange = {onRadioChanged} | ||
| checked = {collectionId == collection.id} | ||
| /> | ||
| <label htmlFor={collection.id}>{collection.title} ({totalTerms(collection.sets)} terms) </label> | ||
|
|
||
| </div> | ||
|
|
||
| ))} | ||
|
|
||
| </fieldset> | ||
| <NavigationButtons | ||
| goToPreviousStep={goToPreviousStep} | ||
| goToNextStep={goToNextStep} | ||
| disabled = {!canGoToNextStep} | ||
| /> | ||
| </form> | ||
| </div> | ||
| ); | ||
| } | ||
100 changes: 100 additions & 0 deletions
100
src/components/GettingStartedModal/GroupRegistrationStep.tsx
This file contains hidden or 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,100 @@ | ||
| import { ChangeEvent, FormEvent, useState } from "react"; | ||
| import { NavigationButtons, Step, StepProps } from "."; | ||
| import { GROUPS } from "../../state/reducers/groupId"; | ||
| import { Button } from "../Button"; | ||
|
|
||
| export const GroupRegistrationStep: Step = { | ||
| title: "Personal Information", | ||
| Component: GroupRegistrationForm, | ||
| commitState: ({ groupId, email, whereFound }, { registerGroup, setUserEmail, setWhereFound }) => { | ||
| registerGroup(groupId); | ||
| setWhereFound(whereFound); | ||
| setUserEmail(email); | ||
| }, | ||
| }; | ||
|
|
||
| export function GroupRegistrationForm({ | ||
| wizardState: { groupId , email, whereFound}, | ||
| setWizardState, | ||
| goToNextStep, | ||
| goToPreviousStep, | ||
| exitWizard | ||
| }: StepProps) { | ||
| const [enabled, setEnabled] = useState(groupId!=undefined && email !== ''); | ||
|
|
||
| function onGroupIdChanged(e: ChangeEvent<HTMLInputElement>) { | ||
| const groupId = e.target.value; | ||
| setWizardState((s) => ({ ...s, groupId })); | ||
| setEnabled(email !== ''); | ||
| } | ||
|
|
||
| function onEmailChanged(e: ChangeEvent<HTMLInputElement>) { | ||
| const email = e.target.value; | ||
| setWizardState((s) => ({ ...s, email })); | ||
| setEnabled(groupId !== undefined && email !== ''); | ||
| } | ||
|
|
||
| function onWhereFoundChanged(e: ChangeEvent<HTMLInputElement>){ | ||
| const whereFound = e.target.value; | ||
| setWizardState((s) => ({ ...s, whereFound })); | ||
| setEnabled(whereFound !== undefined); | ||
| } | ||
|
|
||
| function onSubmit(e: FormEvent<HTMLFormElement>) { | ||
| e.preventDefault(); | ||
| if (groupId && email && goToNextStep) goToNextStep(); | ||
| } | ||
| return ( | ||
| <> | ||
| <p> | ||
| We're happy to have you here! Who are you, and how did you hear about us? | ||
| <br></br> | ||
| <br></br> | ||
| After you've completed this, you're all set! Continue for advanced settings. | ||
| </p> | ||
| <form onSubmit={onSubmit}> | ||
| <fieldset> | ||
| <label>Email Address</label> | ||
| <input | ||
| type = "email" | ||
| name = "email" | ||
| value = {email} | ||
| onChange = {onEmailChanged} | ||
| /> | ||
| </fieldset> | ||
| <fieldset> | ||
| <label>Where did you find us?</label> | ||
| <input | ||
| type = "whereFound" | ||
| name = "whereFound" | ||
| value = {whereFound} | ||
| onChange = {onWhereFoundChanged} | ||
| /> | ||
| </fieldset> | ||
| <fieldset> | ||
| Group | ||
| {Object.entries(GROUPS).map(([id, group]) => ( | ||
| <div key={id}> | ||
| <input | ||
| type="radio" | ||
| name="groupId" | ||
| value={id} | ||
| id={id} | ||
| checked={groupId === id} | ||
| onChange={onGroupIdChanged} | ||
| /> | ||
| <label htmlFor={id}>{group.name}</label> | ||
| </div> | ||
| ))} | ||
| </fieldset> | ||
| <NavigationButtons | ||
| goToPreviousStep={goToPreviousStep} | ||
| goToNextStep={goToNextStep} | ||
| exitWizard={exitWizard} | ||
| disabled = {!enabled} | ||
| > | ||
| </NavigationButtons> | ||
| </form> | ||
| </> | ||
| ); | ||
| } |
This file contains hidden or 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,94 @@ | ||
| import { ChangeEvent, FormEvent, ReactElement, useEffect, useState } from "react"; | ||
| import { NavigationButtons, Step, StepProps } from "."; | ||
| import { Button } from "../Button"; | ||
| import { | ||
| isPhoneticsPreference, | ||
| PhoneticsPreference, | ||
| PREFERENCE_LITERATES, | ||
| } from "../../state/reducers/phoneticsPreference"; | ||
|
|
||
| import { GROUPS, isGroupId } from "../../state/reducers/groupId"; | ||
|
|
||
| export const PhoneticsStep: Step = { | ||
| /* | ||
| * Sets the phonetic preference to the wizard state. | ||
| */ | ||
| title: "Phonetics", | ||
| commitState: ({ phoneticsPreference }, { setPhoneticsPreference }) => { | ||
| if (phoneticsPreference) { setPhoneticsPreference(phoneticsPreference); } | ||
| }, | ||
| Component: PhoneticsStepComponent, | ||
| }; | ||
|
|
||
| function PhoneticsStepComponent({ | ||
| /* | ||
| * Defines the phonetics step. Allows user to set phonetics preference, advance to the next step, or go to the previous step. Offers a default preference. | ||
| */ | ||
| wizardState: { phoneticsPreference, groupId }, | ||
| setWizardState, | ||
| goToNextStep, | ||
| goToPreviousStep, | ||
| }: StepProps): ReactElement { | ||
| const [enabled, setEnbabled] = useState(phoneticsPreference != undefined); | ||
| function setWizardStatePhoneticsPreference( | ||
| newPhoneticsPreference: PhoneticsPreference | ||
| ) { | ||
| setWizardState((s) => ({ | ||
| ...s, | ||
| phoneticsPreference: newPhoneticsPreference, | ||
| })); | ||
| } | ||
| function onPreferenceChanged(e: ChangeEvent<HTMLInputElement>) { | ||
| const phoneticsPreference = e.target.value; | ||
| if (isPhoneticsPreference(phoneticsPreference)) | ||
| setWizardStatePhoneticsPreference(phoneticsPreference); | ||
| setEnbabled(true); | ||
| } | ||
| function onSubmit(e: FormEvent<HTMLFormElement>) { | ||
| e.preventDefault(); | ||
| if (phoneticsPreference && goToNextStep) goToNextStep(); | ||
| } | ||
|
|
||
| useEffect(() => { | ||
| if (!phoneticsPreference) { | ||
| const defaultPhoneticsPreference = | ||
| groupId && isGroupId(groupId) | ||
| ? GROUPS[groupId].phoneticsPreference | ||
| : undefined; | ||
| if (defaultPhoneticsPreference) { | ||
| setWizardStatePhoneticsPreference(defaultPhoneticsPreference); | ||
| setEnbabled(true); | ||
| } | ||
| } | ||
| }, [phoneticsPreference]); | ||
|
|
||
| return ( | ||
| <div> | ||
| <p>Select your phonetics preference!</p> | ||
|
|
||
| <form onSubmit={onSubmit}> | ||
| <fieldset> | ||
| <legend>Phonetics preference</legend> | ||
| {Object.entries(PREFERENCE_LITERATES).map(([value, literate], i) => ( | ||
| <div key={i}> | ||
| <input | ||
| type="radio" | ||
| name="phoneticsPreference" | ||
| value={value} | ||
| id={value} | ||
| checked={phoneticsPreference === value} | ||
| onChange={onPreferenceChanged} | ||
| /> | ||
| <label htmlFor={value}>{literate}</label> | ||
| </div> | ||
| ))} | ||
| </fieldset> | ||
| <NavigationButtons | ||
| goToPreviousStep={goToPreviousStep} | ||
| goToNextStep={goToNextStep} | ||
| disabled ={!enabled} | ||
| /> | ||
| </form> | ||
| </div> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good for now, but I wonder if we should write short descriptions of the sets to put here instead of just # of terms.