Skip to content

Commit

Permalink
feat(icon): add badge attribute to limel-icon, and only add extra p…
Browse files Browse the repository at this point in the history
…adding when true

Partially revert changes from fd006f8

BREAKING CHANGE: Reverts breaking change to limel-icon from v17.0.0 (fd006f8).
  • Loading branch information
adrianschmidt committed Sep 10, 2019
1 parent 2cadb8f commit 90b0f6c
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 16 deletions.
39 changes: 28 additions & 11 deletions src/components/icon/icon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,49 @@
}

:host([size="x-small"]) {
height: pxToRem(23);
width: pxToRem(23);
height: pxToRem(15) !important;
width: pxToRem(15) !important;
}
:host([size="small"]) {
height: pxToRem(20) !important;
width: pxToRem(20) !important;
}
:host([size="medium"]) {
height: pxToRem(25) !important;
width: pxToRem(25) !important;
}
:host([size="large"]) {
height: pxToRem(30) !important;
width: pxToRem(30) !important;
}

:host([badge][size="x-small"]) {
height: pxToRem(23) !important;
width: pxToRem(23) !important;

> div {
margin: pxToRem(4);
}
}
:host([size="small"]) {
height: pxToRem(30);
width: pxToRem(30);
:host([badge][size="small"]) {
height: pxToRem(30) !important;
width: pxToRem(30) !important;

> div {
margin: pxToRem(5);
}
}
:host([size="medium"]) {
height: pxToRem(41);
width: pxToRem(41);
:host([badge][size="medium"]) {
height: pxToRem(41) !important;
width: pxToRem(41) !important;

> div {
margin: pxToRem(8);
}
}
:host([size="large"]) {
height: pxToRem(46);
width: pxToRem(46);
:host([badge][size="large"]) {
height: pxToRem(46) !important;
width: pxToRem(46) !important;

> div {
margin: pxToRem(8);
Expand Down
7 changes: 7 additions & 0 deletions src/components/icon/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ export class Icon {
@Prop({ reflectToAttr: true })
public name: string;

/**
* Set to `true` to give the icon a round background with some padding.
* Only works when the `size` attribute is also set.
*/
@Prop({ reflectToAttr: true })
public badge: boolean;

@Prop({ context: 'config' })
public config: Config;

Expand Down
1 change: 1 addition & 0 deletions src/components/list/list-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export class ListRenderer {

return (
<limel-icon
badge={config.badgeIcons}
class="mdc-list-item__graphic"
name={item.icon}
style={style}
Expand Down
2 changes: 0 additions & 2 deletions src/components/list/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
limel-icon {
background-color: var(--icon-background-color, var(--lime-light-grey));
color: white;
height: pxToRem(30);
width: pxToRem(30);
}
}
}
17 changes: 14 additions & 3 deletions src/examples/icon/icon-background.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@ import { Component } from '@stencil/core';
export class IconBackgroundExample {
public render() {
return [
<limel-icon class="company" name="organization" size="x-small" />,
<limel-icon
badge={true}
class="company"
name="organization"
size="x-small"
/>,
<limel-icon
badge={true}
class="person"
name="user_group_man_man"
size="small"
/>,
<limel-icon class="deal" name="money" size="medium" />,
<limel-icon class="campaign" name="megaphone" size="large" />,
<limel-icon badge={true} class="deal" name="money" size="medium" />,
<limel-icon
badge={true}
class="campaign"
name="megaphone"
size="large"
/>,
];
}
}

0 comments on commit 90b0f6c

Please sign in to comment.