scoobie 14.1.4 → 14.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -5
- package/package.json +1 -3
- package/src/components/InternalLink.tsx +4 -21
package/README.md
CHANGED
|
@@ -345,8 +345,7 @@ export const MyFirstInlineCode = () => (
|
|
|
345
345
|
|
|
346
346
|
Render an internal link with the same opinions as our [MdxProvider](#mdxprovider):
|
|
347
347
|
|
|
348
|
-
- Internal links
|
|
349
|
-
and pass through the `v` URL parameter for UI version switching
|
|
348
|
+
- Internal links pass through the `v` URL parameter for UI version switching
|
|
350
349
|
|
|
351
350
|
Unlike [SmartTextLink](#smarttextlink), this is not bound to a parent [Text] as it has no underlying [TextLink].
|
|
352
351
|
It can be used to make complex components navigable rather than just sections of text.
|
|
@@ -399,8 +398,7 @@ export const Component = () => (
|
|
|
399
398
|
|
|
400
399
|
Render all underlying links as follows:
|
|
401
400
|
|
|
402
|
-
- Internal links
|
|
403
|
-
and pass through the `v` URL parameter for UI version switching
|
|
401
|
+
- Internal links pass through the `v` URL parameter for UI version switching
|
|
404
402
|
- External links open in a new tab
|
|
405
403
|
- Links with a [`download` attribute] prompt the user with a file download
|
|
406
404
|
|
|
@@ -429,7 +427,6 @@ Render a text link with the same opinions as our [MdxProvider](#mdxprovider):
|
|
|
429
427
|
|
|
430
428
|
- External links open in a new tab and have an [IconNewWindow] suffix
|
|
431
429
|
|
|
432
|
-
[react-router-hash-link]: https://github.com/rafrex/react-router-hash-link
|
|
433
430
|
[iconnewwindow]: https://seek-oss.github.io/braid-design-system/components/IconNewWindow
|
|
434
431
|
|
|
435
432
|
```tsx
|
package/package.json
CHANGED
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"version": "14.1.
|
|
7
|
+
"version": "14.1.5",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@capsizecss/core": "^3.0.0",
|
|
10
10
|
"@mdx-js/loader": "^1.6.22",
|
|
11
11
|
"@mdx-js/react": "^1.6.22",
|
|
12
12
|
"@types/mdx-js__react": "^1.5.5",
|
|
13
|
-
"@types/react-router-hash-link": "^2.4.1",
|
|
14
13
|
"@vanilla-extract/css": "^1.2.3",
|
|
15
14
|
"@vanilla-extract/css-utils": "^0.1.1",
|
|
16
15
|
"babel-loader": "^9.0.0",
|
|
@@ -21,7 +20,6 @@
|
|
|
21
20
|
"polished": "^4.1.3",
|
|
22
21
|
"prism-react-renderer": "1.3.5",
|
|
23
22
|
"react-keyed-flatten-children": "^1.3.0",
|
|
24
|
-
"react-router-hash-link": "^2.4.3",
|
|
25
23
|
"refractor": "^3.4.0",
|
|
26
24
|
"remark-slug": "^6.1.0",
|
|
27
25
|
"svgo": "^3.0.0",
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import clsx, { ClassValue } from 'clsx';
|
|
2
2
|
import React, { ComponentProps, forwardRef } from 'react';
|
|
3
|
-
import { useLocation } from 'react-router-dom';
|
|
4
|
-
import { NavHashLink } from 'react-router-hash-link';
|
|
3
|
+
import { NavLink, useLocation } from 'react-router-dom';
|
|
5
4
|
|
|
6
5
|
import { parseInternalHref } from '../private/url';
|
|
7
6
|
|
|
8
7
|
import * as styles from './InternalLink.css';
|
|
9
8
|
|
|
10
9
|
interface Props
|
|
11
|
-
extends Omit<
|
|
12
|
-
ComponentProps<typeof NavHashLink>,
|
|
13
|
-
'className' | 'scroll' | 'smooth' | 'to'
|
|
14
|
-
> {
|
|
10
|
+
extends Omit<ComponentProps<typeof NavLink>, 'className' | 'to'> {
|
|
15
11
|
className?: ClassValue | ((isActive: boolean) => ClassValue);
|
|
16
12
|
href: string;
|
|
17
13
|
reset?: boolean;
|
|
@@ -20,28 +16,17 @@ interface Props
|
|
|
20
16
|
|
|
21
17
|
export const InternalLink = forwardRef<HTMLAnchorElement, Props>(
|
|
22
18
|
({ className, href, reset = true, state, ...restProps }, ref) => {
|
|
23
|
-
const scroll = (element: Element) =>
|
|
24
|
-
setTimeout(() => {
|
|
25
|
-
// Scroll to the header's `Stack` element so we don't cut off the heading
|
|
26
|
-
(element.parentElement ?? element).scrollIntoView({
|
|
27
|
-
behavior: 'smooth',
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
19
|
const location = useLocation();
|
|
32
20
|
|
|
33
21
|
const to = { ...parseInternalHref(href, location), state };
|
|
34
22
|
|
|
35
23
|
return (
|
|
36
|
-
<
|
|
24
|
+
<NavLink
|
|
37
25
|
{...restProps}
|
|
38
26
|
className={(prop) => {
|
|
39
27
|
// The boolean prop was introduced in React Router v5.3 as a bridge to
|
|
40
28
|
// v6, then v6 decided to break the function signature anyway 🙃.
|
|
41
|
-
const isActive =
|
|
42
|
-
typeof prop === 'boolean'
|
|
43
|
-
? prop
|
|
44
|
-
: (prop as { isActive: boolean }).isActive;
|
|
29
|
+
const isActive = typeof prop === 'boolean' ? prop : prop.isActive;
|
|
45
30
|
|
|
46
31
|
return clsx(
|
|
47
32
|
reset ? styles.reset : null,
|
|
@@ -49,8 +34,6 @@ export const InternalLink = forwardRef<HTMLAnchorElement, Props>(
|
|
|
49
34
|
);
|
|
50
35
|
}}
|
|
51
36
|
ref={ref}
|
|
52
|
-
scroll={scroll}
|
|
53
|
-
smooth
|
|
54
37
|
to={to}
|
|
55
38
|
/>
|
|
56
39
|
);
|