Skip to content

Commit d99a09e

Browse files
authored
fix: Library v2 info sidebar UI fixes (#1226)
1 parent 259a50c commit d99a09e

File tree

6 files changed

+49
-8
lines changed

6 files changed

+49
-8
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.library-authoring-page {
2+
.header-actions {
3+
.normal-border {
4+
border: 1px solid;
5+
}
6+
7+
.open-border {
8+
border: 2px solid;
9+
}
10+
}
11+
}

src/library-authoring/LibraryAuthoringPage.test.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,17 +370,22 @@ describe('<LibraryAuthoringPage />', () => {
370370
expect((await screen.findAllByText(libraryData.title))[0]).toBeInTheDocument();
371371
expect((await screen.findAllByText(libraryData.title))[1]).toBeInTheDocument();
372372

373+
// Open by default; close the library info sidebar
373374
const closeButton = screen.getByRole('button', { name: /close/i });
374375
fireEvent.click(closeButton);
375-
376376
expect(screen.queryByText('Draft')).not.toBeInTheDocument();
377377
expect(screen.queryByText('(Never Published)')).not.toBeInTheDocument();
378378

379+
// Open library info sidebar with 'Library info' button
379380
const libraryInfoButton = screen.getByRole('button', { name: /library info/i });
380381
fireEvent.click(libraryInfoButton);
381-
382382
expect(screen.getByText('Draft')).toBeInTheDocument();
383383
expect(screen.getByText('(Never Published)')).toBeInTheDocument();
384+
385+
// CLose library info sidebar with 'Library info' button
386+
fireEvent.click(libraryInfoButton);
387+
expect(screen.queryByText('Draft')).not.toBeInTheDocument();
388+
expect(screen.queryByText('(Never Published)')).not.toBeInTheDocument();
384389
});
385390

386391
it('show the "View All" button when viewing library with many components', async () => {

src/library-authoring/LibraryAuthoringPage.tsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useContext, useEffect } from 'react';
2+
import classNames from 'classnames';
23
import { StudioFooter } from '@edx/frontend-component-footer';
34
import { useIntl } from '@edx/frontend-platform/i18n';
45
import {
@@ -33,7 +34,7 @@ import LibraryCollections from './LibraryCollections';
3334
import LibraryHome from './LibraryHome';
3435
import { useContentLibrary } from './data/apiHooks';
3536
import { LibrarySidebar } from './library-sidebar';
36-
import { LibraryContext } from './common/context';
37+
import { LibraryContext, SidebarBodyComponentId } from './common/context';
3738
import messages from './messages';
3839

3940
enum TabList {
@@ -51,30 +52,49 @@ const HeaderActions = ({ canEditLibrary }: HeaderActionsProps) => {
5152
const {
5253
openAddContentSidebar,
5354
openInfoSidebar,
55+
closeLibrarySidebar,
56+
sidebarBodyComponent,
5457
} = useContext(LibraryContext);
5558

5659
if (!canEditLibrary) {
5760
return null;
5861
}
5962

63+
const infoSidebarIsOpen = () => (
64+
sidebarBodyComponent === SidebarBodyComponentId.Info
65+
);
66+
67+
const handleOnClickInfoSidebar = () => {
68+
if (infoSidebarIsOpen()) {
69+
closeLibrarySidebar();
70+
} else {
71+
openInfoSidebar();
72+
}
73+
};
74+
6075
return (
61-
<>
76+
<div className="header-actions">
6277
<Button
78+
className={classNames('mr-1', {
79+
'normal-border': !infoSidebarIsOpen(),
80+
'open-border': infoSidebarIsOpen(),
81+
})}
6382
iconBefore={InfoOutline}
6483
variant="outline-primary rounded-0"
65-
onClick={openInfoSidebar}
84+
onClick={handleOnClickInfoSidebar}
6685
>
6786
{intl.formatMessage(messages.libraryInfoButton)}
6887
</Button>
6988
<Button
89+
className="ml-1"
7090
iconBefore={Add}
7191
variant="primary rounded-0"
7292
onClick={openAddContentSidebar}
7393
disabled={!canEditLibrary}
7494
>
7595
{intl.formatMessage(messages.newContentButton)}
7696
</Button>
77-
</>
97+
</div>
7898
);
7999
};
80100

@@ -132,7 +152,7 @@ const LibraryAuthoringPage = () => {
132152
};
133153

134154
return (
135-
<Container>
155+
<Container className="library-authoring-page">
136156
<Row>
137157
<Col>
138158
<Header

src/library-authoring/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
@import "library-authoring/components/ComponentCard";
22
@import "library-authoring/library-info/LibraryPublishStatus";
3+
@import "library-authoring/LibraryAuthoringPage";

src/library-authoring/library-info/LibraryInfoHeader.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const LibraryInfoHeader = ({ library } : LibraryInfoHeaderProps) => {
6666
)
6767
: (
6868
<>
69-
<span className="font-weight-bold m-1.5">
69+
<span className="font-weight-bold mt-1.5 ml-1.5">
7070
{library.title}
7171
</span>
7272
{library.canEditLibrary && (
@@ -75,6 +75,8 @@ const LibraryInfoHeader = ({ library } : LibraryInfoHeaderProps) => {
7575
iconAs={Icon}
7676
alt={intl.formatMessage(messages.editNameButtonAlt)}
7777
onClick={handleClick}
78+
className="mt-1"
79+
size="inline"
7880
/>
7981
)}
8082
</>

src/library-authoring/library-sidebar/LibrarySidebar.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ const LibrarySidebar = ({ library }: LibrarySidebarProps) => {
4949
<Stack direction="horizontal" className="d-flex justify-content-between">
5050
{buildHeader()}
5151
<IconButton
52+
className="mt-1"
5253
src={Close}
5354
iconAs={Icon}
5455
alt={intl.formatMessage(messages.closeButtonAlt)}
5556
onClick={closeLibrarySidebar}
5657
variant="black"
58+
size="inline"
5759
/>
5860
</Stack>
5961
<div>

0 commit comments

Comments
 (0)