Skip to content

Commit

Permalink
[dir view] redesigned the 'view modes' UI (#6103)
Browse files Browse the repository at this point in the history
  • Loading branch information
llj authored May 22, 2024
1 parent e599ef3 commit 21e8443
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
20 changes: 8 additions & 12 deletions frontend/src/components/cur-dir-path/dir-tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ class DirTool extends React.Component {
});
};

onMouseDown = (e) => {
e.stopPropagation();
};

hidePopover = (e) => {
if (e) {
let dom = e.target;
Expand Down Expand Up @@ -85,13 +81,13 @@ class DirTool extends React.Component {
};

onMenuItemClick = (item) => {
const { key: operation, href } = item;
switch (operation) {
const { key, href } = item;
switch (key) {
case 'Properties':
this.props.switchViewMode('detail');
break;
case 'Tags':
this.setState({ isRepoTagDialogOpen: !this.state.isRepoTagDialogOpen });
this.setState({isRepoTagDialogOpen: !this.state.isRepoTagDialogOpen});
break;
case 'Trash':
location.href = href;
Expand All @@ -112,9 +108,9 @@ class DirTool extends React.Component {
return list.concat(list2);
};

onMenuItemKeyDown = (e) => {
onMenuItemKeyDown = (e, item) => {
if (e.key == 'Enter' || e.key == 'Space') {
this.onMenuItemClick(e);
this.onMenuItemClick(item);
}
};

Expand All @@ -125,8 +121,8 @@ class DirTool extends React.Component {
const { repoID } = this.props;
return (
<React.Fragment>
<div>
<div className="view-mode btn-group">
<div className="d-flex">
<div className="view-modes">
<button className={`${baseClass} sf3-font-list-view sf3-font ${this.props.currentMode === 'list' ? 'current-mode' : ''}`} id='list' title={gettext('List')} aria-label={gettext('List')} onClick={this.props.switchViewMode.bind(this, 'list')}></button>
<button className={`${baseClass} sf3-font-grid-view sf3-font ${this.props.currentMode === 'grid' ? 'current-mode' : ''}`} id='grid' title={gettext('Grid')} aria-label={gettext('Grid')} onClick={this.props.switchViewMode.bind(this, 'grid')}></button>
</div>
Expand All @@ -148,7 +144,7 @@ class DirTool extends React.Component {
return <DropdownItem key={index} divider />;
} else {
return (
<DropdownItem key={index} onClick={this.onMenuItemClick.bind(this, menuItem)} onKeyDown={this.onMenuItemKeyDown}>{menuItem.value}</DropdownItem>
<DropdownItem key={index} onClick={this.onMenuItemClick.bind(this, menuItem)} onKeyDown={this.onMenuItemKeyDown.bind(this, menuItem)}>{menuItem.value}</DropdownItem>
);
}
})}
Expand Down
16 changes: 11 additions & 5 deletions frontend/src/css/toolbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,22 @@
/* end file-operation toolbar */

/* begin view-mode toolbar */
.view-modes {
padding: 2px;
background-color: #e5e6e7;
border-radius: 3px;
height: 32px;
}
.sf-view-mode-btn {
width: 44px;
height: 32px;
height: 28px;
padding: 0;
background-color: #e5e6e7;
background-color: transparent;
color: #444;
font-size: 14px;
line-height: 30px;
border: 1px solid #ccc;
border-radius: 3px;
line-height: 2;
border: 0;
border-radius: 2px;
}

.sf-view-mode-btn:hover {
Expand Down

0 comments on commit 21e8443

Please sign in to comment.