Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"codesandbox": "^2.2.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-live": "^4.1.0",
"react-router-dom": "^6.0.0",
"react-runner": "^1.0.5"
},
Expand Down
90 changes: 0 additions & 90 deletions apps/docs/src/components/code-block/code-block.scss

This file was deleted.

135 changes: 0 additions & 135 deletions apps/docs/src/components/code-block/index.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion apps/docs/src/components/demo-block/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useCallback, useRef } from 'react';
import { useRunner } from 'react-runner';
import { Highlight, themes } from 'prism-react-renderer';
import { LightCodeTheme, DarkCodeTheme } from '../code-block/code-theme';
import { LightCodeTheme, DarkCodeTheme } from './code-theme';
import * as TinyDesign from '@tiny-design/react';
import * as TinyIcons from '@tiny-design/icons';
import CollapseTransition from '@tiny-design/react/collapse-transition';
Expand Down
56 changes: 56 additions & 0 deletions apps/docs/src/components/highlighted-code/HighlightedCode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Highlight, Prism, PrismTheme } from 'prism-react-renderer';
import { DarkCodeTheme, LightCodeTheme } from '../demo-block/code-theme';
import { useTheme } from '@tiny-design/react';

// Register bash/shell grammar (not included in prism-react-renderer's default bundle)
Prism.languages.bash = Prism.languages.shell = {
comment: { pattern: /(^|[^"{\\$])#.*/, lookbehind: true },
'shell-symbol': { pattern: /^\$(?=\s)/m, alias: 'punctuation' },
string: [
{ pattern: /\$'(?:[^'\\]|\\[\s\S])*'/, greedy: true },
{ pattern: /(^|[^\\])"(?:[^"\\]|\\.)*"/, lookbehind: true, greedy: true },
{ pattern: /(^|[^\\])'[^']*'/, lookbehind: true, greedy: true },
],
variable: [/\$\{[^}]+\}/, /\$\([^)]+\)/, /\$(?:\w+|[!#?*@_])/],
keyword: /\b(?:if|then|else|elif|fi|for|do|done|case|esac|while|until|function|in|select|return|exit)\b/,
function:
/\b(?:npm|npx|node|yarn|pnpm|bun|git|curl|wget|mkdir|cp|mv|rm|ls|cat|grep|sed|awk|chmod|chown|sudo|apt|brew|pip|python|ruby|go|cargo|make|docker|cd|echo|export|source|touch)\b/,
'flag': { pattern: /(^|\s)--?[\w-]+/, lookbehind: true, alias: 'keyword' },
number: /\b\d+\b/,
operator: /&&|\|\||[|;]/,
punctuation: /[{}[\]()]/,
};

export const HighlightedCode = ({ className, children }: { className: string, children: string }) => {
const { resolvedTheme } = useTheme();
const codeTheme = resolvedTheme === 'dark' ? DarkCodeTheme : LightCodeTheme;

let language = 'markup';
if (className != null) {
language = className.replace(/language-/, '');
}

const code = String(children ?? '').trim();

return (
<Highlight code={code} language={language} theme={codeTheme as PrismTheme}>
{({ className: preClassName, style, tokens, getLineProps, getTokenProps }) => (
<pre className={preClassName} style={{ ...style, padding: '10px 12px' }}>
<code>
{tokens.map((line, i) => {
const { key: _lk, ...lineProps } = getLineProps({ line });
return (
<div key={i} {...lineProps}>
{line.map((token, j) => {
const { key: _tk, ...tokenProps } = getTokenProps({ token });
return <span key={j} {...tokenProps} />;
})}
</div>
);
})}
</code>
</pre>
)}
</Highlight>
);
};
1 change: 1 addition & 0 deletions apps/docs/src/components/highlighted-code/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './HighlightedCode';
6 changes: 3 additions & 3 deletions apps/docs/src/components/markdown-tag/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/
import React from 'react';
import './md-tag.scss';
import { CodeBlock } from '../code-block';
import { DemoBlock } from '../demo-block';
import { HighlightedCode } from '../highlighted-code';

const slugifyLink = (name) => {
if (name.includes(' ')) {
Expand Down Expand Up @@ -49,14 +49,14 @@ export const components = {
const { className, children: code } = children.props;
return (
<div className="markdown__pre-container">
<CodeBlock className={className} live>{code}</CodeBlock>
<HighlightedCode className={className}>{code}</HighlightedCode>
</div>
);
}
return <div {...rest} className="markdown__pre-container">{children}</div>;
},
code: ({ className, ...props }) =>
className ? <CodeBlock className={className} {...props} /> : <code {...props} className="markdown__inline-code" />,
className ? <HighlightedCode className={className} {...props} /> : <code {...props} className="markdown__inline-code" />,
// Customised tags (PascalCase for MDX v3 provider resolution)
Layout: (props) => <div {...props} className="markdown__layout" />,
Column: (props) => <div {...props} className="markdown__column" />,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/drawer/demo/Basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function BasicDemo() {
header="Basic Drawer"
placement="right"
onClose={() => setVisible(false)}
open={visible}
visible={visible}
>
<div>Some contents...</div>
<div>Some contents...</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/drawer/demo/MultiLevel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function MultiLevelDemo() {
size={520}
closable={false}
onClose={() => setVisible(false)}
open={visible}
visible={visible}
>
<Button btnType="primary" onClick={() => setChildVisible(true)}>
Two-level drawer
Expand All @@ -25,7 +25,7 @@ export default function MultiLevelDemo() {
size={320}
closable={false}
onClose={() => setChildVisible(false)}
open={childVisible}
visible={childVisible}
>
This is two-level drawer
</Drawer>
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/drawer/demo/Placement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function PlacementDemo() {
header="Basic Drawer"
placement={placement}
onClose={() => setVisible(false)}
open={visible}
visible={visible}
>
<div>Some contents...</div>
<div>Some contents...</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/drawer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ The Drawer can appear from any edge of the screen.
| ----------------- | ----------------------------------------------------- | --------------------------------------------------------- | --------- |
| placement | The placement of the Drawer | enum: `top` &#124; `bottom` &#124; `left` &#124; `right` | `right` |
| size | Drawer dialog width or height | number &#124; string | 256 |
| open | Whether the Drawer dialog is visible or not | boolean | - |
| visible | Whether the Drawer dialog is visible or not | boolean | - |
| header | Drawer header | ReactNode | - |
| footer | Drawer footer | ReactNode | - |
| closable | Display a close button | boolean | `true` |
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/drawer/index.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import { Drawer } from 'tiny-design';
| ----------------- | --------------------------------------------- | --------------------------------------------------------- | --------- |
| placement | 抽屉的弹出位置 | enum: `top` &#124; `bottom` &#124; `left` &#124; `right` | `right` |
| size | 抽屉的宽度或高度 | number &#124; string | 256 |
| open | 抽屉是否可见 | boolean | - |
| visible | 抽屉是否可见 | boolean | - |
| header | 抽屉头部内容 | ReactNode | - |
| footer | 抽屉底部内容 | ReactNode | - |
| closable | 是否显示关闭按钮 | boolean | `true` |
Expand Down
Loading
Loading