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

Responsive behaviour of the main tab bar #2291

Open
wants to merge 2 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions play.pokemonshowdown.com/js/client-topbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
if (!app.user.loaded) {
buf = '<button disabled class="button">Loading...</button>';
} else if (app.user.get('named')) {
buf = '<span class="username" data-name="' + BattleLog.escapeHTML(name) + '"' + (away ? ' data-away="true"' : '') + (status ? 'data-status="' + BattleLog.escapeHTML(status) + '"' : '') + ' style="' + color + '"><i class="fa fa-user" style="color:' + (away ? '#888;' : '#779EC5') + '"></i> <span class="usernametext">' + BattleLog.escapeHTML(name) + '</span></span>';
buf = '<span class="username myuser" data-name="' + BattleLog.escapeHTML(name) + '"' + (away ? ' data-away="true"' : '') + (status ? 'data-status="' + BattleLog.escapeHTML(status) + '"' : '') + ' style="' + color + '"><i class="fa fa-user" style="color:' + (away ? '#888;' : '#779EC5') + '"></i> <span class="usernametext">' + BattleLog.escapeHTML(name) + '</span></span>';
} else {
buf = '<button name="login" class="button">Choose name</button>';
}
Expand Down Expand Up @@ -178,13 +178,18 @@
var $lastLi = $lastUl.children().last();
var offset = $lastLi.offset();
var width = $lastLi.outerWidth();
// 166 here is the difference between the .maintabbar's right margin and the a.button's right margin.
var overflow = offset.left + width + 166 - $(window).width();
// adjust the margin to the responsive margin of the main tab bar plus 1
var dynamicMargin = 166;
if (599 > $(window).width() >= 659) dynamicMargin = 226;
if (659 > $(window).width() >= 1023) dynamicMargin = 191;
if (1023 > $(window).width() >= 1439) dynamicMargin = 241;
if ($(window).width() > 1439) dynamicMargin = 321;
var overflow = offset.left + dynamicMargin - $(window).width();
if (app.curSideRoom && overflow > 0) {
margin -= overflow;
$lastUl.css('margin-left', margin + 'px');
offset = $lastLi.offset();
overflow = offset.left + width + 166 - $(window).width();
overflow = offset.left + width + dynamicMargin - $(window).width();
}
if (offset.top >= 37 || overflow > 0) {
this.$tabbar.append('<div class="overflow" aria-hidden="true"><button name="tablist" class="button" aria-label="More"><i class="fa fa-caret-down"></i></button></div>');
Expand Down
2 changes: 1 addition & 1 deletion play.pokemonshowdown.com/src/panel-topbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class PSHeader extends preact.Component<{style: {}}> {
return <a class="button" href="login">Choose name</a>;
}
const userColor = window.BattleLog && {color: BattleLog.usernameColor(PS.user.userid)};
return <span class="username" data-name={PS.user.name} style={userColor}>
return <span class="username myuser" data-name={PS.user.name} style={userColor}>
<i class="fa fa-user" style="color:#779EC5"></i> <span class="usernametext">{PS.user.name}</span>
</span>;
}
Expand Down
77 changes: 72 additions & 5 deletions play.pokemonshowdown.com/style/client.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Global
*********************************************************/

html, body {
html, body {
margin: 0;
padding: 0;
height: 100%;
Expand Down Expand Up @@ -75,9 +75,12 @@ select {

.userbar {
position: absolute;
top: 12px;
top: 13px;
right: 12px;
font-weight: bold;
display: flex;
align-items: center;
gap: 5px;
}
.userbar .username {
color: black;
Expand All @@ -86,9 +89,49 @@ select {
.username {
cursor: pointer;
}
@media (max-width: 500px) {
.myuser {
display: flex;
align-items: flex-end;
gap: 5px;
}
.usernametext {
overflow: hidden;
text-overflow: ellipsis;
padding-right: 1px;
}
@media (max-width:350px) {
.usernametext {
max-width: 90px;
}
}
@media (min-width:351px) and (max-width:419px) {
.usernametext {
max-width: 120px;
}
}
@media (min-width:420px) and (max-width:600px) {
.usernametext {
max-width: 65px;
}
}
@media (min-width:601px) and (max-width:659px) {
.usernametext {
max-width: 120px;
}
}
@media (min-width:660px) and (max-width:1023px) {
.usernametext {
display: none
max-width: 90px;
}
}
@media (min-width:1024px) and (max-width: 1439px) {
.usernametext {
max-width: 140px;
}
}
@media (min-width:1440px) {
.usernametext {
max-width: 200px;
}
}
.userbar button.icon {
Expand Down Expand Up @@ -140,9 +183,33 @@ select {
}
.tabbar.maintabbar {
margin-left: 144px;
margin-right: 165px;
overflow: hidden;
}
@media (max-width: 599px) {
.tabbar.maintabbar {
margin-right: 165px;
}
}
@media (min-width: 600px) and (max-width: 659px) {
.tabbar.maintabbar {
margin-right: 225px;
}
}
@media (min-width: 660px) and (max-width: 1023px) {
.tabbar.maintabbar {
margin-right: 190px;
}
}
@media (min-width: 1024px) and (max-width: 1439px) {
.tabbar.maintabbar {
margin-right: 240px;
}
}
@media (min-width: 1440px) {
.tabbar.maintabbar {
margin-right: 320px;
}
}
.tabbar.maintabbar.minitabbar {
margin-left: 0;
}
Expand Down
Loading