Skip to content

Commit 02b7e7c

Browse files
authored
Merge pull request #21 from OpenPecha/feature/collapsible-studio-course-outline-help-sidebar
feat: make studio course outline help sidebar collapsible with header
2 parents ea78f4b + aec2689 commit 02b7e7c

3 files changed

Lines changed: 131 additions & 13 deletions

File tree

src/course-outline/outline-sidebar/OutlineSidebar.jsx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { Hyperlink } from '@openedx/paragon';
3+
import { Collapsible, Hyperlink, Icon } from '@openedx/paragon';
4+
import { OpenInNew } from '@openedx/paragon/icons';
45
import { useIntl } from '@edx/frontend-platform/i18n';
56

67
import { HelpSidebar } from '../../generic/help-sidebar';
78
import { useHelpUrls } from '../../help-urls/hooks';
89
import { getFormattedSidebarMessages } from './utils';
10+
import messages from './messages';
911

1012
const OutlineSideBar = ({ courseId }) => {
1113
const intl = useIntl();
@@ -28,32 +30,38 @@ const OutlineSideBar = ({ courseId }) => {
2830
<HelpSidebar
2931
courseId={courseId}
3032
showOtherSettings={false}
31-
className="outline-sidebar mt-4"
33+
className="outline-sidebar"
3234
data-testid="outline-sidebar"
3335
>
34-
{sidebarMessages.map(({ title, descriptions, link }, index) => {
35-
const isLastSection = index === sidebarMessages.length - 1;
36-
37-
return (
38-
<div className="outline-sidebar-section" key={title}>
39-
<h4 className="help-sidebar-about-title">{title}</h4>
36+
<div className="outline-sidebar-header">
37+
<h3 className="outline-sidebar-header-title m-0">{intl.formatMessage(messages.sidebar_header)}</h3>
38+
</div>
39+
<div className="outline-sidebar-sections">
40+
{sidebarMessages.map(({ title, descriptions, link }) => (
41+
<Collapsible
42+
key={title}
43+
className="outline-sidebar-section border-0"
44+
styling="card-lg"
45+
unmountOnExit={false}
46+
title={<h4 className="help-sidebar-about-title m-0">{title}</h4>}
47+
>
4048
{descriptions.map((description) => (
4149
<p className="help-sidebar-about-descriptions" key={description}>{description}</p>
4250
))}
4351
{Boolean(link) && Boolean(link.href) && (
4452
<Hyperlink
45-
className="small"
53+
className="outline-sidebar-section-link small d-inline-flex align-items-center"
4654
destination={link.href}
4755
target="_blank"
4856
showLaunchIcon={false}
4957
>
5058
{link.text}
59+
<Icon src={OpenInNew} className="outline-sidebar-section-link-icon" />
5160
</Hyperlink>
5261
)}
53-
{!isLastSection && <hr className="my-3.5" />}
54-
</div>
55-
);
56-
})}
62+
</Collapsible>
63+
))}
64+
</div>
5765
</HelpSidebar>
5866
);
5967
};

src/course-outline/outline-sidebar/messages.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { defineMessages } from '@edx/frontend-platform/i18n';
22

33
const messages = defineMessages({
4+
sidebar_header: {
5+
id: 'course-authoring.course-outline.sidebar.header',
6+
defaultMessage: 'Need help with your course?',
7+
},
48
section_1_title: {
59
id: 'course-authoring.course-outline.sidebar.section-1.title',
610
defaultMessage: 'Creating your course organization',

src/generic/help-sidebar/HelpSidebar.scss

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,109 @@
3232
margin-bottom: .5rem;
3333
}
3434
}
35+
36+
.outline-sidebar {
37+
// Keep the header at the very top of the sidebar column (aligned with the
38+
// StatusBar on the content side).
39+
margin-top: 0;
40+
}
41+
42+
.outline-sidebar .outline-sidebar-header {
43+
// Offset the header so the FIRST collapsible card lines up with the top of
44+
// the "Optimize your course with AI" box on the content side (the heading
45+
// sits above it).
46+
margin-top: 2.25rem;
47+
48+
.outline-sidebar-header-title {
49+
font: normal var(--pgn-typography-font-weight-bold) 1.375rem/1.75rem var(--pgn-typography-font-family-base);
50+
color: var(--pgn-color-info-500);
51+
}
52+
}
53+
54+
.outline-sidebar .outline-sidebar-sections {
55+
// Align the first collapsible with the top border of the section cards on
56+
// the content side.
57+
margin-top: 1.5rem;
58+
display: flex;
59+
flex-direction: column;
60+
gap: .75rem;
61+
}
62+
63+
.outline-sidebar .outline-sidebar-section.collapsible-card-lg {
64+
border: 1px solid var(--pgn-color-light-400) !important;
65+
border-radius: .5rem;
66+
background: var(--pgn-color-white);
67+
overflow: hidden;
68+
transition: border-color .15s ease, box-shadow .15s ease;
69+
70+
&:hover {
71+
border-color: var(--pgn-color-info-300) !important;
72+
box-shadow: 0 .125rem .5rem rgba(15, 14, 40, .06);
73+
}
74+
75+
&.is-open {
76+
border-color: var(--pgn-color-info-300) !important;
77+
box-shadow: 0 .125rem .75rem rgba(15, 14, 40, .08);
78+
}
79+
80+
.collapsible-trigger {
81+
justify-content: space-between;
82+
align-items: center;
83+
text-decoration: none;
84+
color: var(--pgn-color-black);
85+
padding: .875rem 1rem;
86+
border: 0;
87+
cursor: pointer;
88+
transition: background .15s ease;
89+
90+
&:hover {
91+
background: var(--pgn-color-light-200);
92+
}
93+
}
94+
95+
.help-sidebar-about-title {
96+
font: normal var(--pgn-typography-font-weight-bold) .9375rem/1.375rem var(--pgn-typography-font-family-base);
97+
color: var(--pgn-color-black);
98+
}
99+
100+
.collapsible-icon {
101+
color: var(--pgn-color-gray-500);
102+
margin-left: .5rem;
103+
flex-shrink: 0;
104+
}
105+
106+
&.is-open .collapsible-icon {
107+
color: var(--pgn-color-info-500);
108+
}
109+
110+
.collapsible-body {
111+
padding: 0 1rem 1rem;
112+
}
113+
114+
.help-sidebar-about-descriptions {
115+
font: normal var(--pgn-typography-font-weight-normal) .875rem/1.5rem var(--pgn-typography-font-family-base);
116+
color: $text-color-base;
117+
margin-bottom: .75rem;
118+
119+
&:last-of-type {
120+
margin-bottom: 0;
121+
}
122+
}
123+
124+
.outline-sidebar-section-link {
125+
margin-top: .75rem;
126+
color: var(--pgn-color-info-500);
127+
font-weight: var(--pgn-typography-font-weight-bold);
128+
text-decoration: none;
129+
130+
&:hover {
131+
text-decoration: underline;
132+
}
133+
134+
.outline-sidebar-section-link-icon {
135+
width: 1rem;
136+
height: 1rem;
137+
margin-left: .25rem;
138+
}
139+
}
140+
}

0 commit comments

Comments
 (0)