Skip to content

Commit

Permalink
refactor: move to correct files
Browse files Browse the repository at this point in the history
  • Loading branch information
lucsoft committed Apr 16, 2023
1 parent 83ccf7d commit 6bc670d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
33 changes: 1 addition & 32 deletions pages/music/views/entry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CenterV, Component, Horizontal, MediaQuery, PlainText, Spacer } from "webgen/mod.ts";
import { CenterV, Component, Horizontal, PlainText, Spacer } from "webgen/mod.ts";
import { Drop, DropType } from "../../../spec/music.ts";
import { showPreviewImage } from "../../manager/helper.ts";

Expand Down Expand Up @@ -31,35 +31,4 @@ export function DropEntry(x: Drop, matches: boolean): Component {
.setGap("40px")
.addClass("list-entry", "action", "limited-width")
.onClick(() => x.type === DropType.Unsubmitted ? location.href = "/music/new-drop?id=" + x._id : location.href = "/music/edit?id=" + x._id);
}


export function ExplainerText(drop: Drop[], type: DropType) {
return drop.length == 0 ?
MediaQuery("(min-width: 540px)", (large) => large ? CenterV(
PlainText(`You don’t have any ${EnumToDisplay(type)} Drops`)
.setFont(1.6, 700)
).setMargin("100px 0 0") : PlainText(`You don’t have any ${EnumToDisplay(type)} Drops`)
.setFont(1.6, 700))
.setMargin("100px auto 0")
.addClass("explainer-text")
: null;
}

function EnumToDisplay(state?: DropType) {
switch (state) {
case "PRIVATE": return "unpublished";
case "PUBLISHED": return "published";
default: return "";
}
}

export function DropTypeToText(type?: DropType) {
return (<Record<DropType, string>>{
"PRIVATE": "Private",
"PUBLISHED": "Published",
"UNDER_REVIEW": "Under Review",
"UNSUBMITTED": "Draft",
"REVIEW_DECLINED": "Rejected"
})[ type ?? DropType.Unsubmitted ] ?? "";
}
35 changes: 33 additions & 2 deletions pages/music/views/list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, MediaQuery, PlainText, Vertical } from "webgen/mod.ts";
import { CenterV, Component, MediaQuery, PlainText, Vertical } from "webgen/mod.ts";
import { Drop, DropType } from "../../../spec/music.ts";
import { DropEntry, ExplainerText } from "./entry.ts";
import { DropEntry } from "./entry.ts";

export const musicList = (list: Drop[], type: DropType) => Vertical(
CategoryRender(
Expand Down Expand Up @@ -30,4 +30,35 @@ function CategoryRender(dropList: Drop[], title: string): Component | (Component
Vertical(...dropList.map(x => DropEntry(x, matches))).setGap("1rem")
),
];
}


export function ExplainerText(drop: Drop[], type: DropType) {
return drop.length == 0 ?
MediaQuery("(min-width: 540px)", (large) => large ? CenterV(
PlainText(`You don’t have any ${EnumToDisplay(type)} Drops`)
.setFont(1.6, 700)
).setMargin("100px 0 0") : PlainText(`You don’t have any ${EnumToDisplay(type)} Drops`)
.setFont(1.6, 700))
.setMargin("100px auto 0")
.addClass("explainer-text")
: null;
}

function EnumToDisplay(state?: DropType) {
switch (state) {
case "PRIVATE": return "unpublished";
case "PUBLISHED": return "published";
default: return "";
}
}

export function DropTypeToText(type?: DropType) {
return (<Record<DropType, string>>{
"PRIVATE": "Private",
"PUBLISHED": "Published",
"UNDER_REVIEW": "Under Review",
"UNSUBMITTED": "Draft",
"REVIEW_DECLINED": "Rejected"
})[ type ?? DropType.Unsubmitted ] ?? "";
}

0 comments on commit 6bc670d

Please sign in to comment.