From 52f57d818ade61435d90be962a63cd94a5411e10 Mon Sep 17 00:00:00 2001
From: Michael An <2331806369@qq.com>
Date: Fri, 3 Jan 2025 16:35:28 +0800
Subject: [PATCH] change checkbox style
---
.../components/common/fixed-width-table.js | 16 ++++-
.../src/components/common/seahub-checkbox.js | 25 +++++++
.../dirent-list-view/dirent-list-item.js | 18 +++--
.../dirent-list-view/dirent-list-view.js | 65 +++++++++++--------
frontend/src/css/seahub-checkbox.css | 36 ++++++++++
5 files changed, 119 insertions(+), 41 deletions(-)
create mode 100644 frontend/src/components/common/seahub-checkbox.js
create mode 100644 frontend/src/css/seahub-checkbox.css
diff --git a/frontend/src/components/common/fixed-width-table.js b/frontend/src/components/common/fixed-width-table.js
index 12fd4b11a28..953831fbcf5 100644
--- a/frontend/src/components/common/fixed-width-table.js
+++ b/frontend/src/components/common/fixed-width-table.js
@@ -26,9 +26,19 @@ const FixedWidthTable = ({ className, headers, theadOptions = {}, children }) =>
{headers.map((header, index) => {
- const { width, isFixed, children: thChildren, className } = header;
- const validWidth = isFixed ? width : (containerWidth - fixedWidth) * width;
- return ({thChildren} | );
+ const { width, isFixed, className, onClick = () => {}, title = '', ariaLabel = '' } = header;
+ return (
+
+ {header.children}
+ |
+ );
})}
diff --git a/frontend/src/components/common/seahub-checkbox.js b/frontend/src/components/common/seahub-checkbox.js
new file mode 100644
index 00000000000..633701656af
--- /dev/null
+++ b/frontend/src/components/common/seahub-checkbox.js
@@ -0,0 +1,25 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import classnames from 'classnames';
+import '../../css/seahub-checkbox.css';
+
+const SeahubCheckbox = ({ isSelected, highlight }) => {
+ return (
+
+
+
+ );
+};
+
+SeahubCheckbox.propTypes = {
+ isSelected: PropTypes.bool,
+ highlight: PropTypes.bool,
+};
+
+export default SeahubCheckbox;
diff --git a/frontend/src/components/dirent-list-view/dirent-list-item.js b/frontend/src/components/dirent-list-view/dirent-list-item.js
index a44a81abe24..038e7bc3c5d 100644
--- a/frontend/src/components/dirent-list-view/dirent-list-item.js
+++ b/frontend/src/components/dirent-list-view/dirent-list-item.js
@@ -23,6 +23,7 @@ import LibSubFolderPermissionDialog from '../dialog/lib-sub-folder-permission-di
import FileAccessLog from '../dialog/file-access-log';
import toaster from '../toast';
import FileTag from './file-tag';
+import SeahubCheckbox from '../common/seahub-checkbox';
import '../../css/dirent-list-item.css';
@@ -829,16 +830,13 @@ class DirentListItem extends React.Component {
onMouseDown={this.onItemMouseDown}
onContextMenu={this.onItemContextMenu}
>
-
- {}}
- checked={isSelected}
- aria-label={isSelected ? gettext('Unselect this item') : gettext('Select this item')}
- />
+ |
+
|
{dirent.starred !== undefined &&
diff --git a/frontend/src/components/dirent-list-view/dirent-list-view.js b/frontend/src/components/dirent-list-view/dirent-list-view.js
index d7e4d426bf3..9104a79814c 100644
--- a/frontend/src/components/dirent-list-view/dirent-list-view.js
+++ b/frontend/src/components/dirent-list-view/dirent-list-view.js
@@ -22,6 +22,7 @@ import EmptyTip from '../empty-tip';
import imageAPI from '../../utils/image-api';
import { seafileAPI } from '../../utils/seafile-api';
import FixedWidthTable from '../common/fixed-width-table';
+import SeahubCheckbox from '../common/seahub-checkbox';
const propTypes = {
path: PropTypes.string.isRequired,
@@ -680,7 +681,7 @@ class DirentListView extends React.Component {
};
getHeaders = (isDesktop) => {
- const { direntList, sortBy, sortOrder } = this.props;
+ const { sortBy, sortOrder } = this.props;
if (!isDesktop) {
return [
{ isFixed: false, width: 0.12 },
@@ -689,36 +690,45 @@ class DirentListView extends React.Component {
];
}
- // sort
- const sortByName = sortBy == 'name';
- const sortByTime = sortBy == 'time';
- const sortBySize = sortBy == 'size';
- const sortIcon = sortOrder == 'asc' ? : ;
+ const sortIcon = ;
return [
- { isFixed: true, width: 31, className: 'pl10 pr-2', children: (
-
- ) }, {
+ { isFixed: true,
+ width: 31,
+ className: 'pl10 pr-2 cursor-pointer',
+ title: this.props.isAllItemSelected ? gettext('Unselect all items') : gettext('Select all items'),
+ ariaLabel: this.props.isAllItemSelected ? gettext('Unselect all items') : gettext('Select all items'),
+ children: (),
+ onClick: (e) => {
+ e.stopPropagation();
+ this.props.onAllItemSelected();
+ }
+ },
+ {
isFixed: true, width: 32, className: 'pl-2 pr-2', // star
- }, {
+ },
+ {
isFixed: true, width: 40, className: 'pl-2 pr-2', // icon
- }, {
- isFixed: false, width: 0.5, children: ({gettext('Name')} {sortByName && sortIcon}),
- }, {
+ },
+ {
+ isFixed: false,
+ width: 0.5,
+ children: ({gettext('Name')} {sortBy == 'name' && sortIcon}),
+ },
+ {
isFixed: false, width: 0.06, // tag
- }, {
+ },
+ {
isFixed: false, width: 0.18, // operation
- }, {
- isFixed: false, width: 0.11, children: ({gettext('Size')} {sortBySize && sortIcon})
- }, {
- isFixed: false, width: 0.15, children: ({gettext('Last Update')} {sortByTime && sortIcon})
+ },
+ {
+ isFixed: false,
+ width: 0.11,
+ children: ({gettext('Size')} {sortBy == 'size' && sortIcon})
+ },
+ {
+ isFixed: false,
+ width: 0.15,
+ children: ({gettext('Last Update')} {sortBy == 'time' && sortIcon})
}
];
};
@@ -728,7 +738,6 @@ class DirentListView extends React.Component {
const isDesktop = Utils.isDesktop();
const repoEncrypted = this.props.currentRepoInfo.encrypted;
- const headers = this.getHeaders(isDesktop);
return (
0 && (
{direntList.map((dirent, index) => {
diff --git a/frontend/src/css/seahub-checkbox.css b/frontend/src/css/seahub-checkbox.css
new file mode 100644
index 00000000000..9865a909083
--- /dev/null
+++ b/frontend/src/css/seahub-checkbox.css
@@ -0,0 +1,36 @@
+:root {
+ --seahub-checkbox-hover-color: #c1c5c8;
+ --seahub-checkbox-selected-color: #ff9800;
+ --seahub-checkbox-hover-selected-color: #eb8205;
+}
+
+.seahub-checkbox-icon {
+ width: 14px;
+ height: 14px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ border-radius: 4px;
+ background-color: #fff;
+ border: 1px solid var(--seahub-checkbox-hover-color);
+}
+
+.seahub-checkbox-icon.seahub-checkbox-icon-highlight {
+ background-color: var(--seahub-checkbox-hover-color);
+}
+
+.seahub-checkbox-icon.seahub-checkbox-icon-selected {
+ background-color: var(--seahub-checkbox-selected-color);
+ border: 1px solid var(--seahub-checkbox-selected-color);
+}
+
+.seahub-checkbox-icon.seahub-checkbox-icon-highlight.seahub-checkbox-icon-selected {
+ background-color: var(--seahub-checkbox-hover-selected-color);
+ border: 1px solid var(--seahub-checkbox-hover-selected-color);
+}
+
+.seahub-checkbox-icon .sf2-icon-tick {
+ color: #fff;
+ font-size: 12px;
+ font-weight: 700;
+}
|