centered button icons on mobile view when if text should not be displayed

This commit is contained in:
Florian Scholdei
2019-04-18 18:07:13 +02:00
parent ba3557fbb6
commit 4eb08770b7
5 changed files with 62 additions and 35 deletions

View File

@@ -11,7 +11,7 @@ import {
import injectSheets from "react-jss"; import injectSheets from "react-jss";
import classNames from "classnames"; import classNames from "classnames";
import { translate } from "react-i18next"; import { translate } from "react-i18next";
import {Button} from "../buttons"; import { Button } from "../buttons";
const styles = { const styles = {
panel: { panel: {
@@ -181,11 +181,17 @@ class DiffFile extends React.Component<Props, State> {
); );
} }
const fileControls = fileControlFactory ? fileControlFactory(file, this.setCollapse) : null; const fileControls = fileControlFactory
return <div className={classNames("panel", classes.panel)}> ? fileControlFactory(file, this.setCollapse)
: null;
return (
<div className={classNames("panel", classes.panel)}>
<div className="panel-heading"> <div className="panel-heading">
<div className="level"> <div className="level">
<div className={classNames("level-left", classes.titleHeader)} onClick={this.toggleCollapse}> <div
className={classNames("level-left", classes.titleHeader)}
onClick={this.toggleCollapse}
>
<i className={icon} /> <i className={icon} />
<span className={classes.title}> <span className={classes.title}>
{this.renderFileTitle(file)} {this.renderFileTitle(file)}
@@ -195,11 +201,16 @@ class DiffFile extends React.Component<Props, State> {
</span> </span>
</div> </div>
<div className="level-right"> <div className="level-right">
<Button action={this.toggleSideBySide}> <Button action={this.toggleSideBySide} className="reduced-mobile">
<span className="icon is-small"> <span className="icon is-small">
<i className={classNames("fas", sideBySide ? "fa-align-left" : "fa-columns")} /> <i
className={classNames(
"fas",
sideBySide ? "fa-align-left" : "fa-columns"
)}
/>
</span> </span>
<span className="is-hidden-mobile"> <span>
{t(sideBySide ? "diff.combined" : "diff.sideBySide")} {t(sideBySide ? "diff.combined" : "diff.sideBySide")}
</span> </span>
</Button> </Button>
@@ -208,7 +219,8 @@ class DiffFile extends React.Component<Props, State> {
</div> </div>
</div> </div>
{body} {body}
</div>; </div>
);
} }
} }

View File

@@ -23,21 +23,17 @@ class ChangesetButtonGroup extends React.Component<Props> {
return ( return (
<ButtonGroup className="is-pulled-right"> <ButtonGroup className="is-pulled-right">
<Button link={changesetLink}> <Button link={changesetLink} className="reduced-mobile">
<span className="icon"> <span className="icon">
<i className="fas fa-exchange-alt" /> <i className="fas fa-exchange-alt" />
</span> </span>
<span className="is-hidden-mobile is-hidden-tablet-only"> <span>{t("changeset.buttons.details")}</span>
{t("changeset.buttons.details")}
</span>
</Button> </Button>
<Button link={sourcesLink}> <Button link={sourcesLink} className="reduced-mobile">
<span className="icon"> <span className="icon">
<i className="fas fa-code" /> <i className="fas fa-code" />
</span> </span>
<span className="is-hidden-mobile is-hidden-tablet-only"> <span>{t("changeset.buttons.sources")}</span>
{t("changeset.buttons.sources")}
</span>
</Button> </Button>
</ButtonGroup> </ButtonGroup>
); );

View File

@@ -25,21 +25,17 @@ class BranchButtonGroup extends React.Component<Props> {
return ( return (
<ButtonGroup> <ButtonGroup>
<Button link={changesetLink}> <Button link={changesetLink} className="reduced-mobile">
<span className="icon"> <span className="icon">
<i className="fas fa-exchange-alt" /> <i className="fas fa-exchange-alt" />
</span> </span>
<span className="is-hidden-mobile is-hidden-tablet-only"> <span>{t("branch.commits")}</span>
{t("branch.commits")}
</span>
</Button> </Button>
<Button link={sourcesLink}> <Button link={sourcesLink} className="reduced-mobile">
<span className="icon"> <span className="icon">
<i className="fas fa-code" /> <i className="fas fa-code" />
</span> </span>
<span className="is-hidden-mobile is-hidden-tablet-only"> <span>{t("branch.sources")}</span>
{t("branch.sources")}
</span>
</Button> </Button>
</ButtonGroup> </ButtonGroup>
); );

View File

@@ -27,21 +27,25 @@ class FileButtonGroup extends React.Component<Props> {
return ( return (
<ButtonGroup> <ButtonGroup>
<Button action={this.showSources} color={ this.color(!historyIsSelected) }> <Button
action={this.showSources}
className="reduced-mobile"
color={this.color(!historyIsSelected)}
>
<span className="icon"> <span className="icon">
<i className="fas fa-code"/> <i className="fas fa-code" />
</span>
<span className="is-hidden-mobile">
{t("sources.content.sourcesButton")}
</span> </span>
<span>{t("sources.content.sourcesButton")}</span>
</Button> </Button>
<Button action={this.showHistory} color={ this.color(historyIsSelected) }> <Button
action={this.showHistory}
className="reduced-mobile"
color={this.color(historyIsSelected)}
>
<span className="icon"> <span className="icon">
<i className="fas fa-history"/> <i className="fas fa-history" />
</span>
<span className="is-hidden-mobile">
{t("sources.content.historyButton")}
</span> </span>
<span>{t("sources.content.historyButton")}</span>
</Button> </Button>
</ButtonGroup> </ButtonGroup>
); );

View File

@@ -111,6 +111,25 @@ $fa-font-path: "webfonts";
&.is-primary[disabled] { &.is-primary[disabled] {
background-color: #40dde7; background-color: #40dde7;
} }
&.reduced-mobile {
@media screen and (max-width: 1087px) {
> span:nth-child(2) {
display: none;
}
}
@media screen and (max-width: 1087px) and (min-width: 769px) {
// simultaneously with left margin of Bulma
> .icon:first-child:not(:last-child) {
margin: 0;
}
}
@media screen and (max-width: 768px) {
// simultaneously with left margin of Bulma
.icon:first-child:not(:last-child) {
margin-right: calc(-0.375em - 1px);
}
}
}
} }
// multiline Columns // multiline Columns