generated from openedx/frontend-template-application
-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: add experimental single question version #44
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c054c65
feat: add flags to disable questions
cdeery f4f411d
feat: WIP relatedSkillsInteractiveBox
cdeery 220474b
feat: add query parameter to activate experiment
cdeery 9083334
fix: get unit tests to run
cdeery 9620b81
fix: implement review suggestions
cdeery 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 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 |
---|---|---|
@@ -1,11 +1,23 @@ | ||
import React from 'react'; | ||
import React, { useRef } from 'react'; | ||
import { SkillsBuilderModal } from './skills-builder-modal'; | ||
import { SkillsBuilderProvider } from './skills-builder-context'; | ||
import { useVisibilityFlags } from './skills-builder-modal/view-results/data/hooks'; | ||
import SkillsBuilderProgressive from './skills-builder-modal/SkillsBuilderProgressive'; | ||
|
||
const SkillsBuilder = () => ( | ||
<SkillsBuilderProvider> | ||
<SkillsBuilderModal /> | ||
</SkillsBuilderProvider> | ||
); | ||
const SkillsBuilder = () => { | ||
const visibilityFlags = useRef(useVisibilityFlags()); | ||
const { isProgressive } = visibilityFlags.current; | ||
|
||
return ( | ||
<SkillsBuilderProvider> | ||
{ isProgressive ? ( | ||
<SkillsBuilderProgressive /> | ||
) : ( | ||
<SkillsBuilderModal /> | ||
)} | ||
|
||
</SkillsBuilderProvider> | ||
); | ||
}; | ||
|
||
export default SkillsBuilder; |
88 changes: 88 additions & 0 deletions
88
src/skills-builder/skills-builder-modal/SkillsBuilderProgressive.jsx
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,88 @@ | ||
import React, { useContext } from 'react'; | ||
import { | ||
Button, Container, ModalDialog, Form, Hyperlink, useMediaQuery, breakpoints, | ||
} from '@edx/paragon'; | ||
import { getConfig } from '@edx/frontend-platform'; | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import { sendTrackEvent } from '@edx/frontend-platform/analytics'; | ||
import messages from './messages'; | ||
|
||
import { SkillsBuilderContext } from '../skills-builder-context'; | ||
import { SkillsBuilderHeader } from '../skills-builder-header'; | ||
import { SelectPreferences } from './select-preferences'; | ||
import ViewResults from './view-results/ViewResults'; | ||
|
||
import headerImage from '../images/headerImage.png'; | ||
|
||
const SkillsBuilderProgressive = () => { | ||
const { formatMessage } = useIntl(); | ||
const isMedium = useMediaQuery({ maxWidth: breakpoints.medium.maxWidth }); | ||
const { state } = useContext(SkillsBuilderContext); | ||
const { currentGoal, currentJobTitle, careerInterests } = state; | ||
|
||
const sendActionButtonEvent = (eventSuffix) => { | ||
sendTrackEvent( | ||
`edx.skills_builder.${eventSuffix}`, | ||
{ | ||
app_name: 'skills_builder', | ||
category: 'skills_builder', | ||
learner_data: { | ||
current_goal: currentGoal, | ||
current_job_title: currentJobTitle, | ||
career_interests: careerInterests, | ||
}, | ||
}, | ||
); | ||
}; | ||
|
||
const exitButtonHandle = () => { | ||
sendActionButtonEvent('exit'); | ||
}; | ||
const closeButtonHandle = () => { | ||
sendActionButtonEvent('close'); | ||
window.location.href = getConfig().MARKETING_SITE_SEARCH_URL; | ||
}; | ||
|
||
return ( | ||
<ModalDialog | ||
title="Skills Builder" | ||
size="fullscreen" | ||
className="skills-builder-modal bg-light-200" | ||
isOpen | ||
onClose={closeButtonHandle} | ||
> | ||
<ModalDialog.Hero className="med-min-height"> | ||
<ModalDialog.Hero.Background className="bg-primary-500"> | ||
{ !isMedium && <img src={headerImage} alt="" className="h-100" /> } | ||
</ModalDialog.Hero.Background> | ||
<ModalDialog.Hero.Content> | ||
<SkillsBuilderHeader isMedium={isMedium} /> | ||
</ModalDialog.Hero.Content> | ||
</ModalDialog.Hero> | ||
|
||
<ModalDialog.Body> | ||
<Container size="md" className="p-4.5"> | ||
<Form> | ||
|
||
<SelectPreferences /> | ||
|
||
{ careerInterests.length > 0 && ( | ||
<ViewResults /> | ||
)} | ||
|
||
</Form> | ||
</Container> | ||
</ModalDialog.Body> | ||
|
||
<ModalDialog.Footer> | ||
<Hyperlink destination={getConfig().MARKETING_SITE_SEARCH_URL}> | ||
<Button onClick={exitButtonHandle}> | ||
{formatMessage(messages.exitButton)} | ||
</Button> | ||
</Hyperlink> | ||
</ModalDialog.Footer> | ||
</ModalDialog> | ||
); | ||
}; | ||
|
||
export default SkillsBuilderProgressive; |
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
105 changes: 105 additions & 0 deletions
105
src/skills-builder/skills-builder-modal/view-results/RelatedSkillsInteractiveBoxSet.jsx
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,105 @@ | ||
import React, { useContext } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { | ||
Card, CardDeck, Chip, Stack, | ||
} from '@edx/paragon'; | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import { sendTrackEvent } from '@edx/frontend-platform/analytics'; | ||
import { addCareerInterest } from '../../data/actions'; | ||
import { SkillsBuilderContext } from '../../skills-builder-context'; | ||
import messages from './messages'; | ||
|
||
/* | ||
A variant on the RelatedSkillsSelectableBoxSet that allows for interactive content. | ||
Instead of a radio select button in the top, there is a close button. | ||
Since the contents can be interactive, this form will allow for selecting skills to | ||
drill down for skill-specific recommendations. | ||
|
||
This component needs to be like a CardDeck, but also behave like a radio group. | ||
*/ | ||
const RelatedSkillsInteractiveBoxSet = ({ | ||
jobSkillsList, // selectedJobTitle, onChange, // we will need these | ||
}) => { | ||
const { formatMessage } = useIntl(); | ||
const { state, dispatch } = useContext(SkillsBuilderContext); | ||
const { careerInterests } = state; | ||
|
||
const renderTopFiveSkills = (skills) => { | ||
const topFiveSkills = skills.sort((a, b) => b.significance - a.significance).slice(0, 5); | ||
return ( | ||
topFiveSkills.map(skill => ( | ||
<Chip key={skill.external_id} className="chip-max-width"> | ||
{skill.name} | ||
</Chip> | ||
)) | ||
); | ||
}; | ||
|
||
const handleCareerInterestSelect = (value) => { | ||
if (!careerInterests.includes(value) && careerInterests.length < 3) { | ||
dispatch(addCareerInterest(value)); | ||
|
||
sendTrackEvent( | ||
'edx.skills_builder.career_interest.added', | ||
{ | ||
app_name: 'skills_builder', | ||
category: 'skills_builder', | ||
learner_data: { | ||
career_interest: value, | ||
}, | ||
}, | ||
); | ||
} | ||
}; | ||
|
||
// eslint-disable-next-line react/prop-types | ||
const CardComponent = ({ name, skills }) => ( | ||
<Card | ||
isClickable | ||
onClick={handleCareerInterestSelect} | ||
key={name} | ||
xs={12} | ||
sm={4} | ||
className="mb-4" | ||
> | ||
<Card.Header | ||
title={name} | ||
size="sm" | ||
/> | ||
<Card.Section> | ||
<Stack gap={2} className="align-items-start"> | ||
<p className="heading-label x-small">{formatMessage(messages.relatedSkillsHeading)}</p> | ||
{ renderTopFiveSkills(skills) } | ||
</Stack> | ||
</Card.Section> | ||
</Card> | ||
); | ||
|
||
const interactiveBox = (() => ( | ||
<CardDeck | ||
hasInteractiveChildren | ||
hasEqualColumnHeights | ||
columnSizes={4} | ||
> | ||
{jobSkillsList.map(job => ( | ||
<CardComponent | ||
name={job.name} | ||
skills={job.skills} | ||
key={job.name} | ||
/> | ||
))} | ||
</CardDeck> | ||
)); | ||
|
||
return ( | ||
interactiveBox() | ||
); | ||
}; | ||
|
||
RelatedSkillsInteractiveBoxSet.propTypes = { | ||
jobSkillsList: PropTypes.arrayOf(PropTypes.shape({})).isRequired, | ||
selectedJobTitle: PropTypes.string.isRequired, | ||
onChange: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default RelatedSkillsInteractiveBoxSet; |
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
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 doesn't appear to be doing anything when I test in my local environment. This function
handleCareerInterestSelect
is used add to thecareerInterests
array which doesn't change the what the recommendations are in the UI.I think we need to utilize the
onChange
function here which callshandleJobTitleChange
fromViewResults
. Unfortunately, this function is expecting the clicked item to be a control with ae.target.value
but since it's a card, we'll have to find a different way to pass the value. This value should be the name of the job so that the rest of the function works properly.Or perhaps we need an entirely new function for this?
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.
Correct. This part doesn't actually work. I would love to get your input on how to implement this correctly.
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.
Yes, we need an entirely new function for this.