From 2e301bdd51bdb62565ca229caba3bc8e65d64197 Mon Sep 17 00:00:00 2001 From: Kode Date: Wed, 13 Jun 2018 20:03:26 +0100 Subject: [PATCH] This closes #184, closes #126 --- app/Helper.php | 24 ++ public/css/app.css | 8 + public/js/app.js | 560 ++++++++++++++++++++++++++------ public/mix-manifest.json | 4 +- resources/assets/sass/_app.scss | 6 + resources/views/item.blade.php | 2 +- 6 files changed, 502 insertions(+), 102 deletions(-) diff --git a/app/Helper.php b/app/Helper.php index 513c4287..cb973e21 100644 --- a/app/Helper.php +++ b/app/Helper.php @@ -10,3 +10,27 @@ function format_bytes($bytes, $is_drive_size = true, $beforeunit = '', $afteruni elseif($labels[$x] == "MB") return(round($bytes, 2).$beforeunit.$labels[$x].$afterunit); else return(round($bytes, 0).$beforeunit.$labels[$x].$afterunit); } + +function get_brightness($hex) { + // returns brightness value from 0 to 255 + // strip off any leading # + $hex = str_replace('#', '', $hex); + if(strlen($hex) == 3) { + $hex = $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2]; + } + + $c_r = hexdec(substr($hex, 0, 2)); + $c_g = hexdec(substr($hex, 2, 2)); + $c_b = hexdec(substr($hex, 4, 2)); + + return (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; +} + +function title_color($hex) +{ + if(get_brightness($hex) > 130) { + return ' black'; + } else { + return ' white'; + } +} \ No newline at end of file diff --git a/public/css/app.css b/public/css/app.css index 02518f0a..4a528c96 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -569,6 +569,14 @@ body { font-size: 16px; } +.item .title.black { + color: #000; +} + +.item .title.white { + color: #fff; +} + .item .details { width: 100%; } diff --git a/public/js/app.js b/public/js/app.js index c5b88db9..e7ac9ebd 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -1,164 +1,526 @@ -/** - * Huebee PACKAGED v2.0.0 - * 1-click color picker - * MIT license - * http://huebee.buzz - * Copyright 2018 Metafizzy - */ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 0); +/******/ }) +/************************************************************************/ +/******/ ({ -!function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var n=this._events=this._events||{},i=n[t]=n[t]||[];return i.indexOf(e)==-1&&i.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var n=this._onceEvents=this._onceEvents||{},i=n[t]=n[t]||{};return i[e]=!0,this}},e.off=function(t,e){var n=this._events&&this._events[t];if(n&&n.length){var i=n.indexOf(e);return i!=-1&&n.splice(i,1),this}},e.emitEvent=function(t,e){var n=this._events&&this._events[t];if(n&&n.length){var i=0,o=n[i];e=e||[];for(var s=this._onceEvents&&this._onceEvents[t];o;){var r=s&&s[o];r&&(this.off(t,o),delete s[o]),o.apply(this,e),i+=r?0:1,o=n[i]}return this}},t}),function(t,e){"function"==typeof define&&define.amd?define("unipointer/unipointer",["ev-emitter/ev-emitter"],function(n){return e(t,n)}):"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter")):t.Unipointer=e(t,t.EvEmitter)}(window,function(t,e){function n(){}function i(){}var o=i.prototype=Object.create(e.prototype);o.bindStartEvent=function(t){this._bindStartEvent(t,!0)},o.unbindStartEvent=function(t){this._bindStartEvent(t,!1)},o._bindStartEvent=function(e,n){n=void 0===n||!!n;var i=n?"addEventListener":"removeEventListener";t.navigator.pointerEnabled?e[i]("pointerdown",this):t.navigator.msPointerEnabled?e[i]("MSPointerDown",this):(e[i]("mousedown",this),e[i]("touchstart",this))},o.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},o.getTouch=function(t){for(var e=0;e.5;var o=this.colorGrid[e.toUpperCase()];this.updateCursor(o),this.setTexts(),this.setBackgrounds(),n||this.emitEvent("change",[e,t.hue,t.sat,t.lum])}},f.setTexts=function(){if(this.setTextElems)for(var t=0;t .5;var o = this.colorGrid[e.toUpperCase()];this.updateCursor(o), this.setTexts(), this.setBackgrounds(), n || this.emitEvent("change", [e, t.hue, t.sat, t.lum]); + } + }, f.setTexts = function () { + if (this.setTextElems) for (var t = 0; t < this.setTextElems.length; t++) { + var e = this.setTextElems[t], + n = "INPUT" == e.nodeName ? "value" : "textContent";e[n] = this.color; + } + }, f.setBackgrounds = function () { + if (this.setBGElems) for (var t = this.isLight ? "#222" : "white", e = 0; e < this.setBGElems.length; e++) { + var n = this.setBGElems[e];n.style.backgroundColor = this.color, n.style.color = t; + } + }, f.updateCursor = function (t) { + if (this.isOpen) { + var e = t ? "remove" : "add";if (this.cursor.classList[e]("is-hidden"), t) { + var n = this.gridSize, + i = this.canvasOffset, + o = this.cursorBorder;this.cursor.style.left = t.x * n + i.x - o + "px", this.cursor.style.top = t.y * n + i.y - o + "px"; + } + } + };var C = t.console, + S = document.readyState;"complete" == S || "interactive" == S ? o() : document.addEventListener("DOMContentLoaded", o), i.data = function (t) { + t = h(t);var e = t && t.huebeeGUID;return e && l[e]; + };var y = document.createElement("canvas");y.width = y.height = 1;var _ = y.getContext("2d");return i; +}); + +/***/ }), + +/***/ "./resources/assets/sass/app.scss": +/***/ (function(module, exports) { + +// removed by extract-text-webpack-plugin + +/***/ }), + +/***/ 0: +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__("./resources/assets/js/huebee.js"); +__webpack_require__("./resources/assets/js/app.js"); +module.exports = __webpack_require__("./resources/assets/sass/app.scss"); + + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/public/mix-manifest.json b/public/mix-manifest.json index aa923137..8a1763b6 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,4 +1,4 @@ { - "/css/app.css": "/css/app.css?id=7e76b8c135b6dbd38363", - "/js/app.js": "/js/app.js?id=24ea5e5c1fbea3461a14" + "/js/app.js": "/js/app.js?id=d7ae290137b7fd06f300", + "/css/app.css": "/css/app.css?id=ad5c7660f3763a242dfc" } \ No newline at end of file diff --git a/resources/assets/sass/_app.scss b/resources/assets/sass/_app.scss index 11d71d99..d80f938c 100644 --- a/resources/assets/sass/_app.scss +++ b/resources/assets/sass/_app.scss @@ -272,6 +272,12 @@ body { } .title { font-size: 16px; + &.black { + color: #000; + } + &.white { + color: #fff; + } } .details { width: 100%; diff --git a/resources/views/item.blade.php b/resources/views/item.blade.php index 333bdaa1..3525e1df 100644 --- a/resources/views/item.blade.php +++ b/resources/views/item.blade.php @@ -6,7 +6,7 @@ @endif
-
{{ $app->title }}
+
{{ $app->title }}
@if(isset($app->config->enabled) && ((bool)$app->config->enabled === true))
@endif