Skip to content

chore: use dumi #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2021
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
5 changes: 1 addition & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ module.exports = {
'react/no-unused-prop-types': 0,
'max-len': 0,
'max-classes-per-file': 0,
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: true, optionalDependencies: false, peerDependencies: false },
],
'import/no-extraneous-dependencies': 0,
'brace-style': 0,
'no-unused-expressions': 0,
'@typescript-eslint/no-unused-expressions': 1,
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ es
coverage
yarn.lock
package-lock.json

# umi
.umi
.umi-production
.umi-test
.env.local
17 changes: 17 additions & 0 deletions .umirc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// more config: https://d.umijs.org/config
import { defineConfig } from 'dumi';

export default defineConfig({
title: 'rc-tabs',
favicon: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
outputPath: '.doc',
exportStatic: {},
styles: [
`
.markdown table {
width: auto !important;
}
`,
],
});
3 changes: 1 addition & 2 deletions HISTORY.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# History
----
# Changelog

https://github.com/react-component/tabs/releases

Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@

React Tabs component.

[![NPM version][npm-image]][npm-url]
[![build status][github-actions-image]][github-actions-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Dependencies][david-image]][david-url]
[![DevDependencies][david-dev-image]][david-dev-url]
[![npm download][download-image]][download-url]
[![bundle size][bundlephobia-image]][bundlephobia-url]
[![NPM version][npm-image]][npm-url] [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Test coverage][coveralls-image]][coveralls-url] [![Dependencies][david-image]][david-url] [![DevDependencies][david-dev-image]][david-dev-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url]

[npm-image]: http://img.shields.io/npm/v/rc-tabs.svg?style=flat-square
[npm-url]: http://npmjs.org/package/rc-tabs
Expand Down Expand Up @@ -53,7 +47,7 @@ online example: https://tabs.react-component.now.sh/

## Usage

```jsx
```js
import Tabs, { TabPane } from 'rc-tabs';

var callback = function(key) {};
Expand Down
3 changes: 3 additions & 0 deletions docs/demo/basic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## basic

<code src="../examples/basic.tsx">
3 changes: 3 additions & 0 deletions docs/demo/extra.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## extra

<code src="../examples/extra.tsx">
3 changes: 3 additions & 0 deletions docs/demo/mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## mix

<code src="../examples/mix.tsx">
3 changes: 3 additions & 0 deletions docs/demo/overflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## overflow

<code src="../examples/overflow.tsx">
3 changes: 3 additions & 0 deletions docs/demo/position.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## position

<code src="../examples/position.tsx">
3 changes: 3 additions & 0 deletions docs/demo/renderTabBar-dragable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## renderTabBar-dragable

<code src="../examples/renderTabBar-dragable.tsx">
3 changes: 3 additions & 0 deletions docs/demo/renderTabBar-sticky.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## renderTabBar-sticky

<code src="../examples/renderTabBar-sticky.tsx">
3 changes: 3 additions & 0 deletions docs/demo/renderTabBar-use-panes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## renderTabBar-use-panes

<code src="../examples/renderTabBar-use-panes.tsx">
4 changes: 2 additions & 2 deletions examples/basic.tsx → docs/examples/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Tabs, { TabPane } from '../src';
import '../assets/index.less';
import Tabs, { TabPane } from 'rc-tabs';
import '../../assets/index.less';

