diff --git a/gulp-gh-pages/LICENSE b/gulp-gh-pages/LICENSE new file mode 100644 index 00000000..14a9a57d --- /dev/null +++ b/gulp-gh-pages/LICENSE @@ -0,0 +1,23 @@ +Copyright + +2014 Micheal Benedict (@micheal) +2015 Shinnosuke Watanabe (@shinnn) + +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. diff --git a/gulp-gh-pages/README.md b/gulp-gh-pages/README.md new file mode 100644 index 00000000..05ad1edb --- /dev/null +++ b/gulp-gh-pages/README.md @@ -0,0 +1,107 @@ +// fork version, see https://github.com/shinnn/gulp-gh-pages/pull/83 for deatils + + +# gulp-gh-pages + +[![NPM version](http://img.shields.io/npm/v/gulp-gh-pages.svg)](https://www.npmjs.com/package/gulp-gh-pages) +[![Build Status](https://travis-ci.org/shinnn/gulp-gh-pages.svg?branch=master)](https://travis-ci.org/shinnn/gulp-gh-pages) +[![Build status](https://ci.appveyor.com/api/projects/status/iskj8sml9luhkm21?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/gulp-gh-pages) +[![Coverage Status](https://img.shields.io/coveralls/shinnn/gulp-gh-pages.svg)](https://coveralls.io/r/shinnn/gulp-gh-pages) +[![Dependency Status](https://img.shields.io/david/shinnn/gulp-gh-pages.svg?label=deps)](https://david-dm.org/shinnn/gulp-gh-pages) +[![devDependency Status](https://img.shields.io/david/dev/shinnn/gulp-gh-pages.svg?label=devDeps)](https://david-dm.org/shinnn/gulp-gh-pages#info=devDependencies) + +[gulp](http://gulpjs.com/) plugin to publish contents to [Github pages](https://pages.github.com/) + +## Installation + +[Use npm](https://docs.npmjs.com/cli/install). + +```sh +npm install --save-dev gulp-gh-pages +``` + +## Usage + +Define a `deploy` task in your `gulpfile.js` (as below) which can be used to push to `gh-pages` going forward. + +```javascript +var gulp = require('gulp'); +var ghPages = require('gulp-gh-pages'); + +gulp.task('deploy', function() { + return gulp.src('./dist/**/*') + .pipe(ghPages()); +}); +``` + +Now, you should be able to call your task by doing: + +```she +gulp deploy +``` + +## API + +```javascript +var ghPages = require('gulp-gh-pages'); +``` + +### ghPages([*options*]) + +*options*: `Object` +Return: `Object` ([stream.Transform](https://nodejs.org/api/stream.html#stream_class_stream_transform_1)) + +#### options.remoteUrl + +Type: `String` +Default: URL for the remote of the current dir (assumes a git repository) + +By default `gulp-gh-pages` assumes the current working directory is a git repository and uses its remote url. If your `gulpfile.js` is not in a git repository, or if you want to push to a different remote url, you can specify it. Ensure you have write access to the repository. + +#### options.origin + +Type: `String` +Default: `"origin"` + +Git remote. + +#### options.branch + +Type: `String` +Default: `"gh-pages"` + +The branch where deploy will by done. Change to "master" for `username.github.io` projects. + +#### options.cacheDir + +Type: `String` +Default: `.publish` + +Set the directory path to keep a cache of the repository. If it doesn't exist, gulp-gh-pages automatically create it. + +#### options.push + +Type: `Boolean` +Default: `true` + +Allow you to make a build on the defined branch without pushing it to master. Useful for dry run. + +#### options.force + +Type: `Boolean` +Default: `false` + +Force adding files to the `gh-pages` branch, even if they are ignored by `.gitignore` or `.gitignore_global`. + +#### options.message + +Type: `String` +Default: `"Update [timestamp]"` + +Edit commit message. + +## License + +Copyright (c) 2014 [Micheal Benedict](https://github.com/rowoot), 2015 [Shinnosuke Watanabe](https://github.com/shinnn) + +Licensed under [the MIT License](./LICENSE). diff --git a/gulp-gh-pages/index.js b/gulp-gh-pages/index.js new file mode 100644 index 00000000..64310d9c --- /dev/null +++ b/gulp-gh-pages/index.js @@ -0,0 +1,163 @@ +'use strict'; + +var git = require('./lib/git'); +var gutil = require('gulp-util'); +var Transform = require('readable-stream/transform'); +var vinylFs = require('vinyl-fs'); +var wrapPromise = require('wrap-promise'); + +/* + * Public: Push to gh-pages branch for github + * + * options - {Object} that contains all the options of the plugin + * - remoteUrl: The {String} remote url (github repository) of the project, + * - origin: The {String} origin of the git repository (default to `"origin"`), + * - branch: The {String} branch where deploy will by done (default to `"gh-pages"`), + * - cacheDir: {String} where the git repo will be located. (default to a temporary folder) + * - push: {Boolean} to know whether or not the branch should be pushed (default to `true`) + * - message: {String} commit message (default to `"Update [timestamp]"`) + * + * Returns `Stream`. +**/ +module.exports = function gulpGhPages(options) { + options = options || {}; + var origin = options.origin || 'origin'; + var branch = options.branch || 'gh-pages'; + var message = options.message || 'Update ' + new Date().toISOString(); + + var files = []; + var TAG; + if (branch !== 'gh-pages') { + TAG = '[gh-pages (' + branch + ')]'; + } else { + TAG = '[gh-pages]'; + } + + return new Transform({ + objectMode: true, + transform: function collectFiles(file, enc, cb) { + if (file.isNull()) { + cb(null, file); + return; + } + + if (file.isStream()) { + cb(new gutil.PluginError('gulp-gh-pages', 'Stream content is not supported')); + return; + } + + files.push(file); + cb(null, file); + }, + flush: function publish(cb) { + if (files.length === 0) { + gutil.log(TAG, 'No files in the stream.'); + cb(); + return; + } + + var newBranchCreated = false; + + git.prepareRepo(options.remoteUrl, origin, options.cacheDir || '.publish') + .then(function(repo) { + gutil.log(TAG, 'Cloning repo'); + if (repo._localBranches.indexOf(branch) > -1) { + gutil.log(TAG, 'Checkout branch `' + branch + '`'); + return repo.checkoutBranch(branch); + } + + if (repo._remoteBranches.indexOf('origin/' + branch) > -1) { + gutil.log(TAG, 'Checkout remote branch `' + branch + '`'); + return repo.checkoutBranch(branch); + } + + gutil.log(TAG, 'Create branch `' + branch + '` and checkout'); + newBranchCreated = true; + return repo.createAndCheckoutBranch(branch); + }) + .then(function(repo) { + return wrapPromise(function(resolve, reject) { + if (newBranchCreated) { + resolve(repo); + return; + } + + // updating to avoid having local cache not up to date + gutil.log(TAG, 'Updating repository'); + repo._repo.git('pull', function(err) { + if (err) { + reject(err); + return; + } + resolve(repo); + }); + }); + }) + .then(function(repo) { + // remove all files + return wrapPromise(function(resolve, reject) { + repo._repo.remove('.', {r: true}, function(err) { + if (err) { + reject(err); + return; + } + resolve(repo.status()); + }); + }); + }) + .then(function(repo) { + gutil.log(TAG, 'Copying files to repository'); + + return wrapPromise(function(resolve, reject) { + var destStream = vinylFs.dest(repo._repo.path) + .on('error', reject) + .on('end', function() { + resolve(repo); + }) + .resume(); + + files.forEach(function(file) { + destStream.write(file); + }); + + destStream.end(); + }); + }) + .then(function(repo) { + return repo.addFiles('.', {force: options.force || false}); + }) + .then(function(repo) { + var filesToBeCommitted = Object.keys(repo._staged).length; + if (filesToBeCommitted === 0) { + gutil.log(TAG, 'No files have changed.'); + cb(); + return; + } + + gutil.log(TAG, 'Adding ' + filesToBeCommitted + ' files.'); + gutil.log(TAG, 'Committing "' + message + '"'); + repo.commit(message).then(function(newRepo) { + if (options.push === undefined || options.push) { + gutil.log(TAG, 'Pushing to remote.'); + newRepo._repo.git('push', { + 'set-upstream': true + }, ['origin', newRepo._currentBranch], function(err) { + if (err) { + cb(err); + return; + } + cb(); + }); + return; + } + cb(); + }, cb); + }) + .catch(function(err) { + setImmediate(function() { + cb(new gutil.PluginError('gulp-gh-pages', err)); + }); + }); + } + }); +}; diff --git a/gulp-gh-pages/lib/git.js b/gulp-gh-pages/lib/git.js new file mode 100644 index 00000000..e57a76a7 --- /dev/null +++ b/gulp-gh-pages/lib/git.js @@ -0,0 +1,270 @@ +'use strict'; + +var git = require('gift'); +var rimraf = require('rimraf'); +var wrapPromise = require('wrap-promise'); + +/* + * Git Constructor +**/ +function Git(repo, initialBranch) { + this._repo = repo; + this._staged = []; + this._localBranches = []; + this._remoteBranches = []; + this._currentBranch = initialBranch; + this._commits = []; +} + +/* + * Caller abstract method + * for promisifying traditional callback methods +**/ +function caller() { + var returnedArgs = Array.prototype.slice.call(arguments); + var fn = returnedArgs.shift(); + var self = this; + + return wrapPromise(function(resolve, reject) { + returnedArgs.push(function(err, args) { + if (err) { + reject(err); + return; + } + resolve(args); + }); + + fn.apply(self, returnedArgs); + }); +} + +/* + * Gets the URL for the specified remote of a repo + */ +function getRemoteUrl(repo, remote) { + return wrapPromise(function(resolve, reject) { + repo.config(function(err, config) { + if (err) { + reject(new Error('Failed to find git repository in ' + config.path)); + return; + } + resolve(config.items['remote.' + remote + '.url']); + }); + }); +} + +/* + * Clone repo + * Returns repo object +**/ +function prepareRepo(remoteUrl, origin, dir) { + var promise; + if (remoteUrl) { + // if a remoteUrl was provided, use it + promise = wrapPromise.Promise.resolve(remoteUrl); + } else { + // else try to extract it from the .git folder of + // the current directory. + promise = getRemoteUrl(git(process.cwd()), origin); + } + + return promise.then(function(rUrl) { + remoteUrl = rUrl; + + return wrapPromise(function(resolve, reject) { + function initRepo(repo) { + repo.branch(function(err, head) { + if (err) { + reject(err); + return; + } + resolve(new Git(repo, head.name).status()); + }); + } + + function clearAndInitRepo() { + rimraf(dir, function(rmErr) { + if (rmErr) { + reject(rmErr); + return; + } + + git.clone(rUrl, dir, function(cloneErr, repo) { + if (cloneErr) { + reject(cloneErr); + return; + } + initRepo(repo); + }); + }); + } + + // assume that if there is a .git folder get its remoteUrl + // and check if it mathces the one we want to use. + getRemoteUrl(git(dir), origin).then(function(cwdRemoteUrl) { + if (remoteUrl === cwdRemoteUrl) { + initRepo(git(dir)); + return; + } + clearAndInitRepo(); + }, function() { + clearAndInitRepo(); + }); + }); + }); +} + +/* + * List Local branches +**/ +function listLocalBranches(repo) { + return caller.call(repo, repo.branches).then(function(branches) { + return branches.map(function(branch) { + return branch.name; + }); + }); +} + +function listRemoteBranches(repo) { + return caller.call(repo, repo.git, 'branch', {r: true}, []) + .then(function(branches) { + branches = branches.split('\n'); + branches.shift(); + branches.pop(); + return branches.map(function(branchName) { + branchName = branchName.trim(); + return branchName; + }); + }); +} + +/* + * List commits for specific branch +**/ +function getCommits(repo, branchName) { + return caller.call(repo, repo.commits, branchName) + .then(function(commits) { + return commits.map(function(commitObj) { + return { + id: commitObj.id, + message: commitObj.message, + committed_date: commitObj.committed_date + }; + }); + }); +} + +Git.prepareRepo = prepareRepo; +Git.getRemoteUrl = getRemoteUrl; + +/* + * Status + * files - Array of String paths; or a String path. +**/ +Git.prototype.status = function() { + var self = this; + + return wrapPromise(function(resolve, reject) { + self._repo.status(function(err, repo) { + if (err) { + reject(err); + return; + } + + self._repo = repo.repo; + self._staged = repo.files; + wrapPromise.Promise.all([ + getCommits(self._repo, self._currentBranch), + listRemoteBranches(self._repo), + listLocalBranches(self._repo) + ]) + .then(function(args) { + self._remoteBranches = args[1]; + self._localBranches = args[2]; + self._commits = args[0]; + resolve(self); + }, reject); + }); + }); +}; + +/* + * Checkout a specific branch in a repo + * @param name {String} - String name of the branch. +**/ +Git.prototype.checkoutBranch = function(name) { + var self = this; + + return wrapPromise(function(resolve, reject) { + self._repo.checkout(name, function(err) { + if (err) { + reject(err); + return; + } + + self._currentBranch = name; + resolve(self.status()); + }); + }); +}; + +/* + * Create a branch + * @param name {String} - String name of the new branch. +**/ +Git.prototype.createBranch = function(name) { + var self = this; + + return wrapPromise(function(resolve, reject) { + self._repo.create_branch(name, function(err) { + if (err) { + reject(err); + } else { + self._currentBranch = name; + resolve(self.status()); + } + }); + }); +}; + +/* + * Create and checkout a branch + * @param name {String} - String name of the new branch. +**/ +Git.prototype.createAndCheckoutBranch = function(name) { + return this.createBranch(name) + .then(function(repo) { + return repo.checkoutBranch(name); + }); +}; + +Git.prototype.addFiles = function(files, options) { + var self = this; + + return wrapPromise(function(resolve, reject) { + self._repo.add(files, options, function(err) { + if (err) { + reject(err); + return; + } + + resolve(self.status()); + }); + }); +}; + +Git.prototype.commit = function(commitMsg) { + var self = this; + + return wrapPromise(function(resolve, reject) { + self._repo.commit(commitMsg, {all: true}, function(err) { + if (err) { + reject(err); + } else { + resolve(self.status()); + } + }); + }); +}; + +module.exports = Git; diff --git a/gulp-gh-pages/package.json b/gulp-gh-pages/package.json new file mode 100644 index 00000000..bcc87a5e --- /dev/null +++ b/gulp-gh-pages/package.json @@ -0,0 +1,103 @@ +{ + "name": "gulp-gh-pages", + "version": "0.5.4", + "description": "gulp plugin to publish contents to Github pages", + "repository": { + "type": "git", + "url": "git+https://github.com/shinnn/gulp-gh-pages.git" + }, + "license": "MIT", + "author": { + "name": "Micheal Benedict", + "email": "micheal@visionmasterdesigns.com", + "url": "https://github.com/rowoot" + }, + "contributors": [ + { + "name": "Shinnosuke Watanabe", + "url": "https://github.com/shinnn" + } + ], + "keywords": [ + "git", + "push", + "commit", + "branch", + "deploy", + "deployment", + "publish", + "site", + "website", + "gulp", + "gulpplugin", + "gh-pages", + "dist", + "github" + ], + "files": [ + "index.js", + "lib" + ], + "scripts": { + "pretest": "eslint --config @shinnn/node-legacy --env mocha --rule 'no-underscore-dangle: 0' --rule 'camelcase: 0' index.js test.js lib", + "test": "mocha test.js --timeout 50000 --full-trace", + "test-only": "mocha test.js --timeout 50000 --full-trace", + "coverage": "istanbul cover _mocha test.js -x=test.js -- --timeout 50000" + }, + "dependencies": { + "gift": "^0.6.1", + "gulp-util": "^3.0.7", + "readable-stream": "^2.0.2", + "rimraf": "^2.4.3", + "vinyl-fs": "^2.2.1", + "wrap-promise": "^1.0.1" + }, + "devDependencies": { + "@shinnn/eslint-config-node-legacy": "^1.0.0", + "eslint": "^1.7.2", + "graceful-fs": "^4.1.2", + "istanbul": "^0.4.0", + "log-symbols": "^1.0.2", + "mocha": "^2.3.3", + "node-uuid": "^1.4.3", + "octonode": "^0.7.4", + "read-remove-file": "^3.0.0", + "vinyl": "^1.0.0" + }, + "gitHead": "e740e1c4d8789317db706b3fdb712d82454cbc03", + "bugs": { + "url": "https://github.com/shinnn/gulp-gh-pages/issues" + }, + "homepage": "https://github.com/shinnn/gulp-gh-pages#readme", + "_id": "gulp-gh-pages@0.5.4", + "_shasum": "a6732ca475ab9b5a53253c1c24734c40c21b6546", + "_from": "gulp-gh-pages@>=0.5.4 <0.6.0", + "_npmVersion": "3.3.8", + "_nodeVersion": "4.2.1", + "_npmUser": { + "name": "shinnn", + "email": "snnskwtnb@gmail.com" + }, + "maintainers": [ + { + "name": "rowoot", + "email": "micheal@visionmasterdesigns.com" + }, + { + "name": "shinnn", + "email": "snnskwtnb@gmail.com" + } + ], + "dist": { + "shasum": "a6732ca475ab9b5a53253c1c24734c40c21b6546", + "size": 5343, + "noattachment": false, + "key": "gulp-gh-pages/-/gulp-gh-pages-0.5.4.tgz", + "tarball": "http://registry.npm.alibaba-inc.com/gulp-gh-pages/download/gulp-gh-pages-0.5.4.tgz" + }, + "directories": {}, + "publish_time": 1445375452043, + "_cnpm_publish_time": 1445375452043, + "_resolved": "http://registry.npm.alibaba-inc.com/gulp-gh-pages/download/gulp-gh-pages-0.5.4.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/gulpfile.js b/gulpfile.js index 85282c43..3656d397 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,5 @@ var gulp = require('gulp'); -var ghPages = require('gulp-gh-pages'); +var ghPages = require('./gulp-gh-pages'); var less = require('gulp-less'); var cleanCSS = require('gulp-clean-css'); var rename = require('gulp-rename'); @@ -23,10 +23,9 @@ gulp.task('deploy', function() { gulp.task('coding', function() { return gulp.src('./_site/**/*') .pipe(ghPages({ - remoteUrl: 'https://git.coding.net/uxcore/uxcore.git', + // remoteUrl: 'https://git.coding.net/uxcore/uxcore.git', origin: 'coding', branch: 'master', - push: false, })); }); diff --git a/index.js b/index.js index 6c59bbeb..1e0d94ee 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ window.UXCORE = { 'uxcore-tooltip': require('uxcore-tooltip'), 'uxcore-tabs': require('uxcore-tabs'), 'uxcore-form': require('uxcore-form'), + 'uxcore-form-field': require('uxcore-form-field'), 'uxcore-grid': require('uxcore-grid'), 'uxcore-table': require('uxcore-table'), 'uxcore-dropdown': require('uxcore-dropdown'), @@ -42,6 +43,7 @@ window.UXCORE = { 'uxcore-animate': require('uxcore-animate'), 'uxcore-tag': require('uxcore-tag'), 'uxcore-empty-data': require('uxcore-empty-data'), + 'uxcore-timeline': require('uxcore-timeline'), 'classnames': require('classnames'), 'object-assign': require('object-assign') }; diff --git a/nico.production.js b/nico.production.js index e200eeba..2c5eac8d 100644 --- a/nico.production.js +++ b/nico.production.js @@ -1,6 +1,30 @@ var nicoConfig = require('./nico'); +var webpack = require('webpack'); +var webpackConfig = require('./webpack.config.min'); +var webpackCompiler = webpack(webpackConfig); // nicoConfig.site.urlPrefix = ''; nicoConfig.site.urlPrefix = '//g.alicdn.com/uxcore/site'; +nicoConfig.middlewares = [{ + name: 'webpackDevMiddleware', + filter: /\.(js|css)(\.map)?$/, + handle: function(req, res, next) { + handler = handler || webpackMiddleware(webpackCompiler, { + publicPath: '/static/', + lazy: true, + stats: { + version: true, + hash: false, + cached: false, + cachedAssets: false, + colors: true, + timings: true + } + }); + try { + return handler(req, res, next); + } catch(e) {} + } +}]; module.exports = nicoConfig; diff --git a/package.json b/package.json index 9fc880bc..b0798bd2 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "scripts": { "start": "gulp less && nico server --watch", "clean": "rm -rf _site", - "deploy": "npm run clean && webpack --config webpack.config.min.js && gulp less && nico build -C nico.production.js && gulp deploy", + "deploy": "npm run clean && webpack --config webpack.config.min.js && gulp less && nico build -C nico.production.js && gulp deploy && gulp coding", "coding": "npm run clean && webpack --config webpack.config.min.js && gulp less && nico build -C nico.production.js && gulp coding" }, "dependencies": { @@ -23,13 +23,13 @@ "react": "~0.14.0", "react-dom": "~0.14.0", "react-mixin": "~3.0.5", - "uxcore-album": "~0.1.1", + "uxcore-album": "~0.3.0", "uxcore-alert": "~0.2.1", "uxcore-animate": "^0.1.2", "uxcore-badge": "~0.1.1", "uxcore-button": "~0.4.0", "uxcore-calendar": "~0.6.0", - "uxcore-carousel": "~0.2.0", + "uxcore-carousel": "~0.3.0", "uxcore-cascade-select": "^0.1.1", "uxcore-checkbox-group": "~1.1.0", "uxcore-collapse": "~1.2.0", @@ -38,14 +38,15 @@ "uxcore-dropdown": "~0.2.0", "uxcore-empty-data": "^0.1.2", "uxcore-form": "~1.8.0", + "uxcore-form-field": "^0.2.5", "uxcore-formatter": "~0.1.2", "uxcore-grid": "~1.2.0", - "uxcore-kuma": "~2.7.0", + "uxcore-kuma": "~2.8.0", "uxcore-layout": "~1.0.1", "uxcore-load-more": "^0.1.2", "uxcore-matrix": "^0.1.3", "uxcore-mention": "~0.3.0", - "uxcore-menu": "~1.1.0", + "uxcore-menu": "~1.3.0", "uxcore-message": "~0.2.0", "uxcore-multi-select": "~0.2.0", "uxcore-pagination": "~0.2.1", @@ -57,9 +58,10 @@ "uxcore-select2": "~0.3.0", "uxcore-steps": "~1.1.2", "uxcore-switch": "~0.1.1", - "uxcore-table": "~1.10.0", + "uxcore-table": "~1.12.0", "uxcore-tabs": "~0.4.0", "uxcore-tag": "^1.0.2", + "uxcore-timeline": "^0.1.3", "uxcore-tinymce": "~0.2.2", "uxcore-tooltip": "~0.3.2", "uxcore-totop": "~0.2.0", @@ -110,7 +112,13 @@ "style-loader": "~0.13.0", "url-loader": "~0.5.6", "webpack": "~1.13.0", - "webpack-dev-middleware": "^1.6.0" + "webpack-dev-middleware": "^1.6.0", + "gift": "^0.6.1", + "gulp-util": "^3.0.7", + "readable-stream": "^2.0.2", + "rimraf": "^2.4.3", + "vinyl-fs": "^2.2.1", + "wrap-promise": "^1.0.1" }, "keywords": [ "react", diff --git a/site/components/album/demo/api.md b/site/components/album/demo/api.md new file mode 100644 index 00000000..774b1421 --- /dev/null +++ b/site/components/album/demo/api.md @@ -0,0 +1,57 @@ +# API 调用 + +- order: 1 + +通过 API 的方式,在其他组件中使用点击查看大图的功能 + +--- + +````jsx + +import Album from 'uxcore-album'; +import Button from 'uxcore-button'; + +const { Photo } = Album; + +class Demo extends React.Component { + + constructor(props) { + super(props); + this.state = { + }; + this.handleClick = this.handleClick.bind(this); + } + + handleClick() { + Album.show({ + photos: [ + , + , + , + ], + }); + } + + + render() { + return ( +
+ +
+ ); + } +}; + +ReactDOM.render( + +, document.getElementById('components-album-demo-api')); +```` + +````css +```` diff --git a/site/components/album/demo/basic.md b/site/components/album/demo/basic.md index 408cc3a9..f47bf6e3 100644 --- a/site/components/album/demo/basic.md +++ b/site/components/album/demo/basic.md @@ -9,19 +9,43 @@ ````jsx import Album, { Photo } from 'uxcore-album'; +import Form from 'uxcore-form'; + +const { SwitchFormField, SelectFormField, FormRow } = Form; class Demo extends React.Component { constructor(props) { super(props); this.state = { + values: { + thumbPlacement: 'right', + } }; + this.handleChange = this.handleChange.bind(this); + } + + handleChange(values) { + this.setState({ + values, + }) } render() { return (
- +
+
+ + + +
+ @@ -40,3 +64,10 @@ ReactDOM.render( , document.getElementById('components-album-demo-basic')); ```` + +````css +.demo-control { + width: 400px; +} + +```` diff --git a/site/components/album/index.md b/site/components/album/index.md index 2cf8f99a..dacc207a 100644 --- a/site/components/album/index.md +++ b/site/components/album/index.md @@ -6,18 +6,34 @@ --- -## Props - -## Album.Props +### Album.Props | Name | Type | Required | Default | Comments | |---|---|---|---|---| | width | number or string | no | '' | the default image cover's width | | height | number or string | no | '' | the default image cover's height | | enableKeyBoardControl | boolean | no | true | whether the album can be controlled by the keyboard navigation | +| enableThumbs | boolean | no | false | whether the show thumbnail list| +| thumbPlacement | string | no | right | the placement of thumbnail, you can set 'top'/'right'/'bottom'/'left'/ | +| thumbBackground | string | no | #000 | if the image couldn't cover the gird, give it a background| ### Photo.Props | Name | Type | Required | Default | Comments | |---|---|---|---|---| | src | string | yes | '' | same as img's src | +| thumb-src | string | no | '' | set thumbnail image source if 'enableThumbs' is true | + +## Method + +### Album.show(config) + + With this method, the component can be used by calling `Album.show({src: 'foo/url'})` or `Album.show({photos: [, ]})` directly. + +#### config + +| Name | Type | Required | Default | Comments | +|---|---|---|---|---| +| src | string | false | null | the image src | +| photos | array of `Photo` | false | [] | array of Photo element | +| getContainer | function | false | the function will append a new div to document body. | define the container which album rendered into | diff --git a/site/components/animate/demo/custom.md b/site/components/animate/demo/custom.md new file mode 100644 index 00000000..4f4eba4f --- /dev/null +++ b/site/components/animate/demo/custom.md @@ -0,0 +1,121 @@ +# 定制动画 + +- order: 1 + +默认提供的动画样式,只有入场动画。 + +--- + +````jsx + +const Button = require('uxcore-button'); +const Animate = require('uxcore-animate'); +const Select = require('uxcore-select2'); +const { Option } = Select; + +class AwesomeComponent extends React.Component { + constructor(props) { + super(props); + } + render() { + return ( +
+ 动画展示区域 +
+ ) + } +} + +class Demo extends React.Component { + + constructor(props) { + super(props); + this.state = { + visible: true, + } + } + + showComponent() { + this.setState({ + visible: !this.state.visible, + }); + } + + render() { + return ( +
+
+ { + console.log(key, exists); + }}> + + +
+
+ +
+
+ ); + } +}; + +ReactDOM.render( + +, document.getElementById('components-animate-demo-custom')); +```` + +````css +.awesome-component-wrap { + color: white; + line-height: 40px; + padding: 10px 20px; + border-radius: 10px; + font-size: 16px; +} + +@keyframes flipIn { + 0% { + opacity: 0; + transform: perspective(1000px) rotate3d(1,0,0,45deg); + } + 100% { + opacity: 1; + transform: perspective(1000px) rotate3d(1,0,0,0deg); + } +} + +@keyframes flipOut { + 0% { + opacity: 1; + transform: perspective(1000px) rotate3d(1,0,0,0deg); + } + 100% { + opacity: 0; + transform: perspective(1000px) rotate3d(1,0,0,45deg); + } +} + +.custom-enter, +.custom-appear { + opacity: 0; + transform: perspective(1000px) rotate3d(1,0,0,45deg); + transform-origin: 50% calc(100% + 10px); + animation-duration: 1s; + animation-fill-mode: both; +} +.custom-enter-active, +.custom-appear-active { + animation-name: flipIn; +} + +.custom-leave { + opacity: 1; + transform: perspective(1000px) rotate3d(1,0,0,0deg); + animation-duration: 1s; + animation-fill-mode: both; +} + +.custom-leave-active { + animation-name: flipOut; +} +```` diff --git a/site/components/menu/demo/nw.md b/site/components/menu/demo/nw.md new file mode 100644 index 00000000..7eb6293d --- /dev/null +++ b/site/components/menu/demo/nw.md @@ -0,0 +1,70 @@ +# 无边框的样式 + +- order: 4 + +垂直内嵌菜单的另一种样式,通过设置类名 kuma-menu-none-border 来实现无边框的样式。 + +--- + +````jsx +var Menu = require('uxcore-menu'); +var SubMenu = Menu.SubMenu; +var MenuItem = Menu.Item; + +function handleClick(e) { + console.log('click', e); +} + +class Demo extends React.Component { + + constructor(props) { + super(props); + this.state = { + current: '1' + }; + } + + handleClick(e) { + console.log('click ', e); + this.setState({ + current: e.key + }); + } + + render() { + return ( + + 导航一}> + 选项1 + 选项2 + 选项3 + 选项4 + + 导航二}> + 选项5 + 选项6 + + 选项7 + 选项8 + + + 导航三}> + 选项9 + 选项10 + 选项11 + 选项12 + + + ); + } +} + +ReactDOM.render( + +, document.getElementById('components-menu-demo-nw')); +```` diff --git a/site/components/table/demo/adv.md b/site/components/table/demo/adv.md index 2c5a75f8..52579316 100644 --- a/site/components/table/demo/adv.md +++ b/site/components/table/demo/adv.md @@ -53,7 +53,7 @@ class Demo extends React.Component { } ] - let fetchUrl = './demo/data.json'; + let fetchUrl = '/components/table/demo/data.json'; let renderProps={ height: 400, diff --git a/site/components/table/demo/basic.md b/site/components/table/demo/basic.md index e49ed2f7..d3c2da78 100644 --- a/site/components/table/demo/basic.md +++ b/site/components/table/demo/basic.md @@ -71,7 +71,7 @@ class Demo extends React.Component { } ] - let fetchUrl = './demo/data.json'; + let fetchUrl = '/components/table/demo/data.json'; let renderProps={ height: 400, diff --git a/site/components/table/demo/fixed.md b/site/components/table/demo/fixed.md index 8b87788f..42f441bd 100644 --- a/site/components/table/demo/fixed.md +++ b/site/components/table/demo/fixed.md @@ -6,6 +6,7 @@ ````jsx + let Table = require('uxcore-table'); class Demo extends React.Component { @@ -45,7 +46,7 @@ class Demo extends React.Component { height:300, showSearch: true, fetchParams: {}, - fetchUrl: './demo/data.json', + fetchUrl: '/components/table/demo/data.json', jsxcolumns:columns, beforeFetch: (sendData, from) => { return sendData;}, processData: (data) => {return data;} diff --git a/site/components/table/demo/tree.md b/site/components/table/demo/tree.md index 918e0320..1e1b9050 100644 --- a/site/components/table/demo/tree.md +++ b/site/components/table/demo/tree.md @@ -10,8 +10,6 @@ let classnames = require('classnames'); let Table = require('uxcore-table'); -let urlPrefix = './'; - class Demo extends React.Component { @@ -65,7 +63,7 @@ class Demo extends React.Component { height: 400, width: 800, showSearch: true, - fetchUrl: urlPrefix + 'demo/data.json', + fetchUrl: '/components/table/demo/data.json', jsxcolumns: columns, renderModel: 'tree', rowSelection: { diff --git a/site/components/table/index.md b/site/components/table/index.md index d005ef22..f6802d3c 100644 --- a/site/components/table/index.md +++ b/site/components/table/index.md @@ -23,6 +23,7 @@ * saveAllRow(): 保存所有行的数据(同时切换至查看模式)。 * resetRow(rowData): 重置行到数据(若保存过,则为保存过后的数据)。 + ### 获取数据 * fetchData(from): 使表格重新请求一次数据。 @@ -310,7 +311,7 @@ actions: [ ``` addRowClassName: function(rowData) { - return 'multiline'; + return "multiline"; } ``` diff --git a/site/components/timeline/demo/addons.md b/site/components/timeline/demo/addons.md new file mode 100644 index 00000000..b7d9847d --- /dev/null +++ b/site/components/timeline/demo/addons.md @@ -0,0 +1,54 @@ +# 指定最后一个幽灵节点 + +- order: 2 + + 指定最后一个幽灵节点 + +--- + +````jsx + +const Timeline = require('uxcore-timeline'); + +class Demo extends React.Component { + + constructor(props) { + super(props); + this.state = { + }; + } + + render() { + return ( +
+ To do}> + +

