From 4184c2aac0645e18808d8d34cf9dd1dcc4ec1326 Mon Sep 17 00:00:00 2001 From: Bartosz Kaszubowski Date: Tue, 1 Dec 2020 14:28:31 +0100 Subject: [PATCH 1/3] fix(v2): refactor icons in theme-classic, fix swizzle issue --- .../docusaurus-theme-classic/src/index.ts | 3 ++ .../src/theme/BlogPostPage/index.tsx | 16 +------- .../src/theme/DocItem/index.tsx | 16 +------- .../src/theme/DocPage/index.tsx | 6 ++- .../src/theme/DocPage/styles.module.css | 7 ---- .../src/theme/DocSidebar/index.tsx | 24 ++++-------- .../src/theme/DocSidebar/styles.module.css | 5 ++- .../src/theme/IconArrow/index.tsx | 22 +++++++++++ .../src/theme/IconEdit/index.tsx | 32 +++++++++++++++ .../src/theme/IconMenu/index.tsx | 39 +++++++++++++++++++ .../src/theme/Navbar/index.tsx | 18 +-------- .../src/theme/icons/arrow.svg | 1 - .../docusaurus-theme-classic/src/types.d.ts | 27 +++++++++++++ 13 files changed, 144 insertions(+), 72 deletions(-) create mode 100644 packages/docusaurus-theme-classic/src/theme/IconArrow/index.tsx create mode 100644 packages/docusaurus-theme-classic/src/theme/IconEdit/index.tsx create mode 100644 packages/docusaurus-theme-classic/src/theme/IconMenu/index.tsx delete mode 100644 packages/docusaurus-theme-classic/src/theme/icons/arrow.svg diff --git a/packages/docusaurus-theme-classic/src/index.ts b/packages/docusaurus-theme-classic/src/index.ts index ad7510a65559..fcbd564972a9 100644 --- a/packages/docusaurus-theme-classic/src/index.ts +++ b/packages/docusaurus-theme-classic/src/index.ts @@ -147,6 +147,9 @@ const swizzleAllowedComponents = [ 'Footer', 'NotFound', 'SearchBar', + 'IconArrow', + 'IconEdit', + 'IconMenu', 'hooks/useTheme', 'prism-include-languages', ]; diff --git a/packages/docusaurus-theme-classic/src/theme/BlogPostPage/index.tsx b/packages/docusaurus-theme-classic/src/theme/BlogPostPage/index.tsx index 3fc557a82515..688334f5a044 100644 --- a/packages/docusaurus-theme-classic/src/theme/BlogPostPage/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/BlogPostPage/index.tsx @@ -13,6 +13,7 @@ import BlogPostPaginator from '@theme/BlogPostPaginator'; import type {Props} from '@theme/BlogPostPage'; import BlogSidebar from '@theme/BlogSidebar'; import TOC from '@theme/TOC'; +import IconEdit from '@theme/IconEdit'; function BlogPostPage(props: Props): JSX.Element { const {content: BlogPostContents, sidebar} = props; @@ -41,20 +42,7 @@ function BlogPostPage(props: Props): JSX.Element {
{editUrl && ( - - - - - + Edit this page )} diff --git a/packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx index 7df82eb00c72..080b8d4b5639 100644 --- a/packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx @@ -15,6 +15,7 @@ import DocPaginator from '@theme/DocPaginator'; import DocVersionSuggestions from '@theme/DocVersionSuggestions'; import type {Props} from '@theme/DocItem'; import TOC from '@theme/TOC'; +import IconEdit from '@theme/IconEdit'; import clsx from 'clsx'; import styles from './styles.module.css'; @@ -111,20 +112,7 @@ function DocItem(props: Props): JSX.Element { href={editUrl} target="_blank" rel="noreferrer noopener"> - - - - - + Edit this page )} diff --git a/packages/docusaurus-theme-classic/src/theme/DocPage/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocPage/index.tsx index 187cbee809d3..5ab7bcd93d0e 100644 --- a/packages/docusaurus-theme-classic/src/theme/DocPage/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/DocPage/index.tsx @@ -17,6 +17,7 @@ import MDXComponents from '@theme/MDXComponents'; import NotFound from '@theme/NotFound'; import type {DocumentRoute} from '@theme/DocItem'; import type {Props} from '@theme/DocPage'; +import IconArrow from '@theme/IconArrow'; import {matchPath} from '@docusaurus/router'; import clsx from 'clsx'; @@ -97,8 +98,9 @@ function DocPageContent({ tabIndex={0} role="button" onKeyDown={toggleSidebar} - onClick={toggleSidebar} - /> + onClick={toggleSidebar}> + +
)} )} diff --git a/packages/docusaurus-theme-classic/src/theme/DocPage/styles.module.css b/packages/docusaurus-theme-classic/src/theme/DocPage/styles.module.css index 109738880870..a5a6755212df 100644 --- a/packages/docusaurus-theme-classic/src/theme/DocPage/styles.module.css +++ b/packages/docusaurus-theme-classic/src/theme/DocPage/styles.module.css @@ -49,13 +49,6 @@ background-color: var(--collapse-button-bg-color-dark); } - .collapsedDocSidebar:before { - content: ''; - background-image: url('~!file-loader!../icons/arrow.svg'); - width: 20px; - height: 20px; - } - .docMainContainer { flex-grow: 1; } diff --git a/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.tsx index fa7a51b8301e..f2f0f5a783d8 100644 --- a/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.tsx @@ -16,6 +16,8 @@ import Link from '@docusaurus/Link'; import isInternalUrl from '@docusaurus/isInternalUrl'; import type {Props} from '@theme/DocSidebar'; import Logo from '@theme/Logo'; +import IconArrow from '@theme/IconArrow'; +import IconMenu from '@theme/IconMenu'; import styles from './styles.module.css'; @@ -243,24 +245,11 @@ function DocSidebar({ × ) : ( - - Menu - - + /> )}