From b131361294b3a32d5ac38a27605e1af570f7ce61 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 2 Apr 2023 13:08:28 +0200 Subject: [PATCH 1/2] fix: expose copy, success and word-wrap icons as standalone components --- .../src/theme-classic.d.ts | 24 +++++++++++++++++++ .../src/theme/CodeBlock/CopyButton/index.tsx | 10 ++++---- .../theme/CodeBlock/WordWrapButton/index.tsx | 11 ++------- .../src/theme/Icon/Copy/index.tsx | 20 ++++++++++++++++ .../src/theme/Icon/Success/index.tsx | 20 ++++++++++++++++ .../src/theme/Icon/WordWrap/index.tsx | 20 ++++++++++++++++ 6 files changed, 90 insertions(+), 15 deletions(-) create mode 100644 packages/docusaurus-theme-classic/src/theme/Icon/Copy/index.tsx create mode 100644 packages/docusaurus-theme-classic/src/theme/Icon/Success/index.tsx create mode 100644 packages/docusaurus-theme-classic/src/theme/Icon/WordWrap/index.tsx diff --git a/packages/docusaurus-theme-classic/src/theme-classic.d.ts b/packages/docusaurus-theme-classic/src/theme-classic.d.ts index d3006865e8e7..7984bb35c0bc 100644 --- a/packages/docusaurus-theme-classic/src/theme-classic.d.ts +++ b/packages/docusaurus-theme-classic/src/theme-classic.d.ts @@ -1431,6 +1431,14 @@ declare module '@theme/Icon/Close' { export default function IconClose(props: Props): JSX.Element; } +declare module '@theme/Icon/Copy' { + import type {ComponentProps} from 'react'; + + export interface Props extends ComponentProps<'svg'> {} + + export default function IconCopy(props: Props): JSX.Element; +} + declare module '@theme/Icon/Language' { import type {ComponentProps} from 'react'; @@ -1439,6 +1447,14 @@ declare module '@theme/Icon/Language' { export default function IconLanguage(props: Props): JSX.Element; } +declare module '@theme/Icon/Success' { + import type {ComponentProps} from 'react'; + + export interface Props extends ComponentProps<'svg'> {} + + export default function IconSuccess(props: Props): JSX.Element; +} + declare module '@theme/Icon/ExternalLink' { import type {ComponentProps} from 'react'; @@ -1447,6 +1463,14 @@ declare module '@theme/Icon/ExternalLink' { export default function IconExternalLink(props: Props): JSX.Element; } +declare module '@theme/Icon/WordWrap' { + import type {ComponentProps} from 'react'; + + export interface Props extends ComponentProps<'svg'> {} + + export default function IconWordWrap(props: Props): JSX.Element; +} + declare module '@theme/TagsListByLetter' { import type {TagsListItem} from '@docusaurus/utils'; diff --git a/packages/docusaurus-theme-classic/src/theme/CodeBlock/CopyButton/index.tsx b/packages/docusaurus-theme-classic/src/theme/CodeBlock/CopyButton/index.tsx index 1c05e07a7430..9f5872e6c52f 100644 --- a/packages/docusaurus-theme-classic/src/theme/CodeBlock/CopyButton/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/CodeBlock/CopyButton/index.tsx @@ -11,6 +11,8 @@ import clsx from 'clsx'; import copy from 'copy-text-to-clipboard'; import {translate} from '@docusaurus/Translate'; import type {Props} from '@theme/CodeBlock/CopyButton'; +import IconCopy from '@theme/Icon/Copy'; +import IconSuccess from '@theme/Icon/Success'; import styles from './styles.module.css'; @@ -56,12 +58,8 @@ export default function CopyButton({code, className}: Props): JSX.Element { )} onClick={handleCopyCode}> ); diff --git a/packages/docusaurus-theme-classic/src/theme/CodeBlock/WordWrapButton/index.tsx b/packages/docusaurus-theme-classic/src/theme/CodeBlock/WordWrapButton/index.tsx index 9b08e4432538..0adb3d8d4b01 100644 --- a/packages/docusaurus-theme-classic/src/theme/CodeBlock/WordWrapButton/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/CodeBlock/WordWrapButton/index.tsx @@ -9,6 +9,7 @@ import React from 'react'; import clsx from 'clsx'; import {translate} from '@docusaurus/Translate'; import type {Props} from '@theme/CodeBlock/WordWrapButton'; +import IconWordWrap from '@theme/Icon/WordWrap'; import styles from './styles.module.css'; @@ -35,15 +36,7 @@ export default function WordWrapButton({ )} aria-label={title} title={title}> - +