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/miscellaneous.component.js | 71 ++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 frontend/app/common/miscellaneous.component.js (limited to 'frontend/app/common/miscellaneous.component.js') diff --git a/frontend/app/common/miscellaneous.component.js b/frontend/app/common/miscellaneous.component.js new file mode 100644 index 0000000..bf2c266 --- /dev/null +++ b/frontend/app/common/miscellaneous.component.js @@ -0,0 +1,71 @@ +import React, { Component } from 'react' +import { Link } from 'react-router-dom' +import { clamp, percent } from 'app/utils' + +export const Swatch = ({ color }) => ( +
+) + +export const Dot = ({ color }) => ( +
+) + +export const Columns = ({ count, margin, width, object, children, className }) => { + if (!object || !object.length) object = children + if (!object || !object.length) return null + margin = margin || 380 + width = width || 250 + count = count || Math.floor((window.innerWidth - margin) / width) + let columns = [] + let len = object.length + let j = 0 + for (let i = 0; i < count; i++) { + let column_len = len * (i + 1) / count + let column = [] + for (; j < column_len; j++) { + column.push(
{object[j]}
) + } + columns.push(
{column}
) + if (j >= len) break + } + return ( +
+ {columns} +
+ ) +} + +export const Statistic = ({ name, value, link }) => ( +
+
{link ? {name} : name}
+
{value}
+
+) + +export const Detections = ({ detections, labels }) => ( + (detections || []).map(({ label, rect }, i) => ( +
+ {labels && {label.replace(/_/g, ' ')}} +
+ ) +)) + +export const Progress = ({ current, total }) => ( +
+
+
+) -- cgit v1.2.3-70-g09d2