mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 02:53:31 +01:00
feat: add anchor icon
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { Badge, Group, Stack, Title } from '@mantine/core';
|
import { ActionIcon, Badge, Group, Stack, Title } from '@mantine/core';
|
||||||
|
import { useMediaQuery } from '@mantine/hooks';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
|
import { FiLink } from 'react-icons/fi';
|
||||||
import { HyperlinkedText } from './HyperlinkedText';
|
import { HyperlinkedText } from './HyperlinkedText';
|
||||||
import { InheritanceText } from './InheritanceText';
|
import { InheritanceText } from './InheritanceText';
|
||||||
import { TSDoc } from './tsdoc/TSDoc';
|
import { TSDoc } from './tsdoc/TSDoc';
|
||||||
@@ -35,9 +37,14 @@ export function CodeListing({
|
|||||||
deprecation?: AnyDocNodeJSON | null;
|
deprecation?: AnyDocNodeJSON | null;
|
||||||
inheritanceData?: InheritanceData | null;
|
inheritanceData?: InheritanceData | null;
|
||||||
}) {
|
}) {
|
||||||
|
const matches = useMediaQuery('(max-width: 768px)', true, { getInitialValueInEffect: false });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack id={name} className="scroll-mt-30" spacing="xs">
|
<Stack id={name} className="scroll-mt-30" spacing="xs">
|
||||||
<Group>
|
<Group ml={matches ? 0 : -45}>
|
||||||
|
<ActionIcon component="a" href={`#${name}`} variant="transparent">
|
||||||
|
<FiLink size={20} />
|
||||||
|
</ActionIcon>
|
||||||
{deprecation ? (
|
{deprecation ? (
|
||||||
<Badge variant="filled" color="red">
|
<Badge variant="filled" color="red">
|
||||||
Deprecated
|
Deprecated
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export function DocContainer({
|
|||||||
</Skeleton>
|
</Skeleton>
|
||||||
|
|
||||||
{extendsTokens?.length ? (
|
{extendsTokens?.length ? (
|
||||||
<Group noWrap>
|
<Group pb="xs" noWrap>
|
||||||
<Title order={3} ml="xs">
|
<Title order={3} ml="xs">
|
||||||
Extends
|
Extends
|
||||||
</Title>
|
</Title>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { Badge, Group, Stack, Title } from '@mantine/core';
|
import { ActionIcon, Badge, Group, Stack, Title } from '@mantine/core';
|
||||||
|
import { useMediaQuery } from '@mantine/hooks';
|
||||||
|
import { FiLink } from 'react-icons/fi';
|
||||||
import { HyperlinkedText } from './HyperlinkedText';
|
import { HyperlinkedText } from './HyperlinkedText';
|
||||||
import { InheritanceText } from './InheritanceText';
|
import { InheritanceText } from './InheritanceText';
|
||||||
import { ParameterTable } from './ParameterTable';
|
import { ParameterTable } from './ParameterTable';
|
||||||
@@ -17,17 +19,18 @@ function getShorthandName(data: ApiMethodJSON | ApiMethodSignatureJSON) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function MethodItem({ data }: { data: ApiMethodJSON | ApiMethodSignatureJSON }) {
|
export function MethodItem({ data }: { data: ApiMethodJSON | ApiMethodSignatureJSON }) {
|
||||||
|
const matches = useMediaQuery('(max-width: 768px)', true, { getInitialValueInEffect: false });
|
||||||
const method = data as ApiMethodJSON;
|
const method = data as ApiMethodJSON;
|
||||||
|
const key = `${data.name}${data.overloadIndex && data.overloadIndex > 1 ? `:${data.overloadIndex}` : ''}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack id={key} className="scroll-mt-30" spacing="xs">
|
||||||
id={`${data.name}${data.overloadIndex && data.overloadIndex > 1 ? `:${data.overloadIndex}` : ''}`}
|
|
||||||
className="scroll-mt-30"
|
|
||||||
spacing="xs"
|
|
||||||
>
|
|
||||||
<Group>
|
<Group>
|
||||||
<Stack>
|
<Stack>
|
||||||
<Group>
|
<Group ml={matches ? 0 : -45}>
|
||||||
|
<ActionIcon component="a" href={`#${key}`} variant="transparent">
|
||||||
|
<FiLink size={20} />
|
||||||
|
</ActionIcon>
|
||||||
{data.deprecated ? (
|
{data.deprecated ? (
|
||||||
<Badge variant="filled" color="red">
|
<Badge variant="filled" color="red">
|
||||||
Deprecated
|
Deprecated
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function MethodList({ data }: { data: (ApiMethodJSON | ApiMethodSignature
|
|||||||
key={`${method.name}${method.overloadIndex && method.overloadIndex > 1 ? `:${method.overloadIndex}` : ''}`}
|
key={`${method.name}${method.overloadIndex && method.overloadIndex > 1 ? `:${method.overloadIndex}` : ''}`}
|
||||||
>
|
>
|
||||||
<MethodItem data={method} />
|
<MethodItem data={method} />
|
||||||
<Divider className="bg-gray-100" size="md" />
|
<Divider size="md" />
|
||||||
</Fragment>
|
</Fragment>
|
||||||
))}
|
))}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export function ConstructorSection({ data }: { data: ApiConstructorJSON }) {
|
|||||||
|
|
||||||
return data.parameters.length ? (
|
return data.parameters.length ? (
|
||||||
<Section title="Constructor" icon={<VscSymbolMethod size={20} />} padded dense={matches}>
|
<Section title="Constructor" icon={<VscSymbolMethod size={20} />} padded dense={matches}>
|
||||||
<Stack id={`${data.name}`} className="scroll-mt-30" spacing="xs">
|
<Stack id={data.name} className="scroll-mt-30" spacing="xs">
|
||||||
<Group>
|
<Group>
|
||||||
<Stack>
|
<Stack>
|
||||||
<Group>
|
<Group>
|
||||||
|
|||||||
@@ -78,13 +78,15 @@ const useStyles = createStyles((theme) => ({
|
|||||||
color: theme.colorScheme === 'dark' ? theme.colors.dark![0] : theme.colors.gray![7],
|
color: theme.colorScheme === 'dark' ? theme.colors.dark![0] : theme.colors.gray![7],
|
||||||
borderLeft: `1px solid ${theme.colorScheme === 'dark' ? theme.colors.dark![4] : theme.colors.gray![3]}`,
|
borderLeft: `1px solid ${theme.colorScheme === 'dark' ? theme.colors.dark![4] : theme.colors.gray![3]}`,
|
||||||
|
|
||||||
|
'&[data-active]': {
|
||||||
|
'&:hover': {
|
||||||
|
color: theme.white,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
'&:hover': {
|
'&:hover': {
|
||||||
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark![6] : theme.colors.gray![0],
|
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark![6] : theme.colors.gray![0],
|
||||||
color: theme.colorScheme === 'dark' ? theme.white : theme.black,
|
color: theme.colorScheme === 'dark' ? theme.white : theme.black,
|
||||||
|
|
||||||
'&[data-active]': {
|
|
||||||
color: theme.white,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export function TableOfContentItems({
|
|||||||
const key = `${member.name}${member.overloadIndex && member.overloadIndex > 1 ? `:${member.overloadIndex}` : ''}`;
|
const key = `${member.name}${member.overloadIndex && member.overloadIndex > 1 ? `:${member.overloadIndex}` : ''}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box<'a'> key={key} href={`#${key}`} component="a" className={classes.link}>
|
<Box<'a'> key={key} component="a" href={`#${key}`} className={classes.link}>
|
||||||
<Group>
|
<Group>
|
||||||
<Text sx={{ textOverflow: 'ellipsis', overflow: 'hidden' }} className="line-clamp-1">
|
<Text sx={{ textOverflow: 'ellipsis', overflow: 'hidden' }} className="line-clamp-1">
|
||||||
{member.name}
|
{member.name}
|
||||||
|
|||||||
Reference in New Issue
Block a user