Skip to content

Commit

Permalink
Empty Project
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Feb 27, 2019
0 parents commit b13c2a6
Show file tree
Hide file tree
Showing 21 changed files with 13,417 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
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
23 changes: 23 additions & 0 deletions .gitignore
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*
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.test.tsx
package.json
package-lock.json
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "all",
"printWidth": 120,
"semi": false,
"singleQuote": true,
"jsxBracketSameLine": true
}
4 changes: 4 additions & 0 deletions .storybook/addons.js
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'
82 changes: 82 additions & 0 deletions .storybook/config.js
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>
)
}
16 changes: 16 additions & 0 deletions .storybook/webpack.config.js
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
}
15 changes: 15 additions & 0 deletions .vscode/launch.json
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 added README.md
Empty file.
3 changes: 3 additions & 0 deletions config-overrides.js
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
}
58 changes: 58 additions & 0 deletions package.json
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"
}
}
37 changes: 37 additions & 0 deletions public/index.html
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>
9 changes: 9 additions & 0 deletions src/App.tsx
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
12 changes: 12 additions & 0 deletions src/index.css
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;
}
6 changes: 6 additions & 0 deletions src/index.tsx
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'))
1 change: 1 addition & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
5 changes: 5 additions & 0 deletions src/stories/index.tsx
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', () => <></>)
39 changes: 39 additions & 0 deletions src/utils/theme.ts
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>
}
}
20 changes: 20 additions & 0 deletions tsconfig.json
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"]
}
25 changes: 25 additions & 0 deletions tslint.json
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
}
}
Loading

0 comments on commit b13c2a6

Please sign in to comment.