Skip to content

Commit

Permalink
Feature/media source icon (#1862)
Browse files Browse the repository at this point in the history
Co-authored-by: soonshiny <[email protected]>
  • Loading branch information
Fredi and soonshiny authored Feb 14, 2021
1 parent 6785f38 commit 1288dd7
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 4 deletions.
Binary file added assets/img/youtube-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion src/components/MediaList/Row.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:root {
--media-list-row-height: 56px;
--media-list-row-icon-offset: 8px;
--unpadded-media-list-row-height: calc(var(--media-list-row-height) - 14px);
}

Expand Down Expand Up @@ -40,7 +41,7 @@
height: 100%;
padding: 7px 0;
line-height: var(--unpadded-media-list-row-height);
width: calc(100% - var(--media-list-spacing) - var(--media-list-thumb-width) - var(--media-list-duration-width));
width: calc(100% - var(--media-list-spacing) - var(--media-list-thumb-width) - var(--media-list-row-icon-offset) - var(--media-list-duration-width));
float: inline-start;
}

Expand Down Expand Up @@ -88,6 +89,14 @@
width: var(--media-list-duration-width);
}


.MediaListRow-icon {
height: 100%;
float: left;
display: flex;
align-items: center;
}

.MediaListRow-actions {
height: 100%;
position: absolute;
Expand All @@ -98,3 +107,8 @@
.MediaListRow:hover .MediaListRow-actions {
display: block;
}

.MediaListRow:hover .MediaListRow-icon {
display: none;
}

11 changes: 11 additions & 0 deletions src/components/MediaList/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import { useDrag } from 'react-dnd';
import { getEmptyImage } from 'react-dnd-html5-backend';
import formatDuration from 'format-duration';
import { useMediaSources } from '../../context/MediaSourceContext';
import { MEDIA } from '../../constants/DDItemTypes';
import MediaLoadingIndicator from './MediaLoadingIndicator';
import MediaThumbnail from './MediaThumbnail';
Expand Down Expand Up @@ -48,6 +49,13 @@ function Row({
connectDragPreview(getEmptyImage());
}, []);

const { getMediaSource } = useMediaSources();
const sourceIcon = (
<img
height="20dp"
src={getMediaSource(media.sourceType).icon}
/>
)
const selectedClass = selected ? 'is-selected' : '';
const loadingClass = media.loading ? 'is-loading' : '';
const duration = 'start' in media
Expand Down Expand Up @@ -90,6 +98,9 @@ function Row({
<div className="MediaListRow-duration">
{formatDuration(duration * 1000)}
</div>
<div className="MediaListRow-icon">
{sourceIcon}
</div>
<Actions
className={cx('MediaListRow-actions', selectedClass)}
selection={selection}
Expand Down
11 changes: 10 additions & 1 deletion src/components/RoomHistory/Row.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:root {
--history-list-thumb-width: 85px;
--history-list-icon-width: 50px;
--history-list-user-width: 130px;
--history-list-time-width: 170px;
--history-list-votes-width: 250px;
Expand All @@ -8,7 +9,8 @@
var(--history-list-thumb-width) +
var(--history-list-time-width) +
var(--history-list-user-width) +
var(--history-list-votes-width)
var(--history-list-votes-width) +
var(--history-list-icon-width)
);
}

Expand All @@ -29,6 +31,13 @@
width: var(--history-list-votes-width);
}

.HistoryRow-icon {
height: 100%;
float: left;
display: flex;
align-items: center;
}

.HistoryRow-user {
height: 100%;
float: left;
Expand Down
15 changes: 14 additions & 1 deletion src/components/RoomHistory/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import { useDrag } from 'react-dnd';
import { getEmptyImage } from 'react-dnd-html5-backend';
import { MEDIA } from '../../constants/DDItemTypes';
import { useMediaSources } from '../../context/MediaSourceContext';
import Actions from '../MediaList/Actions';
import SongTitle from '../SongTitle';
import TimeAgo from '../TimeAgo';
Expand Down Expand Up @@ -60,7 +61,14 @@ function HistoryRow({
onClick();
}
}, [onClick]);

const { getMediaSource } = useMediaSources();
const sourceIcon = (
<img
height="20dp"
src={getMediaSource(media.sourceType).icon}
alt=""
/>
);
const selectedClass = selected ? 'is-selected' : '';
const thumbnail = (
<div className="MediaListRow-thumb">
Expand Down Expand Up @@ -91,6 +99,7 @@ function HistoryRow({
artist={media.artist}
title={media.title}
/>

<div className="HistoryRow-votes">
<HistoryVotes {...stats} />
</div>
Expand All @@ -100,6 +109,10 @@ function HistoryRow({
<div className="HistoryRow-time" dateTime={timestamp}>
<TimeAgo timestamp={timestamp} />
</div>
<div className="HistoryRow-icon">
{sourceIcon}
</div>

{showActions && (
<Actions
className={cx('MediaListRow-actions', selectedClass)}
Expand Down
2 changes: 2 additions & 0 deletions src/sources/soundcloud/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import Player from './PlayerWrapper';

const logo = new URL('../../../assets/img/soundcloud.png', import.meta.url);
const icon = new URL('../../../assets/img/soundcloud.png', import.meta.url);

export default function soundcloud() {
return {
name: 'soundcloud',
Player,
logo,
icon,
};
}
3 changes: 2 additions & 1 deletion src/sources/youtube/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import ImportForm from './ImportForm';
import reducer from './reducer';

const ImportPanel = React.lazy(() => import('./ImportPanel'));

const logo = new URL('../../../assets/img/youtube.png', import.meta.url);
const icon = new URL('../../../assets/img/youtube-icon.png', import.meta.url);

export default function youtube() {
return {
name: 'youtube',
Player,
logo,
icon,
ImportForm,
ImportPanel,
reducer,
Expand Down

0 comments on commit 1288dd7

Please sign in to comment.