Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Place the user actions in a dropdown window with labels #15260

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
113 changes: 56 additions & 57 deletions app/views/user/show/header.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,67 +90,66 @@ object header:
(ctx.isAuth && ctx.isnt(u))
.option(a(cls := "nm-item note-zone-toggle")(splitNumber(s"${social.notes.size} Notes")))
),
div(cls := "user-actions btn-rack")(
(ctx
.is(u))
.option(
frag(
a(
cls := "btn-rack__btn",
href := routes.Account.profile,
titleOrText(trans.site.editProfile.txt()),
dataIcon := Icon.Gear
),
a(
cls := "btn-rack__btn",
href := routes.Relation.blocks(),
titleOrText(trans.site.listBlockedPlayers.txt()),
dataIcon := Icon.NotAllowed
)
)
),
isGranted(_.UserModView).option(
a(
cls := "btn-rack__btn mod-zone-toggle",
href := routes.User.mod(u.username),
titleOrText("Mod zone (Hotkey: m)"),
dataIcon := Icon.Agent
)
),
div(cls := "user-actions dropdown")(
a(
cls := "btn-rack__btn",
href := routes.User.tv(u.username),
titleOrText(trans.site.watchGames.txt()),
dataIcon := Icon.AnalogTv
cls := "text",
dataIcon := Icon.List
),
ctx
.isnt(u)
.option(
views.relation.actions(
u.light,
relation = social.relation,
followable = social.followable,
blocked = social.blocked
)
div(cls := "dropdown-window")(
(ctx
.is(u))
.option(
frag(
a(
cls := "text",
href := routes.Account.profile,
dataIcon := Icon.Gear
)(trans.site.editProfile.txt()),
a(
cls := "text",
href := routes.Relation.blocks(),
dataIcon := Icon.NotAllowed
)(trans.site.listBlockedPlayers.txt())
)
),
isGranted(_.UserModView).option(
a(
cls := "text mod-zone-toggle",
href := routes.User.mod(u.username),
dataIcon := Icon.Agent
)("Mod zone (Hotkey: m)")
),
a(
cls := "btn-rack__btn",
href := s"${routes.UserAnalysis.index}#explorer/${u.username}",
titleOrText(trans.site.openingExplorer.txt()),
dataIcon := Icon.Book
),
a(
cls := "btn-rack__btn",
href := routes.User.download(u.username),
titleOrText(trans.site.exportGames.txt()),
dataIcon := Icon.Download
),
(ctx.isAuth && ctx.kid.no && ctx.isnt(u)).option(
a(
titleOrText(trans.site.reportXToModerators.txt(u.username)),
cls := "btn-rack__btn",
href := s"${routes.Report.form}?username=${u.username}",
dataIcon := Icon.CautionTriangle
cls := "text",
href := routes.User.tv(u.username),
dataIcon := Icon.AnalogTv
)(trans.site.watchGames.txt()),
ctx
.isnt(u)
.option(
views.relation.actions(
u.light,
relation = social.relation,
followable = social.followable,
blocked = social.blocked
)
),
a(
cls := "text",
href := s"${routes.UserAnalysis.index}#explorer/${u.username}",
dataIcon := Icon.Book
)(trans.site.openingExplorer.txt()),
a(
cls := "text",
href := routes.User.download(u.username),
dataIcon := Icon.Download
)(trans.site.exportGames.txt()),
(ctx.isAuth && ctx.kid.no && ctx.isnt(u)).option(
a(
cls := "text",
href := s"${routes.Report.form}?username=${u.username}",
dataIcon := Icon.CautionTriangle
)(trans.site.reportXToModerators.txt(u.username))
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/main/userId.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ object userId:
extension (e: UserName) def str = UserStr(e)
given UserIdOf[UserName] = n => UserId(n.value.toLowerCase)
// what existing usernames are like
val historicalRegex = "(?i)[a-z0-9][a-z0-9_-]{0,28}[a-z0-9]".r
val historicalRegex = "(?i)[a-z0-9_][a-z0-9_-]{0,28}[a-z0-9]".r
val anonymous: UserName = "Anonymous"
val lichess: UserName = "lichess"
val anonMod: String = "A Lichess Moderator"
Expand Down
47 changes: 19 additions & 28 deletions modules/relation/src/main/ui/RelationUi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ final class RelationUi(helpers: Helpers):
blocked: Boolean,
signup: Boolean = false
)(using ctx: Context) =
div(cls := "relation-actions btn-rack")(
div(cls := "relation-actions")(
(ctx.isnt(user) && !blocked).option(
a(
titleOrText(trans.challenge.challengeToPlay.txt()),
cls := "text",
href := s"${routes.Lobby.home}?user=${user.name}#friend",
cls := "btn-rack__btn",
dataIcon := Icon.Swords
)
)(trans.challenge.challengeToPlay.txt())
),
ctx.userId
.map: myId =>
Expand All @@ -67,54 +66,46 @@ final class RelationUi(helpers: Helpers):
frag(
(!blocked && !user.isBot).option(
a(
titleOrText(trans.site.composeMessage.txt()),
cls := "text",
href := routes.Msg.convo(user.name),
cls := "btn-rack__btn",
dataIcon := Icon.BubbleSpeech
)
)(trans.site.composeMessage.txt())
),
(!blocked && !user.isPatron).option(
a(
titleOrText(trans.patron.giftPatronWingsShort.txt()),
cls := "text",
href := s"${routes.Plan.list}?dest=gift&giftUsername=${user.name}",
cls := "btn-rack__btn",
dataIcon := Icon.Wings
)
)(trans.patron.giftPatronWingsShort.txt())
),
relation match
case None =>
frag(
(followable && !blocked).option(
a(
cls := "btn-rack__btn relation-button",
href := routes.Relation.follow(user.name),
titleOrText(trans.site.follow.txt()),
cls := "text relation-button",
href := routes.Relation.follow(user.name),
dataIcon := Icon.ThumbsUp
)
)(trans.site.follow.txt())
),
a(
cls := "btn-rack__btn relation-button",
href := routes.Relation.block(user.name),
titleOrText(trans.site.block.txt()),
cls := "text relation-button",
href := routes.Relation.block(user.name),
dataIcon := Icon.NotAllowed
)
)(trans.site.block.txt())
)
case Some(Relation.Follow) =>
a(
dataIcon := Icon.ThumbsUp,
cls := "btn-rack__btn relation-button text hover-text",
cls := "text relation-button",
href := routes.Relation.unfollow(user.name),
titleOrText(trans.site.following.txt()),
dataHoverText := trans.site.unfollow.txt()
)
dataIcon := Icon.ThumbsUp
)(trans.site.unfollow.txt())
case Some(Relation.Block) =>
a(
dataIcon := Icon.NotAllowed,
cls := "btn-rack__btn relation-button text hover-text",
cls := "text relation-button",
href := routes.Relation.unblock(user.name),
titleOrText(trans.site.blocked.txt()),
dataHoverText := trans.site.unblock.txt()
)
dataIcon := Icon.NotAllowed
)(trans.site.unblock.txt())
)
)
.getOrElse:
Expand Down
5 changes: 5 additions & 0 deletions ui/bits/css/user/_profile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@