2016-10-25

+

content1

+

content1

+
+ +

2016-10-26

+

content2

+

content2

+
+ +

2016-10-27

+

content3

+

content3

+
+ +

2016-10-28

+

content4

+

content4

+
+
+
+ ); + } +} + +ReactDOM.render( + +, document.getElementById('components-timeline-demo-addons')); +```` diff --git a/site/components/timeline/demo/basic.md b/site/components/timeline/demo/basic.md new file mode 100644 index 00000000..2365fa96 --- /dev/null +++ b/site/components/timeline/demo/basic.md @@ -0,0 +1,54 @@ +# 基本使用 + +- order: 0 + +基本使用 + +--- + +````jsx + +const Timeline = require('uxcore-timeline'); + +class Demo extends React.Component { + + constructor(props) { + super(props); + this.state = { + }; + } + + render() { + return ( +
+ + +

2016-10-25

+

content1

+

content1

+
+ +

2016-10-26

+

content2

+

content2

+
+ +

2016-10-27

+

content3

+

content3

+
+ +

2016-10-28

+

content4

+

content4

+
+
+
+ ); + } +} + +ReactDOM.render( + +, document.getElementById('components-timeline-demo-basic')); +```` diff --git a/site/components/timeline/demo/custom.md b/site/components/timeline/demo/custom.md new file mode 100644 index 00000000..69bad47c --- /dev/null +++ b/site/components/timeline/demo/custom.md @@ -0,0 +1,54 @@ +# 自定义线条颜色 + +- order: 1 + +自定义线条颜色 + +--- + +````jsx + +const Timeline = require('uxcore-timeline'); + +class Demo extends React.Component { + + constructor(props) { + super(props); + this.state = { + }; + } + + render() { + return ( +
+ + +

