@umijs/plugin-docs 4.0.0-canary.20220615.1 → 4.0.0-canary.20220624.1

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.
@@ -1,5 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { useThemeContext } from './context';
3
+ import ExternalLink from './icons/link.svg';
3
4
  import useLanguage from './useLanguage';
4
5
 
5
6
  export default () => {
@@ -17,6 +18,7 @@ interface NavItemProps {
17
18
  nav: {
18
19
  path: string;
19
20
  title: string;
21
+ type?: 'nav' | 'link';
20
22
  dropdown?: {
21
23
  title: string;
22
24
  path: string;
@@ -29,19 +31,35 @@ function NavItem(props: NavItemProps) {
29
31
  const { nav } = props;
30
32
  const lang = useLanguage();
31
33
  const [isExpanded, setExpanded] = useState(false);
34
+
35
+ const isExternalLink = (n: NavItemProps['nav']) => {
36
+ return (
37
+ n.type === 'link' && /(https|http):\/\/([\w.]+\/?)\S*/.test(nav.path)
38
+ );
39
+ };
40
+
32
41
  return (
33
42
  <li
34
43
  className="ml-8 dark:text-white relative"
35
44
  onMouseEnter={() => nav.dropdown && setExpanded(true)}
36
45
  onMouseLeave={() => nav.dropdown && setExpanded(false)}
37
46
  >
38
- <components.Link
39
- to={
40
- lang.isFromPath ? lang.currentLanguage?.locale + nav.path : nav.path
41
- }
42
- >
43
- {lang.render(nav.title)}
44
- </components.Link>
47
+ {isExternalLink(nav) ? (
48
+ <a href={nav.path} target="_blank">
49
+ <span className="flex">
50
+ {nav.title}
51
+ <img src={ExternalLink} alt="ExternalLink" />
52
+ </span>
53
+ </a>
54
+ ) : (
55
+ <components.Link
56
+ to={
57
+ lang.isFromPath ? lang.currentLanguage?.locale + nav.path : nav.path
58
+ }
59
+ >
60
+ {lang.render(nav.title)}
61
+ </components.Link>
62
+ )}
45
63
  {nav.dropdown && (
46
64
  <div
47
65
  style={{ maxHeight: isExpanded ? nav.dropdown.length * 48 : 0 }}
@@ -49,19 +67,37 @@ function NavItem(props: NavItemProps) {
49
67
  cursor-pointer shadow overflow-hidden top-8"
50
68
  >
51
69
  {nav.dropdown.map((n) => (
52
- <components.Link
53
- key={n.path}
54
- to={
55
- lang.isFromPath ? lang.currentLanguage?.locale + n.path : n.path
56
- }
57
- >
58
- <p
59
- className="p-2 bg-white dark:bg-gray-700 dark:text-white
70
+ <>
71
+ {isExternalLink(n) ? (
72
+ <a href={n.path} target="_blank">
73
+ <span className="flex">
74
+ <span
75
+ className="p-2 bg-white dark:bg-gray-700 dark:text-white
76
+ hover:bg-gray-50 transition duration-300"
77
+ >
78
+ {nav.title}
79
+ </span>
80
+ <img src={ExternalLink} alt="ExternalLink" />
81
+ </span>
82
+ </a>
83
+ ) : (
84
+ <components.Link
85
+ key={n.path}
86
+ to={
87
+ lang.isFromPath
88
+ ? lang.currentLanguage?.locale + n.path
89
+ : n.path
90
+ }
91
+ >
92
+ <p
93
+ className="p-2 bg-white dark:bg-gray-700 dark:text-white
60
94
  hover:bg-gray-50 transition duration-300"
61
- >
62
- {n.title}
63
- </p>
64
- </components.Link>
95
+ >
96
+ {n.title}
97
+ </p>
98
+ </components.Link>
99
+ )}
100
+ </>
65
101
  ))}
66
102
  </div>
67
103
  )}
@@ -22,6 +22,7 @@ interface IContext {
22
22
  navs: {
23
23
  path: string;
24
24
  title: string;
25
+ type: 'nav' | 'link';
25
26
  dropdown?: { title: string; path: string }[];
26
27
  children: any[];
27
28
  }[];
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="__dumi-default-external-link-icon"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg>
@@ -209,7 +209,7 @@ html {
209
209
  :root {
210
210
  --anchor-offset: 28px;
211
211
 
212
- color-scheme: var(--color-scheme, light dark);
212
+ color-scheme: var(--color-scheme, light);
213
213
  }
214
214
 
215
215
  /** Anchor with offset for headings */
@@ -1,5 +1,5 @@
1
1
  /*
2
- ! tailwindcss v3.0.24 | MIT License | https://tailwindcss.com
2
+ ! tailwindcss v3.1.3 | MIT License | https://tailwindcss.com
3
3
  */
4
4
 
5
5
  /*
@@ -187,6 +187,8 @@ textarea {
187
187
  /* 1 */
188
188
  font-size: 100%;
189
189
  /* 1 */
190
+ font-weight: inherit;
191
+ /* 1 */
190
192
  line-height: inherit;
191
193
  /* 1 */
192
194
  color: inherit;
@@ -415,15 +417,103 @@ video {
415
417
  height: auto;
416
418
  }
417
419
 
418
- /*
419
- Ensure the default browser behavior of the `hidden` attribute.
420
- */
420
+ *, ::before, ::after {
421
+ --tw-border-spacing-x: 0;
422
+ --tw-border-spacing-y: 0;
423
+ --tw-translate-x: 0;
424
+ --tw-translate-y: 0;
425
+ --tw-rotate: 0;
426
+ --tw-skew-x: 0;
427
+ --tw-skew-y: 0;
428
+ --tw-scale-x: 1;
429
+ --tw-scale-y: 1;
430
+ --tw-pan-x: ;
431
+ --tw-pan-y: ;
432
+ --tw-pinch-zoom: ;
433
+ --tw-scroll-snap-strictness: proximity;
434
+ --tw-ordinal: ;
435
+ --tw-slashed-zero: ;
436
+ --tw-numeric-figure: ;
437
+ --tw-numeric-spacing: ;
438
+ --tw-numeric-fraction: ;
439
+ --tw-ring-inset: ;
440
+ --tw-ring-offset-width: 0px;
441
+ --tw-ring-offset-color: #fff;
442
+ --tw-ring-color: rgb(59 130 246 / 0.5);
443
+ --tw-ring-offset-shadow: 0 0 #0000;
444
+ --tw-ring-shadow: 0 0 #0000;
445
+ --tw-shadow: 0 0 #0000;
446
+ --tw-shadow-colored: 0 0 #0000;
447
+ --tw-blur: ;
448
+ --tw-brightness: ;
449
+ --tw-contrast: ;
450
+ --tw-grayscale: ;
451
+ --tw-hue-rotate: ;
452
+ --tw-invert: ;
453
+ --tw-saturate: ;
454
+ --tw-sepia: ;
455
+ --tw-drop-shadow: ;
456
+ --tw-backdrop-blur: ;
457
+ --tw-backdrop-brightness: ;
458
+ --tw-backdrop-contrast: ;
459
+ --tw-backdrop-grayscale: ;
460
+ --tw-backdrop-hue-rotate: ;
461
+ --tw-backdrop-invert: ;
462
+ --tw-backdrop-opacity: ;
463
+ --tw-backdrop-saturate: ;
464
+ --tw-backdrop-sepia: ;
465
+ }
421
466
 
422
- [hidden] {
423
- display: none;
467
+ ::-webkit-backdrop {
468
+ --tw-border-spacing-x: 0;
469
+ --tw-border-spacing-y: 0;
470
+ --tw-translate-x: 0;
471
+ --tw-translate-y: 0;
472
+ --tw-rotate: 0;
473
+ --tw-skew-x: 0;
474
+ --tw-skew-y: 0;
475
+ --tw-scale-x: 1;
476
+ --tw-scale-y: 1;
477
+ --tw-pan-x: ;
478
+ --tw-pan-y: ;
479
+ --tw-pinch-zoom: ;
480
+ --tw-scroll-snap-strictness: proximity;
481
+ --tw-ordinal: ;
482
+ --tw-slashed-zero: ;
483
+ --tw-numeric-figure: ;
484
+ --tw-numeric-spacing: ;
485
+ --tw-numeric-fraction: ;
486
+ --tw-ring-inset: ;
487
+ --tw-ring-offset-width: 0px;
488
+ --tw-ring-offset-color: #fff;
489
+ --tw-ring-color: rgb(59 130 246 / 0.5);
490
+ --tw-ring-offset-shadow: 0 0 #0000;
491
+ --tw-ring-shadow: 0 0 #0000;
492
+ --tw-shadow: 0 0 #0000;
493
+ --tw-shadow-colored: 0 0 #0000;
494
+ --tw-blur: ;
495
+ --tw-brightness: ;
496
+ --tw-contrast: ;
497
+ --tw-grayscale: ;
498
+ --tw-hue-rotate: ;
499
+ --tw-invert: ;
500
+ --tw-saturate: ;
501
+ --tw-sepia: ;
502
+ --tw-drop-shadow: ;
503
+ --tw-backdrop-blur: ;
504
+ --tw-backdrop-brightness: ;
505
+ --tw-backdrop-contrast: ;
506
+ --tw-backdrop-grayscale: ;
507
+ --tw-backdrop-hue-rotate: ;
508
+ --tw-backdrop-invert: ;
509
+ --tw-backdrop-opacity: ;
510
+ --tw-backdrop-saturate: ;
511
+ --tw-backdrop-sepia: ;
424
512
  }
425
513
 
426
- *, ::before, ::after {
514
+ ::backdrop {
515
+ --tw-border-spacing-x: 0;
516
+ --tw-border-spacing-y: 0;
427
517
  --tw-translate-x: 0;
428
518
  --tw-translate-y: 0;
429
519
  --tw-rotate: 0;
@@ -2035,7 +2125,7 @@ html {
2035
2125
 
2036
2126
  :root {
2037
2127
  --anchor-offset: 28px;
2038
- color-scheme: var(--color-scheme, light dark);
2128
+ color-scheme: var(--color-scheme, light);
2039
2129
  }
2040
2130
 
2041
2131
  /** Anchor with offset for headings */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugin-docs",
3
- "version": "4.0.0-canary.20220615.1",
3
+ "version": "4.0.0-canary.20220624.1",
4
4
  "description": "@umijs/plugin-docs",
5
5
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/plugin-docs#readme",
6
6
  "bugs": "https://github.com/umijs/umi-next/issues",
@@ -21,7 +21,7 @@
21
21
  "build:css": "tailwindcss -i ./client/theme-doc/tailwind.css -o ./client/theme-doc/tailwind.out.css",
22
22
  "build:deps": "umi-scripts bundleDeps",
23
23
  "build:extra": "pnpm build:css",
24
- "dev": "pnpm build -- --watch",
24
+ "dev": "pnpm build --watch",
25
25
  "dev:css": "pnpm build:css -- --watch",
26
26
  "test": "umi-scripts jest-turbo"
27
27
  },
@@ -39,7 +39,7 @@
39
39
  "rehype-slug": "5.0.1",
40
40
  "remark-gfm": "^3.0.1",
41
41
  "tailwindcss": "^3.0.24",
42
- "umi": "4.0.0-canary.20220615.1"
42
+ "umi": "4.0.0-canary.20220624.1"
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public"