diff --git a/.gitignore b/.gitignore index 6724578..a5292fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ KiCad/CanGrow/CanGrow-backups +KiCad/CanGrow/CanGrow.kicad_sch-bak +KiCad/CanGrow/fp-info-cache diff --git a/playground/html/material-gauge-gh-pages/LICENSE.md b/playground/html/material-gauge-gh-pages/LICENSE.md new file mode 100644 index 0000000..0bed89b --- /dev/null +++ b/playground/html/material-gauge-gh-pages/LICENSE.md @@ -0,0 +1,7 @@ +Copyright (c) 2015 Stephen Thomas + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/playground/html/material-gauge-gh-pages/README.md b/playground/html/material-gauge-gh-pages/README.md new file mode 100644 index 0000000..6d4e0f2 --- /dev/null +++ b/playground/html/material-gauge-gh-pages/README.md @@ -0,0 +1,69 @@ +A simple [Material Design](https://www.google.com/design/spec/material-design/introduction.html) gauge control implemented in pure CSS/HTML. Includes a JavaScript implementation to change the gauge value dynamically. + +Origin: https://github.com/sathomas/material-gauge + +![](example.png) + +Check out the [live example](http://sathomas.me/material-gauge/). + +The basic markup for the gauge is as follows: + +``` +
+
+
+
+
+
+
+
+
+ No + + Yes +
+
+``` + +The gauge value is specified by `transform:` property on both the `.gauge__data` and `.gauge__needle` elements. The value for the rotation is +`0.5 × X - 0.5` turns, where `X` ranges from 0 (left-most position) to 1 (right-most position). For example, to set the gauge at "3/4 full", you can specify the `transform` as + +``` +.gauge__data { + -webkit-transform: rotate(-0.125turn); + -moz-transform: rotate(-0.125turn); + -ms-transform: rotate(-0.125turn); + -o-transform: rotate(-0.125turn); + transform: rotate(-0.125turn); +} +.gauge__needle { + -webkit-transform: rotate(-0.125turn); + -moz-transform: rotate(-0.125turn); + -ms-transform: rotate(-0.125turn); + -o-transform: rotate(-0.125turn); + transform: rotate(-0.125turn); +} +``` + +As the example indicates, you probably want to use vendor prefixes for maximum compatibility. + +If you wish, you can use the included JavaScript component to set and update the gauge value. The component API is quite simple. First, create a new object: + + var gauge = new Gauge(); + +You can optionally pass a DOM element (constructed as above) to the constructor: + + var gauge = new Gauge(document.getElementById("myGauge")); + +If you don't pass the DOM element as a constructor parameter, you can initialize it later using the `element()` method: + + gauge.element(document.getElementById("myGauge")); + +> Note that the component will not construct the DOM element itself. You must supply a pre-constructed element with the sub-elements indicated above. + +Once you have an initialized constructor, set the value (between 0 and 1) using the `value()` method: + + gauge.value(0.75); + +As a final enhancement, if you're going to update the gauge live on the page, you can add the `gauge--liveupdate` class to the parent element. This will enable a nice CSS-based animation for value updates. + diff --git a/playground/html/material-gauge-gh-pages/example.png b/playground/html/material-gauge-gh-pages/example.png new file mode 100644 index 0000000..b2bcea6 Binary files /dev/null and b/playground/html/material-gauge-gh-pages/example.png differ diff --git a/playground/html/material-gauge-gh-pages/index.html b/playground/html/material-gauge-gh-pages/index.html new file mode 100644 index 0000000..079fd33 --- /dev/null +++ b/playground/html/material-gauge-gh-pages/index.html @@ -0,0 +1,51 @@ + + + + + + Material Design Gauge + + + + + + +
+
+
+
+
+
+
+
+
+ No + + Yes +
+
+ + + + diff --git a/playground/html/material-gauge-gh-pages/material-gauge.css b/playground/html/material-gauge-gh-pages/material-gauge.css new file mode 100644 index 0000000..46e27e5 --- /dev/null +++ b/playground/html/material-gauge-gh-pages/material-gauge.css @@ -0,0 +1,192 @@ +/* + * #### Gauge Component + * + * The standard markup for the component is: + * + *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * No + * + * Yes + *
+ *
+ */ + +/* + * First define all of the relevant rules that aren't dependent + * on the size of the gauge. We want to collect the size-depenent + * rules in one place to make it easier to adjust the size. + */ + +.gauge { + position: relative; +} + +.gauge__container { + margin: 0; + padding: 0; + position: absolute; + left: 50%; + overflow: hidden; + text-align: center; + -webkit-transform: translateX(-50%); + -moz-transform: translateX(-50%); + -ms-transform: translateX(-50%); + -o-transform: translateX(-50%); + transform: translateX(-50%); +} + +.gauge__background { + z-index: 0; + position: absolute; + background-color: #C5CAE9; + top: 0; + border-radius: 300px 300px 0 0; +} + +.gauge__data { + z-index: 1; + position: absolute; + background-color: #3F51B5; + margin-left: auto; + margin-right: auto; + border-radius: 300px 300px 0 0; + -webkit-transform-origin: center bottom; + -moz-transform-origin: center bottom; + -ms-transform-origin: center bottom; + -o-transform-origin: center bottom; + transform-origin: center bottom; +} + +.gauge__center { + z-index: 2; + position: absolute; + background-color: #1d211e; + margin-right: auto; + border-radius: 300px 300px 0 0; +} + +.gauge__marker { + z-index: 3; + background-color: #fff; + position: absolute; + width: 1px; +} + +.gauge__needle { + z-index: 4; + background-color: #E91E63; + height: 3px; + position: absolute; + -webkit-transform-origin: left center; + -moz-transform-origin: left center; + -ms-transform-origin: left center; + -o-transform-origin: left center; + transform-origin: left center; +} + +.gauge__labels { + display: table; + margin: 0 auto; + position: relative; +} + +.gauge__label--low { + display: table-cell; + text-align: center; +} + +.gauge__label--spacer { + display: table-cell; +} + +.gauge__label--high { + display: table-cell; + text-align: center; +} + +/* + * Now define the rules that depend on the size of + * the gauge. We start with sizing for a small mobile + * device. + */ + +.gauge { height: calc(120px + 3em); } +.gauge__container { width: 240px; height: 120px; } +.gauge__marker { height: 120px; left: 119.5px; } +.gauge__background { width: 240px; height: 120px; } +.gauge__center { width: 144px; height: 72px; top: 48px; margin-left: 48px; } +.gauge__data { width: 240px; height: 120px; } +.gauge__needle { left: 120px; top: 117px; width: 120px; } +.gauge__labels { top: 120px; width: 240px; } +.gauge__label--low { width: 48px; } +.gauge__label--spacer { width: 144px; } +.gauge__label--high { width: 48px; } + +/* + * Increase the gauge size slightly on larger viewports. + */ + + @media only screen and (min-width: 400px) { + .gauge { height: calc(150px + 3em); } + .gauge__container { width: 300px; height: 150px; } + .gauge__marker { height: 150px; left: 149.5px; } + .gauge__background { width: 300px; height: 150px; } + .gauge__center { width: 180px; height: 90px; top: 60px; margin-left: 60px; } + .gauge__data { width: 300px; height: 150px; } + .gauge__needle { left: 150px; top: 147px; width: 150px; } + .gauge__labels { top: 150px; width: 300px; } + .gauge__label--low { width: 60px; } + .gauge__label--spacer { width: 180px; } + .gauge__label--high { width: 60px; } +} + +/* + * As an option, the `gauge--liveupdate` class can be added + * to the main gauge element. When this class is present, + * we add a transition that animates any changes to the gauge + * value. Currently, the app does not use this option because + * all the inputs that can change gauge values are present + * on tab panels that are different from the gauge itself. + * Therefore, users won't be able to see any gauge changes + * when they make input changes. The code is available, though, + * should this change. + */ + +.gauge--liveupdate .gauge__data, +.gauge--liveupdate .gauge__needle { + -webkit-transition: all 1s ease-in-out; + -moz-transition: all 1s ease-in-out; + -ms-transition: all 1s ease-in-out; + -o-transition: all 1s ease-in-out; + transition: all 1s ease-in-out; +} + +/* + * For a given gauge value, x, ranging from 0.0 to 1.0, set + * the `transform: rotate()` property according to the + * following equation: `-0.5 + 0.5x turns` The default + * properties below represent an x value of 0. + */ + +.gauge__data { + -webkit-transform: rotate(-.50turn); + -moz-transform: rotate(-.50turn); + -ms-transform: rotate(-.50turn); + -o-transform: rotate(-.50turn); + transform: rotate(-.50turn); +} +.gauge__needle { + -webkit-transform: rotate(-.50turn); + -moz-transform: rotate(-.50turn); + -ms-transform: rotate(-.50turn); + -o-transform: rotate(-.50turn); + transform: rotate(-.50turn); +} diff --git a/playground/html/material-gauge-gh-pages/material-gauge.js b/playground/html/material-gauge-gh-pages/material-gauge.js new file mode 100644 index 0000000..17fa69d --- /dev/null +++ b/playground/html/material-gauge-gh-pages/material-gauge.js @@ -0,0 +1,67 @@ +// #### Gauge + +// The Gauge object encapsulates the behavior +// of simple gauge. Most of the implementation +// is in the CSS rules, but we do have a bit +// of JavaScript to set or read the gauge value + +function Gauge(el) { + + // ##### Private Properties and Attributes + + var element, // Containing element for the info component + data, // `.gauge__data` element + needle, // `.gauge__needle` element + value = 0.0, // Current gauge value from 0 to 1 + prop; // Style for transform + + // ##### Private Methods and Functions + + var setElement = function(el) { + // Keep a reference to the various elements and sub-elements + element = el; + data = element.querySelector(".gauge__data"); + needle = element.querySelector(".gauge__needle"); + }; + + var setValue = function(x) { + value = x; + var turns = -0.5 + (x * 0.5); + data.style[prop] = "rotate(" + turns + "turn)"; + needle.style[prop] = "rotate(" + turns + "turn)"; + }; + + // ##### Object to be Returned + + function exports() { }; + + // ##### Public API Methods + + exports.element = function(el) { + if (!arguments.length) { return element; } + setElement(el); + return this; + }; + + exports.value = function(x) { + if (!arguments.length) { return value; } + setValue(x); + return this; + }; + + // ##### Initialization + + var body = document.getElementsByTagName("body")[0]; + ["webkitTransform", "mozTransform", "msTransform", "oTransform", "transform"]. + forEach(function(p) { + if (typeof body.style[p] !== "undefined") { prop = p; } + } + ); + + if (arguments.length) { + setElement(el); + } + + return exports; + +};