Skip to content

Commit 3669ad2

Browse files
authored
Shanbady/topic channel page header fixes (#1063)
* remove padding from FieldControls element * making margin on breadcrumb 16px * font size adjustments * fixing width for right panel * adding mail outline icon * adjusting margins around text container and subscribe button * visual tweaks * changing body text * minor visual tweaks * padding tweaks * fixing background placement and padding adjustments * style fixes * slight width adjustment * font fixes * ui tweaks * removing unused alt attributes * adding reversed banner images * Revert "adding reversed banner images" This reverts commit 9a72754. * Reapply "adding reversed banner images" This reverts commit 9a45c26. * adding dimmable background * some lint * removing some margin * removing duplicate css * fixing lint * fixing broken test * background image size adjustment * adding default bg constant * fixing background dimming and zindex issues * fixing banner padding to match figma * fixing responsive sizing of channel box * fixing padding * fix ordering of elements * lint fix and padding * fixing interior padding for sm dimension * lint fix * lint fix * padding adjustment * pushed fix for padding * revert heading change
1 parent c1cd0c7 commit 3669ad2

File tree

11 files changed

+118
-99
lines changed

11 files changed

+118
-99
lines changed
-28.9 KB
Loading
-43.6 KB
Loading

frontends/mit-open/src/page-components/ChannelDetails/ChannelDetails.tsx

Lines changed: 52 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const FACETS_BY_CHANNEL_TYPE: Record<ChannelTypeEnum, string[]> = {
2424
[ChannelTypeEnum.Unit]: [
2525
"offerings",
2626
"audience",
27+
"fee",
2728
"formats",
2829
"content_types",
2930
"certifications",
@@ -47,34 +48,42 @@ const getFacetManifest = (channelType: ChannelTypeEnum) => {
4748
{
4849
name: "topic",
4950
title: "Topic",
51+
order: 0,
5052
},
5153
{
5254
name: "formats",
5355
title: "Formats",
56+
order: 0,
5457
},
5558
{
5659
name: "fee",
5760
title: "Fee",
61+
order: 0,
5862
},
5963
{
6064
name: "department",
6165
title: "Department",
66+
order: 0,
6267
},
6368
{
6469
name: "offerings",
6570
title: "Offerings",
71+
order: -1,
6672
},
6773
{
6874
name: "level",
6975
title: "Level",
76+
order: 0,
7077
},
7178
{
7279
name: "content_types",
7380
title: "Type of Content",
81+
order: 0,
7482
},
7583
{
7684
name: "audience",
7785
title: "Audience",
86+
order: 0,
7887
},
7988
{
8089
name: "more_information",
@@ -84,22 +93,27 @@ const getFacetManifest = (channelType: ChannelTypeEnum) => {
8493
{channelTitle} website <OpenInNewIcon fontSize="inherit" />
8594
</a>
8695
),
96+
order: 1,
8797
},
8898
{
8999
name: "platform",
90100
title: "Platform",
101+
order: 0,
91102
},
92103
{
93104
name: "offered_by",
94105
title: "Offered By",
106+
order: 0,
95107
},
96108
{
97109
name: "certifications",
98110
title: "Certificate",
111+
order: 0,
99112
},
100113
{
101114
name: "learning_format",
102115
title: "Format",
116+
order: 0,
103117
labelFunction: (key: string) =>
104118
key
105119
.split("_")
@@ -127,12 +141,15 @@ const InfoLabel = styled(Typography)(({ theme }) => ({
127141
const ChannelDetailsCard = styled(Box)(({ theme }) => ({
128142
borderRadius: "12px",
129143
backgroundColor: "white",
130-
minWidth: "300px",
131-
padding: "32px",
144+
padding: "36px",
132145
display: "flex",
133146
flexDirection: "column",
134147
gap: "16px",
148+
[theme.breakpoints.up("md")]: {
149+
minWidth: "408px",
150+
},
135151
[theme.breakpoints.down("md")]: {
152+
padding: "16px",
136153
width: "100%",
137154
},
138155
}))
@@ -142,36 +159,45 @@ const ChannelDetails: React.FC<ChannelDetailsProps> = (props) => {
142159
const channelDetails = getChannelDetails(field)
143160
const channelType = field.channel_type
144161
const channelTitle = field.title
162+
145163
const facetManifest = useMemo(
146164
() => getFacetManifest(channelType),
147165
[channelType],
148166
)
149167

150-
const body = facetManifest.map((value) => {
151-
const detailValue = (
152-
channelDetails as unknown as { [key: string]: string }
153-
)[value.name]
154-
if (detailValue) {
155-
const label = value?.labelFunction
156-
? value.labelFunction(detailValue, channelTitle)
157-
: detailValue
168+
const body = facetManifest
169+
.sort((a, b) =>
170+
a?.order && b?.order && a?.order > b?.order
171+
? 1
172+
: a?.order && b?.order && b?.order > a?.order
173+
? -1
174+
: 0,
175+
)
176+
.map((value) => {
177+
const detailValue = (
178+
channelDetails as unknown as { [key: string]: string }
179+
)[value.name]
180+
if (detailValue) {
181+
const label = value?.labelFunction
182+
? value.labelFunction(detailValue, channelTitle)
183+
: detailValue
158184

159-
return (
160-
<Box key={value.title}>
161-
<InfoLabel
162-
variant="subtitle2"
163-
sx={{ marginBottom: (theme) => theme.typography.pxToRem(4) }}
164-
>
165-
{value.title}:
166-
</InfoLabel>
167-
<Typography variant="body3" color="text.secondary">
168-
{Array.isArray(label) ? label.join(" | ") : label}
169-
</Typography>
170-
</Box>
171-
)
172-
}
173-
return null
174-
})
185+
return (
186+
<Box key={value.title}>
187+
<InfoLabel
188+
variant="subtitle2"
189+
sx={{ marginBottom: (theme) => theme.typography.pxToRem(4) }}
190+
>
191+
{value.title}
192+
</InfoLabel>
193+
<Typography variant="body3" color="text.secondary">
194+
{Array.isArray(label) ? label.join(" | ") : label}
195+
</Typography>
196+
</Box>
197+
)
198+
}
199+
return null
200+
})
175201
return <ChannelDetailsCard>{body}</ChannelDetailsCard>
176202
}
177203

frontends/mit-open/src/page-components/SearchSubscriptionToggle/SearchSubscriptionToggle.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { SimpleMenuItem } from "ol-components"
1010
import ExpandMoreSharpIcon from "@mui/icons-material/ExpandMoreSharp"
1111
import { useUserMe } from "api/hooks/user"
1212
import { SourceTypeEnum } from "api"
13+
import MailOutlineIcon from "@mui/icons-material/MailOutline"
1314

1415
const SearchSubscriptionToggle = ({
1516
searchParams,
@@ -61,6 +62,7 @@ const SearchSubscriptionToggle = ({
6162
<Button
6263
variant="primary"
6364
disabled={subscriptionCreate.isLoading}
65+
startIcon={<MailOutlineIcon />}
6466
onClick={() =>
6567
subscriptionCreate.mutateAsync({
6668
PercolateQuerySubscriptionRequestRequest: subscribeParams,

frontends/mit-open/src/pages/ArticleDetailsPage/ArticleDetailsPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const ArticlesDetailPage: React.FC = () => {
2424
return (
2525
<BannerPage
2626
src="/static/images/course_search_banner.png"
27-
alt=""
2827
className="articles-detail-page"
2928
>
3029
<MetaTags>

frontends/mit-open/src/pages/FieldPage/FieldPage.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@ describe("FieldPage", () => {
115115
const header = title[0].closest("header")
116116
assertInstanceOf(header, HTMLElement)
117117
const images = within(header).getAllByRole("img") as HTMLImageElement[]
118-
119-
expect(images[0].src).toContain(field.configuration.banner_background)
120-
expect(images[1].src).toContain(field.configuration.logo)
118+
const headerStyles = getComputedStyle(header)
119+
expect(headerStyles.backgroundImage).toContain(
120+
field.configuration.banner_background,
121+
)
122+
expect(images[0].src).toContain(field.configuration.logo)
121123
})
122124
it("Displays a featured carousel if the channel type is 'unit'", async () => {
123125
const { field } = setupApis({

frontends/mit-open/src/pages/FieldPage/FieldPageSkeleton.tsx

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export const FieldControls = styled.div`
3636
position: relative;
3737
min-height: 38px;
3838
display: flex;
39-
margin-bottom: 1em;
4039
`
4140

4241
interface FieldSkeletonProps {
@@ -52,7 +51,10 @@ const NAV_PATH: { [key: string]: string } = {
5251

5352
const NavText = styled(Typography)(({ theme }) => ({
5453
color: theme.custom.colors.lightGray2,
55-
marginBottom: "10px",
54+
marginBottom: "16px",
55+
[theme.breakpoints.down("md")]: {
56+
marginBottom: "32px",
57+
},
5658
".current": {
5759
color: theme.custom.colors.silverGrayLight,
5860
},
@@ -94,10 +96,11 @@ const FieldSkeletonProps: React.FC<FieldSkeletonProps> = ({
9496
displayConfiguration?.banner_background ??
9597
"/static/images/background_steps.jpeg"
9698
}
97-
alt=""
9899
omitBackground={field.isLoading}
100+
backgroundSize="2000px auto"
101+
dim={30}
99102
bannerContent={
100-
<Container sx={{ my: 2, py: "48px" }}>
103+
<Container sx={{ pt: "48px", pb: "64px" }}>
101104
<NavText variant="subtitle3">
102105
Home / {NAV_PATH[channelType]} /{" "}
103106
<span className="current">{field.data?.title}</span>
@@ -120,13 +123,28 @@ const FieldSkeletonProps: React.FC<FieldSkeletonProps> = ({
120123
display="flex"
121124
flexDirection="column"
122125
alignItems="start"
123-
sx={{ flexGrow: 24, flexShrink: 0, order: 1, width: "60%" }}
126+
sx={{
127+
flexGrow: 1,
128+
flexShrink: 0,
129+
order: 1,
130+
width: "50%",
131+
}}
124132
>
125133
<Box
126134
display="flex"
127135
flexDirection="row"
128136
alignItems="center"
129-
sx={{ flexGrow: 1, flexShrink: 0, order: 1, mt: 3 }}
137+
sx={(theme) => ({
138+
flexGrow: 1,
139+
flexShrink: 0,
140+
order: 1,
141+
py: "24px",
142+
143+
[theme.breakpoints.down("md")]: {
144+
py: 0,
145+
pb: "8px",
146+
},
147+
})}
130148
>
131149
{displayConfiguration?.logo ? (
132150
<FieldAvatar
@@ -136,7 +154,7 @@ const FieldSkeletonProps: React.FC<FieldSkeletonProps> = ({
136154
field={field.data}
137155
/>
138156
) : (
139-
<Typography variant="h3" data-testid="header">
157+
<Typography variant="h1" data-testid="header">
140158
<Link
141159
to={routes.makeFieldViewPath(
142160
field.data.channel_type,
@@ -157,8 +175,8 @@ const FieldSkeletonProps: React.FC<FieldSkeletonProps> = ({
157175
flexGrow: 0,
158176
flexShrink: 0,
159177
order: 2,
160-
width: "90%",
161-
my: 2,
178+
width: { md: "80%", sm: "100%" },
179+
my: 1,
162180
}}
163181
>
164182
<Typography variant="h4">
@@ -176,11 +194,11 @@ const FieldSkeletonProps: React.FC<FieldSkeletonProps> = ({
176194
flexGrow: 0,
177195
flexShrink: 0,
178196
order: 2,
179-
width: "60%",
180-
my: 2,
197+
width: { md: "80%", sm: "100%" },
198+
my: 1,
181199
}}
182200
>
183-
<Typography variant="body2">
201+
<Typography variant="body1">
184202
{displayConfiguration.sub_heading}
185203
</Typography>
186204
</Box>
@@ -194,7 +212,8 @@ const FieldSkeletonProps: React.FC<FieldSkeletonProps> = ({
194212
width: "100%",
195213
flexShrink: 1,
196214
order: 3,
197-
my: 2,
215+
mt: { xs: "8px" },
216+
mb: { xs: "48px" },
198217
}}
199218
>
200219
<FieldControls>
@@ -222,9 +241,9 @@ const FieldSkeletonProps: React.FC<FieldSkeletonProps> = ({
222241
display="flex"
223242
sx={{
224243
order: 2,
225-
flexGrow: 1,
244+
flexGrow: 0,
226245
flexShrink: 0,
227-
width: { md: "300px", xs: "100%" },
246+
width: { md: "408px", xs: "100%" },
228247
}}
229248
>
230249
<ChannelDetails field={field.data} />
@@ -235,11 +254,12 @@ const FieldSkeletonProps: React.FC<FieldSkeletonProps> = ({
235254
flexDirection="row"
236255
alignItems="end"
237256
sx={{
238-
flexGrow: 1,
257+
flexGrow: 0,
239258
width: { md: "15%", xs: "100%" },
240259
flexShrink: 0,
241260
order: 2,
242-
my: 1,
261+
mt: { md: "0px", sm: "8px" },
262+
mb: { md: "0px", sm: "48px" },
243263
}}
244264
>
245265
<FieldControls>

frontends/mit-open/src/pages/LearningPathListingPage/LearningPathListingPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ const LearningPathListingPage: React.FC = () => {
9191
return (
9292
<BannerPage
9393
src="/static/images/course_search_banner.png"
94-
alt=""
9594
className="learningpaths-page"
9695
>
9796
<MetaTags>

frontends/mit-open/src/pages/ListDetailsPage/ListDetailsPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ const ListDetailsPage: React.FC<ListDetailsPageProps> = ({
112112
return (
113113
<BannerPage
114114
src="/static/images/course_search_banner.png"
115-
alt=""
116115
className="learningpaths-page"
117116
>
118117
<MetaTags>

frontends/mit-open/src/pages/UserListListingPage/UserListListingPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ const UserListListingPage: React.FC = () => {
159159
return (
160160
<BannerPage
161161
src="/static/images/course_search_banner.png"
162-
alt=""
163162
className="learningpaths-page"
164163
>
165164
<MetaTags>

0 commit comments

Comments
 (0)