forked from DimensionDev/Maskbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b13c2a6
Showing
21 changed files
with
13,417 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
charset = utf-8 | ||
end_of_line = lf | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = space | ||
|
||
[*] | ||
indent_size = 4 | ||
|
||
[{.*rc,ts*.json,package.json}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.test.tsx | ||
package.json | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"trailingComma": "all", | ||
"printWidth": 120, | ||
"semi": false, | ||
"singleQuote": true, | ||
"jsxBracketSameLine": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import '@storybook/addon-knobs/register' | ||
import '@storybook/addon-actions/register' | ||
import '@storybook/addon-links/register' | ||
import '@storybook/addon-options/register' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { configure, addDecorator } from '@storybook/react' | ||
import { withKnobs } from '@storybook/addon-knobs' | ||
import { withInfo } from '@storybook/addon-info' | ||
import { muiTheme } from 'storybook-addon-material-ui' | ||
import { withOptions } from '@storybook/addon-options' | ||
import { themes } from '@storybook/components' | ||
import { MaskbookDarkTheme, MaskbookLightTheme } from '../src/utils/theme' | ||
import { merge } from 'lodash' | ||
|
||
// UI | ||
addDecorator( | ||
withOptions({ | ||
name: 'Maskbook', | ||
addonPanelInRight: true, | ||
// @ts-ignore | ||
theme: { ...themes.dark, mainBackground: 'black' }, | ||
}), | ||
) | ||
addDecorator( | ||
withInfo({ | ||
inline: true, | ||
header: false, | ||
TableComponent, | ||
styles: x => | ||
merge(x, { | ||
infoBody: { background: 'transparent', filter: 'invert(1)', padding: '0', border: 'none' }, | ||
infoStory: { background: '#e8e8e8', padding: '2em' }, | ||
infoContent: { marginTop: 16 }, | ||
jsxInfoContent: { filter: 'invert(1)', marginTop: 16 }, | ||
source: { | ||
h1: { fontWeight: 100 }, | ||
}, | ||
propTableHead: { fontWeight: 100 }, | ||
}), | ||
}), | ||
) | ||
// Addons | ||
addDecorator(withKnobs) | ||
// Theme for MUI | ||
addDecorator(muiTheme([MaskbookLightTheme, MaskbookDarkTheme])) | ||
function loadStories() { | ||
require('../src/stories') | ||
} | ||
|
||
configure(loadStories, module) | ||
|
||
import React from 'react' | ||
import Table from '@material-ui/core/Table' | ||
import TableBody from '@material-ui/core/TableBody' | ||
import TableCell from '@material-ui/core/TableCell' | ||
import TableHead from '@material-ui/core/TableHead' | ||
import TableRow from '@material-ui/core/TableRow' | ||
|
||
function TableComponent({ propDefinitions }) { | ||
const props = propDefinitions.map(({ property, propType, required, description, defaultValue }) => { | ||
return ( | ||
<TableRow key={property}> | ||
<TableCell> | ||
{property} | ||
{required ? null : '?'} | ||
</TableCell> | ||
<TableCell>{propType.name}</TableCell> | ||
<TableCell>{defaultValue}</TableCell> | ||
<TableCell>{description}</TableCell> | ||
</TableRow> | ||
) | ||
}) | ||
|
||
return ( | ||
<Table> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell>名称</TableCell> | ||
<TableCell>类型</TableCell> | ||
<TableCell>默认值</TableCell> | ||
<TableCell>描述</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody>{props}</TableBody> | ||
</Table> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const path = require('path') | ||
module.exports = (baseConfig, env, config) => { | ||
config.module.rules.push({ | ||
test: /\.(ts|tsx)$/, | ||
use: [ | ||
{ | ||
loader: require.resolve('awesome-typescript-loader'), | ||
}, | ||
{ | ||
loader: require.resolve('react-docgen-typescript-loader'), | ||
}, | ||
], | ||
}) | ||
config.resolve.extensions.push('.ts', '.tsx') | ||
return config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Chrome", | ||
"type": "chrome", | ||
"request": "launch", | ||
"url": "http://localhost:3000", | ||
"webRoot": "${workspaceFolder}/src", | ||
"sourceMapPathOverrides": { | ||
"webpack:///src/*": "${webRoot}/*" | ||
} | ||
} | ||
] | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function override(/** @type{import("webpack").Configuration} */ config, env) { | ||
return config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"name": "maskbook", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"@material-ui/core": "^3.9.2", | ||
"@material-ui/icons": "^3.0.2", | ||
"@types/classnames": "^2.2.7", | ||
"@types/jest": "^24.0.6", | ||
"@types/node": "11.9.4", | ||
"@types/react": "16.8.4", | ||
"@types/react-dom": "16.8.2", | ||
"classnames": "^2.2.6", | ||
"node-sass": "^4.11.0", | ||
"react": "^16.8.3", | ||
"react-dom": "^16.8.3", | ||
"react-scripts": "2.1.5", | ||
"storybook-addon-material-ui": "0.9.0-alpha.17", | ||
"tslint": "^5.12.1", | ||
"typescript": "^3.3.3333" | ||
}, | ||
"scripts": { | ||
"watch": "react-app-rewired start", | ||
"build": "react-app-rewired build", | ||
"test": "react-app-rewired test", | ||
"start": "start-storybook -p 9009 -s public", | ||
"build-storybook": "build-storybook -s public" | ||
}, | ||
"eslintConfig": { | ||
"extends": "react-app" | ||
}, | ||
"browserslist": [ | ||
">0.2%", | ||
"not dead", | ||
"not ie <= 11", | ||
"not op_mini all" | ||
], | ||
"devDependencies": { | ||
"@babel/core": "^7.3.3", | ||
"@storybook/addon-actions": "^4.1.13", | ||
"@storybook/addon-info": "^4.1.13", | ||
"@storybook/addon-knobs": "^4.1.13", | ||
"@storybook/addon-links": "^4.1.13", | ||
"@storybook/addon-options": "^4.1.13", | ||
"@storybook/addons": "^4.1.13", | ||
"@storybook/react": "^4.1.13", | ||
"@types/storybook__addon-actions": "^3.4.2", | ||
"@types/storybook__addon-info": "^4.1.0", | ||
"@types/storybook__addon-knobs": "^4.0.1", | ||
"@types/storybook__addon-links": "^3.3.4", | ||
"@types/storybook__addon-options": "^4.0.1", | ||
"@types/storybook__react": "^4.0.1", | ||
"awesome-typescript-loader": "^5.2.1", | ||
"babel-loader": "^8.0.5", | ||
"react-app-rewired": "^2.1.0", | ||
"react-docgen-typescript-loader": "^3.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<!-- | ||
manifest.json provides metadata used when your web app is installed on a | ||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
--> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>React App</title> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React, { Component } from 'react' | ||
|
||
class App extends Component { | ||
render() { | ||
return <div /> | ||
} | ||
} | ||
|
||
export default App |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', | ||
'Droid Sans', 'Helvetica Neue', sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
} | ||
|
||
code { | ||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import './index.css' | ||
import App from './App' | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference types="react-scripts" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from 'react' | ||
|
||
import { storiesOf } from '@storybook/react' | ||
|
||
storiesOf('组件', module).add('Nothing', () => <></>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { blue, purple } from '@material-ui/core/colors' | ||
import withStyles, { | ||
WithStyles, | ||
WithStylesOptions, | ||
StyleRules, | ||
StyleRulesCallback, | ||
} from '@material-ui/core/styles/withStyles' | ||
import React from 'react' | ||
import createMuiTheme from '@material-ui/core/styles/createMuiTheme' | ||
|
||
// 主题 | ||
export const MaskbookLightTheme = createMuiTheme({ | ||
palette: { primary: { main: '#486db6' }, secondary: { main: '#486db6' } }, | ||
typography: { | ||
useNextVariants: true, | ||
}, | ||
}) | ||
export const MaskbookDarkTheme = createMuiTheme({ | ||
palette: { primary: blue, secondary: purple, type: 'dark' }, | ||
typography: { | ||
useNextVariants: true, | ||
}, | ||
}) | ||
|
||
// 类型安全的 withStyles | ||
export function withStylesTyped<ClassKey extends string, Options extends WithStylesOptions<ClassKey> = {}>( | ||
style: StyleRulesCallback<ClassKey> | StyleRules<ClassKey>, | ||
options?: Options, | ||
) { | ||
return function<Props, Ref = null>( | ||
component: Ref extends null | ||
? React.ComponentType<Props & WithStyles<typeof style>> | ||
: React.ForwardRefExoticComponent<Props & WithStyles<typeof style> & React.RefAttributes<Ref>>, | ||
) { | ||
return withStyles(style, options as any)(component as any) as Ref extends null | ||
? React.ComponentType<Props> | ||
: React.ForwardRefExoticComponent<React.RefAttributes<Ref> & Props> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2017", | ||
"lib": ["dom", "dom.iterable", "es2017"], | ||
"allowJs": false, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "preserve", | ||
"experimentalDecorators": true | ||
}, | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"rules": { | ||
"await-promise": true, | ||
"deprecation": true, | ||
"encoding": true, | ||
"increment-decrement": true, | ||
"no-bitwise": true, | ||
"no-construct": true, | ||
"no-duplicate-super": true, | ||
"no-duplicate-variable": true, | ||
"no-eval": true, | ||
"no-for-in-array": true, | ||
"no-invalid-template-strings": true, | ||
"no-parameter-reassignment": true, | ||
"no-return-await": true, | ||
"no-sparse-arrays": true, | ||
"no-string-literal": true, | ||
"no-switch-case-fall-through": true, | ||
"prefer-const": true, | ||
"triple-equals": true, | ||
"typeof-compare": true, | ||
"unnecessary-bind": true, | ||
"use-isnan": true | ||
} | ||
} |
Oops, something went wrong.