From f065a7a909054a744cb93e5f0c7fa8b756dfc933 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Wed, 19 Jan 2022 11:56:57 +0000 Subject: [PATCH] Improve the Icon component (#6245) GitOrigin-RevId: fbb23b32c47edbe5a22badc627318accbd09e82a --- .../components/back-to-projects-button.js | 4 +- .../components/chat-toggle-button.js | 10 +--- .../components/history-toggle-button.js | 2 +- .../components/layout-dropdown-button.js | 8 +-- .../components/menu-button.js | 6 +- .../components/online-users-widget.js | 2 +- .../components/pdf-toggle-button.js | 2 +- .../components/project-name-editable-label.js | 2 +- .../components/share-project-button.js | 2 +- .../file-tree-modal-create-file-mode.js | 2 +- .../file-tree/components/file-tree-doc.js | 55 ++++++++++--------- .../file-tree/components/file-tree-folder.js | 4 +- .../file-tree/components/file-tree-toolbar.js | 14 ++--- .../file-view/components/file-view-header.js | 23 ++------ .../file-view/components/file-view-icons.js | 12 ++++ .../file-view/components/file-view.js | 2 +- .../outline/components/outline-item.js | 2 +- .../outline/components/outline-pane.js | 2 +- .../pdf-code-check-failed-notice.js | 2 +- .../components/pdf-compile-button.js | 12 ++-- .../components/pdf-download-button.js | 2 +- .../components/pdf-hybrid-download-button.js | 2 +- .../components/pdf-hybrid-logs-button.js | 2 +- .../components/pdf-synctex-controls.js | 16 ++---- .../components/preview-download-button.js | 2 +- .../preview-logs-pane-max-entries.js | 3 +- .../preview/components/preview-logs-pane.js | 2 +- .../components/preview-recompile-button.js | 14 ++--- .../components/select-collaborators.js | 6 +- .../components/word-count-modal-content.js | 4 +- .../js/shared/components/icon-checked.js | 2 +- .../web/frontend/js/shared/components/icon.js | 33 ++++++----- .../js/shared/components/loading-spinner.js | 2 +- .../js/shared/components/processing.js | 3 +- services/web/frontend/stories/icon.stories.js | 2 +- .../stylesheets/app/editor/file-tree.less | 15 +++-- .../frontend/shared/components/icon.test.js | 20 +++---- 37 files changed, 146 insertions(+), 152 deletions(-) create mode 100644 services/web/frontend/js/features/file-view/components/file-view-icons.js diff --git a/services/web/frontend/js/features/editor-navigation-toolbar/components/back-to-projects-button.js b/services/web/frontend/js/features/editor-navigation-toolbar/components/back-to-projects-button.js index 1a76a3b774..8574d0b34a 100644 --- a/services/web/frontend/js/features/editor-navigation-toolbar/components/back-to-projects-button.js +++ b/services/web/frontend/js/features/editor-navigation-toolbar/components/back-to-projects-button.js @@ -6,8 +6,8 @@ function BackToProjectsButton() { return ( diff --git a/services/web/frontend/js/features/editor-navigation-toolbar/components/chat-toggle-button.js b/services/web/frontend/js/features/editor-navigation-toolbar/components/chat-toggle-button.js index 7fe6d51fa3..7835f2d73b 100644 --- a/services/web/frontend/js/features/editor-navigation-toolbar/components/chat-toggle-button.js +++ b/services/web/frontend/js/features/editor-navigation-toolbar/components/chat-toggle-button.js @@ -17,14 +17,10 @@ function ChatToggleButton({ chatIsOpen, unreadMessageCount, onClick }) { return (
diff --git a/services/web/frontend/js/features/editor-navigation-toolbar/components/history-toggle-button.js b/services/web/frontend/js/features/editor-navigation-toolbar/components/history-toggle-button.js index 923e860cc2..3a19ea9274 100644 --- a/services/web/frontend/js/features/editor-navigation-toolbar/components/history-toggle-button.js +++ b/services/web/frontend/js/features/editor-navigation-toolbar/components/history-toggle-button.js @@ -13,7 +13,7 @@ function HistoryToggleButton({ historyIsOpen, onClick }) { return (
diff --git a/services/web/frontend/js/features/editor-navigation-toolbar/components/layout-dropdown-button.js b/services/web/frontend/js/features/editor-navigation-toolbar/components/layout-dropdown-button.js index cc127e8caa..7c1d1e96b9 100644 --- a/services/web/frontend/js/features/editor-navigation-toolbar/components/layout-dropdown-button.js +++ b/services/web/frontend/js/features/editor-navigation-toolbar/components/layout-dropdown-button.js @@ -12,19 +12,19 @@ import { useLayoutContext } from '../../../shared/context/layout-context' import * as eventTracking from '../../../infrastructure/event-tracking' function IconPlaceholder() { - return + return } function IconRefresh() { - return + return } function IconLayout() { - return + return } function IconDetach() { - return + return } function IconCheckmark({ iconFor, pdfLayout, view, detachRole }) { diff --git a/services/web/frontend/js/features/editor-navigation-toolbar/components/menu-button.js b/services/web/frontend/js/features/editor-navigation-toolbar/components/menu-button.js index 178e780a46..c7b860fcb6 100644 --- a/services/web/frontend/js/features/editor-navigation-toolbar/components/menu-button.js +++ b/services/web/frontend/js/features/editor-navigation-toolbar/components/menu-button.js @@ -8,11 +8,7 @@ function MenuButton({ onClick }) { return (
diff --git a/services/web/frontend/js/features/editor-navigation-toolbar/components/online-users-widget.js b/services/web/frontend/js/features/editor-navigation-toolbar/components/online-users-widget.js index 67ebcea17a..7742631863 100644 --- a/services/web/frontend/js/features/editor-navigation-toolbar/components/online-users-widget.js +++ b/services/web/frontend/js/features/editor-navigation-toolbar/components/online-users-widget.js @@ -105,7 +105,7 @@ const DropDownToggleButton = React.forwardRef((props, ref) => { onClick={props.onClick} // required by Bootstrap Dropdown to trigger an opening > {props.onlineUserCount} - + ) diff --git a/services/web/frontend/js/features/editor-navigation-toolbar/components/pdf-toggle-button.js b/services/web/frontend/js/features/editor-navigation-toolbar/components/pdf-toggle-button.js index 83d5ba6db0..8c7c230421 100644 --- a/services/web/frontend/js/features/editor-navigation-toolbar/components/pdf-toggle-button.js +++ b/services/web/frontend/js/features/editor-navigation-toolbar/components/pdf-toggle-button.js @@ -21,7 +21,7 @@ function PdfToggleButton({ onClick, pdfViewIsOpen }) { > {/* eslint-disable-next-line jsx-a11y/anchor-is-valid,jsx-a11y/click-events-have-key-events,jsx-a11y/interactive-supports-focus */} - + ) diff --git a/services/web/frontend/js/features/editor-navigation-toolbar/components/project-name-editable-label.js b/services/web/frontend/js/features/editor-navigation-toolbar/components/project-name-editable-label.js index a06a83279d..44a1eec5cf 100644 --- a/services/web/frontend/js/features/editor-navigation-toolbar/components/project-name-editable-label.js +++ b/services/web/frontend/js/features/editor-navigation-toolbar/components/project-name-editable-label.js @@ -82,7 +82,7 @@ function ProjectNameEditableLabel({ > {/* eslint-disable-next-line jsx-a11y/anchor-is-valid, jsx-a11y/click-events-have-key-events, jsx-a11y/interactive-supports-focus */} - + )} diff --git a/services/web/frontend/js/features/editor-navigation-toolbar/components/share-project-button.js b/services/web/frontend/js/features/editor-navigation-toolbar/components/share-project-button.js index 16b9d449aa..6a6a26a182 100644 --- a/services/web/frontend/js/features/editor-navigation-toolbar/components/share-project-button.js +++ b/services/web/frontend/js/features/editor-navigation-toolbar/components/share-project-button.js @@ -8,7 +8,7 @@ function ShareProjectButton({ onClick }) { return (
diff --git a/services/web/frontend/js/features/file-tree/components/file-tree-create/file-tree-modal-create-file-mode.js b/services/web/frontend/js/features/file-tree/components/file-tree-create/file-tree-modal-create-file-mode.js index 645b573488..40912f0158 100644 --- a/services/web/frontend/js/features/file-tree/components/file-tree-create/file-tree-modal-create-file-mode.js +++ b/services/web/frontend/js/features/file-tree/components/file-tree-create/file-tree-modal-create-file-mode.js @@ -19,7 +19,7 @@ export default function FileTreeModalCreateFileMode({ mode, icon, label }) { onClick={handleClick} className="modal-new-file-mode" > - +   {label} diff --git a/services/web/frontend/js/features/file-tree/components/file-tree-doc.js b/services/web/frontend/js/features/file-tree/components/file-tree-doc.js index 9e58dfb5d1..00e6082e67 100644 --- a/services/web/frontend/js/features/file-tree/components/file-tree-doc.js +++ b/services/web/frontend/js/features/file-tree/components/file-tree-doc.js @@ -1,36 +1,16 @@ import PropTypes from 'prop-types' -import { useTranslation } from 'react-i18next' - -import Icon from '../../../shared/components/icon' -import iconTypeFromName from '../util/icon-type-from-name' import { useSelectableEntity } from '../contexts/file-tree-selectable' import FileTreeItemInner from './file-tree-item/file-tree-item-inner' +import { useTranslation } from 'react-i18next' +import Icon from '../../../shared/components/icon' +import iconTypeFromName from '../util/icon-type-from-name' +import classnames from 'classnames' function FileTreeDoc({ name, id, isLinkedFile }) { - const { t } = useTranslation() - const { isSelected, props: selectableEntityProps } = useSelectableEntity(id) - const icons = ( - <> - - {isLinkedFile ? ( - - ) : null} - - - ) return (
  • } />
  • ) @@ -54,4 +34,29 @@ FileTreeDoc.propTypes = { isLinkedFile: PropTypes.bool, } +export const FileTreeIcon = ({ isLinkedFile, name }) => { + const { t } = useTranslation() + + const className = classnames('spaced', { 'linked-file-icon': isLinkedFile }) + + return ( + <> +   + + {isLinkedFile && ( + + )} + + ) +} +FileTreeIcon.propTypes = { + name: PropTypes.string.isRequired, + isLinkedFile: PropTypes.bool, +} + export default FileTreeDoc diff --git a/services/web/frontend/js/features/file-tree/components/file-tree-folder.js b/services/web/frontend/js/features/file-tree/components/file-tree-folder.js index 07fea9a29c..8fe8d1153c 100644 --- a/services/web/frontend/js/features/file-tree/components/file-tree-folder.js +++ b/services/web/frontend/js/features/file-tree/components/file-tree-folder.js @@ -45,9 +45,9 @@ function FileTreeFolder({ name, id, folders, docs, files }) { onClick={handleExpandCollapseClick} aria-label={expanded ? t('collapse') : t('expand')} > - + - + ) diff --git a/services/web/frontend/js/features/file-tree/components/file-tree-toolbar.js b/services/web/frontend/js/features/file-tree/components/file-tree-toolbar.js index 181bbb8efc..9bdafb2965 100644 --- a/services/web/frontend/js/features/file-tree/components/file-tree-toolbar.js +++ b/services/web/frontend/js/features/file-tree/components/file-tree-toolbar.js @@ -42,25 +42,21 @@ function FileTreeToolbarLeft() { description={t('new_file')} onClick={startCreatingDocOrFile} > - + - + - + ) @@ -83,7 +79,7 @@ function FileTreeToolbarRight() { description={t('rename')} onClick={startRenaming} > - + ) : null} {canDelete ? ( @@ -92,7 +88,7 @@ function FileTreeToolbarRight() { description={t('delete')} onClick={startDeleting} > - + ) : null} diff --git a/services/web/frontend/js/features/file-view/components/file-view-header.js b/services/web/frontend/js/features/file-view/components/file-view-header.js index a01c73c797..92b5772bf4 100644 --- a/services/web/frontend/js/features/file-view/components/file-view-header.js +++ b/services/web/frontend/js/features/file-view/components/file-view-header.js @@ -10,6 +10,7 @@ import { useProjectContext } from '../../../shared/context/project-context' import importOverleafModules from '../../../../macros/import-overleaf-module.macro' import useAbortController from '../../../shared/hooks/use-abort-controller' +import { LinkedFileIcon } from './file-view-icons' const tprLinkedFileInfo = importOverleafModules('tprLinkedFileInfo') const tprLinkedFileRefreshError = importOverleafModules( 'tprLinkedFileRefreshError' @@ -120,7 +121,7 @@ export default function FileViewHeader({ file, storeReferencesKeys }) { onClick={refreshFile} disabled={refreshing} > - + {refreshing ? t('refreshing') + '...' : t('refresh')} )} @@ -129,7 +130,7 @@ export default function FileViewHeader({ file, storeReferencesKeys }) { href={`/project/${projectId}/file/${file.id}`} className="btn btn-info" > - +   {t('download')} @@ -162,11 +163,7 @@ FileViewHeader.propTypes = { function UrlProvider({ file }) { return (

    - +   - +   - +   { + return ( + + ) +} diff --git a/services/web/frontend/js/features/file-view/components/file-view.js b/services/web/frontend/js/features/file-view/components/file-view.js index 6e222929f6..443cc04e99 100644 --- a/services/web/frontend/js/features/file-view/components/file-view.js +++ b/services/web/frontend/js/features/file-view/components/file-view.js @@ -65,7 +65,7 @@ function FileViewLoadingIndicator() { return (

    - +   {t('loading')}…
    diff --git a/services/web/frontend/js/features/outline/components/outline-item.js b/services/web/frontend/js/features/outline/components/outline-item.js index cdc723d715..7410141f68 100644 --- a/services/web/frontend/js/features/outline/components/outline-item.js +++ b/services/web/frontend/js/features/outline/components/outline-item.js @@ -80,7 +80,7 @@ function OutlineItem({ outlineItem, jumpToLine, highlightedLine }) { > ) : null} diff --git a/services/web/frontend/js/features/outline/components/outline-pane.js b/services/web/frontend/js/features/outline/components/outline-pane.js index ba4d47875b..ded992c7e9 100644 --- a/services/web/frontend/js/features/outline/components/outline-pane.js +++ b/services/web/frontend/js/features/outline/components/outline-pane.js @@ -57,7 +57,7 @@ const OutlinePane = React.memo(function OutlinePane({ >

    {t('file_outline')}

    diff --git a/services/web/frontend/js/features/pdf-preview/components/pdf-code-check-failed-notice.js b/services/web/frontend/js/features/pdf-preview/components/pdf-code-check-failed-notice.js index 05d1d93b2b..e0d1455b49 100644 --- a/services/web/frontend/js/features/pdf-preview/components/pdf-code-check-failed-notice.js +++ b/services/web/frontend/js/features/pdf-preview/components/pdf-code-check-failed-notice.js @@ -9,7 +9,7 @@ function PdfCodeCheckFailedNotice() {
    - +

    {t('code_check_failed_explanation')} diff --git a/services/web/frontend/js/features/pdf-preview/components/pdf-compile-button.js b/services/web/frontend/js/features/pdf-preview/components/pdf-compile-button.js index 638e783238..42a53f3982 100644 --- a/services/web/frontend/js/features/pdf-preview/components/pdf-compile-button.js +++ b/services/web/frontend/js/features/pdf-preview/components/pdf-compile-button.js @@ -48,36 +48,36 @@ function PdfCompileButton() { {t('auto_compile')} setAutoCompile(true)}> - + {t('on')} setAutoCompile(false)}> - + {t('off')} {t('compile_mode')} setDraft(false)}> - + {t('normal')} setDraft(true)}> - + {t('fast')} [draft] Syntax Checks setStopOnValidationError(true)}> - + {t('stop_on_validation_error')} setStopOnValidationError(false)}> - + {t('ignore_validation_errors')} diff --git a/services/web/frontend/js/features/pdf-preview/components/pdf-download-button.js b/services/web/frontend/js/features/pdf-preview/components/pdf-download-button.js index e00ffe97ec..e962d5ce76 100644 --- a/services/web/frontend/js/features/pdf-preview/components/pdf-download-button.js +++ b/services/web/frontend/js/features/pdf-preview/components/pdf-download-button.js @@ -26,7 +26,7 @@ function PdfDownloadButton() { download href={pdfDownloadUrl || '#'} > - + {t('download_pdf')} diff --git a/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-download-button.js b/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-download-button.js index e31cbc35fd..bda9c4d432 100644 --- a/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-download-button.js +++ b/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-download-button.js @@ -28,7 +28,7 @@ function PdfHybridDownloadButton() { target="_blank" style={{ pointerEvents: 'auto' }} > - + ) diff --git a/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-logs-button.js b/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-logs-button.js index f843b16a61..c16359d81a 100644 --- a/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-logs-button.js +++ b/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-logs-button.js @@ -40,7 +40,7 @@ function PdfHybridLogsButton() { style={{ position: 'relative' }} aria-label={showLogs ? t('view_pdf') : t('view_logs')} > - + {!showLogs && totalCount > 0 && (