Few minor updates

This commit is contained in:
Eduard Urbach 2017-07-06 03:24:56 +02:00
parent d31b812b6e
commit e183360cb8
20 changed files with 76 additions and 44 deletions

View File

@ -28,5 +28,5 @@ func Get(ctx *aero.Context) string {
animeList.PrefetchAnime() animeList.PrefetchAnime()
animeList.Sort() animeList.Sort()
return ctx.HTML(components.AnimeLists(animeList.SplitByStatus(), animeList.User(), user)) return ctx.HTML(components.AnimeLists(animeList.SplitByStatus(), animeList.User(), user, ctx.URI()))
} }

View File

@ -1,5 +1,5 @@
component AnimeLists(animeLists map[string]*arn.AnimeList, viewUser *arn.User, user *arn.User) component AnimeLists(animeLists map[string]*arn.AnimeList, viewUser *arn.User, user *arn.User, uri string)
ProfileHeader(viewUser, user) ProfileHeader(viewUser, user, uri)
h2.page-title.anime-list-owner= viewUser.Nick + "'s collection" h2.page-title.anime-list-owner= viewUser.Nick + "'s collection"
@ -49,8 +49,8 @@ component AnimeList(animeList *arn.AnimeList, viewUser *arn.User, user *arn.User
if user != nil if user != nil
th.anime-list-item-actions Actions th.anime-list-item-actions Actions
tbody tbody
for i, item := range animeList.Items each item in animeList.Items
tr(class=utils.ItemCSSClass(animeList, i), title=item.Notes, data-api="/api/animelist/" + animeList.UserID + "/update/" + item.AnimeID) tr.anime-list-item.mountable(title=item.Notes, data-api="/api/animelist/" + animeList.UserID + "/update/" + item.AnimeID)
td.anime-list-item-name td.anime-list-item-name
a.ajax(href=item.Link(animeList.User().Nick))= item.Anime().Title.Canonical a.ajax(href=item.Link(animeList.User().Nick))= item.Anime().Title.Canonical
td.anime-list-item-airing-date td.anime-list-item-airing-date

View File

@ -72,3 +72,6 @@
< 1100px < 1100px
.anime-list-item-rating .anime-list-item-rating
display none display none
.fill-screen
min-height calc(100vh - nav-height - content-padding * 2 - 1rem - 43px - 23px)

View File

@ -19,7 +19,7 @@ func FilterByStatus(status string) aero.Handle {
return response return response
} }
return ctx.HTML(components.AnimeListFilteredByStatus(list, list.User(), user)) return ctx.HTML(components.AnimeListFilteredByStatus(list, list.User(), user, status, ctx.URI()))
} }
} }

View File

@ -1,8 +1,9 @@
component AnimeListFilteredByStatus(animeList *arn.AnimeList, viewUser *arn.User, user *arn.User) component AnimeListFilteredByStatus(animeList *arn.AnimeList, viewUser *arn.User, user *arn.User, status string, uri string)
ProfileHeader(viewUser, user) ProfileHeader(viewUser, user, uri)
if len(animeList.Items) == 0 if len(animeList.Items) == 0
p.no-data.mountable= viewUser.Nick + " hasn't added any anime to this list yet." p.no-data.mountable= viewUser.Nick + " hasn't added any anime to this list yet."
else else
.anime-list-container .anime-list-container.fill-screen
h3.status-name= arn.ListItemStatusName(status)
AnimeList(animeList, viewUser, user) AnimeList(animeList, viewUser, user)

View File

@ -35,6 +35,6 @@ func GetPostsByUser(ctx *aero.Context) string {
postables[i] = arn.ToPostable(post) postables[i] = arn.ToPostable(post)
} }
return ctx.HTML(components.LatestPosts(postables, viewUser, utils.GetUser(ctx))) return ctx.HTML(components.LatestPosts(postables, viewUser, utils.GetUser(ctx), ctx.URI()))
} }

View File

@ -1,5 +1,5 @@
component LatestPosts(postables []arn.Postable, viewUser *arn.User, user *arn.User) component LatestPosts(postables []arn.Postable, viewUser *arn.User, user *arn.User, uri string)
ProfileHeader(viewUser, user) ProfileHeader(viewUser, user, uri)
if len(postables) > 0 if len(postables) > 0
h2.page-title= len(postables), " latest posts by ", postables[0].Author().Nick h2.page-title= len(postables), " latest posts by ", postables[0].Author().Nick

View File

