From aa6bd2a884ee3b08bb1ca8a4f4fd887d4ea4b061 Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Wed, 8 Mar 2023 20:21:19 +0100 Subject: [PATCH] fix: deduplicate different buttons Signed-off-by: Tilman Vatteroth --- frontend/cypress/e2e/language.spec.ts | 4 +- frontend/locales/de.json | 3 ++ frontend/locales/en.json | 3 ++ .../new-note-button/new-note-button.tsx | 24 ++++++++++ .../editor-page/app-bar/app-bar.tsx | 6 +-- .../editor-page/app-bar/new-note-button.tsx | 25 ---------- .../navigation/header-bar/header-bar.tsx | 26 +++-------- .../navigation/new-guest-note-button.tsx | 34 -------------- .../navigation/new-user-note-button.tsx | 34 -------------- .../social-link-button.module.scss | 27 ----------- .../social-link-button/social-link-button.tsx | 46 ------------------- .../login-page/auth/via-one-click.tsx | 6 +-- 12 files changed, 44 insertions(+), 194 deletions(-) create mode 100644 frontend/src/components/common/new-note-button/new-note-button.tsx delete mode 100644 frontend/src/components/editor-page/app-bar/new-note-button.tsx delete mode 100644 frontend/src/components/landing-layout/navigation/new-guest-note-button.tsx delete mode 100644 frontend/src/components/landing-layout/navigation/new-user-note-button.tsx delete mode 100644 frontend/src/components/login-page/auth/social-link-button/social-link-button.module.scss delete mode 100644 frontend/src/components/login-page/auth/social-link-button/social-link-button.tsx diff --git a/frontend/cypress/e2e/language.spec.ts b/frontend/cypress/e2e/language.spec.ts index 07511175c..c2a47d82a 100644 --- a/frontend/cypress/e2e/language.spec.ts +++ b/frontend/cypress/e2e/language.spec.ts @@ -21,8 +21,8 @@ describe('Languages', () => { it('language changes affect the UI', () => { cy.getByCypressId('language-picker').select('English') - cy.getByCypressId('new-note-button').find('span').contains('New note') + cy.getByCypressId('new-note-button').contains('New Note') cy.getByCypressId('language-picker').select('Deutsch') - cy.getByCypressId('new-note-button').find('span').contains('Neue Notiz') + cy.getByCypressId('new-note-button').contains('Neue Notiz') }) }) diff --git a/frontend/locales/de.json b/frontend/locales/de.json index cc0e0e162..e909fb6fa 100644 --- a/frontend/locales/de.json +++ b/frontend/locales/de.json @@ -3,6 +3,9 @@ "slogan": "Der beste Weg, Notizen zu schreiben und teilen.", "title": "Gemeinschaftliche Markdown Notizen" }, + "navigation": { + "newNote": "Neue Notiz" + }, "landing": { "intro": { "exploreFeatures": "Alle Funktionen", diff --git a/frontend/locales/en.json b/frontend/locales/en.json index 610026c02..f587d4ac3 100644 --- a/frontend/locales/en.json +++ b/frontend/locales/en.json @@ -8,6 +8,9 @@ "title": "Test", "content": "It works!" }, + "navigation": { + "newNote": "New Note" + }, "renderer": { "highlightCode": { "copyCode": "Copy code to clipboard" diff --git a/frontend/src/components/common/new-note-button/new-note-button.tsx b/frontend/src/components/common/new-note-button/new-note-button.tsx new file mode 100644 index 000000000..24f58b7b8 --- /dev/null +++ b/frontend/src/components/common/new-note-button/new-note-button.tsx @@ -0,0 +1,24 @@ +/* + * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) + * + * SPDX-License-Identifier: AGPL-3.0-only + */ +import { cypressId } from '../../../utils/cypress-attribute' +import { IconButton } from '../icon-button/icon-button' +import Link from 'next/link' +import React from 'react' +import { FileEarmarkPlus as IconPlus } from 'react-bootstrap-icons' +import { Trans } from 'react-i18next' + +/** + * Links to the "new note" endpoint + */ +export const NewNoteButton: React.FC = () => { + return ( + + + + + + ) +} diff --git a/frontend/src/components/editor-page/app-bar/app-bar.tsx b/frontend/src/components/editor-page/app-bar/app-bar.tsx index 16c4468ea..8a82673c4 100644 --- a/frontend/src/components/editor-page/app-bar/app-bar.tsx +++ b/frontend/src/components/editor-page/app-bar/app-bar.tsx @@ -5,13 +5,13 @@ */ import { useApplicationState } from '../../../hooks/common/use-application-state' import { NoteType } from '../../../redux/note-details/types/note-details' +import { NewNoteButton } from '../../common/new-note-button/new-note-button' import { ShowIf } from '../../common/show-if/show-if' import { SignInButton } from '../../landing-layout/navigation/sign-in-button' import { UserDropdown } from '../../landing-layout/navigation/user-dropdown' import { SettingsButton } from '../../layout/settings-dialog/settings-button' import { HelpButton } from './help-button/help-button' import { NavbarBranding } from './navbar-branding' -import { NewNoteButton } from './new-note-button' import { ReadOnlyModeButton } from './read-only-mode-button' import { SlideModeButton } from './slide-mode-button' import React from 'react' @@ -49,8 +49,8 @@ export const AppBar: React.FC = ({ mode }) => { -