Skip to content

Commit fc2c65a

Browse files
authored
Layout fixes (#2623)
* Layout fixes * Explicit top position and test factory values for certificate type
1 parent b2128b2 commit fc2c65a

File tree

6 files changed

+67
-11
lines changed

6 files changed

+67
-11
lines changed

frontends/api/src/test-utils/factories/learningResources.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
ResourceTypeEnum,
4040
LearningResourceRunLevelInnerCodeEnum,
4141
PlatformEnum,
42+
CourseResourceCertificationTypeCodeEnum,
4243
} from "api"
4344

4445
const uniqueEnforcerId = new UniqueEnforcer()
@@ -343,6 +344,9 @@ const learningResourceSummary: LearningResourceFactory<
343344
const learningResourceSummaries = makePaginatedFactory(learningResourceSummary)
344345

345346
const program: PartialFactory<ProgramResource> = (overrides = {}) => {
347+
const certificationCode = faker.helpers.enumValue(
348+
CourseResourceCertificationTypeCodeEnum,
349+
)
346350
return mergeOverrides<ProgramResource>(
347351
_learningResourceShared(),
348352
{ resource_type: ResourceTypeEnum.Program },
@@ -353,13 +357,28 @@ const program: PartialFactory<ProgramResource> = (overrides = {}) => {
353357
program: {
354358
course_count: faker.number.int({ min: 0, max: 8 }),
355359
},
360+
certification_type: {
361+
code: certificationCode,
362+
name: {
363+
[CourseResourceCertificationTypeCodeEnum.Professional]:
364+
"Professional Certificate",
365+
[CourseResourceCertificationTypeCodeEnum.Micromasters]:
366+
"MicroMasters Credential",
367+
[CourseResourceCertificationTypeCodeEnum.Completion]:
368+
"Certificate of Completion",
369+
[CourseResourceCertificationTypeCodeEnum.None]: "No Certificate",
370+
}[certificationCode],
371+
},
356372
},
357373
overrides,
358374
)
359375
}
360376
const programs = makePaginatedFactory(program)
361377

