Skip to content

Commit 0275493

Browse files
committed
chore: bump typescript's version to latest
1 parent 6a63cc7 commit 0275493

File tree

12 files changed

+181
-368
lines changed

12 files changed

+181
-368
lines changed
+32-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
1+
@import "~@shikijs/twoslash/style-rich.css";
2+
13
.source-code {
24
&-container {
35
position: relative;
4-
}
5-
6-
&-content {
76
max-height: 400px;
8-
padding: 24px 20px;
97
overflow: auto;
108
}
11-
9+
&-content {
10+
padding: 12px 24px;
11+
> pre {
12+
overflow: visible;
13+
}
14+
}
1215
&-shadow {
1316
box-shadow: inset 0 6px 6px -6px #00000029;
1417
width: 100%;
1518
height: 3px;
16-
position: absolute;
19+
position: sticky;
1720
top: 0;
21+
opacity: 0;
22+
transition: opacity 0.3s;
23+
&__active {
24+
opacity: 1;
25+
}
26+
}
27+
}
28+
29+
// override style-rich.css
30+
.twoslash {
31+
.twoslash-hover {
32+
position: static;
33+
}
34+
.twoslash-popup-docs {
35+
max-height: 200px;
36+
overflow: auto;
37+
}
38+
.twoslash-popup-container {
39+
max-width: 50vw;
40+
transform: translateY(-100%);
41+
}
42+
.twoslash-popup-code {
43+
white-space: break-spaces;
1844
}
1945
}

.dumi/theme/builtins/sourceCode/index.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import React from 'react';
2-
import { useScrollWithShadow } from '../../hooks';
32
import classNames from 'classnames';
3+
4+
import { useScrollWithShadow } from '../../hooks';
45
import './index.less';
56

67
export default function SourceCode({ jsx }: { jsx: string }) {
78
const [ref, shadow] = useScrollWithShadow();
9+
console.log('shadow:', shadow.top);
810

911
return (
10-
<div className="source-code-container">
11-
{shadow.top && <div className="source-code-shadow" />}
12+
<div className="source-code-container" ref={ref}>
13+
<div
14+
className={classNames(
15+
'source-code-shadow',
16+
shadow.top && 'source-code-shadow__active'
17+
)}
18+
/>
1219
<div
13-
ref={ref}
1420
className={classNames('source-code-content')}
1521
dangerouslySetInnerHTML={{ __html: jsx }}
1622
/>

.dumi/theme/plugin.ts

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
import { IApi } from 'dumi';
22
import ReactTechStack from 'dumi/dist/techStacks/react';
33
import type { ExampleBlockAsset } from 'dumi-assets-types';
4+
import ts from 'typescript';
45

56
class DTReactTech extends ReactTechStack {
67
async generateMetadata(asset: ExampleBlockAsset) {
78
// workaround for esm module
8-
// const { transformerTwoslash } = await import('@shikijs/twoslash');
9+
const { transformerTwoslash } = await import('@shikijs/twoslash');
910
const { codeToHtml } = await import('shiki');
1011
for (const [filename, dep] of Object.entries(asset.dependencies)) {
11-
if (dep.type === 'FILE') {
12+
if (dep.type === 'FILE' && asset.id === 'blockheader-demo-basic') {
1213
const html = await codeToHtml(dep.value, {
13-
lang: 'ts',
14+
lang: 'tsx',
1415
theme: 'vitesse-light',
15-
// transformers: [transformerTwoslash()],
16+
transformers: [
17+
transformerTwoslash({
18+
twoslashOptions: {
19+
compilerOptions: {
20+
jsx: ts.JsxEmit.React,
21+
},
22+
handbookOptions: {
23+
noErrors: true,
24+
},
25+
},
26+
}),
27+
],
1628
});
1729

1830
asset.dependencies[filename] = <any>{ ...dep, jsx: html };

.dumi/theme/slots/PreviewerActions/index.less

-226
This file was deleted.

.dumi/theme/slots/PreviewerActions/index.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1+
import React, { type FC, type ReactNode, useRef, useState } from 'react';
12
import { ReactComponent as IconCheck } from '@ant-design/icons-svg/inline-svg/outlined/check.svg';
23
import { ReactComponent as IconCodeSandbox } from '@ant-design/icons-svg/inline-svg/outlined/code-sandbox.svg';
34
import { ReactComponent as IconSketch } from '@ant-design/icons-svg/inline-svg/outlined/sketch.svg';
45
import { ReactComponent as IconStackBlitz } from '@ant-design/icons-svg/inline-svg/outlined/thunderbolt.svg';
56
import {
67
getSketchJSON,
8+
type IPreviewerProps,
79
openCodeSandbox,
810
openStackBlitz,
911
useIntl,
10-
type IPreviewerProps,
1112
} from 'dumi';
12-
import SourceCode from '../../builtins/sourceCode';
1313
import PreviewerActionsExtra from 'dumi/theme-default/slots/PreviewerActionsExtra';
1414
import Tabs from 'rc-tabs';
15-
import React, { useRef, useState, type FC, type ReactNode } from 'react';
1615
import useClippy from 'use-clippy';
17-
import './index.less';
16+
17+
import SourceCode from '../../builtins/sourceCode';
18+
import 'dumi/theme-default/slots/PreviewerActions/index.less';
1819
export interface IPreviewerActionsProps extends IPreviewerProps {
1920
/**
2021
* disabled actions
@@ -55,7 +56,6 @@ const PreviewerActions: FC<IPreviewerActionsProps> = (props) => {
5556
const copyTimer = useRef<number>();
5657
const [isCopied, setIsCopied] = useState(false);
5758
const isSingleFile = files.length === 1;
58-
const lang = (files[activeKey][0].match(/\.([^.]+)$/)?.[1] || 'text') as any;
5959

6060
console.log('files[activeKey][1]:', files[activeKey][1]);
6161

.dumirc.ts

-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ export default defineConfig({
2323
},
2424
],
2525
],
26-
clickToComponent: {},
2726
});

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11

22
.dumi/tmp
3+
.dumi/tmp-production

.prettierignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/dist
22
*.yaml
3-
.dumi/tmp
3+
.dumi/tmp
4+
.dumi/tmp-production

.stylelintignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.dumi/tmp
1+
.dumi/tmp
2+
.dumi/tmp-production

0 commit comments

Comments
 (0)