From a17b76ac75f506f5da6fe8adf9c36632b60d4226 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 26 Sep 2020 14:56:02 +0200 Subject: refactor to use app-rooted js imports --- frontend/app/common/menubutton.component.js | 128 ++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 frontend/app/common/menubutton.component.js (limited to 'frontend/app/common/menubutton.component.js') diff --git a/frontend/app/common/menubutton.component.js b/frontend/app/common/menubutton.component.js new file mode 100644 index 0000000..5fd8e2f --- /dev/null +++ b/frontend/app/common/menubutton.component.js @@ -0,0 +1,128 @@ +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: + }, + // 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