362378
const course: LearningResourceFactory<CourseResource> = (overrides = {}) => {
379+
const certificationCode = faker.helpers.enumValue(
380+
CourseResourceCertificationTypeCodeEnum,
381+
)
363382
return mergeOverrides<CourseResource>(
364383
_learningResourceShared(),
365384
{ resource_type: ResourceTypeEnum.Course },
@@ -368,6 +387,18 @@ const course: LearningResourceFactory<CourseResource> = (overrides = {}) => {
368387
platform: learningResourcePlatform(),
369388
runs: repeat(learningResourceRun, { min: 1, max: 5 }),
370389
certification: faker.datatype.boolean(),
390+
certification_type: {
391+
code: certificationCode,
392+
name: {
393+
[CourseResourceCertificationTypeCodeEnum.Professional]:
394+
"Professional Certificate",
395+
[CourseResourceCertificationTypeCodeEnum.Micromasters]:
396+
"MicroMasters Credential",
397+
[CourseResourceCertificationTypeCodeEnum.Completion]:
398+
"Certificate of Completion",
399+
[CourseResourceCertificationTypeCodeEnum.None]: "No Certificate",
400+
}[certificationCode],
401+
},
371402
course: {
372403
course_numbers:
373404
maybe(() => repeat(learningResourceCourseNumber)) ?? null,

frontends/main/src/app-pages/DashboardPage/DashboardLayout.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ const Background = styled.div(({ theme }) => ({
7474
},
7575
}))
7676

77+
const PADDING_TOP = 40
78+
7779
const PageContainer = styled(Container)({
78-
paddingTop: "40px",
80+
paddingTop: PADDING_TOP,
7981
paddingBottom: "80px",
8082
})
8183

@@ -97,15 +99,16 @@ const DashboardGridItem = styled.div({
9799
},
98100
})
99101

100-
const ProfileSidebar = styled(Card)({
101-
position: "fixed",
102+
const ProfileSidebar = styled(Card)(({ theme }) => ({
103+
position: "sticky",
104+
top: `${theme.custom.dimensions.headerHeight + PADDING_TOP}px`,
102105
display: "flex",
103106
flexDirection: "column",
104107
alignItems: "flex-start",
105108
width: "300px",
106109
boxShadow: "-4px 4px 0px 0px #A31F34",
107110
transform: "translateX(4px)", // keep solid shadow from bleeding into page margins
108-
})
111+
}))
109112

110113
const ProfilePhotoContainer = styled.div(({ theme }) => ({
111114
display: "flex",

frontends/main/src/app-pages/HomePage/NewsEventsSection.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ const EventCard = styled(Card)`
110110
gap: 16px;
111111
flex: 1 0 0;
112112
align-self: stretch;
113-
justify-content: space-between;
114113
overflow: visible;
115114
padding: 16px;
116115
`
@@ -142,7 +141,8 @@ const EventMonth = styled.p`
142141
${{ ...theme.typography.subtitle3 }}
143142
`
144143

145-
const EventTitle = styled.p`
144+
const EventTitle = styled(Link)`
145+
flex-grow: 1;
146146
color: ${theme.custom.colors.darkGray2};
147147
${{ ...theme.typography.subtitle1 }}
148148
margin: 0;
@@ -238,9 +238,9 @@ const NewsEventsSection: React.FC = () => {
238238
/>
239239
</EventMonth>
240240
</EventDate>
241-
<Link href={item.url} data-card-link>
242-
<EventTitle>{item.title}</EventTitle>
243-
</Link>
241+
<EventTitle href={item.url} data-card-link>
242+
{item.title}
243+
</EventTitle>
244244
<Chevron />
245245
</Card.Content>
246246
</EventCard>

frontends/ol-components/src/components/Card/ListCard.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const Body = styled.div`
2222
margin: 24px;
2323
${theme.breakpoints.down("md")} {
2424
margin: 12px;
25+
min-width: 190px;
2526
}
2627
2728
display: flex;

frontends/ol-components/src/components/LearningResourceCard/LearningResourceListCard.test.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ describe("Learning Resource List Card", () => {
167167

168168
setup({ resource })
169169

170-
screen.getByText("Certificate")
170+
expect(screen.getAllByText("Certificate").length).toEqual(2)
171171
})
172172

173173
test("Displays certificate type", () => {
@@ -239,6 +239,7 @@ describe("Learning Resource List Card", () => {
239239

240240
test('Free course with paid certificate option displays the certificate price and "Free"', () => {
241241
const resource = factories.learningResources.resource({
242+
resource_type: ResourceTypeEnum.Course,
242243
certification: true,
243244
free: true,
244245
resource_prices: [
@@ -248,12 +249,14 @@ describe("Learning Resource List Card", () => {
248249
})
249250
setup({ resource })
250251
screen.getByText("Certificate")
252+
screen.getByText(resource.certification_type.name)
251253
screen.getByText(": $49")
252254
screen.getByText("Free")
253255
})
254256

255257
test('Free course with paid certificate option range displays the certificate price range and "Free". Prices are sorted correctly', () => {
256258
const resource = factories.learningResources.resource({
259+
resource_type: ResourceTypeEnum.Program,
257260
certification: true,
258261
free: true,
259262
resource_prices: [
@@ -263,7 +266,10 @@ describe("Learning Resource List Card", () => {
263266
],
264267
})
265268
setup({ resource })
269+
266270
screen.getByText("Certificate")
271+
screen.getByText(resource.certification_type.name)
272+
267273
screen.getByText(": $49 – $99")
268274
screen.getByText("Free")
269275
})

frontends/ol-components/src/components/LearningResourceCard/LearningResourceListCard.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ const CertificateText = styled.div`
7575
display: flex;
7676
`
7777

78+
const MobileOnly = styled.div(({ theme }) => ({
79+
[theme.breakpoints.up("sm")]: {
80+
display: "none",
81+
},
82+
}))
83+
84+
const DesktopOnly = styled.div(({ theme }) => ({
85+
[theme.breakpoints.down("sm")]: {
86+
display: "none",
87+
},
88+
}))
89+
7890
const CertificatePrice = styled.div`
7991
${{ ...theme.typography.body3 }}
8092
${theme.breakpoints.down("md")} {
@@ -121,7 +133,10 @@ const Info = ({ resource }: { resource: LearningResource }) => {
121133
<Certificate>
122134
<RiAwardFill />
123135
<CertificateText>
124-
{resource.certification_type?.name || "Certificate"}
136+
<MobileOnly>Certificate</MobileOnly>
137+
<DesktopOnly>
138+
{resource.certification_type?.name || "Certificate"}
139+
</DesktopOnly>
125140
<CertificatePrice>
126141
{prices.certificate.display ? ": " : ""}{" "}
127142
{prices.certificate.display}

0 commit comments

Comments
 (0)