From ef78bc6a084f92b4794e987b5832240d85b6479e Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 22 Jul 2020 14:05:15 +0200 Subject: refactor app using babel module-resolver --- .../frontend/app/common/menubutton.component.js | 133 +++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 animism-align/frontend/app/common/menubutton.component.js (limited to 'animism-align/frontend/app/common/menubutton.component.js') diff --git a/animism-align/frontend/app/common/menubutton.component.js b/animism-align/frontend/app/common/menubutton.component.js new file mode 100644 index 0000000..ce26d74 --- /dev/null +++ b/animism-align/frontend/app/common/menubutton.component.js @@ -0,0 +1,133 @@ +import React, { Component } from 'react' +import { Route, Link } from 'react-router-dom' +import { history } from 'app/store' + +const icons = { + upload: { + title: 'Upload', + image: '/static/img/add.svg', + // svg: , + // svg: + // svg: + svg: , + }, + new: { + title: 'New', + image: '/static/img/add.svg', + svg: , + // svg: , + // svg: + }, + save: { + title: 'Export', + image: '/static/img/save.svg', + svg: , + }, + saved: { + title: 'Saved', + image: '/static/img/folder.svg', + svg: , + }, + recent: { + title: 'Recent', + image: '/static/img/history.svg', + svg: , + }, + random: { + title: 'Random', + image: '/static/img/random.svg', + // svg: , + svg: + }, + menu: { + title: 'Menu', + image: '/static/img/menu.svg', + svg: , + }, + list: { + title: 'List', + image: '/static/img/view_list.svg', + svg: , + }, + edit: { + title: 'Edit', + image: '/static/img/edit.svg', + svg: + }, + delete: { + title: 'Delete', + image: '/static/img/delete.svg', + svg: + }, + back: { + title: 'Back', + image: '/static/img/back.svg', + svg: , + }, + image_search: { + title: 'Search', + image: '/static/img/image_search.svg', + svg: , + }, + search: { + title: 'Search', + image: '/static/img/search.svg', + svg: , + }, + open_in_new: { + title: 'Open', + image: '/static/img/open_in_new.svg', + svg: , + }, + test: { + title: 'Test', + image: '/static/img/fastfood.svg', + svg: + }, + copy: { + title: 'Copy', + image: '/static/img/copy.svg', + svg: , + }, + // export: { + // title: 'Export', + // image: '/static/img/export.svg', + // svg: , + // }, +} + +const goBack = () => history.goBack() + +export const MenuButton = ({ name, href, onClick, label, children, className }) => { + const { svg, title } = icons[name] + if (name === 'back') { + onClick = goBack + } + if (href) { + return ( + +
{svg}
+ {label === false ? "" : title} + {children} + + ) + } else { + return ( +
+
{svg}
+ {label === false ? "" : title} + {children} +
+ ) + } +} + +export const SmallMenuButton = (props) => ( + +) + +export const MenuRoute = ({ component: Component, props, ...rest }) => ( + ( + + )}/> +) -- cgit v1.2.3-70-g09d2