@ -1,6 +1,8 @@
package profile package profile
import ( import (
"sort"
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/aerogo/flow" "github.com/aerogo/flow"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
@ -36,7 +38,12 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string {
}, func() { }, func() {
animeList = viewUser.AnimeList() animeList = viewUser.AnimeList()
animeList.PrefetchAnime() animeList.PrefetchAnime()
// Sort by rating
sort.Slice(animeList.Items, func(i, j int) bool {
return animeList.Items[i].Rating.Overall > animeList.Items[j].Rating.Overall
})
}) })
return ctx.HTML(components.Profile(viewUser, user, animeList, threads, posts, tracks)) return ctx.HTML(components.Profile(viewUser, user, animeList, threads, posts, tracks, ctx.URI()))
} }

View File

@ -1,4 +1,4 @@
component ProfileHeader(viewUser *arn.User, user *arn.User) component ProfileHeader(viewUser *arn.User, user *arn.User, uri string)
.profile .profile
img.profile-cover(src=viewUser.CoverImageURL(), alt="Cover image") img.profile-cover(src=viewUser.CoverImageURL(), alt="Cover image")
@ -44,9 +44,9 @@ component ProfileHeader(viewUser *arn.User, user *arn.User)
Icon("rocket") Icon("rocket")
span= arn.Capitalize(viewUser.Role) span= arn.Capitalize(viewUser.Role)
ProfileNavigation(viewUser) ProfileNavigation(viewUser, uri)
component ProfileNavigation(viewUser *arn.User) component ProfileNavigation(viewUser *arn.User, uri string)
.buttons.tabs .buttons.tabs
a.button.tab.action(href="/+" + viewUser.Nick, data-action="diff", data-trigger="click") a.button.tab.action(href="/+" + viewUser.Nick, data-action="diff", data-trigger="click")
Icon("th") Icon("th")
@ -68,32 +68,33 @@ component ProfileNavigation(viewUser *arn.User)
Icon("music") Icon("music")
span.tab-text Tracks span.tab-text Tracks
//- StatusTabs("/+" + viewUser.Nick + "/animelist") //- if strings.Contains(uri, "/animelist")
//- StatusTabs("/+" + viewUser.Nick + "/animelist")
component StatusTabs(urlPrefix string) component StatusTabs(urlPrefix string)
.buttons.tabs .buttons.tabs.status-tabs
a.button.tab.action(href=urlPrefix + "/watching", data-action="diff", data-trigger="click") a.button.status-tab.action(href=urlPrefix + "/watching", data-action="diff", data-trigger="click")
Icon("play") Icon("play")
span.tab-text Watching span.tab-text Watching
a.button.tab.action(href=urlPrefix + "/completed", data-action="diff", data-trigger="click") a.button.status-tab.action(href=urlPrefix + "/completed", data-action="diff", data-trigger="click")
Icon("check") Icon("check")
span.tab-text Completed span.tab-text Completed
a.button.tab.action(href=urlPrefix + "/planned", data-action="diff", data-trigger="click") a.button.status-tab.action(href=urlPrefix + "/planned", data-action="diff", data-trigger="click")
Icon("forward") Icon("forward")
span.tab-text Planned span.tab-text Planned
a.button.tab.action(href=urlPrefix + "/hold", data-action="diff", data-trigger="click") a.button.status-tab.action(href=urlPrefix + "/hold", data-action="diff", data-trigger="click")
Icon("pause") Icon("pause")
span.tab-text On Hold span.tab-text On Hold
a.button.tab.action(href=urlPrefix + "/dropped", data-action="diff", data-trigger="click") a.button.status-tab.action(href=urlPrefix + "/dropped", data-action="diff", data-trigger="click")
Icon("stop") Icon("stop")
span.tab-text Dropped span.tab-text Dropped
component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, threads []*arn.Thread, posts []*arn.Post, tracks []*arn.SoundTrack) component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, threads []*arn.Thread, posts []*arn.Post, tracks []*arn.SoundTrack, uri string)
ProfileHeader(viewUser, user) ProfileHeader(viewUser, user, uri)
if len(animeList.Items) == 0 if len(animeList.Items) == 0
p.no-data.mountable= viewUser.Nick + " hasn't added any anime yet." p.no-data.mountable= viewUser.Nick + " hasn't added any anime yet."

View File

@ -27,5 +27,5 @@ func GetThreadsByUser(ctx *aero.Context) string {
threads = threads[:maxThreads] threads = threads[:maxThreads]
} }
return ctx.HTML(components.ProfileThreads(threads, viewUser, utils.GetUser(ctx))) return ctx.HTML(components.ProfileThreads(threads, viewUser, utils.GetUser(ctx), ctx.URI()))
} }

View File