unicode-bidi: plaintext;
text-align: start;

time {
font-size: 100%;
opacity: 1;
}
}

.insight {
Expand Down
50 changes: 47 additions & 3 deletions ui/bits/css/user/_show.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,54 @@
}
}

.relation-actions {
@extend %flex-center-nowrap;
.dropdown {
position: relative;
font-size: x-large;
> a {
color: $c-font-page;
float: right;
padding-left: 0.5em;
}

.dropdown-window {
visibility: hidden;
background: $c-bg-header-dropdown;
border-radius: 3px 0 3px 3px;
box-shadow: 2px 5px 6px rgba(0, 0, 0, 0.3);
position: absolute;
top: 1.45em;
right: 0;
a {
width: 16em;
font-size: small;
display: block;
padding: 0.6rem 1rem;
color: $c-header-dropdown;
&:first-child {
border-radius: 3px 0 0 0;
}
&:last-child {
border-radius: 0 0 3px 3px;
}
&:hover {
background: $c-primary;
&,
&::after {
color: $c-over;
}
}
}
}
}

border-inline-end: $border;
.dropdown:hover {
> a {
background: $c-bg-header-dropdown;
box-shadow: 2px 5px 6px rgba(0, 0, 0, 0.3);
}
.dropdown-window {
visibility: visible;
}
}
}

Expand Down