Skip to content

TCA-1105 move category filter to course section #550

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

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions src-ts/tools/learn/welcome/WelcomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import '../../../lib/styles/index.scss'
import { AvailableCoursesList } from './available-courses-list'
import { WhatTCACanDo } from './what-tca-cando'
import { TCCertifications } from './tc-certifications'
import { FilterBar } from './filter-bar'
import styles from './WelcomePage.module.scss'

const PRIORITY_CATEGORIES: ReadonlyArray<string> = [
Expand Down Expand Up @@ -68,20 +67,6 @@ const WelcomePage: FC = () => {
groupBy(orderBy(allCertsData.certifications, 'title', 'asc'), 'certificationCategory.category')
), [allCertsData.certifications])

// compute all the available category dropdown options
const certsCategoriesOptions: Array<{
label: string,
value: string,
}> = useMemo(() => [
{ label: 'All Categories', orderIndex: -1, value: '' },
...Object.keys(certsByCategory)
.sort()
.map(c => ({
label: c,
value: c,
})),
], [certsByCategory])

// create and sort the certificates groups
const certificationsGroups: Array<string> = useMemo(() => orderBy(
Object.keys(certsByCategory),
Expand Down Expand Up @@ -124,14 +109,6 @@ const WelcomePage: FC = () => {

<WhatTCACanDo />

<FilterBar
certsCategoriesOptions={certsCategoriesOptions}
onSelectCategory={onSelectCategory}
selectedCategory={selectedCategory}
/>

<PageDivider />

<TCCertifications
certifications={allTCACertifications.certifications}
progress={certsProgress}
Expand All @@ -146,6 +123,7 @@ const WelcomePage: FC = () => {
certificationsGroups={certificationsGroups}
selectedCategory={selectedCategory}
certificationsProgresses={userCertsData.progresses}
onSelectCategory={onSelectCategory}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
@include ltemd {
flex-direction: column;
align-items: flex-start;
padding-bottom: 0;
padding-bottom: $space-xxl;

h2 {
margin: $space-md 0 $space-xxl;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Dictionary } from 'lodash'
import { FC, Fragment, ReactNode } from 'react'
import { ChangeEvent, FC, Fragment, ReactNode, useMemo } from 'react'
import classNames from 'classnames'

import { LearnCertification, LearnUserCertificationProgress } from '../../learn-lib'
import { CoursesCard } from '../courses-card'
import { FilterBar } from '../filter-bar'

import styles from './AvailableCoursesList.module.scss'

Expand All @@ -13,6 +14,7 @@ interface AvailableCoursesListProps {
certificationsGroups: Array<string>
selectedCategory: string
certificationsProgresses: ReadonlyArray<LearnUserCertificationProgress>
onSelectCategory: (e: ChangeEvent<HTMLInputElement>) => void
}

const AvailableCoursesList: FC<AvailableCoursesListProps> = (props: AvailableCoursesListProps) => {
Expand Down Expand Up @@ -41,6 +43,20 @@ const AvailableCoursesList: FC<AvailableCoursesListProps> = (props: AvailableCou
</Fragment>
)

// compute all the available category dropdown options
const certsCategoriesOptions: Array<{
label: string,
value: string,
}> = useMemo(() => [
{ label: 'All Categories', orderIndex: -1, value: '' },
...Object.keys(props.certsByCategory)
.sort()
.map(c => ({
label: c,
value: c,
})),
], [props.certsByCategory])

return (
<div className={styles.wrap}>
<div className={styles.coursesListHeaderWrap}>
Expand All @@ -52,6 +68,11 @@ const AvailableCoursesList: FC<AvailableCoursesListProps> = (props: AvailableCou
</span>
</h2>

<FilterBar
certsCategoriesOptions={certsCategoriesOptions}
onSelectCategory={props.onSelectCategory}
selectedCategory={props.selectedCategory}
/>
</div>

<div className={styles.teaseBanner}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.coursesListFilters {
display: flex;
margin-left: auto;
margin-top: $space-xxxxl;

gap: $space-xxl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
display: flex;
flex-direction: column;
margin-bottom: $space-xxxxl;
margin-top: $space-xxl;

@include ltemd {
margin-bottom: 0;
Expand Down