Skip to content

Commit 62a879d

Browse files
committed
feat: add visibility badge to private songs
1 parent b0c34cf commit 62a879d

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

shared/validation/song/dto/SongView.dto.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99

1010
import { SongStats } from '@shared/validation/song/dto/SongStats';
1111

12-
import type { CategoryType } from './types';
12+
import type { CategoryType, VisibilityType } from './types';
1313
import { SongDocument } from '../../../../server/src/song/entity/song.entity';
1414

1515
export type SongViewUploader = {
@@ -59,6 +59,10 @@ export class SongViewDto {
5959
@IsString()
6060
description: string;
6161

62+
@IsString()
63+
@IsNotEmpty()
64+
visibility: VisibilityType;
65+
6266
@IsString()
6367
@IsNotEmpty()
6468
category: CategoryType;
@@ -90,6 +94,7 @@ export class SongViewDto {
9094
originalAuthor: song.originalAuthor,
9195
description: song.description,
9296
category: song.category,
97+
visibility: song.visibility,
9398
license: song.license,
9499
customInstruments: song.customInstruments,
95100
fileSize: song.fileSize,

web/src/modules/song/components/SongPage.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
OpenSongInNBSButton,
1313
ShareButton,
1414
UploaderBadge,
15+
VisibilityBadge,
1516
} from './SongPageButtons';
1617
import SongCard from '../../browse/components/SongCard';
1718
import SongCardGroup from '../../browse/components/SongCardGroup';
@@ -73,7 +74,15 @@ export async function SongPage({ id }: { id: string }) {
7374
/>
7475
</picture>
7576

76-
<h1 className='text-xl font-bold'>{song.title}</h1>
77+
<div className='text-xl font-bold inline'>
78+
<h1 className='inline'>{song.title}</h1>
79+
{song.visibility === 'private' && (
80+
<>
81+
<span className='inline-block w-3 align-middle' />
82+
<VisibilityBadge />
83+
</>
84+
)}
85+
</div>
7786

7887
{/* Uploader and actions */}
7988
<div className='flex flex-row flex-wrap justify-start items-center gap-8 w-full'>

web/src/modules/song/components/SongPageButtons.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
faDownload,
66
faExternalLink,
77
faHeart,
8+
faLock,
89
faPlay,
910
faPlus,
1011
faShare,
@@ -27,6 +28,15 @@ import {
2728
} from '../../shared/components/tooltip';
2829
import { downloadSongFile, openSongInNBS } from '../util/downloadSong';
2930

31+
const VisibilityBadge = () => {
32+
return (
33+
<span className='inline-flex items-center bg-zinc-700 text-zinc-400 px-1.5 py-0.5 rounded-md text-sm font-semibold'>
34+
<FontAwesomeIcon icon={faLock} className='w-3' />
35+
<span className='ml-1.5'>Private</span>
36+
</span>
37+
);
38+
};
39+
3040
const UploaderBadge = ({ user }: { user: SongViewDtoType['uploader'] }) => {
3141
return (
3242
<div className='flex flex-row items-center gap-3'>
@@ -276,6 +286,7 @@ const DownloadButton = ({
276286
};
277287

278288
export {
289+
VisibilityBadge,
279290
UploaderBadge,
280291
FollowButton,
281292
LikeButton,

0 commit comments

Comments
 (0)