@ -1,5 +1,5 @@
component ProfileThreads(threads []*arn.Thread, viewUser *arn.User, user *arn.User) component ProfileThreads(threads []*arn.Thread, viewUser *arn.User, user *arn.User, uri string)
ProfileHeader(viewUser, user) ProfileHeader(viewUser, user, uri)
if len(threads) == 0 if len(threads) == 0
p.no-data.mountable= viewUser.Nick + " hasn't written any threads yet." p.no-data.mountable= viewUser.Nick + " hasn't written any threads yet."

View File

@ -27,6 +27,6 @@ func GetSoundTracksByUser(ctx *aero.Context) string {
arn.SortSoundTracksLatestFirst(tracks) arn.SortSoundTracksLatestFirst(tracks)
return ctx.HTML(components.TrackList(tracks, viewUser, user)) return ctx.HTML(components.TrackList(tracks, viewUser, user, ctx.URI()))
} }

View File

@ -1,5 +1,5 @@
component TrackList(tracks []*arn.SoundTrack, viewUser *arn.User, user *arn.User) component TrackList(tracks []*arn.SoundTrack, viewUser *arn.User, user *arn.User, uri string)
ProfileHeader(viewUser, user) ProfileHeader(viewUser, user, uri)
h2.page-title= "Tracks added by " + viewUser.Nick h2.page-title= "Tracks added by " + viewUser.Nick

View File

@ -10,6 +10,15 @@
height 78px !important height 78px !important
border-radius 2px border-radius 2px
// .status-tabs
// position fixed
// top 4.6rem
// right 1.6rem
// flex-direction column
// .status-tab
// font-size 0.9rem
// < 380px // < 380px
// .profile-watching-list // .profile-watching-list
// justify-content center // justify-content center

View File

@ -83,7 +83,7 @@ export function diff(arn: AnimeNotifier, element: HTMLElement) {
let url = element.dataset.url || (element as HTMLAnchorElement).getAttribute("href") let url = element.dataset.url || (element as HTMLAnchorElement).getAttribute("href")
arn.diff(url).then(() => { arn.diff(url).then(() => {
const duration = 300.0 const duration = 250.0
const steps = 60 const steps = 60
const interval = duration / steps const interval = duration / steps
const fullSin = Math.PI / 2 const fullSin = Math.PI / 2

View File

@ -225,9 +225,11 @@ export class AnimeNotifier {
modifyDelayed(className: string, func: (element: HTMLElement) => void) { modifyDelayed(className: string, func: (element: HTMLElement) => void) {
const delay = 20 const delay = 20
const maxDelay = 1000
let time = 0 let time = 0
let start = Date.now() let start = Date.now()
let maxTime = start + maxDelay
let collection = document.getElementsByClassName(className) let collection = document.getElementsByClassName(className)
let mutations = [] let mutations = []
@ -245,6 +247,10 @@ export class AnimeNotifier {
time = mountableTypes[type] = start time = mountableTypes[type] = start
} }
if(time > maxTime) {
time = maxTime
}
mutations.push({ mutations.push({
element, element,
time time
@ -276,7 +282,7 @@ export class AnimeNotifier {
diff(url: string) { diff(url: string) {
if(url == this.app.currentPath) { if(url == this.app.currentPath) {
return return Promise.reject(null)
} }
let request = fetch("/_" + url, { let request = fetch("/_" + url, {
@ -292,7 +298,7 @@ export class AnimeNotifier {
// Delay by transition-speed // Delay by transition-speed
return delay(300).then(() => { return delay(300).then(() => {
request return request
.then(html => this.app.setContent(html, true)) .then(html => this.app.setContent(html, true))
.then(() => this.app.markActiveLinks()) .then(() => this.app.markActiveLinks())
.then(() => this.app.emit("DOMContentLoaded")) .then(() => this.app.emit("DOMContentLoaded"))

View File

@ -29,12 +29,6 @@ a
// &.active // &.active
// color link-active-color // color link-active-color
strong
font-weight bold
em
font-style italic
img img
backface-visibility hidden backface-visibility hidden

View File

@ -65,3 +65,4 @@ nav-height = 3.11rem
// Timings // Timings
fade-speed = 200ms fade-speed = 200ms
transition-speed = 250ms transition-speed = 250ms
mountable-transition-speed = 400ms

View File

@ -1,5 +1,3 @@
mountable-transition-speed = 400ms
.mountable .mountable
opacity 0 opacity 0
transform translateY(0.85rem) transform translateY(0.85rem)

View File

@ -11,6 +11,18 @@ h2
margin-top content-padding margin-top content-padding
margin-bottom content-padding margin-bottom content-padding
strong
font-weight bold
em
font-style italic
hr
border none
border-bottom 1px solid text-color
opacity 0.1
margin-bottom content-padding
p > img p > img
max-width 100% max-width 100%
border-radius 3px border-radius 3px