Skip to content

TagSpaces is an offline, open source, document manager with tagging support

polish: improving design of the list view in default perspective (#1288)

Ilian7fcba764980c
diff --git a/app/perspectives/grid-perspective/components/CellContent.tsx b/app/perspectives/grid-perspective/components/CellContent.tsx
index 3dbf56db7..cdf5f2f09 100644
--- a/app/perspectives/grid-perspective/components/CellContent.tsx
+++ b/app/perspectives/grid-perspective/components/CellContent.tsx
@@ -23,9 +23,9 @@ import Grid from '@material-ui/core/Grid';
import Typography from '@material-ui/core/Typography';
import IconButton from '@material-ui/core/IconButton';
import Paper from '@material-ui/core/Paper';
-import FolderIcon from '@material-ui/icons/FolderOpen';
-// import SelectedIcon from '@material-ui/icons/CheckCircle';
-// import UnSelectedIcon from '@material-ui/icons/RadioButtonUnchecked';
+import FolderIcon from '@material-ui/icons/Folder';
+import SelectedIcon from '@material-ui/icons/CheckBox';
+import UnSelectedIcon from '@material-ui/icons/CheckBoxOutlineBlank';
import TagIcon from '@material-ui/icons/LocalOfferOutlined';
import { formatFileSize, formatDateTime } from '-/utils/misc';
import { extractTagsAsObjects, extractTitle } from '-/utils/paths';
@@ -50,6 +50,8 @@ interface Props {
addTags: () => void;
openFsEntry: (fsEntry: FileSystemEntry) => void;
selectedEntries: Array<FileSystemEntry>;
+ selectEntry: (fsEntry: FileSystemEntry) => void;
+ deselectEntry: (fsEntry: FileSystemEntry) => void;
isReadOnlyMode: boolean;
showTags: boolean;
handleTagMenu: (event: Object, tag: Tag, entryPath: string) => void;
@@ -77,9 +79,11 @@ const CellContent = (props: Props) => {
handleGridCellDblClick,
handleGridCellClick,
showTags,
- openFsEntry
+ openFsEntry,
+ selectEntry,
+ deselectEntry
} = props;
- const fsEntryBackgroundColor = fsEntry.color ? fsEntry.color : 'transparent';
+ const fsEntryBackgroundColor = fsEntry.color; // ? fsEntry.color : 'transparent';
const entryTitle = extractTitle(
fsEntry.name,
!fsEntry.isFile,
@@ -245,25 +249,35 @@ const CellContent = (props: Props) => {
padding: 3,
marginRight: 5,
textAlign: 'left',
- backgroundColor: fsEntryBackgroundColor
+ display: 'flex'
}}
>
- {fsEntry.isFile ? (
- <div
- className={classes.rowFileExtension}
- title={fsEntry.path}
- style={{ backgroundColor: fsEntryColor }}
- >
- {fsEntry.extension}
- </div>
- ) : (
- <span title={fsEntry.path}>
- <FolderIcon
- className={classes.rowFolder}
- style={{ backgroundColor: fsEntryColor }}
- />
- </span>
- )}
+ <div
+ className={classes.rowFileExtension}
+ role="presentation"
+ title={fsEntry.path}
+ onClick={e => {
+ e.stopPropagation();
+ if (selected) {
+ deselectEntry(fsEntry);
+ } else {
+ selectEntry(fsEntry);
+ }
+ }}
+ style={{
+ backgroundColor: fsEntry.isFile
+ ? fsEntryColor
+ : fsEntryBackgroundColor || fsEntryColor
+ }}
+ >
+ {fsEntry.isFile ? fsEntry.extension : <FolderIcon />}
+ {entrySize !== 'small' &&
+ (selected ? (
+ <SelectedIcon style={{ paddingTop: 5 }} />
+ ) : (
+ <UnSelectedIcon style={{ paddingTop: 5 }} />
+ ))}
+ </div>
</Grid>
{entrySize === 'small' ? (
<Grid
@@ -292,9 +306,9 @@ const CellContent = (props: Props) => {
: tagPlaceholder}
<Typography
style={{
- color: 'gray',
- padding: 5
+ color: 'gray'
}}
+ variant="body2"
>
<span title={fsEntry.size + ' ' + i18n.t('core:sizeInBytes')}>
{fsEntry.isFile && formatFileSize(fsEntry.size) + ' - '}
@@ -311,7 +325,7 @@ const CellContent = (props: Props) => {
formatDateTime(fsEntry.lmdt, false)}
</span>
<span title={i18n.t('core:entryDescription')}>
- {description && ' | ' + description}
+ {description && (fsEntry.isFile && ' | ') + description}
</span>
</Typography>
</Grid>
diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsx
index 665409734..577266595 100644
--- a/app/perspectives/grid-perspective/components/MainContainer.tsx
+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx
@@ -502,6 +502,19 @@ class GridPerspective extends React.Component<Props, State> {
}
};
+ selectEntry = (fsEntry: FileSystemEntry) => {
+ const { setSelectedEntries, selectedEntries } = this.props;
+ setSelectedEntries([...selectedEntries, fsEntry]);
+ };
+
+ deselectEntry = (fsEntry: FileSystemEntry) => {
+ const { setSelectedEntries, selectedEntries } = this.props;
+ const newSelection = selectedEntries.filter(
+ data => data.path !== fsEntry.path
+ );
+ setSelectedEntries(newSelection);
+ };
+
handleTagMenu = (
event: React.ChangeEvent<HTMLInputElement>,
tag: Tag,
@@ -658,6 +671,8 @@ class GridPerspective extends React.Component<Props, State> {
thumbnailMode={thumbnailMode}
addTags={addTags}
selectedEntries={selectedEntries}
+ selectEntry={this.selectEntry}
+ deselectEntry={this.deselectEntry}
isReadOnlyMode={this.props.isReadOnlyMode}
handleTagMenu={this.handleTagMenu}
layoutType={layoutType}
diff --git a/app/perspectives/grid-perspective/components/styles.css.tsx b/app/perspectives/grid-perspective/components/styles.css.tsx
index e30bf9881..3f0eda639 100644
--- a/app/perspectives/grid-perspective/components/styles.css.tsx
+++ b/app/perspectives/grid-perspective/components/styles.css.tsx
@@ -103,6 +103,7 @@ export default (theme: any): any => ({
rowFileExtension: {
flex: 1,
padding: 5,
+ paddingTop: 7,
width: 35,
maxWidth: 60,
minHeight: 15,
@@ -111,7 +112,7 @@ export default (theme: any): any => ({
textTransform: 'uppercase',
fontSize: 12,
fontWeight: 'bold',
- borderRadius: 3,
+ borderRadius: 4,
textAlign: 'center',
overflow: 'hidden',
textOverflow: 'ellipsis'
@@ -127,13 +128,6 @@ export default (theme: any): any => ({
display: 'flex',
whiteSpace: 'nowrap'
},
- rowFolder: {
- color: 'white',
- padding: 5,
- minHeight: 10,
- height: 20,
- borderRadius: 3
- },
gridFolder: {
color: 'white',
padding: 5,