diff --git a/packages/docusaurus-theme-classic/codeTranslations/ar.json b/packages/docusaurus-theme-classic/codeTranslations/ar.json index 1dad274abd46..32030b7c9e0c 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/ar.json +++ b/packages/docusaurus-theme-classic/codeTranslations/ar.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "إغلاق", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "تم النسخ", "theme.CodeBlock.copy": "نسخ", "theme.CodeBlock.copyButtonAriaLabel": "نسخ الرمز إلى الحافظة", diff --git a/packages/docusaurus-theme-classic/codeTranslations/base.json b/packages/docusaurus-theme-classic/codeTranslations/base.json index 8cceead805ce..0a088fd3e8b1 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/base.json +++ b/packages/docusaurus-theme-classic/codeTranslations/base.json @@ -1,6 +1,7 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "Close", "theme.AnnouncementBar.closeButtonAriaLabel___DESCRIPTION": "The ARIA label for close button of announcement bar", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "Copied", "theme.CodeBlock.copied___DESCRIPTION": "The copied button label on code blocks", "theme.CodeBlock.copy": "Copy", @@ -96,7 +97,7 @@ "theme.docs.versions.latestVersionLinkLabel": "latest version", "theme.docs.versions.latestVersionLinkLabel___DESCRIPTION": "The label used for the latest version suggestion link label", "theme.docs.versions.latestVersionSuggestionLabel": "For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).", - "theme.docs.versions.latestVersionSuggestionLabel___DESCRIPTION": "The label used to tell the user to check the latest version", + "theme.docs.versions.latestVersionSuggestionLabel___DESCRIPTION": "The label userd to tell the user that he's browsing an unmaintained doc version", "theme.docs.versions.unmaintainedVersionLabel": "This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.", "theme.docs.versions.unmaintainedVersionLabel___DESCRIPTION": "The label used to tell the user that he's browsing an unmaintained doc version", "theme.docs.versions.unreleasedVersionLabel": "This is unreleased documentation for {siteTitle} {versionLabel} version.", diff --git a/packages/docusaurus-theme-classic/codeTranslations/bn.json b/packages/docusaurus-theme-classic/codeTranslations/bn.json index 814ac74598d0..e09538899978 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/bn.json +++ b/packages/docusaurus-theme-classic/codeTranslations/bn.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "বন্ধ করুন", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "কপিড", "theme.CodeBlock.copy": "কপি", "theme.CodeBlock.copyButtonAriaLabel": "ক্লিপবোর্ডে কোড কপি করুন", diff --git a/packages/docusaurus-theme-classic/codeTranslations/cs.json b/packages/docusaurus-theme-classic/codeTranslations/cs.json index 5bdafce490ae..5778e9acaa28 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/cs.json +++ b/packages/docusaurus-theme-classic/codeTranslations/cs.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "Zavřít", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "Zkopírováno", "theme.CodeBlock.copy": "Zkopírovat", "theme.CodeBlock.copyButtonAriaLabel": "Zkopírovat kód do schránky", diff --git a/packages/docusaurus-theme-classic/codeTranslations/da.json b/packages/docusaurus-theme-classic/codeTranslations/da.json index eb4a015e82dd..305c871b8006 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/da.json +++ b/packages/docusaurus-theme-classic/codeTranslations/da.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "Luk", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "Kopieret", "theme.CodeBlock.copy": "Kopier", "theme.CodeBlock.copyButtonAriaLabel": "Kopier kode til udklipsholder", diff --git a/packages/docusaurus-theme-classic/codeTranslations/de.json b/packages/docusaurus-theme-classic/codeTranslations/de.json index f3ed0f57d536..219ba427859d 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/de.json +++ b/packages/docusaurus-theme-classic/codeTranslations/de.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "Schließen", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "Kopiert", "theme.CodeBlock.copy": "Kopieren", "theme.CodeBlock.copyButtonAriaLabel": "In die Zwischenablage kopieren", diff --git a/packages/docusaurus-theme-classic/codeTranslations/es.json b/packages/docusaurus-theme-classic/codeTranslations/es.json index c561eb1da76b..cf2692a7942c 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/es.json +++ b/packages/docusaurus-theme-classic/codeTranslations/es.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "Cerrar", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "Copiado", "theme.CodeBlock.copy": "Copiar", "theme.CodeBlock.copyButtonAriaLabel": "Copiar código al portapaples", diff --git a/packages/docusaurus-theme-classic/codeTranslations/fa.json b/packages/docusaurus-theme-classic/codeTranslations/fa.json index b90b9923a9be..9b0ba63c7279 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/fa.json +++ b/packages/docusaurus-theme-classic/codeTranslations/fa.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "بستن", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "کپی شد", "theme.CodeBlock.copy": "کپی", "theme.CodeBlock.copyButtonAriaLabel": "کپی به کلیپ بورد", diff --git a/packages/docusaurus-theme-classic/codeTranslations/fil.json b/packages/docusaurus-theme-classic/codeTranslations/fil.json index 5153a059dfbe..b533a0438617 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/fil.json +++ b/packages/docusaurus-theme-classic/codeTranslations/fil.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "Isara", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "Kinopya", "theme.CodeBlock.copy": "Kopyahin", "theme.CodeBlock.copyButtonAriaLabel": "Kopyahin ang code sa clipboard", diff --git a/packages/docusaurus-theme-classic/codeTranslations/fr.json b/packages/docusaurus-theme-classic/codeTranslations/fr.json index 2c8e256c5f5d..811c9c429c13 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/fr.json +++ b/packages/docusaurus-theme-classic/codeTranslations/fr.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "Fermer", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "Copié", "theme.CodeBlock.copy": "Copier", "theme.CodeBlock.copyButtonAriaLabel": "Copier le code", diff --git a/packages/docusaurus-theme-classic/codeTranslations/he.json b/packages/docusaurus-theme-classic/codeTranslations/he.json index 1d5bf59a93ca..bc11e01546a5 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/he.json +++ b/packages/docusaurus-theme-classic/codeTranslations/he.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "סגור", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "הועתק", "theme.CodeBlock.copy": "העתק", "theme.CodeBlock.copyButtonAriaLabel": "העתק קוד ללוח העריכה", diff --git a/packages/docusaurus-theme-classic/codeTranslations/hi.json b/packages/docusaurus-theme-classic/codeTranslations/hi.json index 831d16e23b6f..12d9fa649335 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/hi.json +++ b/packages/docusaurus-theme-classic/codeTranslations/hi.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "बंद करे", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "कॉपीड", "theme.CodeBlock.copy": "कॉपी", "theme.CodeBlock.copyButtonAriaLabel": "क्लिपबोर्ड पर कोड कॉपी करें", diff --git a/packages/docusaurus-theme-classic/codeTranslations/ja.json b/packages/docusaurus-theme-classic/codeTranslations/ja.json index 333544f6f185..7857fa7db283 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/ja.json +++ b/packages/docusaurus-theme-classic/codeTranslations/ja.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "閉じる", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "コピーしました", "theme.CodeBlock.copy": "コピー", "theme.CodeBlock.copyButtonAriaLabel": "クリップボードにコードをコピー", diff --git a/packages/docusaurus-theme-classic/codeTranslations/ko.json b/packages/docusaurus-theme-classic/codeTranslations/ko.json index ad15e3613841..74e5c8fed624 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/ko.json +++ b/packages/docusaurus-theme-classic/codeTranslations/ko.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "닫기", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "복사했습니다", "theme.CodeBlock.copy": "복사", "theme.CodeBlock.copyButtonAriaLabel": "클립보드에 코드 복사", diff --git a/packages/docusaurus-theme-classic/codeTranslations/pl.json b/packages/docusaurus-theme-classic/codeTranslations/pl.json index 87a110a670d2..31cf68e1096b 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/pl.json +++ b/packages/docusaurus-theme-classic/codeTranslations/pl.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "Zamknij", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "Skopiowano!", "theme.CodeBlock.copy": "Kopiuj", "theme.CodeBlock.copyButtonAriaLabel": "Kopiuj do schowka", diff --git a/packages/docusaurus-theme-classic/codeTranslations/pt-BR.json b/packages/docusaurus-theme-classic/codeTranslations/pt-BR.json index 673ce1ca444b..5138cfe64d28 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/pt-BR.json +++ b/packages/docusaurus-theme-classic/codeTranslations/pt-BR.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "Fechar", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "Copiado", "theme.CodeBlock.copy": "Copiar", "theme.CodeBlock.copyButtonAriaLabel": "Copiar código para a área de transferência", diff --git a/packages/docusaurus-theme-classic/codeTranslations/pt-PT.json b/packages/docusaurus-theme-classic/codeTranslations/pt-PT.json index 2fda703b7f2c..9950e8db02de 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/pt-PT.json +++ b/packages/docusaurus-theme-classic/codeTranslations/pt-PT.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "Fechar", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "Copiado", "theme.CodeBlock.copy": "Copiar", "theme.CodeBlock.copyButtonAriaLabel": "Copiar código para a área de transferência", diff --git a/packages/docusaurus-theme-classic/codeTranslations/ru.json b/packages/docusaurus-theme-classic/codeTranslations/ru.json index e64e0f9b7054..7c6a32d604d9 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/ru.json +++ b/packages/docusaurus-theme-classic/codeTranslations/ru.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "Закрыть", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "Скопировано", "theme.CodeBlock.copy": "Скопировать", "theme.CodeBlock.copyButtonAriaLabel": "Скопировать в буфер обмена", diff --git a/packages/docusaurus-theme-classic/codeTranslations/tr.json b/packages/docusaurus-theme-classic/codeTranslations/tr.json index a5df4adcfa0b..f3189d2fc085 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/tr.json +++ b/packages/docusaurus-theme-classic/codeTranslations/tr.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "Kapat", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "Kopyalandı", "theme.CodeBlock.copy": "Kopyala", "theme.CodeBlock.copyButtonAriaLabel": "Kodu panoya kopyala", diff --git a/packages/docusaurus-theme-classic/codeTranslations/vi.json b/packages/docusaurus-theme-classic/codeTranslations/vi.json index 473c9288f457..9fca85ffe051 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/vi.json +++ b/packages/docusaurus-theme-classic/codeTranslations/vi.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "Đóng", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "Đã sao chép", "theme.CodeBlock.copy": "Sao chép", "theme.CodeBlock.copyButtonAriaLabel": "Sao chép code vào bộ nhớ tạm", diff --git a/packages/docusaurus-theme-classic/codeTranslations/zh-Hans.json b/packages/docusaurus-theme-classic/codeTranslations/zh-Hans.json index 93f95629aec9..98d437177e75 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/zh-Hans.json +++ b/packages/docusaurus-theme-classic/codeTranslations/zh-Hans.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "关闭", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "复制成功", "theme.CodeBlock.copy": "复制", "theme.CodeBlock.copyButtonAriaLabel": "复制代码到剪贴板", diff --git a/packages/docusaurus-theme-classic/codeTranslations/zh-Hant.json b/packages/docusaurus-theme-classic/codeTranslations/zh-Hant.json index 029be6844406..80bcbf4f73ea 100644 --- a/packages/docusaurus-theme-classic/codeTranslations/zh-Hant.json +++ b/packages/docusaurus-theme-classic/codeTranslations/zh-Hant.json @@ -1,5 +1,6 @@ { "theme.AnnouncementBar.closeButtonAriaLabel": "關閉", + "theme.BackToTopButton.buttonAriaLabel": "Scroll back to top", "theme.CodeBlock.copied": "複製成功", "theme.CodeBlock.copy": "複製", "theme.CodeBlock.copyButtonAriaLabel": "複製代碼至剪貼簿", diff --git a/packages/docusaurus-theme-classic/src/theme/BackToTopButton/index.tsx b/packages/docusaurus-theme-classic/src/theme/BackToTopButton/index.tsx index 890f0c59d6d7..a495f884b36e 100644 --- a/packages/docusaurus-theme-classic/src/theme/BackToTopButton/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/BackToTopButton/index.tsx @@ -8,9 +8,11 @@ import React, {useRef, useState} from 'react'; import clsx from 'clsx'; import {useLocation} from '@docusaurus/router'; +import {translate} from '@docusaurus/Translate'; import useScrollPosition from '@theme/hooks/useScrollPosition'; import styles from './styles.module.css'; +import {ThemeClassNames} from '@docusaurus/theme-common'; const threshold = 300; @@ -106,18 +108,22 @@ function BackToTopButton(): JSX.Element { return ( + onClick={() => smoothScrollTop()} + /> ); } diff --git a/packages/docusaurus-theme-classic/src/theme/BackToTopButton/styles.module.css b/packages/docusaurus-theme-classic/src/theme/BackToTopButton/styles.module.css index fea310f664e3..9cb0866a25e2 100644 --- a/packages/docusaurus-theme-classic/src/theme/BackToTopButton/styles.module.css +++ b/packages/docusaurus-theme-classic/src/theme/BackToTopButton/styles.module.css @@ -5,32 +5,35 @@ * LICENSE file in the root directory of this source tree. */ -:root { - --docusaurus-btt-background: var(--ifm-color-primary); - --docusaurus-btt-color: #fff; -} - .backToTopButton { - display: flex; - align-items: center; - justify-content: center; position: fixed; right: 1.3rem; bottom: 1.3rem; border-radius: 50%; - background: var(--docusaurus-btt-background); - color: var(--docusaurus-btt-color); + background-color: var(--ifm-color-emphasis-200); width: 3rem; height: 3rem; z-index: var(--ifm-z-index-fixed); - box-shadow: 0 0.125rem 0.3125rem 0 rgba(0, 0, 0, 0.3); - transition: all var(--ifm-transition-fast) ease-in-out; + box-shadow: var(--ifm-global-shadow-lw); + transition: all var(--ifm-transition-fast) + var(--ifm-transition-timing-default); opacity: 0; transform: scale(0); } -.backToTopButton:not(:focus):hover { - opacity: 0.8; +.backToTopButton:after { + content: ' '; + display: inline-block; + mask: var(--ifm-menu-link-sublist-icon) 50% / 2rem 2rem no-repeat; + background-color: var(--ifm-color-emphasis-1000); + width: 100%; + height: 100%; +} + +@media (hover: hover) { + .backToTopButton:hover { + background-color: var(--ifm-color-emphasis-300); + } } .backToTopButtonShow { diff --git a/packages/docusaurus-theme-common/src/utils/ThemeClassNames.ts b/packages/docusaurus-theme-common/src/utils/ThemeClassNames.ts index b33c24937220..7481eba871a6 100644 --- a/packages/docusaurus-theme-common/src/utils/ThemeClassNames.ts +++ b/packages/docusaurus-theme-common/src/utils/ThemeClassNames.ts @@ -33,6 +33,7 @@ export const ThemeClassNames = { common: { editThisPage: 'theme-edit-this-page', lastUpdated: 'theme-last-updated', + backToTopButton: 'theme-back-to-top-button', }, layout: { // TODO add other stable classNames here