Skip to content

Commit

Permalink
Update project structure using the generator-element template
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeno Rocha committed Jun 29, 2014
1 parent 3665181 commit e9279ae
Show file tree
Hide file tree
Showing 9 changed files with 349 additions and 125 deletions.
16 changes: 12 additions & 4 deletions .editorconfig
@@ -1,11 +1,19 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org

root = true

[*]
indent_style = tab
# Change these settings to your own preference
indent_style = space
indent_size = 4

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
bower_components/
node_modules/
42 changes: 42 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,42 @@
module.exports = function(grunt) {

grunt.initConfig({
'connect': {
demo: {
options: {
open: true,
keepalive: true
}
}
},
'gh-pages': {
options: {
clone: 'bower_components/video-camera-element'
},
src: [
'bower_components/**/*',
'!bower_components/video-camera-element/**/*',
'demo/*', 'src/*', 'index.html'
]
},
'replace': {
example: {
src: ['src/*'],
dest: 'dist/',
replacements: [{
from: 'bower_components',
to: '..'
}]
}
}
});

grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-gh-pages');
grunt.loadNpmTasks('grunt-text-replace');

grunt.registerTask('build', ['replace']);
grunt.registerTask('deploy', ['gh-pages']);
grunt.registerTask('server', ['connect']);

};
73 changes: 55 additions & 18 deletions README.md
@@ -1,42 +1,86 @@
# <video-camera>
# <video-camera-element>

