From a1b4bc347124e2a4ffe3db2b9175adfe5d4adcad Mon Sep 17 00:00:00 2001 From: Hermann <blumh@ethz.ch> Date: Thu, 7 Jun 2018 21:52:48 +0200 Subject: [PATCH] add chip element --- src/views/elements.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/views/elements.js b/src/views/elements.js index ade6109..e2f52ed 100644 --- a/src/views/elements.js +++ b/src/views/elements.js @@ -5,6 +5,7 @@ import { Toolbar, ToolbarTitle, Card, + Icon, } from 'polythene-mithril'; export const icons = { @@ -270,6 +271,33 @@ export class selectGroup { } } +export class chip { + view({ attrs: { svg, color = '#000000', background = '#dddddd', ...styleAttrs }, children }) { + return m('div', { + style: { + height: '32px', + 'background-color': '#ffffff', + 'border-radius': '16px', + padding: '4px 8px', + display: 'inline-flex', + ...styleAttrs, + }, + }, [ + svg && m('div', { + style: { + 'background-color': background, + 'border-radius': '12px', + margin: '0px 4px 0px -2px', + height: '24px', + width: '24px', + padding: '2px 2px 2px 4px', + }, + }, m(Icon, { svg: { content: m.trust(svg) }, size: 'small', style: { color } })), + m('div', { style: { 'line-height': '24px' } }, children), + ]); + } +} + export class submitButton { view({ attrs: { args, active, text } }) { const argsCopy = args; -- GitLab