Skip to content

Commit

Permalink
feat: add basic
Browse files Browse the repository at this point in the history
  • Loading branch information
Jandiasnow committed May 31, 2024
1 parent 66e2494 commit 9c3e931
Show file tree
Hide file tree
Showing 45 changed files with 1,425 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig } from 'dumi';
import { readdirSync } from 'fs';
import { join } from 'path';

const PUBLIC_PATH = '/';
const PUBLIC_PATH = '/frontend/';
const isProduction = process.env.NODE_ENV === 'production';

const headPkgList: string[] = [];
Expand All @@ -12,6 +12,7 @@ const pkgDirList = readdirSync(join(__dirname, 'packages')).filter(
const pkgs = {
'antv-ava': 'antv-ava',
'annotate-text': 'annotate-text',
'basic': 'basic',
};
export const alias = pkgDirList.reduce((pre, name) => {
pre[`@jandia/${pkgs[name]}`] = join(__dirname, 'packages', name, 'src');
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-ghpages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GH_TOKEN }}
publish_dir: ./dist/FrontEnd
publish_dir: ./dist/frontend
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ $ pnpm run build
| ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- | --------------------------- |
| [@jandiasnow/antv-ava][antv-ava-url] | [packages/antv-ava][antv-ava-github] | [![][antv-ava-shield]][antv-ava-url] | ![][antv-ava-download] |
| [@jandiasnow/annotate-text][annotate-text-url] | [packages/annotate-text][annotate-text-github] | [![][annotate-text-shield]][annotate-text-url] | ![][annotate-text-download] |
| [@jandiasnow/basic][basic-url] | [packages/basic][basic-github] | [![][basic-shield]][basic-url] | ![][basic-download] |

## LICENSE

Expand All @@ -34,3 +35,7 @@ MIT
[antv-ava-github]: https://github.com/jandiasnow/frontend/tree/master/packages/antv-ava/README.md
[antv-ava-shield]: https://img.shields.io/npm/v/@jandiasnow/antv-ava?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
[antv-ava-url]: https://www.npmjs.com/package/@jandiasnow/antv-ava
[basic-download]: https://img.shields.io/npm/dt/@jandiasnow/basic?labelColor=black&style=flat-square
[basic-github]: https://github.com/jandiasnow/frontend/tree/master/packages/basic/README.md
[basic-shield]: https://img.shields.io/npm/v/@jandiasnow/basic?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
[basic-url]: https://www.npmjs.com/package/@jandiasnow/basic
12 changes: 8 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ hero:
- text: Github
link: https://github.com/Jandiasnow/FrontEnd
features:
- title: basic
emoji: 🧩
link: /packages/basic
description: Basic warehouse of frontend
- title: AVA
emoji: 💎
emoji: 🚀
link: /packages/antv-ava
description: Intelligent visualization
description: antv-ava demos
- title: annotate-text
emoji: 💎
emoji: 📜
link: /packages/annotate-text
description: Intelligent visualization
description: annotate-text warehouse comparison and use examples
---
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dev": "dumi dev",
"dev:annotate-text": "concurrently \"pnpm --filter 'annotate-text' dev\" \"npm run dev\"",
"dev:antv-ava": "concurrently \"pnpm --filter 'antv-ava' dev\" \"npm run dev\"",
"dev:basic": "concurrently \"pnpm --filter 'basic' dev\" \"npm run dev\"",
"docs:build": "dumi build",
"lint": "npm run lint:es && npm run lint:style && npm run lint:md",
"lint-fix": "npm run lint-fix:es && npm run lint-fix:style",
Expand Down
4 changes: 2 additions & 2 deletions packages/annotate-text/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @jadiasnow/annotate-text
# @jandiasnow/annotate-text

🌐 [@jadiasnow/annotate-text](https://www.npmjs.com/package/@jandiasnow/annotate-text) is an demo examples for
📜 [@jandiasnow/annotate-text](https://www.npmjs.com/package/@jandiasnow/annotate-text) is an demo examples for
[react-text-annotate-blend](https://github.com/smhaley/react-text-annotate-blend),
[react-nlp-annotate](https://github.com/UniversalDataTool/react-nlp-annotate),
[@recogito/react-text-annotator](https://github.com/recogito/text-annotator-js/blob/main/packages/text-annotator-react/package.json),
Expand Down
8 changes: 4 additions & 4 deletions packages/annotate-text/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ order: 0

<h1>Annotate Text </h1>

🌐 [@jadiasnow/annotate-text](https://www.npmjs.com/package/@jandiasnow/annotate-text) is an demo examples for
📜 [@jandiasnow/annotate-text](https://www.npmjs.com/package/@jandiasnow/annotate-text) is an demo examples for
[react-text-annotate-blend](https://github.com/smhaley/react-text-annotate-blend),
[react-nlp-annotate](https://github.com/UniversalDataTool/react-nlp-annotate),
[@recogito/react-text-annotator](https://github.com/recogito/text-annotator-js/blob/main/packages/text-annotator-react/package.json),
Expand All @@ -18,13 +18,13 @@ order: 0

</div>

### website
## 🔗 website

<https://github.com/HumanSignal/awesome-data-labeling#text>

<https://github.com/FransHeuvelmans/Textcodify?tab=readme-ov-file>

## Warehouse comparison
## 🆚 Warehouse comparison

| name | website repo | advantage | defect | used |
| ------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
Expand All @@ -34,7 +34,7 @@ order: 0
| [@recogito/recogito-js](https://github.com/recogito/recogito-js) | - | 1. 最近一年有更新 <br> 2. 支持 html 类型标记 <br> 3. 支持标签关系标记 | 1. 没有 react 版本 <br> 2. 样式不好调整,点击事件不好添加 | 页面功能复杂可考虑 |
| [annotato](https://github.com/YusufCelik/annotato) | - | 1. react 版本,代码简单,二次开发比较容易 <br> 2. 支持点击事件、样式自定义<br> 3. 支持 html<br> 4. 使用简单 | 1. 最近更新 3 年前 <br> 2. 不支持 html 类型 <br> 3. 不支持标签关系标记 | 页面功能简单可使用 |

## 🌐 Usage
## 📝 Usage

### react-text-annotate-blend

Expand Down
4 changes: 2 additions & 2 deletions packages/antv-ava/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @jadiasnow/antv-ava
# @jandiasnow/antv-ava

🌐 [@jadiasnow/antv-ava](https://www.npmjs.com/package/@jandiasnow/ava) is an demo examples for [@antv/ava](https://ava.antv.antgroup.com/guide/intro).
🚀 [@jandiasnow/antv-ava](https://www.npmjs.com/package/@jandiasnow/ava) is an demo examples for [@antv/ava](https://ava.antv.antgroup.com/guide/intro).

## Development

Expand Down
12 changes: 2 additions & 10 deletions packages/antv-ava/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,11 @@ order: 0

<h1>Antv Ava </h1>

🌐 [@jadiasnow/antv-ava](https://www.npmjs.com/package/@jandiasnow/ava) is an demo examples for [@antv/ava](https://ava.antv.antgroup.com/guide/intro).
🚀 [@jandiasnow/antv-ava](https://www.npmjs.com/package/@jandiasnow/ava) is an demo examples for [@antv/ava](https://ava.antv.antgroup.com/guide/intro).

</div>

## 📦 Installation

To install @, run the following command:

```bash

```

## 🌐 Usage
## 📝 Usage

### 图表知识库(ckb)

Expand Down
23 changes: 23 additions & 0 deletions packages/basic/.fatherrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { defineConfig } from 'father';

const library = 'JandiasnowBasic';

const externals = {};

export default defineConfig({
extends: '../../.fatherrc.base.ts',
cjs: {
input: 'src', // 默认编译目录
platform: 'node', // 默认构建为 Node.js 环境的产物
transformer: 'esbuild', // 默认使用 esbuild 以获得更快的构建速度
},
umd: {
entry: {
'src/index.ts': {
name: library,
sourcemap: true,
externals,
},
},
},
});
3 changes: 3 additions & 0 deletions packages/basic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
.dumi
20 changes: 20 additions & 0 deletions packages/basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# @jandiasnow/basic

🧩 [@jandiasnow/basic](https://www.npmjs.com/package/@jandiasnow/basic) is an warehouse of frontend basic

## Development

```bash
# install dependencies
$ pnpm install

# start dev server
$ pnpm start

# build docs
$ pnpm run build
```

## LICENSE

MIT
25 changes: 25 additions & 0 deletions packages/basic/docs/react/Profiler.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Tabs } from 'antd';
import React, { Profiler, useState } from 'react';

export default () => {
const [tab, setTab] = useState('key1');
return (
<Profiler
id="tabs"
onRender={(...params) => {
console.warn('<Profiler>:', params);
}}
>
<Tabs
activeKey={tab}
items={[
{ key: 'key1', label: 'label1', children: 'children1' },
{ key: 'key2', label: 'label2', children: 'children2' },
]}
onChange={v => {
setTab(v);
}}
/>
</Profiler>
);
};
35 changes: 35 additions & 0 deletions packages/basic/docs/react/StrictMode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Space } from 'antd';
import React, { StrictMode, useState } from 'react';

let initialStories = [
{ id: 0, label: "Ankit's Story" },
{ id: 1, label: "Taylor's Story" },
];

export default function App() {
let [stories] = useState(initialStories);
const [isHover, setIsHover] = useState(false);
const items = stories as any;
items.push({ id: 'create', label: 'Create Story' });

return (
<StrictMode>
<Space
onPointerEnter={() => setIsHover(true)}
onPointerLeave={() => setIsHover(false)}
style={{
backgroundColor: isHover ? '#ddd' : '#fff',
}}
>
{items.map(story => (
<li
key={story.id}
style={{ border: '1px solid #ddd', borderRadius: '4px', padding: '24px' }}
>
{story.label}
</li>
))}
</Space>
</StrictMode>
);
}
13 changes: 13 additions & 0 deletions packages/basic/docs/react/Suspense.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Space, Spin } from 'antd';
import React, { Suspense } from 'react';

export default () => {
return (
<Suspense fallback={<Spin spinning={true}>loading</Spin>}>
<Space>
wrapper
<Suspense fallback={<Spin spinning={true}>loading1</Spin>}>info</Suspense>
</Space>
</Suspense>
);
};
31 changes: 31 additions & 0 deletions packages/basic/docs/react/createPortal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Button, Space, Typography } from 'antd';
import React, { useId, useState } from 'react';
import { createPortal } from 'react-dom';

const ModalContent = ({ onClose }) => {
return (
<Space style={{ border: '1px solid #ccc', padding: '24px', borderRadius: '4px' }}>
<Typography.Text>modal content</Typography.Text>
<Button onClick={() => onClose()}>close</Button>
</Space>
);
};

export default () => {
const [showModal, setShowModal] = useState(false);
const domId = useId();

return (
<Space>
<Button onClick={() => setShowModal(true)}>Show modal using a portal</Button>

<div id={domId}></div>

{showModal &&
createPortal(
<ModalContent onClose={() => setShowModal(false)} />,
document.querySelector("[id=':r3:']") as any
)}
</Space>
);
};
21 changes: 21 additions & 0 deletions packages/basic/docs/react/flushSync.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Button, Input, Space } from 'antd';
import React, { useState } from 'react';
import { flushSync } from 'react-dom';

export default () => {
const [text, setText] = useState('init');

const handleChange = () => {
flushSync(() => {
setText('change');
});
};

return (
<Space>
{text}
<Button onClick={handleChange}>Change</Button>
<Input onChange={e => setText(e.target.value)} value={text} />
</Space>
);
};
28 changes: 28 additions & 0 deletions packages/basic/docs/react/lazy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Checkbox, Space, Spin } from 'antd';
import { Suspense, lazy, useState } from 'react';

const delayForDemo = promise => {
return new Promise(resolve => {
setTimeout(resolve, 2000);
}).then(() => promise);
};

const LazyComponent = lazy(() => delayForDemo(import('./lazyComponent.tsx')));

export default () => {
const [showPreview, setShowPreview] = useState(false);

return (
<Space>
<Checkbox onChange={e => setShowPreview(e.target.checked)} value={showPreview}>
Show preview
</Checkbox>
{showPreview && (
<Suspense fallback={<Spin spinning={true} />}>
Preview:
<LazyComponent />
</Suspense>
)}
</Space>
);
};
3 changes: 3 additions & 0 deletions packages/basic/docs/react/lazyComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default () => {
return 'lazyComponent';
};
23 changes: 23 additions & 0 deletions packages/basic/docs/react/memo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Input, Space } from 'antd';
import { memo, useState } from 'react';

const MemoComponent = memo(({ name }) => {
console.warn('Greeting was rendered at', new Date().toLocaleTimeString());
return (
<Space>
{new Date().toLocaleTimeString()}: {name || '-'}
</Space>
);
});

export default function MyApp() {
const [name, setName] = useState('');
const [address, setAddress] = useState('');
return (
<Space>
<Input onChange={e => setName(e.target.value)} placeholder="Name" value={name} />
<Input onChange={e => setAddress(e.target.value)} placeholder="Address" value={address} />
<MemoComponent name={name} />
</Space>
);
}
Loading

0 comments on commit 9c3e931

Please sign in to comment.