export default () => {
const [destroy, setDestroy] = React.useState(false);
Expand Down
4 changes: 2 additions & 2 deletions examples/extra.tsx → docs/examples/extra.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Tabs, { TabPane } from '../src';
import '../assets/index.less';
import Tabs, { TabPane } from 'rc-tabs';
import '../../assets/index.less';

const tabs: React.ReactElement[] = [];

Expand Down
4 changes: 2 additions & 2 deletions examples/mix.tsx → docs/examples/mix.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Tabs, { TabPane } from '../src';
import '../assets/index.less';
import Tabs, { TabPane } from 'rc-tabs';
import '../../assets/index.less';

function getTabPanes(count = 50) {
const tabs: React.ReactElement[] = [];
Expand Down
4 changes: 2 additions & 2 deletions examples/overflow.tsx → docs/examples/overflow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Tabs, { TabPane } from '../src';
import '../assets/index.less';
import Tabs, { TabPane } from 'rc-tabs';
import '../../assets/index.less';

const tabs: React.ReactElement[] = [];

Expand Down
4 changes: 2 additions & 2 deletions examples/position.tsx → docs/examples/position.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Tabs, { TabPane } from '../src';
import '../assets/index.less';
import Tabs, { TabPane } from 'rc-tabs';
import '../../assets/index.less';

export default () => {
const [position, setPosition] = React.useState<any>('left');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import React from 'react';
import { DndProvider, DragSource, DropTarget } from 'react-dnd';
import HTML5Backend from 'react-dnd-html5-backend';
import Tabs from '../src';
import '../assets/index.less';
import Tabs from 'rc-tabs';
import '../../assets/index.less';

const { TabPane } = Tabs;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { StickyContainer, Sticky } from 'react-sticky';
import Tabs, { TabPane } from '../src';
import '../assets/index.less';
import Tabs, { TabPane } from 'rc-tabs';
import '../../assets/index.less';

const renderTabBar = (props, DefaultTabBar) => (
<Sticky bottomOffset={80}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import Tabs, { TabPane } from '../src';
import '../assets/index.less';
import Tabs, { TabPane } from 'rc-tabs';
import '../../assets/index.less';

const renderTabBar = props => {
return (
<div>
{props.panes.map(pane => {
const key = pane.key;
const { key } = pane;
return <span key={key}>{key}</span>;
})}
</div>
Expand Down
5 changes: 5 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: rc-tabs
---

<embed src="../README.md"></embed>
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
},
"license": "MIT",
"scripts": {
"start": "cross-env NODE_ENV=development father doc dev --storybook",
"build": "father doc build --storybook",
"start": "dumi dev",
"build": "dumi build",
"docs:deploy": "gh-pages -d .doc",
"compile": "father build && npm run compile:style",
"test": "father test",
"coverage": "father test --coverage",
"now-build": "npm run build",
"lint": "eslint src/ examples/ --ext .tsx,.ts,.jsx,.js",
"lint": "eslint src/ docs/examples/ --ext .tsx,.ts,.jsx,.js",
"compile:style": "lessc --js assets/index.less assets/index.css",
"prepublishOnly": "npm run lint && npm run test && npm run compile && np --yolo --no-publish"
},
Expand All @@ -48,12 +49,14 @@
"@umijs/fabric": "^2.3.1",
"coveralls": "^3.0.6",
"cross-env": "^7.0.2",
"dumi": "^1.1.0",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.7.0",
"enzyme-to-json": "^3.3.4",
"eslint": "^7.0.0",
"fastclick": "~1.0.6",
"father": "^2.29.2",
"gh-pages": "^3.1.0",
"history": "^1.17.0",
"immutability-helper": "^3.0.1",
"less": "^3.11.1",
Expand All @@ -68,7 +71,7 @@
"react-sticky": "^6.0.3",
"react-test-renderer": "^16.0.0",
"sortablejs": "^1.7.0",
"typescript": "^4.0.0"
"typescript": "^4.0.5"
},
"dependencies": {
"@babel/runtime": "^7.11.2",
Expand Down
2 changes: 1 addition & 1 deletion src/TabContext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext } from 'react';
import { Tab } from './interface';
import type { Tab } from './interface';

export interface TabContextProps {
tabs: Tab[];
Expand Down
2 changes: 1 addition & 1 deletion src/TabNavList/AddButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { EditableConfig, TabsLocale } from '../interface';
import type { EditableConfig, TabsLocale } from '../interface';

export interface AddButtonProps {
prefixCls: string;
Expand Down
2 changes: 1 addition & 1 deletion src/TabNavList/OperationNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useState, useEffect } from 'react';
import KeyCode from 'rc-util/lib/KeyCode';
import Menu, { MenuItem } from 'rc-menu';
import Dropdown from 'rc-dropdown';
import { Tab, TabsLocale, EditableConfig } from '../interface';
import type { Tab, TabsLocale, EditableConfig } from '../interface';
import AddButton from './AddButton';

export interface OperationNodeProps {
Expand Down
2 changes: 1 addition & 1 deletion src/TabNavList/TabNode.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import classNames from 'classnames';
import KeyCode from 'rc-util/lib/KeyCode';
import { Tab, TabPosition, EditableConfig } from '../interface';
import type { Tab, TabPosition, EditableConfig } from '../interface';

export interface TabNodeProps {
id: string;
Expand Down
2 changes: 1 addition & 1 deletion src/TabNavList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import raf from 'rc-util/lib/raf';
import ResizeObserver from 'rc-resize-observer';
import useRaf, { useRafState } from '../hooks/useRaf';
import TabNode from './TabNode';
import {
import type {
TabSizeMap,
TabPosition,
RenderTabBar,
Expand Down
2 changes: 1 addition & 1 deletion src/TabPanelList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import classNames from 'classnames';
import TabContext from '../TabContext';
import { TabPosition, AnimatedConfig } from '../interface';
import type { TabPosition, AnimatedConfig } from '../interface';

export interface TabPanelListProps {
activeKey: React.Key;
Expand Down
5 changes: 3 additions & 2 deletions src/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import isMobile from 'rc-util/lib/isMobile';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import TabNavList from './TabNavList';
import TabPanelList from './TabPanelList';
import TabPane, { TabPaneProps } from './TabPanelList/TabPane';
import {
import type { TabPaneProps } from './TabPanelList/TabPane';
import TabPane from './TabPanelList/TabPane';
import type {
TabPosition,
RenderTabBar,
TabsLocale,
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useOffsets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMemo } from 'react';
import { TabSizeMap, TabOffsetMap, Tab, TabOffset } from '../interface';
import type { TabSizeMap, TabOffsetMap, Tab, TabOffset } from '../interface';

const DEFAULT_SIZE = { width: 0, height: 0, left: 0, top: 0 };

Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useVisibleRange.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from 'react';
import { Tab, TabOffsetMap } from '../interface';
import { TabNavListProps } from '../TabNavList';
import type { Tab, TabOffsetMap } from '../interface';
import type { TabNavListProps } from '../TabNavList';

const DEFAULT_SIZE = { width: 0, height: 0, left: 0, top: 0, right: 0 };

Expand Down
10 changes: 7 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import Tabs, { TabsProps } from './Tabs';
import TabPane, { TabPaneProps } from './TabPanelList/TabPane';
import Tabs from './Tabs';
import type { TabsProps } from './Tabs';
import TabPane from './TabPanelList/TabPane';
import type { TabPaneProps } from './TabPanelList/TabPane'

export { TabPane, TabsProps, TabPaneProps };
export type { TabsProps, TabPaneProps };

export { TabPane }

export default Tabs;
2 changes: 1 addition & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TabPaneProps } from './TabPanelList/TabPane';
import type { TabPaneProps } from './TabPanelList/TabPane';

export type TabSizeMap = Map<
React.Key,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"target": "esnext",
"moduleResolution": "node",
"baseUrl": "./",
"lib": ["dom", "es2017"],
"jsx": "preserve",
"declaration": true,
"skipLibCheck": true,
Expand Down
3 changes: 3 additions & 0 deletions type.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module '*.css';

declare module '*.less';