generated from openedx/frontend-template-application
-
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 pull request #3 from edx/mfrank/port-over-Skills-Builder
feat: port over Skills Builder
- Loading branch information
Showing
53 changed files
with
2,418 additions
and
32 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
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,11 @@ | ||
import React from 'react'; | ||
import { SkillsBuilderModal } from './skills-builder-modal'; | ||
import { SkillsBuilderProvider } from './skills-builder-context'; | ||
|
||
const SkillsBuilder = () => ( | ||
<SkillsBuilderProvider> | ||
<SkillsBuilderModal /> | ||
</SkillsBuilderProvider> | ||
); | ||
|
||
export default SkillsBuilder; |
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,26 @@ | ||
import { | ||
SET_GOAL, | ||
SET_CURRENT_JOB_TITLE, | ||
ADD_CAREER_INTEREST, | ||
REMOVE_CAREER_INTEREST, | ||
} from './constants'; | ||
|
||
export const setGoal = (payload) => ({ | ||
type: SET_GOAL, | ||
payload, | ||
}); | ||
|
||
export const setCurrentJobTitle = (payload) => ({ | ||
type: SET_CURRENT_JOB_TITLE, | ||
payload, | ||
}); | ||
|
||
export const addCareerInterest = (payload) => ({ | ||
type: ADD_CAREER_INTEREST, | ||
payload, | ||
}); | ||
|
||
export const removeCareerInterest = (payload) => ({ | ||
type: REMOVE_CAREER_INTEREST, | ||
payload, | ||
}); |
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,9 @@ | ||
// Actions for Skills Context | ||
export const SET_GOAL = 'SET_GOAL'; | ||
export const SET_CURRENT_JOB_TITLE = 'SET_CURRENT_JOB_TITLE'; | ||
export const ADD_CAREER_INTEREST = 'ADD_CAREER_INTEREST'; | ||
export const REMOVE_CAREER_INTEREST = 'REMOVE_CAREER_INTEREST'; | ||
|
||
// Stepper keys | ||
export const STEP1 = 'select-your-preferences'; | ||
export const STEP2 = 'review-your-results'; |
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,41 @@ | ||
import { | ||
SET_GOAL, | ||
SET_CURRENT_JOB_TITLE, | ||
ADD_CAREER_INTEREST, | ||
REMOVE_CAREER_INTEREST, | ||
} from './constants'; | ||
|
||
export function skillsReducer(state, action) { | ||
switch (action.type) { | ||
case SET_GOAL: | ||
return { | ||
...state, | ||
currentGoal: action.payload, | ||
}; | ||
case SET_CURRENT_JOB_TITLE: | ||
return { | ||
...state, | ||
currentJobTitle: action.payload, | ||
}; | ||
case ADD_CAREER_INTEREST: | ||
return { | ||
...state, | ||
careerInterests: [...state.careerInterests, action.payload], | ||
}; | ||
case REMOVE_CAREER_INTEREST: | ||
return { | ||
...state, | ||
careerInterests: state.careerInterests.filter(interest => interest !== action.payload), | ||
}; | ||
default: | ||
return state; | ||
} | ||
} | ||
|
||
export const skillsInitialState = { | ||
currentGoal: '', | ||
currentJobTitle: '', | ||
careerInterests: [], | ||
}; | ||
|
||
export default skillsReducer; |
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,60 @@ | ||
import { skillsReducer, skillsInitialState } from '../reducer'; | ||
import { | ||
SET_GOAL, | ||
SET_CURRENT_JOB_TITLE, | ||
ADD_CAREER_INTEREST, | ||
REMOVE_CAREER_INTEREST, | ||
} from '../constants'; | ||
|
||
describe('skillsReducer', () => { | ||
const testState = skillsInitialState; | ||
beforeEach(() => jest.resetModules()); | ||
|
||
it('does not remove present data when SET_GOAL action is dispatched', () => { | ||
const newGoalPayload = 'test-goal'; | ||
const returnedState = skillsReducer(testState, { type: SET_GOAL, payload: newGoalPayload }); | ||
const finalState = { | ||
...testState, | ||
currentGoal: 'test-goal', | ||
}; | ||
expect(returnedState).toEqual(finalState); | ||
}); | ||
|
||
it('does not remove present data when SET_JOB_TITLE action is dispatched', () => { | ||
const newJobTitlePayload = 'test-job-title'; | ||
const returnedState = skillsReducer(testState, { type: SET_CURRENT_JOB_TITLE, payload: newJobTitlePayload }); | ||
const finalState = { | ||
...testState, | ||
currentJobTitle: 'test-job-title', | ||
}; | ||
expect(returnedState).toEqual(finalState); | ||
}); | ||
|
||
it('adds a careerInterest when ADD_CAREER_INTEREST action is dispatched', () => { | ||
const newCareerInterestPayload = 'test-career-interest'; | ||
const returnedState = skillsReducer(testState, { type: ADD_CAREER_INTEREST, payload: newCareerInterestPayload }); | ||
const finalState = { | ||
...testState, | ||
careerInterests: [...testState.careerInterests, 'test-career-interest'], | ||
}; | ||
expect(returnedState).toEqual(finalState); | ||
}); | ||
|
||
it('removes a careerInterest when REMOVE_CAREER_INTEREST action is dispatched', () => { | ||
const newCareerInterestPayload = 'test-career-interest'; | ||
const testStateWithInterest = { | ||
...testState, | ||
careerInterests: [newCareerInterestPayload], | ||
}; | ||
const returnedState = skillsReducer( | ||
testStateWithInterest, | ||
{ type: REMOVE_CAREER_INTEREST, payload: newCareerInterestPayload }, | ||
); | ||
const finalState = { | ||
...testStateWithInterest, | ||
// override the 'careerInterests` field and remove 'test-career-interest' from the array | ||
careerInterests: testStateWithInterest.careerInterests.filter(interest => interest !== newCareerInterestPayload), | ||
}; | ||
expect(returnedState).toEqual(finalState); | ||
}); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,2 @@ | ||
// eslint-disable-next-line import/prefer-default-export | ||
export { default as SkillsBuilder } from './SkillsBuilder'; |
32 changes: 32 additions & 0 deletions
32
src/skills-builder/skills-builder-context/SkillsBuilderProvider.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,32 @@ | ||
import React, { createContext, useReducer, useMemo } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import reducer, { skillsInitialState } from '../data/reducer'; | ||
import { useAlgoliaSearch } from '../utils/search'; | ||
|
||
export const SkillsBuilderContext = createContext(); | ||
|
||
export const SkillsBuilderProvider = ({ children }) => { | ||
const [state, dispatch] = useReducer(reducer, skillsInitialState); | ||
|
||
const [searchClient, productSearchIndex, jobSearchIndex] = useAlgoliaSearch(); | ||
|
||
const value = useMemo(() => ({ | ||
state, | ||
dispatch, | ||
algolia: { | ||
searchClient, | ||
productSearchIndex, | ||
jobSearchIndex, | ||
}, | ||
}), [state, searchClient, productSearchIndex, jobSearchIndex]); | ||
|
||
return ( | ||
<SkillsBuilderContext.Provider value={value}> | ||
{children} | ||
</SkillsBuilderContext.Provider> | ||
); | ||
}; | ||
|
||
SkillsBuilderProvider.propTypes = { | ||
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired, | ||
}; |
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,2 @@ | ||
// eslint-disable-next-line import/prefer-default-export | ||
export { SkillsBuilderProvider, SkillsBuilderContext } from './SkillsBuilderProvider'; |
25 changes: 25 additions & 0 deletions
25
src/skills-builder/skills-builder-header/SkillsBuilderHeader.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,25 @@ | ||
import React from 'react'; | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import edXLogo from '../images/edX-logo.svg'; | ||
import messages from './messages'; | ||
|
||
const SkillsBuilderHeader = () => { | ||
const { formatMessage } = useIntl(); | ||
|
||
return ( | ||
<div className="d-flex"> | ||
<img src={edXLogo} alt="edx-logo" className="mt-2 h-50" /> | ||
<div className="ml-5 vertical-line" /> | ||
<div className="w-100 ml-5"> | ||
<h1 className="h1 text-warning-300"> | ||
{formatMessage(messages.skillsBuilderHeaderTitle)} | ||
</h1> | ||
<p className="h2 text-white"> | ||
{formatMessage(messages.skillsBuilderHeaderSubheading)} | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SkillsBuilderHeader; |
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,2 @@ | ||
// eslint-disable-next-line import/prefer-default-export | ||
export { default as SkillsBuilderHeader } from './SkillsBuilderHeader'; |
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,16 @@ | ||
import { defineMessages } from '@edx/frontend-platform/i18n'; | ||
|
||
const messages = defineMessages({ | ||
skillsBuilderHeaderTitle: { | ||
id: 'skills.builder.header.title', | ||
defaultMessage: 'Skills Builder', | ||
description: 'Title for the Skills Builder feature', | ||
}, | ||
skillsBuilderHeaderSubheading: { | ||
id: 'skills.builder.header.subheading', | ||
defaultMessage: 'Let edX be your guide', | ||
description: 'Subheading to the Skills Builder title in the header component', | ||
}, | ||
}); | ||
|
||
export default messages; |
4 changes: 4 additions & 0 deletions
4
src/skills-builder/skills-builder-header/skillsBuilderHeader.scss
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,4 @@ | ||
.vertical-line { | ||
border-left: 7px solid #D23228; | ||
transform: rotate(13deg); | ||
} |
Oops, something went wrong.