Skip to content
Snippets Groups Projects
Commit acb141b2 authored by Hermann's avatar Hermann
Browse files

move icons and iconbuttons to elements

parent 39bb90bb
No related branches found
No related tags found
No related merge requests found
const m = require('mithril'); import m from 'mithril';
import { IconButton } from 'polythene-mithril';
export class inputGroup { export class inputGroup {
constructor(vnode) { constructor(vnode) {
...@@ -51,3 +52,30 @@ export class submitButton { ...@@ -51,3 +52,30 @@ export class submitButton {
return m('div.btn', argsCopy, text); return m('div.btn', argsCopy, text);
} }
} }
export const icons = {
iconSearchSVG: '<svg width="24" height="24" viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>',
iconBackSVG: '<svg width="24" height="24" viewBox="0 0 24 24"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg>',
iconClearSVG: '<svg width="24" height="24" viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>',
};
export const BackButton = {
view: ({ attrs }) => m(IconButton, {
icon: { svg: m.trust(icons.iconBackSVG) },
ink: false,
events: { onclick: attrs.leave },
}),
};
export const ClearButton = {
view: ({ attrs }) => m(IconButton, {
icon: { svg: m.trust(icons.iconClearSVG) },
ink: false,
events: { onclick: attrs.clear },
}),
};
export const SearchIcon = {
view: () => m(IconButton, {
icon: { svg: m.trust(icons.iconSearchSVG) },
inactive: true,
}),
};
...@@ -6,33 +6,9 @@ import { ...@@ -6,33 +6,9 @@ import {
} from 'polythene-mithril'; } from 'polythene-mithril';
import infinite from 'mithril-infinite'; import infinite from 'mithril-infinite';
import { debounce } from '../utils'; import { debounce } from '../utils';
import { icons, BackButton, ClearButton, SearchIcon } from './elements';
const iconSearchSVG = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z\"/></svg>";
const iconBackSVG = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z\"/></svg>";
const iconClearSVG = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\"/></svg>";
const createSearchField = () => { const createSearchField = () => {
const BackButton = {
view: ({ attrs }) => m(IconButton, {
icon: { svg: m.trust(iconBackSVG) },
ink: false,
events: { onclick: attrs.leave },
}),
};
const ClearButton = {
view: ({ attrs }) => m(IconButton, {
icon: { svg: m.trust(iconClearSVG) },
ink: false,
events: { onclick: attrs.clear },
}),
};
const SearchIcon = {
view: () => m(IconButton, {
icon: { svg: m.trust(iconSearchSVG) },
inactive: true,
}),
};
return { return {
oninit: vnode => { oninit: vnode => {
const value = Stream(""); const value = Stream("");
...@@ -123,7 +99,7 @@ export default class SelectList { ...@@ -123,7 +99,7 @@ export default class SelectList {
return m('div', [ return m('div', [
this.selected ? m(Toolbar, { compact: true }, [ this.selected ? m(Toolbar, { compact: true }, [
m(IconButton, { m(IconButton, {
icon: { svg: m.trust(iconClearSVG) }, icon: { svg: m.trust(icons.iconClearSVG) },
ink: false, ink: false,
events: { onclick: () => { this.selected = null; } }, events: { onclick: () => { this.selected = null; } },
}), }),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment