diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..2a99dae --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,14 @@ +{ + "extends": "vaadin", + "env": { + "browser": true, + "node": true, + "es6": true + }, + "plugins": [ + "html" + ], + "globals": { + "Polymer": false + } +} diff --git a/.gemini.yml b/.gemini.yml new file mode 100644 index 0000000..67bd05f --- /dev/null +++ b/.gemini.yml @@ -0,0 +1,49 @@ +rootUrl: http://127.0.0.1:3000/test/visual +gridUrl: http://127.0.0.1:4444/wd/hub +screenshotsDir: ./test/visual/screens + +system: + plugins: + express: + port: 3000 + sauce: true + +browsers: + chrome: + desiredCapabilities: + browserName: "chrome" + version: "55.0" + platform: "Windows 10" + + firefox: + desiredCapabilities: + browserName: "firefox" + version: "47.0" + platform: "Windows 10" + + edge: + desiredCapabilities: + browserName: "microsoftedge" + version: "14" + platform: "Windows 10" + + # The following setups don't currently work due to Selenium SafariDriver issue + # https://github.com/vaadin/vaadin-element-skeleton/issues/19 + # + # safari: + # desiredCapabilities: + # browserName: "safari" + # version: "10.0" + # platform: "OS X 10.11" + # + # iphone: + # desiredCapabilities: + # browserName: "iphone" + # version: "9.2" + # platform: "OS X 10.11" + # + # ipad: + # desiredCapabilities: + # browserName: "ipad" + # version: "9.2" + # platform: "OS X 10.11" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7bf6eb1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bower_components +node_modules diff --git a/.stylelintrc b/.stylelintrc new file mode 100644 index 0000000..b2189e2 --- /dev/null +++ b/.stylelintrc @@ -0,0 +1,3 @@ +{ + "extends": "stylelint-config-vaadin" +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ad4f48c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +sudo: false +dist: trusty +language: node_js +node_js: stable + +cache: + directories: + - node_modules + +addons: + firefox: latest + google-chrome: latest + +install: + - npm install + - npm install -g bower + - bower install + +before_script: + - gulp lint + - ([ "$TRAVIS_EVENT_TYPE" = "pull_request" ] || TRAVIS_BRANCH=quick/${TRAVIS_BUILD_ID} xvfb-run -s '-screen 0 1024x768x24' wct) + +script: + - ([ "$TRAVIS_EVENT_TYPE" = "pull_request" ] || gemini test test/visual) + - xvfb-run -s '-screen 0 1024x768x24' wct diff --git a/LICENSE b/LICENSE index 8dada3e..d656cec 100644 --- a/LICENSE +++ b/LICENSE @@ -175,18 +175,7 @@ END OF TERMS AND CONDITIONS - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} + Copyright 2017 Vaadin Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..940bfb9 --- /dev/null +++ b/README.md @@ -0,0 +1,74 @@ +![Bower version](https://img.shields.io/bower/v/vaadin-button.svg) +[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://beta.webcomponents.org/element/vaadin/vaadin-button) +[![Build Status](https://travis-ci.org/vaadin/vaadin-button.svg?branch=master)](https://travis-ci.org/vaadin/vaadin-button) +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/vaadin/vaadin-core-elements?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) + +# <vaadin-button> + +[Live Demo ↗](https://cdn.vaadin.com/vaadin-core-elements/master/vaadin-button/demo/) + +[<vaadin-button>](https://vaadin.com/elements/-/element/vaadin-button) is a [Polymer](http://polymer-project.org) element providing <element-functionality>, part of the [Vaadin Core Elements](https://vaadin.com/elements). + + +```html + + ... + +``` + +[Screenshot of vaadin-button](https://vaadin.com/elements/-/element/vaadin-button) + + +## Contributing + +1. Fork the `vaadin-button` repository and clone it locally. + +1. Make sure you have [npm](https://www.npmjs.com/) installed. + +1. When in the `vaadin-button` directory, run `npm install` to install dependencies. + + +## Running demos and tests in browser + +1. Install [polyserve](https://www.npmjs.com/package/polyserve): `npm install -g polyserve` + +1. When in the `vaadin-button` directory, run `polyserve --open`, browser will automatically open the component API documentation. + +1. You can also open demo or in-browser tests by adding **demo** or **test** to the URL, for example: + + - http://127.0.0.1:8080/components/vaadin-date-picker/demo + - http://127.0.0.1:8080/components/vaadin-date-picker/test + + +## Running tests from the command line + +1. Install [web-component-tester](https://www.npmjs.com/package/web-component-tester): `npm install -g web-component-tester` + +1. When in the `vaadin-button` directory, run `wct` or `npm test` + + +## Following the coding style + +We are using [ESLint](http://eslint.org/) for linting JavaScript code. You can check if your code is following our standards by running `gulp lint`, which will automatically lint all `.js` files as well as JavaScript snippets inside `.html` files. + + +## Creating a pull request + + - Make sure your code is compliant with our code linters: `gulp lint` + - Check that tests are passing: `npm test` + - [Submit a pull request](https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github) with detailed title and description + - Wait for response from one of Vaadin Elements team members + + +## License + +Apache License 2.0 diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..af64769 --- /dev/null +++ b/bower.json @@ -0,0 +1,39 @@ +{ + "name": "vaadin-button", + "homepage": "https://vaadin.com/elements", + "authors": [ + "Vaadin Ltd" + ], + "description": "vaadin-button", + "main": "vaadin-button.html", + "keywords": [ + "Vaadin", + "button", + "web-components", + "web-component", + "polymer" + ], + "license": "Apache-2.0", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "gulpfile.js", + "package.json", + "wct.conf.js" + ], + "devDependencies": { + "web-component-tester": "^5.0.0", + "test-fixture": "2.0.0", + "elements-demo-resources": "vaadin/elements-demo-resources#2.0-preview", + "iron-component-page": "polymerelements/iron-component-page#2.0-preview", + "iron-demo-helpers": "polymerelements/iron-demo-helpers#2.0-preview" + }, + "resolutions": { + "test-fixture": "^2.0.0" + }, + "dependencies": { + "polymer": "Polymer/polymer#2.0-preview" + } +} diff --git a/demo/advanced.html b/demo/advanced.html new file mode 100644 index 0000000..5fa024f --- /dev/null +++ b/demo/advanced.html @@ -0,0 +1,21 @@ + + + + + + + + vaadin-button Advanced Examples + + + + + + +
+ + + +
+ + diff --git a/demo/common.html b/demo/common.html new file mode 100644 index 0000000..5b1c47d --- /dev/null +++ b/demo/common.html @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + diff --git a/demo/index.html b/demo/index.html new file mode 100644 index 0000000..3218b31 --- /dev/null +++ b/demo/index.html @@ -0,0 +1,27 @@ + + + + + + + + vaadin-button Basic Examples + + + + + + +
+ + + +

