Skip to content
This repository has been archived by the owner on Jan 16, 2018. It is now read-only.

Commit

Permalink
Merge 9a2c5d7 into 54ab80e
Browse files Browse the repository at this point in the history
  • Loading branch information
carloslancha committed Dec 15, 2017
2 parents 54ab80e + 9a2c5d7 commit 9fe39d4
Show file tree
Hide file tree
Showing 25 changed files with 1,714 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"jest": "jest",
"lerna": "lerna bootstrap -- --no-optional --no-package-lock",
"lint": "eslint packages/clay-*/src/*.js packages/clay-*/src/**/*.js && npm run mcritic",
"mcritic": "mcritic packages/ --ignore '**/{browserslist-config-clay-components,generator-metal-clay,clay-dropdown,clay-alert,clay-list,clay-management-toolbar,clay-card,node_modules}/**'",
"mcritic": "mcritic packages/ --ignore '**/{browserslist-config-clay-components,generator-metal-clay,clay-dropdown,clay-alert,clay-grid,clay-list,clay-management-toolbar,clay-card,node_modules}/**'",
"precommit": "lint-staged",
"prettier": "prettier-eslint packages/clay-*/src/*.js packages/clay-*/src/**/*.js",
"start": "http-server . -p 4000",
Expand Down
11 changes: 10 additions & 1 deletion packages/clay-card/src/ClayCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ import templates from './ClayCard.soy.js';
/**
* Metal ClayCard component.
*/
class ClayCard extends Component {}
class ClayCard extends Component {
/**
* Continues the propagation of the checkbox changed event
* @param {!Event} event
* @private
*/
handleItemCheckboxClick_(event) {
this.emit('itemToggled', event);
}
}

/**
* State definition.
Expand Down
2 changes: 2 additions & 0 deletions packages/clay-card/src/ClayCard.soy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
{@param? elementClasses: string}
{@param? fileType: string}
{@param? fileTypeStyle: string}
{@param? handleItemCheckboxClick_: any}
{@param? href: string}
{@param? icon: string}
{@param? id: string}
Expand Down Expand Up @@ -78,6 +79,7 @@
{call ClayCheckbox.render}
{param checked: $selected /}
{param disabled: $disabled /}
{param events: ['change': $handleItemCheckboxClick_] /}
{param labelContent kind="html"}
{$visualArea}
{/param}
Expand Down
11 changes: 10 additions & 1 deletion packages/clay-card/src/ClayFileCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ import templates from './ClayFileCard.soy.js';
/**
* Metal ClayFileCard component.
*/
class ClayFileCard extends Component {}
class ClayFileCard extends Component {
/**
* Continues the propagation of the checkbox changed event
* @param {!Event} event
* @private
*/
handleItemToggled_(event) {
this.emit('itemToggled', event);
}
}

/**
* State definition.
Expand Down
2 changes: 2 additions & 0 deletions packages/clay-card/src/ClayFileCard.soy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
{@param? elementClasses: string}
{@param? fileType: string}
{@param? fileTypeStyle: string}
{@param? handleItemToggled_: any}
{@param? href: string}
{@param? icon: string}
{@param? id: string}
Expand All @@ -40,6 +41,7 @@
{param contentRenderer: 'file' /}
{param disabled: $disabled /}
{param elementClasses: $classes /}
{param events: ['itemToggled': $handleItemToggled_ ] /}
{param fileType: $fileType /}
{param fileTypeStyle: $fileTypeStyle /}
{param icon: $icon ?: 'documents-and-media' /}
Expand Down
11 changes: 10 additions & 1 deletion packages/clay-card/src/ClayHorizontalCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ import templates from './ClayHorizontalCard.soy.js';
/**
* Metal ClayHorizontalCard component.
*/
class ClayHorizontalCard extends Component {}
class ClayHorizontalCard extends Component {
/**
* Continues the propagation of the checkbox changed event
* @param {!Event} event
* @private
*/
handleItemCheckboxClick_(event) {
this.emit('itemToggled', event);
}
}

/**
* State definition.
Expand Down
2 changes: 2 additions & 0 deletions packages/clay-card/src/ClayHorizontalCard.soy
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
]>}
{@param? disabled: bool}
{@param? elementClasses: string}
{@param? handleItemCheckboxClick_: any}
{@param? href: string}
{@param? icon: string}
{@param? id: string}
Expand Down Expand Up @@ -54,6 +55,7 @@
{call ClayCheckbox.render}
{param checked: $selected /}
{param disabled: $disabled /}
{param events: ['change': $handleItemCheckboxClick_] /}
{param labelContent kind="html"}
<div class="card card-horizontal">
{$descriptiveArea}
Expand Down
11 changes: 10 additions & 1 deletion packages/clay-card/src/ClayImageCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ import templates from './ClayImageCard.soy.js';
/**
* Metal ClayImageCard component.
*/
class ClayImageCard extends Component {}
class ClayImageCard extends Component {
/**
* Continues the propagation of the checkbox changed event
* @param {!Event} event
* @private
*/
handleItemToggled_(event) {
this.emit('itemToggled', event);
}
}

