Skip to content

Commit 09d5960

Browse files
committed
feat: initial commit
0 parents  commit 09d5960

37 files changed

+897
-0
lines changed

.babelrc.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const presets = [
2+
[
3+
'@babel/preset-env',
4+
{
5+
modules: process.env.NODE_ENV === 'es' ? false : 'commonjs'
6+
}
7+
],
8+
'@babel/preset-react',
9+
'@babel/preset-typescript'
10+
]
11+
12+
const plugins = [
13+
'@babel/plugin-proposal-class-properties',
14+
'@babel/plugin-proposal-object-rest-spread'
15+
]
16+
17+
if (process.env.NODE_ENV === 'test') {
18+
plugins.push('@babel/plugin-transform-modules-commonjs')
19+
}
20+
21+
module.exports = { presets, plugins }

.circleci/config.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
docker:
9+
# specify the version you desire here
10+
- image: circleci/node:10.11
11+
12+
# Specify service dependencies here if necessary
13+
# CircleCI maintains a library of pre-built images
14+
# documented at https://circleci.com/docs/2.0/circleci-images/
15+
# - image: circleci/mongo:3.4.4
16+
17+
working_directory: ~/repo
18+
19+
steps:
20+
- checkout
21+
22+
# Download and cache dependencies
23+
- restore_cache:
24+
keys:
25+
- v1-dependencies-{{ checksum "package.json" }}
26+
# fallback to using the latest cache if no exact match is found
27+
- v1-dependencies-
28+
29+
- run: yarn install
30+
31+
- save_cache:
32+
paths:
33+
- node_modules
34+
key: v1-dependencies-{{ checksum "package.json" }}
35+
36+
# run tests!
37+
- run: yarn test
38+

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# http://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
insert_final_newline = false
15+
trim_trailing_whitespace = false

.gitignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (http://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# Typescript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
# bundle dir
61+
lib
62+
es
63+
64+
package-lock.json

.npmignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.gitignore
2+
.editorconfig
3+
4+
node_modules/
5+
npm-debug.log
6+
7+
src/
8+
tests/
9+
examples/
10+
coverage/
11+
.circleci
12+
.vscode
13+
14+
.babelrc.js
15+
.travis.yml
16+
*.config.js
17+
tslint.json
18+
tsconfig.json
19+
.prettierrc
20+
commitlint.config.js

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"semi": false
4+
}

.travis.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
sudo: false
2+
language: node_js
3+
cache:
4+
directories:
5+
- ~/.npm
6+
- node_modules
7+
notifications:
8+
email: false
9+
node_js:
10+
- '10'
11+
- '9'
12+
- '8'
13+
before_script:
14+
- PATH=${PATH//:\.\/node_modules\/\.bin/}
15+
after_success:
16+
- npm run build
17+
- npm run coverage
18+
- npm install -g travis-deploy-once
19+
- travis-deploy-once "npm run semantic-release"
20+
branches:
21+
only:
22+
- master
23+
- dev
24+
- /^greenkeeper/.*$/
25+
before_deploy:
26+
- cd examples
27+
- npm install
28+
- npm run build
29+
deploy:
30+
provider: pages
31+
skip-cleanup: true
32+
github-token: $GH_TOKEN
33+
keep-history: false
34+
local-dir: examples/site
35+
on:
36+
branch: master
37+
node: '10'

.vscode/launch.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "Jest All",
8+
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
9+
"args": [
10+
"--runInBand"
11+
],
12+
"console": "integratedTerminal",
13+
"internalConsoleOptions": "neverOpen"
14+
},
15+
{
16+
"type": "node",
17+
"request": "launch",
18+
"name": "Jest Current File",
19+
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
20+
"args": [
21+
"${relativeFile}"
22+
],
23+
"console": "integratedTerminal",
24+
"internalConsoleOptions": "neverOpen"
25+
}
26+
]
27+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017-present foryuki
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {extends: ['@commitlint/config-angular']}

examples/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

examples/.storybook/addons.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '@storybook/addon-options/register'
2+
import '@storybook/addon-actions/register'

