Reduced character component complexity

This commit is contained in:
Eduard Urbach 2018-04-26 20:19:27 +02:00
parent b6b6f22af6
commit 1f0adabde2

View File

@ -55,54 +55,57 @@ component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime
each quote in quotes each quote in quotes
if mainQuote == nil || quote.ID != mainQuote.ID if mainQuote == nil || quote.ID != mainQuote.ID
Quote(quote, user) Quote(quote, user)
CharacterSidebar(character, friends, relevantCharacters, user)
.character-sidebar component CharacterSidebar(character *arn.Character, friends []*arn.User, relevantCharacters []*arn.Character, user *arn.User)
if len(character.Attributes) > 0 .character-sidebar
h3.mountable Information if len(character.Attributes) > 0
h3.mountable Information
table.character-attributes.mountable table.character-attributes.mountable
each attribute in character.Attributes each attribute in character.Attributes
tr.mountable(data-mountable-type="info") tr.mountable(data-mountable-type="info")
td.character-attributes-name= attribute.Name + ":" td.character-attributes-name= attribute.Name + ":"
if strings.Contains(attribute.Value, "<") if strings.Contains(attribute.Value, "<")
td.character-attributes-value!= markdown.Render(attribute.Value) td.character-attributes-value!= markdown.Render(attribute.Value)
else
td.character-attributes-value= attribute.Value
if len(relevantCharacters) > 0
h3.mountable Relevant
.relevant-characters.mountable
each relevantCharacter in relevantCharacters
.mountable(data-mountable-type="relevant-character")
CharacterSmall(relevantCharacter, user)
if len(friends) > 0
.character-friends
h3.mountable Friends
.user-avatars.mountable
each friend in friends
.mountable(data-mountable-type="friend")
if friend.IsActive()
Avatar(friend)
else else
td.character-attributes-value= attribute.Value .inactive-user
if len(relevantCharacters) > 0
h3.mountable Relevant
.relevant-characters.mountable
each relevantCharacter in relevantCharacters
.mountable(data-mountable-type="relevant-character")
CharacterSmall(relevantCharacter, user)
if len(friends) > 0
.character-friends
h3.mountable Friends
.user-avatars.mountable
each friend in friends
.mountable(data-mountable-type="friend")
if friend.IsActive()
Avatar(friend) Avatar(friend)
else
.inactive-user
Avatar(friend)
h3.mountable Links h3.mountable Links
.light-button-group.mountable .light-button-group.mountable
if character.GetMapping("myanimelist/character") != "" if character.GetMapping("myanimelist/character") != ""
a.light-button(href="https://myanimelist.net/character/" + character.GetMapping("myanimelist/character"), target="_blank", rel="noopener") a.light-button(href="https://myanimelist.net/character/" + character.GetMapping("myanimelist/character"), target="_blank", rel="noopener")
Icon("external-link") Icon("external-link")
span MAL span MAL
else if user != nil && (user.Role == "editor" || user.Role == "admin") else if user != nil && (user.Role == "editor" || user.Role == "admin")
a.light-button(href="https://myanimelist.net/character.php?q=" + character.Name.Canonical, target="_blank", rel="noopener") a.light-button(href="https://myanimelist.net/character.php?q=" + character.Name.Canonical, target="_blank", rel="noopener")
Icon("exclamation-triangle") Icon("exclamation-triangle")
span Error: No MAL ID span Error: No MAL ID
a.light-button(href="/api" + character.Link(), target="_blank") a.light-button(href="/api" + character.Link(), target="_blank")
Icon("code") Icon("code")
span API span API