diff --git a/components/interviews/interviewsList/index.js b/components/interviews/interviewsList/index.js index 3cb5066..f122b64 100644 --- a/components/interviews/interviewsList/index.js +++ b/components/interviews/interviewsList/index.js @@ -3,36 +3,91 @@ import { PropTypes } from 'prop-types'; import Modal from '../../modal'; import './style.scss'; -const InterviewsList = props => ( -
-
- Interviews ({ props.data.length }) {/* eslint-disable-line */} - View {/* eslint-disable-line */} -
- -
-

Interviews ({ props.data.length })

-
    - { props.data.map(interview => ( - // eslint-disable-next-line -
  • - { interview.name } -
  • - )) - } -
+const InterviewsList = props => { + + // Sort interviews alphabetically + const sortedInterviews = props.data.sort((a, b) => { return a.name.localeCompare(b.name); }); + const interviews = {}; + + // Build up interviews object with letter key + sortedInterviews.forEach(interview => { + const firstLetter = interview.name.charAt(0); + if (typeof interviews[firstLetter] === 'undefined') { + interviews[firstLetter] = []; + } + interviews[firstLetter].push(interview); + }); + + return ( +
+
+ {/* eslint-disable-next-line */} + + Interviews ({props.data.length}) + + {/* eslint-disable-next-line */} + + View +
- -
-); + + +

Interviews ({ props.data.length })

+
+
+ { + Object.keys(interviews).map(firstLetter => ( +
+
{ firstLetter }
+
    + {interviews[firstLetter].map(interview => ( + // eslint-disable-next-line +
  • + {interview.name} +
  • + ) + )} +
+
+ ) + ) + } +
+
+ { + Object.keys(interviews).map(firstLetter => ( + { document.querySelector(`#${firstLetter}`).scrollIntoView({ behavior: 'smooth' }); }} + > + { firstLetter } + + ) + ) + } +
+
+
+
+
+ ); +}; InterviewsList.propTypes = { isInterviewsListModalOpen: PropTypes.bool.isRequired, diff --git a/components/interviews/interviewsList/style.scss b/components/interviews/interviewsList/style.scss index 8054835..60be0f0 100644 --- a/components/interviews/interviewsList/style.scss +++ b/components/interviews/interviewsList/style.scss @@ -19,8 +19,28 @@ } } +.interviews-nav-wrap { + display: flex; + justify-content: space-between; + justify-content: flex-end; + position: relative; +} + .interviews-list { + @media (min-width: $desktop) { + position: absolute; + top: 0; + left: 0; + height: 100%; + overflow: auto; + width: 96%; + } + + .letter-block { + padding-bottom: calculateRem(32); + } + li { cursor: pointer; outline: none; @@ -30,3 +50,16 @@ } } } + +.letters-nav { + display: none; + + @media (min-width: $desktop) { + display: flex; + flex-direction: column; + + span { + cursor: pointer; + } + } +}