Sample example

+ + + +
+ + diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..87b24ef --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,48 @@ +'use strict'; + +var gulp = require('gulp'); +var eslint = require('gulp-eslint'); +var htmlExtract = require('gulp-html-extract'); +var stylelint = require('gulp-stylelint'); + +gulp.task('lint', ['lint:js', 'lint:html', 'lint:css']); + +gulp.task('lint:js', function() { + return gulp.src([ + '*.js', + 'test/*.js' + ]) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError('fail')); +}); + +gulp.task('lint:html', function() { + return gulp.src([ + '*.html', + 'demo/*.html', + 'test/*.html' + ]) + .pipe(htmlExtract({ + sel: 'script, code-example code' + })) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError('fail')); +}); + +gulp.task('lint:css', function() { + return gulp.src([ + '*.html', + 'demo/*.html', + 'test/*.html' + ]) + .pipe(htmlExtract({ + sel: 'style' + })) + .pipe(stylelint({ + reporters: [ + {formatter: 'string', console: true} + ] + })); +}); diff --git a/index.html b/index.html new file mode 100644 index 0000000..4704e37 --- /dev/null +++ b/index.html @@ -0,0 +1,14 @@ + + + + + vaadin-button + + + + + + + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..621cb26 --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "vaadin-button", + "version": "0.1.0", + "description": "vaadin-button", + "main": "vaadin-button.html", + "repository": "vaadin/vaadin-button", + "keywords": [ + "Vaadin", + "button", + "web-components", + "web-component", + "polymer" + ], + "author": "Vaadin Ltd", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/vaadin/vaadin-button/issues" + }, + "homepage": "https://vaadin.com/elements", + "scripts": { + "test": "wct" + }, + "devDependencies": { + "gemini": "^4.17.1", + "gemini-express": "^1.0.0", + "gemini-sauce": "^1.0.0", + "gulp": "latest", + "gulp-html-extract": "^0.0.3", + "gulp-eslint": "^3.0.1", + "gulp-stylelint": "^3.7.0", + "eslint-plugin-html": "^1.7.0", + "eslint-config-vaadin": "^0.1.0", + "stylelint-config-vaadin": "^0.1.0", + "web-component-tester": "^5.0.0" + } +} diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..bc18cdd Binary files /dev/null and b/screenshot.png differ diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 0000000..6105413 --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,11 @@ +{ + "globals": { + "WCT": false, + "describe": false, + "beforeEach": false, + "fixture": false, + "it": false, + "expect": false, + "gemini": false + } +} diff --git a/test/index.html b/test/index.html new file mode 100644 index 0000000..e6a79c5 --- /dev/null +++ b/test/index.html @@ -0,0 +1,23 @@ + + + + + + + vaadin-button tests + + + + + + + + diff --git a/test/sample-test.html b/test/sample-test.html new file mode 100644 index 0000000..35dca05 --- /dev/null +++ b/test/sample-test.html @@ -0,0 +1,31 @@ + + + + + vaadin-button tests + + + + + + + + + + + diff --git a/test/visual/index.html b/test/visual/index.html new file mode 100644 index 0000000..432935a --- /dev/null +++ b/test/visual/index.html @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + diff --git a/test/visual/test.js b/test/visual/test.js new file mode 100644 index 0000000..0b83fb1 --- /dev/null +++ b/test/visual/test.js @@ -0,0 +1,17 @@ +gemini.suite('vaadin-element', function(rootSuite) { + + rootSuite.setUrl('/'); + + gemini.suite('button', function(suite) { + suite + .setCaptureElements('#visual-tests') + .before(function(actions, find) { + this.button = find('button'); + }) + .capture('normal-button') + .capture('clicked-button', function(actions) { + actions.mouseDown(this.button); + }); + }); + +}); diff --git a/vaadin-button.html b/vaadin-button.html new file mode 100644 index 0000000..2cfdced --- /dev/null +++ b/vaadin-button.html @@ -0,0 +1,46 @@ + + + + + + + + + + + diff --git a/wct.conf.js b/wct.conf.js new file mode 100644 index 0000000..1bf1f24 --- /dev/null +++ b/wct.conf.js @@ -0,0 +1,25 @@ +module.exports = { + registerHooks: function(context) { + var crossPlatforms = [ + 'Windows 10/chrome@55', + 'Windows 10/firefox@50' + ]; + + var otherPlatforms = [ + 'OS X 10.11/iphone@10.0', + 'OS X 10.11/ipad@10.0', + 'Windows 10/microsoftedge@14', + 'OS X 10.11/safari@10.0' + ]; + + // run SauceLabs tests for pushes, except cases when branch contains 'quick/' + if (process.env.TRAVIS_EVENT_TYPE === 'push' && process.env.TRAVIS_BRANCH.indexOf('quick/') === -1) { + // crossPlatforms are not tested here, but in Selenium WebDriver (see .travis.yml) + context.options.plugins.sauce.browsers = otherPlatforms; + + // Run SauceLabs for daily builds, triggered by cron + } else if (process.env.TRAVIS_EVENT_TYPE === 'cron') { + context.options.plugins.sauce.browsers = crossPlatforms.concat(otherPlatforms); + } + } +};