Skip to content

Commit

Permalink
feat: initial
Browse files Browse the repository at this point in the history
  • Loading branch information
afeiship committed Sep 7, 2020
0 parents commit 0bcb51a
Show file tree
Hide file tree
Showing 40 changed files with 895 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"presets": [[
"@babel/preset-env",
{
"targets": { "browsers": [ "last 2 versions" ] }
}
], "@babel/react"],
"plugins": [
[ "@babel/plugin-proposal-decorators", { "legacy": true } ],
[ "@babel/plugin-proposal-class-properties", { "loose": true } ],
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-transform-parameters"
]
}
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
node_modules
bower_components
coverage
npm-debug.log
yarn.lock
Gemfile.lock
yarn-error.log
package-lock.json
.DS_Store

# editor
.idea
.vscode
.history
35 changes: 35 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.idea
.DS_Store
.prettierrc
.babelrc
.editorconfig
Gemfile
postcss.config.js
Rakefile
**/npm-debug.log
**/node_modules

bin
src
docs
build
docs
public
tests
postcss.config.js
webpack.config.babel.js
example
examples

# vscode
jsconfig.json
.history

# tests
test
__test__
__tests__
jest.config.js
jest.setup.js


2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
package-lock=false
38 changes: 38 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"trailingComma": "none",
"arrowParens": "always",
"printWidth": 80,
"bracketSpacing": true,
"jsxBracketSameLine": true,
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"overrides": [
{
"files": [
"*.json",
".eslintrc",
".tslintrc",
".prettierrc",
".tern-project"
],
"options": {
"parser": "json",
"tabWidth": 2
}
},
{
"files": "*.{css,sass,scss,less}",
"options": {
"parser": "postcss",
"tabWidth": 2
}
},
{
"files": "*.ts",
"options": {
"parser": "typescript"
}
}
]
}
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gem 'fileutils'
gem 'sshkit'
gem 'semver'
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 afei <1290657123@qq.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
124 changes: 124 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# react-details
> Details for react.
[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]

## installation
```shell
npm install -S @feizheng/react-details
```

## update
```shell
npm update @feizheng/react-details
```

## properties
| Name | Type | Required | Default | Description |
| --------- | ------ | -------- | ------- | ------------------------------------- |
| className | string | false | - | The extended className for component. |
| value | bool | false | - | The changed value. |
| onChange | func | false | noop | The change handler. |
| summary | any | false | - | The changed value. |


## usage
1. import css
```scss
@import "~@feizheng/react-details/dist/style.scss";

// customize your styles:
$react-details-options: ()
```
2. import js
```js
import NxOfflineSw from '@feizheng/next-offline-sw';
import ReactGithubCorner from '@feizheng/react-github-corner';
import ReactSwUpdateTips from '@feizheng/react-sw-update-tips';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactDetails from '@feizheng/react-details';
import './assets/style.scss';

class App extends React.Component {
state = { hasUpdate: false, value: true };

componentDidMount() {
NxOfflineSw.install({
onUpdateReady: () => {
this.setState({ hasUpdate: true });
}
});
}

render() {
return (
<div className="p-3 app-container">
<p className="p-3 bg-gray-200 mb-2">value: {this.state.value + ''}</p>
<ReactDetails
value={true}
summary="道可道,非常道"
onChange={(e) => {
this.setState({ value: e.target.value });
}}>
道可道,非常道;名可名,非常名。 无名,天地之始,有名,万物之母。
故常无欲,以观其妙,常有欲,以观其徼。
此两者,同出而异名,同谓之玄,玄之又玄,众妙之门。
</ReactDetails>
<ReactSwUpdateTips value={this.state.hasUpdate} />
<ReactGithubCorner value="https://github.com/afeiship/react-details" />
</div>
);
}
}

ReactDOM.render(<App />, document.getElementById('app'));

```

## animation
```css
/* remove arrow */
&::-webkit-details-marker {
// display: none;
}


/* add animation */
&[open] summary ~ * {
animation: open 0.5s ease-in-out;
}

@keyframes open {
0% {
opacity: 0;
margin-left: -5px;
}
100% {
opacity: 1;
margin-left: 0px;
}
}
```

## documentation
- https://afeiship.github.io/react-details/


## license
Code released under [the MIT license](https://github.com/afeiship/react-details/blob/master/LICENSE.txt).

[version-image]: https://img.shields.io/npm/v/@feizheng/react-details
[version-url]: https://npmjs.org/package/@feizheng/react-details

[license-image]: https://img.shields.io/npm/l/@feizheng/react-details
[license-url]: https://github.com/afeiship/react-details/blob/master/LICENSE.txt

[size-image]: https://img.shields.io/bundlephobia/minzip/@feizheng/react-details
[size-url]: https://github.com/afeiship/react-details/blob/master/dist/react-details.min.js

[download-image]: https://img.shields.io/npm/dm/@feizheng/react-details
[download-url]: https://www.npmjs.com/package/@feizheng/react-details
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

Dir["./node_modules/@feizheng/rake-*/index.rake"].each do |task|
load task
end
12 changes: 12 additions & 0 deletions __tests__/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { shallow } from 'enzyme';
import BoilerplateReactCompnent from '../src/main';

describe('Basic Test', () => {
test('renders to document', () => {
const component = shallow(<BoilerplateReactCompnent />);
const cnt = component.find('.react-component');
cnt.simulate('click');
expect(cnt).toMatch(/Hello React/);
});
});
48 changes: 48 additions & 0 deletions bin/docs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env ruby
require "net/http"
require "json"

TOKEN = ENV["GITHUB_API_TOKEN"]

class DocApp
def initialize
@uri = URI("https://api.github.com/repos/afeiship/react-details/pages")
@http = Net::HTTP.new(@uri.host, @uri.port)
@http.use_ssl = true

@header = {
'Accept': "application/vnd.github.switcheroo-preview+json",
'Authorization': "token #{TOKEN}",
'Content-Type': "application/vnd.api+json",
}

@data = {
"source": {
"branch": "master",
"path": "/docs",
},
}
end

def del
@req = Net::HTTP::Delete.new(@uri.path, @header)
@http.request(@req)
end

def create
@req = Net::HTTP::Post.new(@uri.path, @header)
@req.body = @data.to_json
@http.request(@req)
end

def set_doc
del
create

puts "Has set master/docs to gh-pages!"
end
end

# start app:
app = DocApp.new
app.set_doc
Loading

0 comments on commit 0bcb51a

Please sign in to comment.