Skip to content

Commit

Permalink
fix: video selection gallery scroll (#477)
Browse files Browse the repository at this point in the history
* fix: video selection gallery scroll

* fix: lint errors
  • Loading branch information
KristinAoki authored May 22, 2024
1 parent 3315205 commit 6c743f8
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 115 deletions.
52 changes: 0 additions & 52 deletions src/editors/containers/VideoEditor/components/BaseModal.jsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
import { Button } from '@openedx/paragon';

import { thunkActions } from '../../../data/redux';
import BaseModal from './BaseModal';
import BaseModal from '../../../sharedComponents/BaseModal';
import * as module from './SelectVideoModal';

export const hooks = {
Expand Down
46 changes: 24 additions & 22 deletions src/editors/containers/VideoGallery/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,30 @@ export const VideoGallery = () => {
);

return (
<SelectionModal
{...{
isOpen: true,
close: handleCancel,
size: 'fullscreen',
isFullscreenScroll: false,
galleryError,
inputError,
fileInput,
galleryProps: {
...galleryProps,
thumbnailFallback,
},
searchSortProps,
selectBtnProps,
acceptedFiles: acceptedImgKeys,
modalMessages,
isLoaded,
isUploadError,
isFetchError,
}}
/>
<div style={isLoaded ? { backgroundColor: '#E9E6E4' } : {}}>
<SelectionModal
{...{
isOpen: true,
close: handleCancel,
size: 'fullscreen',
isFullscreenScroll: false,
galleryError,
inputError,
fileInput,
galleryProps: {
...galleryProps,
thumbnailFallback,
},
searchSortProps,
selectBtnProps,
acceptedFiles: acceptedImgKeys,
modalMessages,
isLoaded,
isUploadError,
isFetchError,
}}
/>
</div>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ exports[`BaseModal ImageUploadModal template component snapshot 1`] = `
props.title node
</ModalDialog.Title>
</ModalDialog.Header>
<ModalDialog.Body
<Scrollable
style={null}
>
props.children node
</ModalDialog.Body>
<ModalDialog.Body>
props.children node
</ModalDialog.Body>
</Scrollable>
<ModalDialog.Footer>
<ActionRow>
props.footerAction node
Expand Down
9 changes: 6 additions & 3 deletions src/editors/sharedComponents/BaseModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import {
ActionRow,
ModalDialog,
Scrollable,
} from '@openedx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';

Expand Down Expand Up @@ -39,9 +40,11 @@ export const BaseModal = ({
</ModalDialog.Title>
{headerComponent}
</ModalDialog.Header>
<ModalDialog.Body style={bodyStyle}>
{children}
</ModalDialog.Body>
<Scrollable style={bodyStyle}>
<ModalDialog.Body>
{children}
</ModalDialog.Body>
</Scrollable>
<ModalDialog.Footer>
<ActionRow>
{footerAction}
Expand Down
42 changes: 19 additions & 23 deletions src/editors/sharedComponents/SelectionModal/Gallery.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';

import {
Scrollable, Spinner,
} from '@openedx/paragon';
import { Spinner } from '@openedx/paragon';
import {
FormattedMessage,
useIntl,
Expand Down Expand Up @@ -59,26 +57,24 @@ export const Gallery = ({
);
}
return (
<Scrollable className="gallery bg-light-400" style={{ height, margin: '0 -1.5rem' }}>
<div className="p-4">
<SelectableBox.Set
columns={1}
name="images"
onChange={onHighlightChange}
type="radio"
value={highlighted}
>
{ displayList.map(asset => (
<GalleryCard
key={asset.id}
asset={asset}
showId={showIdsOnCards}
thumbnailFallback={thumbnailFallback}
/>
)) }
</SelectableBox.Set>
</div>
</Scrollable>
<div className="p-4 gallery bg-light-400" style={{ height, margin: '0 -1.5rem' }}>
<SelectableBox.Set
columns={1}
name="images"
onChange={onHighlightChange}
type="radio"
value={highlighted}
>
{ displayList.map(asset => (
<GalleryCard
key={asset.id}
asset={asset}
showId={showIdsOnCards}
thumbnailFallback={thumbnailFallback}
/>
)) }
</SelectableBox.Set>
</div>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/editors/sharedComponents/SelectionModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const SelectionModal = ({
</Button>
)}
title={intl.formatMessage(titleMsg)}
bodyStyle={{ background, padding: '3px 24px' }}
bodyStyle={{ background }}
headerComponent={(
<div style={{ margin: '18px 0' }}>
<SearchSort {...searchSortProps} />
Expand Down
2 changes: 1 addition & 1 deletion src/editors/sharedComponents/SelectionModal/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}

/* Set top padding to 0 when there is an alert above. */
.selection-modal .pgn__vstack > .alert + .gallery > .pgn__scrollable-body-content > .p-4 {
.selection-modal .pgn__scrollable-body-content > .pgn__vstack > .alert + .gallery > .p-4 {
padding-top: 0 !important;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

exports[`SourceCodeModal renders as expected with default behavior 1`] = `
<BaseModal
bodyStyle={null}
bodyStyle={
Object {
"maxHeight": NaN,
}
}
close={[MockFunction]}
confirmAction={
<Button
Expand Down Expand Up @@ -32,11 +36,7 @@ exports[`SourceCodeModal renders as expected with default behavior 1`] = `
title="Edit Source Code"
>
<div
style={
Object {
"padding": "10px 30px",
}
}
className="px-4.5 pt-2.5"
>
<injectIntl(ShimmedIntlComponent)
innerRef="moCKrEf"
Expand Down
7 changes: 5 additions & 2 deletions src/editors/sharedComponents/SourceCodeModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
intlShape,
} from '@edx/frontend-platform/i18n';

import { Button } from '@openedx/paragon';
import { Button, useWindowSize } from '@openedx/paragon';
import messages from './messages';
import hooks from './hooks';
import BaseModal from '../BaseModal';
Expand All @@ -22,6 +22,8 @@ export const SourceCodeModal = ({
intl,
}) => {
const { saveBtnProps, value, ref } = hooks.prepareSourceCodeModal({ editorRef, close });
const { height } = useWindowSize();

return (
<BaseModal
close={close}
Expand All @@ -33,8 +35,9 @@ export const SourceCodeModal = ({
)}
isOpen={isOpen}
title={intl.formatMessage(messages.titleLabel)}
bodyStyle={{ maxHeight: (height - 180) }}
>
<div style={{ padding: '10px 30px' }}>
<div className="px-4.5 pt-2.5">
<CodeEditor
innerRef={ref}
value={value}
Expand Down
2 changes: 1 addition & 1 deletion src/setupTest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */

import 'babel-polyfill';
import 'jest-canvas-mock';

Expand Down Expand Up @@ -125,6 +124,7 @@ jest.mock('@openedx/paragon', () => jest.requireActual('testUtils').mockNestedCo
Stack: 'Stack',
Toast: 'Toast',
Truncate: 'Truncate',
useWindowSize: { height: '500px' },
}));

jest.mock('@openedx/paragon/icons', () => ({
Expand Down

0 comments on commit 6c743f8

Please sign in to comment.