examples/.storybook/config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { configure } from '@storybook/react'
2+
import { setOptions } from '@storybook/addon-options'
3+
4+
setOptions({
5+
name: 'One React',
6+
url: 'https://github.com/one-react/code-previewer',
7+
goFullScreen: false,
8+
showAddonPanel: true,
9+
addonPanelInRight: true,
10+
})
11+
12+
// automatically import all files ending with *.story.tsx
13+
const req = require.context('../stories', true, /.story.tsx$/)
14+
function loadStories() {
15+
req.keys().forEach(filename => req(filename))
16+
}
17+
18+
configure(loadStories, module)

examples/.storybook/manager-head.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<script>
2+
document.title = "One React"
3+
</script>
4+
<link rel="icon" type="image/png" href="https://cdn.rawgit.com/one-react/assets/2a4f10b4/logo.png">

examples/.storybook/webpack.config.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const path = require('path')
2+
3+
module.exports = (baseConfig, env, defaultConfig) => {
4+
defaultConfig.module.rules.push({
5+
test: /\.(ts|tsx)$/,
6+
exclude: /node_modules/,
7+
use: [
8+
{
9+
loader: require.resolve('babel-loader'),
10+
options: {
11+
cacheDirectory: true,
12+
...require('../../.babelrc')
13+
}
14+
},
15+
require.resolve('react-docgen-typescript-loader')
16+
]
17+
}, {
18+
test: /\.scss$/,
19+
use: ['style-loader', 'css-loader', 'sass-loader']
20+
})
21+
22+
defaultConfig.resolve.alias['or-code-previewer'] = path.resolve(__dirname, '../../src')
23+
24+
defaultConfig.resolve.extensions.push('.ts', '.tsx')
25+
26+
defaultConfig.resolve.modules.push(
27+
path.resolve(__dirname, '../node_modules'),
28+
path.resolve(__dirname, '../../node_modules')
29+
)
30+
31+
defaultConfig.devServer = {
32+
inline: true,
33+
hot: true
34+
}
35+
36+
return defaultConfig
37+
}

examples/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "examples",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"dev": "start-storybook -s public -p 9001 -c .storybook",
8+
"build": "build-storybook -s public -o site"
9+
},
10+
"author": "foryuki <foryuki@outlook.com>",
11+
"license": "MIT",
12+
"devDependencies": {
13+
"@babel/core": "^7.0.1",
14+
"@storybook/addon-info": "^3.4.10",
15+
"@storybook/addon-options": "^3.4.10",
16+
"@storybook/react": "^3.4.10",
17+
"@types/storybook__addon-actions": "^3.4.1",
18+
"@types/storybook__addon-info": "^3.4.2",
19+
"@types/storybook__react": "^3.0.9",
20+
"babel-loader": "^8.0.2",
21+
"css-loader": "^1.0.0",
22+
"node-sass": "^4.7.2",
23+
"react-docgen-typescript-loader": "^3.0.0",
24+
"sass-loader": "^7.1.0",
25+
"style-loader": "^0.23.0",
26+
"typescript": "^3.0.3"
27+
},
28+
"dependencies": {
29+
"react": "^16.1.1",
30+
"react-dom": "^16.1.1",
31+
"react-scripts": "^1.0.17"
32+
}
33+
}

examples/public/.gitkeep

Whitespace-only changes.

examples/stories/example.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { action } from '@storybook/addon-actions'
2+
import Sample from 'or-code-previewer'
3+
import React, { PureComponent } from 'react'
4+
5+
const handleClick = action('sample-click')
6+
7+
export default class Example extends PureComponent<{}, {}> {
8+
render() {
9+
return (
10+
<div>
11+
<h1>button type:</h1>
12+
<div>
13+
<Sample type="primary" onClick={handleClick}>
14+
ADD TO CART
15+
</Sample>
16+
<Sample onClick={handleClick}>SIGN UP</Sample>
17+
<Sample type="warning" onClick={handleClick}>
18+
DELETE
19+
</Sample>
20+
<Sample onClick={handleClick}>TOO LOOOOOOOOOOOOOOOOOOG</Sample>
21+
</div>
22+
</div>
23+
)
24+
}
25+
}

0 commit comments

Comments
 (0)