2016-10-25

+

content1

+

content1

+
+ +

2016-10-26

+

content2

+

content2

+
+ +

2016-10-27

+

content3

+

content3

+
+ +

2016-10-28

+

content4

+

content4

+
+
+
+ ); + } +} + +ReactDOM.render( + +, document.getElementById('components-timeline-demo-custom')); +```` diff --git a/site/components/timeline/index.md b/site/components/timeline/index.md new file mode 100644 index 00000000..72e66d89 --- /dev/null +++ b/site/components/timeline/index.md @@ -0,0 +1,29 @@ +# Timeline + +- category: Components +- subtype: Presentation +- chinese: 时间轴 + +--- + +## Props + +### Timeline + +时间轴。 + +| Name | Type | Required | Default | Comments | +|---|---|---|---|---| +| className | String | false | 无 | 额外类名 | +| pending | jsx | false | 无 | 指定最后一个幽灵节点内容 | + +### Timeline.Item + +时间轴的每一个节点。 + +| Name | Type | Required | Default | Comments | +|---|---|---|---|---| +| className | String | false | 无 | 额外类名 | +| color | String | false | orange | 指定圆圈颜色 `orange, blue, gray, green`,或自定义的色值 | +| dot | jsx | false | 无 | 自定义时间轴点 | + diff --git a/site/scene/commonForm/demo/defineField.md b/site/scene/commonForm/demo/defineField.md index 5e83df87..95ed74ab 100644 --- a/site/scene/commonForm/demo/defineField.md +++ b/site/scene/commonForm/demo/defineField.md @@ -12,27 +12,24 @@ const Form = require("uxcore-form"); const Button = require("uxcore-button"); const deepcopy = require('deepcopy'); const assign = require('object-assign'); +const FormField = require('uxcore-form-field'); const { - FormField, OtherFormField: Other } = Form; class DoubleInputFormField extends FormField { constructor(props) { super(props); + // 这里不要直接覆盖 this.state = {}; + // 如果希望增加 state,使用扩展。 + // this.state = assign({}, this.state, {xxx: 1}) } // 改写 addSpecificClass,增加该 FormField 专属的 class addSpecificClass() { - let me = this; - if (me.props.jsxprefixCls == "kuma-uxform-field") { - return me.props.jsxprefixCls + " kuma-doubleinput-uxform-field" ; - } - else { - return me.props.jsxprefixCls - } + return "kuma-doubleinput-uxform-field" } @@ -63,6 +60,7 @@ class DoubleInputFormField extends FormField { DoubleInputFormField.displayName = "DoubleInputFormField" // 重要,必须 displayName 中带有 FormField 才可以被识别为 FormField。 // 如果你的代码需要兼容 IE,以下两行不可缺少。 +// 即使不需要兼容 IE,也不可直接覆盖,如 DoubleInputFormField.defaultProps = {}; DoubleInputFormField.defaultProps = assign({}, FormField.defaultProps); DoubleInputFormField.propTypes = assign({}, FormField.propTypes); diff --git a/site/start/base/index.md b/site/start/base/index.md index af43d9b0..24c04d48 100644 --- a/site/start/base/index.md +++ b/site/start/base/index.md @@ -33,15 +33,15 @@ The easiest way to start hacking on UXCore is using the following CodePen Demo: If you're just getting started, you can download the starter kit. The starter kit is initialized by [NOWA](http://nowa-webpack.github.io/web/index.html?en) which is our project-level development and production solution collections. -Download Starter Kit 0.2 +Download Starter Kit ## Installation The fastest way to get started is to serve JavaScript and CSS from the CDN ```html - -