From 2eea01fc740bfa4db2dc45045c04033421a94297 Mon Sep 17 00:00:00 2001 From: Abhinav Chadaga Date: Sat, 17 Feb 2024 11:22:12 -0600 Subject: [PATCH] use chip component in header --- src/views/components/common/Chip/Chip.tsx | 33 ++++++++++++------- .../CoursePopup2/CourseHeadingAndActions.tsx | 13 ++------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/views/components/common/Chip/Chip.tsx b/src/views/components/common/Chip/Chip.tsx index 35dac4a6..b6701517 100644 --- a/src/views/components/common/Chip/Chip.tsx +++ b/src/views/components/common/Chip/Chip.tsx @@ -1,26 +1,37 @@ import React from 'react'; import Text from '../Text/Text'; - -export const flags = ["WR", "QR", "GC", "CD", "E", "II"] +/** + * A type that represents the flags that a course can have. + */ +export type Flag = 'WR' | 'QR' | 'GC' | 'CD' | 'E' | 'II'; +export const flagMap: Record = { + Writing: 'WR', + 'Quantitative Reasoning': 'QR', + 'Global Cultures': 'GC', + 'Cultural Diversity in the United States': 'CD', + Ethics: 'E', + 'Independent Inquiry': 'II', +}; interface Props { - label: string; + label: Flag; } /** * A reusable chip component that follows the design system of the extension. * @returns */ -export function Chip({ - label -}: React.PropsWithChildren): JSX.Element { +export function Chip({ label }: React.PropsWithChildren): JSX.Element { return ( - + {label} ); diff --git a/src/views/components/injected/CoursePopup2/CourseHeadingAndActions.tsx b/src/views/components/injected/CoursePopup2/CourseHeadingAndActions.tsx index 47a7274a..960e9fdb 100644 --- a/src/views/components/injected/CoursePopup2/CourseHeadingAndActions.tsx +++ b/src/views/components/injected/CoursePopup2/CourseHeadingAndActions.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { Course } from 'src/shared/types/Course'; import { Button } from '../../common/Button/Button'; +import { Chip, flagMap } from '../../common/Chip/Chip'; import Icon from '../../common/Icon/Icon'; import Text from '../../common/Text/Text'; @@ -31,20 +32,12 @@ const CourseHeadingAndActions = ({ course, onClose }: CourseHeadingAndActionsPro
- + with {instructorString}
{flags.map(flag => ( -
- {/* get the first letter of each word in flag */} - - {flag - .split(' ') - .map(word => word.charAt(0)) - .join('')} - -
+ ))}