Skip to content

Commit 75d5978

Browse files
authored
update content-dropdown (#7060)
1 parent 12b25a6 commit 75d5978

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/components/content-dropdown/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ type DropdownType = {
1515
const Dropdown = ({
1616
anchorText,
1717
items,
18-
dark = false,
1918
rightClick = false,
2019
pos = "bottom",
2120
}: DropdownType) => {

src/components/content-dropdown/styles.module.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ $border-color: #2d3748;
7272
width: auto;
7373
}
7474
}
75+
[data-theme="dark"]:root .container {
76+
border: 1px solid var(--disabled-font-color);
77+
}
7578

7679
.item {
7780
color: var(--primary-font-color);

src/theme/TOC/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Dropdown from '@site/src/components/content-dropdown';
22
import { Icon } from '@site/src/components/Icon';
33
import TOCItems from '@theme/TOCItems';
44
import clsx from 'clsx';
5-
import React, { ReactNode } from 'react';
5+
import React, { ReactNode, useState } from 'react';
66

77
import type {Props} from '@theme/TOC';
88

@@ -26,11 +26,19 @@ export default function TOC({className, metadata, ...props}: Props & {metadata:
2626
target: '_blank',
2727
rel: 'opener noreferrer'
2828
}
29+
const [text, setText] = useState<string>("Open in")
2930
const markdown = metadata.editUrl.replace("github", "raw.githubusercontent").replace("/blob", "").replace("/tree", "");
31+
const getMDX = () => {
32+
getMarkdown(markdown);
33+
setText("Copied!");
34+
setTimeout(() => {
35+
setText("Open in")
36+
}, 1200)
37+
}
3038
return (
3139
<div className={styles.tableOfContentsWrapper}>
32-
<Dropdown anchorText="Open in" items={[
33-
<div key="cp-markdown" onClick={() => getMarkdown(markdown)}><Icon btn="left" icon="fa-brands fa-markdown" size='16px'/>Copy as Markdown</div>,
40+
<Dropdown anchorText={text} items={[
41+
<div key="cp-markdown" onClick={() => getMDX()}><Icon btn="left" icon="fa-brands fa-markdown" size='16px'/>Copy as Markdown</div>,
3442
<a key="open-claude" href={`https://claude.ai/new?q=Read%20${url}%20so%20I%20can%20ask%20questions%20about%20it.`} {...externalProps}>
3543
<Icon btn="left" customicon={anthropic} size='16px'/>
3644
Open in Claude

0 commit comments

Comments
 (0)