/**
* State definition.
Expand Down
2 changes: 2 additions & 0 deletions packages/clay-card/src/ClayImageCard.soy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
{@param? elementClasses: string}
{@param? fileType: string}
{@param? fileTypeStyle: string}
{@param? handleItemToggled_: any}
{@param? href: string}
{@param? icon: string}
{@param? id: string}
Expand Down Expand Up @@ -42,6 +43,7 @@
{param contentRenderer: 'image' /}
{param disabled: $disabled /}
{param elementClasses: $classes /}
{param events: ['itemToggled': $handleItemToggled_ ] /}
{param fileType: $fileType /}
{param fileTypeStyle: $fileTypeStyle /}
{param href: $href /}
Expand Down
11 changes: 10 additions & 1 deletion packages/clay-card/src/ClayUserCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ import templates from './ClayUserCard.soy.js';
/**
* Metal ClayUserCard component.
*/
class ClayUserCard extends Component {}
class ClayUserCard extends Component {
/**
* Continues the propagation of the checkbox changed event
* @param {!Event} event
* @private
*/
handleItemToggled_(event) {
this.emit('itemToggled', event);
}
}

/**
* State definition.
Expand Down
2 changes: 2 additions & 0 deletions packages/clay-card/src/ClayUserCard.soy
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
]>}
{@param? disabled: bool}
{@param? elementClasses: string}
{@param? handleItemToggled_: any}
{@param? href: string}
{@param? id: string}
{@param? imageAlt: string}
Expand All @@ -37,6 +38,7 @@
{param contentRenderer: 'user' /}
{param disabled: $disabled /}
{param elementClasses: $elementClasses /}
{param events: ['itemToggled': $handleItemToggled_ ] /}
{param fileType: $initials /}
{param fileTypeStyle: $userColor /}
{param href: $href /}
Expand Down
15 changes: 15 additions & 0 deletions packages/clay-card/src/__tests__/ClayFileCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,21 @@ describe('ClayFileCard', function() {
expect(component).toMatchSnapshot();
});

it('should render a selectable ClayFileCard and emit an event on item toggle', () => {
component = new ClayFileCard({
selectable: true,
spritemap: spritemap,
title: 'My Title',
});

const spy = jest.spyOn(component, 'emit');

component.element.querySelector('input[type="checkbox"]').click();

expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledWith('itemToggled', expect.any(Object));
});

it('should fail when no spritemap is passed', function() {
expect(() => {
component = new ClayFileCard({
Expand Down
15 changes: 15 additions & 0 deletions packages/clay-card/src/__tests__/ClayHorizontalCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ describe('ClayHorizontalCard', function() {
expect(component).toMatchSnapshot();
});

it('should render a selectable ClayHorizontalCard and emit an event on item toggle', () => {
component = new ClayHorizontalCard({
selectable: true,
spritemap: spritemap,
title: 'My Title',
});

const spy = jest.spyOn(component, 'emit');

component.element.querySelector('input[type="checkbox"]').click();

expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledWith('itemToggled', expect.any(Object));
});

it('should fail when no spritemap is passed', function() {
expect(() => {
component = new ClayHorizontalCard({
Expand Down
15 changes: 15 additions & 0 deletions packages/clay-card/src/__tests__/ClayImageCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,21 @@ describe('ClayImageCard', function() {
expect(component).toMatchSnapshot();
});

it('should render a selectable ClayImageCard and emit an event on item toggle', () => {
component = new ClayImageCard({
selectable: true,
spritemap: spritemap,
title: 'My Title',
});

const spy = jest.spyOn(component, 'emit');

component.element.querySelector('input[type="checkbox"]').click();

expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledWith('itemToggled', expect.any(Object));
});

it('should fail when no title is passed', function() {
expect(() => {
component = new ClayImageCard();
Expand Down
15 changes: 15 additions & 0 deletions packages/clay-card/src/__tests__/ClayUserCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,21 @@ describe('ClayUserCard', function() {
expect(component).toMatchSnapshot();
});

it('should render a selectable ClayUserCard and emit an event on item toggle', () => {
component = new ClayUserCard({
name: 'User Name',
selectable: true,
spritemap: spritemap,
});

const spy = jest.spyOn(component, 'emit');

component.element.querySelector('input[type="checkbox"]').click();

expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledWith('itemToggled', expect.any(Object));
});

it('should fail when no name is passed', function() {
expect(() => {
component = new ClayUserCard();
Expand Down
29 changes: 29 additions & 0 deletions packages/clay-grid/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Software License Agreement (BSD License)

Copyright (c) 2014, Liferay Inc.
All rights reserved.

Redistribution and use of this software in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:

* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.

* The name of Liferay Inc. may not be used to endorse or promote products
derived from this software without specific prior
written permission of Liferay Inc.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 changes: 26 additions & 0 deletions packages/clay-grid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# clay-grid

Metal ClayGrid Component

## Setup

1. Install NodeJS >= v0.12.0 and NPM >= v3.0.0, if you don't have it yet. You
can find it [here](https://nodejs.org).

2. Install local dependencies:

```
npm install
```

3. Build the code:

```
npm run build
```

4. Open the demo at demos/index.html on your browser.

## Contribute

We'd love to get contributions from you! Please, check our [Contributing Guidelines](CONTRIBUTING.md) to see how you can help us improve.
Binary file added packages/clay-grid/demos/image1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9fe39d4

Please sign in to comment.