Skip to content

Commit

Permalink
Merge pull request #1210 from boton/issue/1209-add-title-to-sticker
Browse files Browse the repository at this point in the history
Fixes #1209 - Add title to clay-sticker
  • Loading branch information
carloslancha authored Oct 2, 2018
2 parents 0a14437 + a72ca87 commit 081a017
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/clay-sticker/demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ <h2>Sticker Positions Outside</h2>
imageSrc: './avatar.jpg',
shape: 'circle',
size: 'sm',
title: 'My awesome title',
},
'#images-block'
);
Expand All @@ -258,6 +259,7 @@ <h2>Sticker Positions Outside</h2>
{
imageSrc: './avatar.jpg',
shape: 'circle',
title: 'My awesome title',
},
'#images-block'
);
Expand All @@ -267,6 +269,7 @@ <h2>Sticker Positions Outside</h2>
imageSrc: './avatar.jpg',
shape: 'circle',
size: 'lg',
title: 'My awesome title',
},
'#images-block'
);
Expand All @@ -276,6 +279,7 @@ <h2>Sticker Positions Outside</h2>
imageSrc: './avatar.jpg',
shape: 'circle',
size: 'xl',
title: 'My awesome title',
},
'#images-block'
);
Expand Down
9 changes: 9 additions & 0 deletions packages/clay-sticker/src/ClaySticker.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ ClaySticker.STATE = {
'unstyled',
'warning',
]).value('primary'),

/**
* Title to be applied to the sticker element.
* @default undefined
* @instance
* @memberof ClaySticker
* @type {?(string|undefined)}
*/
title: Config.string(),
};

defineWebComponent('clay-sticker', ClaySticker);
Expand Down
5 changes: 5 additions & 0 deletions packages/clay-sticker/src/ClaySticker.soy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{@param? size: string}
{@param? spritemap: string}
{@param? style: string}
{@param? title: string}

{let $attributes kind="attributes"}
class="sticker
Expand All @@ -42,6 +43,10 @@
{if $id}
id="{$id}"
{/if}

{if $title}
title="{$title}"
{/if}
{/let}

<span {$attributes}>
Expand Down
8 changes: 8 additions & 0 deletions packages/clay-sticker/src/__tests__/ClaySticker.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,12 @@ describe('ClaySticker', function() {

expect(sticker).toMatchSnapshot();
});

it('should render a sticker with title', () => {
sticker = new ClaySticker({
title: 'My awesome title',
});

expect(sticker).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ exports[`ClaySticker should render a sticker with label 1`] = `
</span>
`;
exports[`ClaySticker should render a sticker with title 1`] = `
<span class="sticker sticker-rounded sticker-primary" title="My awesome title">
<span class="sticker-overlay"></span>
</span>
`;
exports[`ClaySticker should render a top left positioned sticker 1`] = `
<span class="sticker sticker-rounded sticker-primary sticker-top-left">
<span class="sticker-overlay"></span>
Expand Down

0 comments on commit 081a017

Please sign in to comment.