Skip to content

Commit

Permalink
feat(list): add property for setting size on icon
Browse files Browse the repository at this point in the history
  • Loading branch information
jgroth authored and adrianschmidt committed Sep 10, 2019
1 parent 33e7bc1 commit 4eafbbc
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/components/list/list-renderer-config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { IconSize } from '../icon/icon.types';
import { ListType } from './list.types';

export interface ListRendererConfig {
isMenu?: boolean;
isOpen?: boolean;
badgeIcons?: boolean;
type?: ListType;
iconSize?: IconSize;
}
4 changes: 3 additions & 1 deletion src/components/list/list-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export class ListRenderer {
'mdc-list--two-line': twoLines,
selectable: selectableListTypes.includes(config.type),
'mdc-list--avatar-list': badgeIcons,
'list--compact':
twoLines && ['small', 'x-small'].includes(config.iconSize),
};

return (
Expand Down Expand Up @@ -151,7 +153,7 @@ export class ListRenderer {
class="mdc-list-item__graphic"
name={item.icon}
style={style}
size={config.isMenu ? 'small' : 'medium'}
size={config.iconSize}
/>
);
}
Expand Down
10 changes: 10 additions & 0 deletions src/components/list/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,14 @@
color: white;
}
}

&.mdc-list--two-line.list--compact {
.mdc-list-item {
height: 4rem;

.mdc-list-item__text {
margin-top: pxToRem(-4);
}
}
}
}
8 changes: 8 additions & 0 deletions src/components/list/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Watch,
} from '@stencil/core';
import { ListItem, ListSeparator } from '../../interface';
import { IconSize } from '../icon/icon.types';
import { ListRenderer } from './list-renderer';
import { ListRendererConfig } from './list-renderer-config';
import { ListType } from './list.types';
Expand All @@ -33,6 +34,12 @@ export class List {
@Prop()
public badgeIcons: boolean;

/**
* Size of the icons in the list
*/
@Prop()
public iconSize: IconSize = 'medium';

/**
* The type of the list, omit to get a regular list. Available types are:
* `selectable`: regular list with single selection.
Expand Down Expand Up @@ -81,6 +88,7 @@ export class List {
this.config = {
badgeIcons: this.badgeIcons,
type: this.type,
iconSize: this.iconSize,
};
return this.listRenderer.render(this.items, this.config);
}
Expand Down
1 change: 1 addition & 0 deletions src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class Menu {
public render() {
const config: ListRendererConfig = {
isMenu: true,
iconSize: 'small',
isOpen: this.open,
badgeIcons: this.badgeIcons,
type: 'selectable',
Expand Down
1 change: 1 addition & 0 deletions src/components/picker/picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ export class Picker {
>
<limel-list
badgeIcons={hasIcons}
iconSize="small"
onChange={this.handleListChange}
type="selectable"
items={this.items}
Expand Down

0 comments on commit 4eafbbc

Please sign in to comment.