Skip to content

Commit ea4bad3

Browse files
committed
add waveform previews to sound lib
1 parent 11c1f0a commit ea4bad3

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

src/components/library-item/library-item.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@
223223
max-width: 100%;
224224
max-height: 100%;
225225
}
226+
.library-item-image-overlay {
227+
position: absolute;
228+
left: 0;
229+
top: 0;
230+
width: 100%;
231+
max-width: 100%;
232+
max-height: 100%;
233+
}
226234

227235
.library-item-inset-image {
228236
width: 2.5rem;

src/components/library-item/library-item.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,14 @@ class LibraryItemComponent extends React.PureComponent {
333333
src={this.props.iconURL}
334334
draggable={false}
335335
/>
336+
{this.props.overlayURL && (
337+
<img
338+
className={styles.libraryItemImageOverlay}
339+
loading="lazy"
340+
src={this.props.overlayURL}
341+
draggable={false}
342+
/>
343+
)}
336344
</Box>
337345
</Box>
338346
<span className={styles.libraryItemName}>{this.props.name}</span>
@@ -367,6 +375,7 @@ LibraryItemComponent.propTypes = {
367375
featured: PropTypes.bool,
368376
hidden: PropTypes.bool,
369377
iconURL: PropTypes.string,
378+
overlayURL: PropTypes.string,
370379
insetIconURL: PropTypes.string,
371380
customInsetColor: PropTypes.string,
372381
internetConnectionRequired: PropTypes.bool,

src/components/library/library.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ class LibraryComponent extends React.Component {
453453
href={dataItem.href}
454454
iconMd5={dataItem.costumes ? dataItem.costumes[0].md5ext : dataItem.md5ext}
455455
iconRawURL={this.props.actor === "CostumeLibrary" ? `${PM_LIBRARY_API}files/${dataItem.libraryFilePage}` : dataItem.rawURL}
456+
overlayURL={dataItem.overlayURL}
456457
icons={dataItem.costumes}
457458
id={index}
458459
_id={dataItem._id}

src/containers/library-item.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ class LibraryItem extends React.PureComponent {
191191
featured={this.props.featured}
192192
hidden={this.props.hidden}
193193
iconURL={iconURL}
194+
overlayURL={this.props.overlayURL}
194195
icons={this.props.icons}
195196
id={this.props.id}
196197
_id={this.props._id}
@@ -242,6 +243,7 @@ LibraryItem.propTypes = {
242243
hidden: PropTypes.bool,
243244
iconMd5: PropTypes.string,
244245
iconRawURL: PropTypes.string,
246+
overlayURL: PropTypes.string,
245247
icons: PropTypes.arrayOf(
246248
PropTypes.shape({
247249
baseLayerMD5: PropTypes.string, // 2.0 library format, TODO GH-5084

src/containers/sound-library.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,18 @@ const getSoundLibraryThumbnailData = (soundLibraryContent, isRtl) => soundLibrar
4040
};
4141
const isLoop = sound.tags ? sound.tags.includes('loops') : false;
4242
const isTheme = sound.tags ? sound.tags.includes('themes') : false;
43+
4344
const {
4445
md5ext,
46+
assetId,
4547
...otherData
4648
} = sound;
4749
return {
4850
_md5: md5ext,
49-
rawURL: isTheme ? icons.theme : (isLoop ? icons.loop : icons.sound),
51+
rawURL: sound.fromPenguinModLibrary ?
52+
`${PM_LIBRARY_API}files/sound_previews/${sound.libraryFilePage.replace(/\//g, "_").replace(".mp3", ".png")}` :
53+
`${PM_LIBRARY_API}files/scratch_sound_previews/${assetId}.png`,
54+
overlayURL: isTheme ? icons.theme : (isLoop ? icons.loop : icons.sound),
5055
...otherData
5156
};
5257
});

0 commit comments

Comments
 (0)