Web Component wrapper for [getUserMedia API](http://dev.w3.org/2011/webrtc/editor/getusermedia.html) using Polymer.
> Web Component wrapper for [getUserMedia API](http://dev.w3.org/2011/webrtc/editor/getusermedia.html) using Polymer.
## Demo

![Camera Element](http://f.cl.ly/items/3U3E2w0n3q0i3Y403s1Y/camera-element.gif)

> [Check it live](http://eduardolundgren.github.io/video-camera-element).
[Check it live!](http://eduardolundgren.github.io/video-camera-element)

## Install

Install the component using [Bower](http://bower.io/):

```sh
$ bower install video-camera-element --save
```

Or [download as ZIP](https://github.com/eduardolundgren/video-camera-element/archive/master.zip).

## Usage

1. Import Web Components' polyfill:

```html
<script src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.0.20130816/polymer.min.js"></script>
<script src="bower_components/platform/platform.js"></script>
```

2. Import Custom Element:

```html
<link rel="import" href="src/video-camera.html">
<link rel="import" href="bower_components/video-camera-element/dist/video-camera.html">
```

3. Start using it!

```html
<video is="video-camera"></video>
<video is="video-camera" autoplay></video>
```

## Options

Attribute | Options | Default | Description
--- | --- | --- | ---
`audio` | `true` | `false` | Capture audio using the device's local microphone
`filter` | `blur`, `brightness`, `contrast`, `hue-rotate`, `saturate`, `grayscale`, `sepia`, `invert` | None | Apply filter effects
Attribute | Options | Default | Description
--- | --- | --- | ---
`audio` | `true`, `false` | `false` | Capture audio using the device's local microphone
`filter` | `blur`, `brightness`, `contrast`, `hue-rotate`, `saturate`, `grayscale`, `sepia`, `invert` | None | Apply CSS filter effects

> See [getUserMedia API spec](http://dev.w3.org/2011/webrtc/editor/getusermedia.html).
## Development

In order to run it locally you'll need to fetch some dependencies and a basic server setup.

* Install [Bower](http://bower.io/) & [Grunt](http://gruntjs.com/):

```sh
$ [sudo] npm install -g bower grunt-cli
```

* Install local dependencies:

```sh
$ bower install && npm install
```

* To test your project, start the development server and open `http://localhost:8000`.

```sh
$ grunt server
```

* To build the distribution files before releasing a new version.

```sh
$ grunt build
```

* To provide a live demo, send everything to `gh-pages` branch.

```sh
$ grunt deploy
```

## Contributing

1. Fork it!
Expand All @@ -47,14 +91,7 @@ Attribute | Options

## History

* [v0.1.2](https://github.com/eduardolundgren/video-camera-element/releases/tag/0.1.2) September 18, 2013
* Rename element from `<camera>` to `<video-camera>`
* [v0.1.1](https://github.com/eduardolundgren/video-camera-element/releases/tag/0.1.1) August 21, 2013
* Add filter effects
* [v0.1.0](https://github.com/eduardolundgren/video-camera-element/releases/tag/0.1.0) August 20, 2013
* Initial development release
* v0.0.1 August 19, 2013
* Started project using [boilerplate-element](https://github.com/customelements/boilerplate-element)
For detailed changelog, check [Releases](https://github.com/eduardolundgren/video-camera-element/releases).

## License

Expand Down
19 changes: 19 additions & 0 deletions bower.json
@@ -0,0 +1,19 @@
{
"name": "video-camera-element",
"version": "0.1.2",
"description": "Web Component wrapper for getUserMedia API using Polymer",
"license": "MIT",
"main": "dist/video-camera.html",
"keywords": [
"polymer",
"web-components"
],
"ignore": [
"**/.*",
"node_modules",
"bower_components"
],
"dependencies": {
"polymer": "Polymer/polymer#~0.3.3"
}
}
102 changes: 102 additions & 0 deletions dist/video-camera.html
@@ -0,0 +1,102 @@
<!-- Import Polymer -->
<link rel="import" href="../../polymer/polymer.html">

<!-- Define your custom element -->
<polymer-element name="video-camera" extends="video" attributes="audio filter">
<script>
Polymer('video-camera', {
audio: false,

created: function() {
if (!window.URL) {
window.URL = window.URL || window.webkitURL || window.msURL || window.oURL;
}

if (!navigator.getUserMedia) {
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
}
},

ready: function() {
var that = this;

navigator.getUserMedia({
audio: that.audio,
video: true
},
function(stream) {
that.src = window.URL.createObjectURL(stream);
},
function(err) {
throw Error(err);
});
},

filterChanged: function(oldVal) {
var filter = this.filter;

this.classList.remove(oldVal);
this.classList.add(filter);
}
});
</script>

<style>
.blur {
-webkit-filter: blur(3px);
-moz-filter: blur(3px);
-ms-filter: blur(3px);
-o-filter: blur(3px);
filter: blur(3px);
}
.brightness {
-webkit-filter: brightness(5);
-moz-filter: brightness(5);
-ms-filter: brightness(5);
-o-filter: brightness(5);
filter: brightness(5);
}
.contrast {
-webkit-filter: contrast(8);
-moz-filter: contrast(8);
-ms-filter: contrast(8);
-o-filter: contrast(8);
filter: contrast(8);
}
.hue-rotate {
-webkit-filter: hue-rotate(90deg);
-moz-filter: hue-rotate(90deg);
-ms-filter: hue-rotate(90deg);
-o-filter: hue-rotate(90deg);
filter: hue-rotate(90deg);
}
.saturate {
-webkit-filter: saturate(10);
-moz-filter: saturate(10);
-ms-filter: saturate(10);
-o-filter: saturate(10);
filter: saturate(10);
}
.grayscale {
-webkit-filter: grayscale(1);
-moz-filter: grayscale(1);
-ms-filter: grayscale(1);
-o-filter: grayscale(1);
filter: grayscale(1);
}
.sepia {
-webkit-filter: sepia(1);
-moz-filter: sepia(1);
-ms-filter: sepia(1);
-o-filter: sepia(1);
filter: sepia(1);
}
.invert {
-webkit-filter: invert(1);
-moz-filter: invert(1);
-ms-filter: invert(1);
-o-filter: invert(1);
filter: invert(1);
}
</style>
</polymer-element>
18 changes: 9 additions & 9 deletions index.html
@@ -1,19 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>&lt;video-camera&gt;</title>
<meta charset="UTF-8">
<title>&lt;video-camera-element&gt;</title>

<!-- Importing Web Component's Polyfill -->
<script src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.0.20130816/polymer.min.js"></script>
<!-- Importing Web Component's Polyfill -->
<script src="bower_components/platform/platform.js"></script>

<!-- Importing Custom Elements -->
<link rel="import" href="src/video-camera.html">
<!-- Importing Custom Elements -->
<link rel="import" href="src/video-camera.html">
</head>
<body>

<!-- Using Custom Elements -->
<video is="video-camera" audio autoplay controls></video>
<!-- Using Custom Elements -->
<video is="video-camera" autoplay></video>

</body>
</html>
</html>
10 changes: 10 additions & 0 deletions package.json
@@ -0,0 +1,10 @@
{
"private": true,
"devDependencies": {
"grunt": "~0.4.1",
"grunt-cli": "~0.1.9",
"grunt-contrib-connect": "~0.8.0",
"grunt-gh-pages": "~0.9.1",
"grunt-text-replace": "~0.3.11"
}
}

0 comments on commit e9279ae

Please sign in to comment.