This repository has been archived by the owner on Dec 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WebGen Routing and add moved /c/music to pages
- Loading branch information
Showing
10 changed files
with
273 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,15 @@ | ||
.entry-subtitle { | ||
color: rgb(255 255 255 / 80%); | ||
} | ||
|
||
.under-review { | ||
background-color: #BCBCBC; | ||
color: rgba(0, 0, 0, 0.8); | ||
border-radius: 10rem; | ||
font-weight: 700; | ||
font-size: 15px; | ||
padding: 0.2rem 0.8rem; | ||
margin: 0 2rem; | ||
} | ||
|
||
.small-preview.image-preview .wimage { | ||
height: 2.2rem; | ||
border-radius: 3px; | ||
margin: 0 0.4rem 0 0; | ||
} | ||
|
||
@media (prefers-color-scheme: dark) { | ||
body { | ||
background-color: black !important; | ||
background-image: linear-gradient(360deg, #00000000, #f19d2d2b); | ||
background-size: 100vw 100vh; | ||
background-repeat: no-repeat; | ||
} | ||
} | ||
|
||
nav.music { | ||
background: linear-gradient(166deg, #F19D2D 6.59%, #DB5721 101.73%); | ||
} | ||
|
||
@media (max-width: 800px) { | ||
nav.music { | ||
background: linear-gradient(166deg, #F19D2D 6.59%, #db7621 101.73%); | ||
@media (prefers-color-scheme: dark) { | ||
body { | ||
--wg-reverse-neutral: rgba(255, 255, 255, 2%); | ||
} | ||
} | ||
|
||
div.navigation>div.vertical-stack { | ||
gap: unset !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,94 @@ | ||
import { RegisterAuthRefresh, renewAccessTokenIfNeeded, sheetStack } from "shared/helper.ts"; | ||
import "./pages/artists.ts"; | ||
import "./pages/draftDrops.ts"; | ||
import "./pages/payouts.ts"; | ||
import "./pages/publishedDrops.ts"; | ||
import "./pages/unpublishedDrops.ts"; | ||
|
||
/// <reference types="npm:@types/dom-navigation/index.d.ts" /> | ||
|
||
import { activeUser, RegisterAuthRefresh, renewAccessTokenIfNeeded, sheetStack } from "shared/helper.ts"; | ||
import { API, stupidErrorAlert } from "shared/restSpec.ts"; | ||
import { appendBody, Content, DialogContainer, WebGenTheme } from "webgen/mod.ts"; | ||
import { activeRoute, appendBody, Box, Content, createRoute, css, DialogContainer, FullWidthSection, Grid, Label, menuList, PageRouter, PrimaryButton, ref, SecondaryButton, StartRouting, WebGenTheme } from "webgen/mod.ts"; | ||
import "../../assets/css/main.css"; | ||
import "../../assets/css/music.css"; | ||
import { DynaNavigation } from "../../components/nav.ts"; | ||
import { DropType } from "../../spec/music.ts"; | ||
import { menuState, musicMenu } from "./views/menu.ts"; | ||
import { draftsDropsPage } from "./pages/draftDrops.ts"; | ||
import { publishedDrops } from "./pages/publishedDrops.ts"; | ||
|
||
await RegisterAuthRefresh(); | ||
|
||
createRoute({ | ||
path: "/c/music", | ||
events: { | ||
onActive: async () => { | ||
const list = await API.music.drops.list().then(stupidErrorAlert); | ||
const published = list.filter((x) => x.type === DropType.Published); | ||
|
||
if (published.length >= 1) { | ||
publishedDrops.route.navigate({}); | ||
} else { | ||
draftsDropsPage.route.navigate({}); | ||
} | ||
}, | ||
}, | ||
}); | ||
|
||
export function Navigation() { | ||
return Box( | ||
Content( | ||
Grid( | ||
Label(ref`Hi ${activeUser.username} 👋`) | ||
.setFontWeight("bold") | ||
.setTextSize("4xl"), | ||
Grid( | ||
menuList | ||
.map((item) => | ||
item | ||
.filter((item) => item.route.entry.patternUrl.startsWith("/c/music?list=")) | ||
.map((item) => | ||
Box(activeRoute.map((activeRoute) => | ||
(activeRoute == item.route.entry ? PrimaryButton(item.label) : SecondaryButton(item.label)) | ||
.onPromiseClick(async () => { | ||
await window.navigation.navigate(item.route.entry.patternUrl).finished; | ||
}) | ||
)) | ||
) | ||
), | ||
) | ||
.setGap(".8rem") | ||
.setAutoFlow("column") | ||
.setAutoColumn("max-content"), | ||
) | ||
.setGap("1rem") | ||
.setMargin("4rem 0 1rem"), | ||
) | ||
.addStyle(css` | ||
:host { | ||
--wg-button-border-radius: var(--wg-radius-large); | ||
} | ||
`), | ||
PageRouter, | ||
); | ||
} | ||
|
||
appendBody( | ||
WebGenTheme( | ||
DialogContainer(sheetStack.visible(), sheetStack), | ||
Content( | ||
DynaNavigation("Music"), | ||
musicMenu, | ||
FullWidthSection( | ||
DynaNavigation("Music"), | ||
), | ||
), | ||
), | ||
Navigation(), | ||
) | ||
.addStyle(css` | ||
:host { | ||
--wg-primary: rgb(255, 171, 82); | ||
--content-max-width: 1200px; | ||
} | ||
`), | ||
); | ||
|
||
renewAccessTokenIfNeeded() | ||
.then(async () => { | ||
const list = await API.music.drops.list().then(stupidErrorAlert); | ||
|
||
menuState.published = list.filter((x) => x.type === DropType.Published); | ||
menuState.drafts = list.filter((x) => x.type === DropType.Unsubmitted); | ||
menuState.unpublished = list.filter((x) => | ||
x.type === DropType.UnderReview || | ||
x.type === DropType.Private || | ||
x.type === DropType.ReviewDeclined | ||
); | ||
menuState.payouts = await API.payment.payouts.get().then(stupidErrorAlert); | ||
menuState.artists = await API.music.artists.list().then(stupidErrorAlert); | ||
}); | ||
StartRouting(); | ||
renewAccessTokenIfNeeded(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { API, stupidErrorAlert } from "shared/restSpec.ts"; | ||
import { asRef, Box, Content, createPage, createRoute, Entry, Grid, Label, Spinner } from "webgen/mod.ts"; | ||
import { Artist } from "../../../spec/music.ts"; | ||
|
||
const data = asRef<"loading" | Artist[]>("loading"); | ||
|
||
const source = data.map((data) => data === "loading" ? [] : data); | ||
|
||
export const artistsPage = createPage( | ||
{ | ||
label: "Artists", | ||
weight: 5, | ||
route: createRoute({ | ||
path: "/c/music?list=artists", | ||
events: { | ||
onLazyInit: async () => { | ||
const list = await API.music.artists.list().then(stupidErrorAlert); | ||
data.value = list; | ||
}, | ||
}, | ||
}), | ||
}, | ||
Content( | ||
Box(data.map((data) => data === "loading" ? Spinner() : [])), | ||
Grid( | ||
source.map((items) => | ||
items.map((item) => | ||
Entry( | ||
Label(item.name), | ||
) | ||
) | ||
), | ||
), | ||
), | ||
); |
Oops, something went wrong.