From c66278cf897bdcf72fc23ec23371b6ae47627811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Alby?= Date: Thu, 26 May 2022 14:58:10 +0200 Subject: [PATCH] Merge pull request #8148 from overleaf/ta-pr-dictionary-style Polish Dictionary Modal UI GitOrigin-RevId: 48aceb56c84a218380c619ecc5cd527f5062d3c4 --- .../app/views/project/editor/left-menu.pug | 2 +- .../components/dictionary-modal-content.tsx | 70 +++++++++++++------ .../web/frontend/stylesheets/app/editor.less | 1 + .../stylesheets/app/editor/dictionary.less | 29 ++++++++ .../stylesheets/app/editor/left-menu.less | 6 -- .../dictionary-modal-content.test.js | 4 +- 6 files changed, 82 insertions(+), 30 deletions(-) create mode 100644 services/web/frontend/stylesheets/app/editor/dictionary.less diff --git a/services/web/app/views/project/editor/left-menu.pug b/services/web/app/views/project/editor/left-menu.pug index 953e390692..13c2adf50e 100644 --- a/services/web/app/views/project/editor/left-menu.pug +++ b/services/web/app/views/project/editor/left-menu.pug @@ -120,7 +120,7 @@ aside#left-menu.full-size( if dictionaryEditorEnabled .form-controls(ng-controller="DictionaryModalController") label #{translate("dictionary")} - button.btn.btn-default.btn-sm(ng-click="openModal()") #{translate("edit")} + button.btn.btn-default.btn-xs(ng-click="openModal()") #{translate("edit")} dictionary-modal( handle-hide="handleHide" diff --git a/services/web/frontend/js/features/dictionary/components/dictionary-modal-content.tsx b/services/web/frontend/js/features/dictionary/components/dictionary-modal-content.tsx index 44c6c05fb3..03b4032c7f 100644 --- a/services/web/frontend/js/features/dictionary/components/dictionary-modal-content.tsx +++ b/services/web/frontend/js/features/dictionary/components/dictionary-modal-content.tsx @@ -1,4 +1,4 @@ -import { useCallback } from 'react' +import { useCallback, useMemo } from 'react' import { useTranslation } from 'react-i18next' import { Alert, Button, Modal } from 'react-bootstrap' import Icon from '../../../shared/components/icon' @@ -6,11 +6,14 @@ import Tooltip from '../../../shared/components/tooltip' import useAsync from '../../../shared/hooks/use-async' import { postJSON } from '../../../infrastructure/fetch-json' import ignoredWords from '../ignored-words' +import BetaBadge from '../../../shared/components/beta-badge' type DictionaryModalContentProps = { handleHide: () => void } +const wordsSortFunction = (a, b) => a.localeCompare(b) + export default function DictionaryModalContent({ handleHide, }: DictionaryModalContentProps) { @@ -32,10 +35,31 @@ export default function DictionaryModalContent({ [runAsync] ) + const betaBadgeTooltipProps = useMemo(() => { + return { + id: 'dictionary-modal-tooltip', + placement: 'bottom', + className: 'tooltip-wide', + text: ( + <> + We are beta testing the dictionary manager. +
+ Click to give feedback + + ), + } + }, []) + return ( <> - {t('edit_dictionary')} + + {t('edit_dictionary')}{' '} + + @@ -44,26 +68,30 @@ export default function DictionaryModalContent({ ) : null} {ignoredWords.learnedWords?.size > 0 ? ( - ) : ( {t('edit_dictionary_empty')} diff --git a/services/web/frontend/stylesheets/app/editor.less b/services/web/frontend/stylesheets/app/editor.less index 8a715135d3..13741f120b 100644 --- a/services/web/frontend/stylesheets/app/editor.less +++ b/services/web/frontend/stylesheets/app/editor.less @@ -15,6 +15,7 @@ @import './editor/publish-modal.less'; @import './editor/outline.less'; @import './editor/logs.less'; +@import './editor/dictionary.less'; @ui-layout-toggler-def-height: 50px; @ui-resizer-size: 7px; diff --git a/services/web/frontend/stylesheets/app/editor/dictionary.less b/services/web/frontend/stylesheets/app/editor/dictionary.less new file mode 100644 index 0000000000..021eb96105 --- /dev/null +++ b/services/web/frontend/stylesheets/app/editor/dictionary.less @@ -0,0 +1,29 @@ +#dictionary-modal { + .modal-body { + padding: 0; + } +} + +.dictionary-entries-list { + overflow-y: scroll; + max-height: calc(100vh - 225px); + margin: 0; + padding: @padding-sm; +} + +.dictionary-entry { + word-break: break-all; + display: flex; + padding: @padding-sm; + border-bottom: solid 1px @modal-header-border-color; + align-items: center; + + &:last-child { + border-bottom: none; + } +} + +.dictionary-entry-name { + flex-grow: 1; + padding-right: @padding-xs; +} diff --git a/services/web/frontend/stylesheets/app/editor/left-menu.less b/services/web/frontend/stylesheets/app/editor/left-menu.less index 906f1d61de..7a6f607d0b 100644 --- a/services/web/frontend/stylesheets/app/editor/left-menu.less +++ b/services/web/frontend/stylesheets/app/editor/left-menu.less @@ -126,9 +126,3 @@ background-color: #999; z-index: 99; } - -#dictionary-modal { - li { - word-break: break-all; - } -} diff --git a/services/web/test/frontend/features/dictionary/components/dictionary-modal-content.test.js b/services/web/test/frontend/features/dictionary/components/dictionary-modal-content.test.js index 437eadfd09..072357dd83 100644 --- a/services/web/test/frontend/features/dictionary/components/dictionary-modal-content.test.js +++ b/services/web/test/frontend/features/dictionary/components/dictionary-modal-content.test.js @@ -33,7 +33,7 @@ describe('', function () { it('removes words', async function () { fetchMock.post('/spelling/unlearn', 200) - setLearnedWords(['foo', 'bar']) + setLearnedWords(['Foo', 'bar']) renderWithEditorContext( {}} />) screen.getByText('bar') const [firstButton] = screen.getAllByRole('button', { @@ -41,7 +41,7 @@ describe('', function () { }) fireEvent.click(firstButton) expect(screen.queryByText('bar')).to.not.exist - screen.getByText('foo') + screen.getByText('Foo') }) it('handles errors', async function () {