6 Commits

Author SHA1 Message Date
Josh Creek 77049455b9 chore(#2): Update version number 2022-10-08 22:34:18 +01:00
Josh Creek f549faab16 feat(#2): Add image customisation for mid-spinner 2022-10-08 22:32:24 +01:00
Josh Creek fced394f3e Merge pull request #14 from jcreek/12-empty-lines-in-the-textarea-are-added-to-the-spinner-as-names
12 empty lines in the textarea are added to the spinner as names
2022-10-08 17:26:23 +01:00
Josh Creek c51fca8425 chore(#12): Update package version 2022-10-08 17:25:01 +01:00
Josh Creek 866346ea01 fix(#12): Fix empty lines being added to spinner 2022-10-08 17:24:49 +01:00
Josh Creek 050f87301c Merge pull request #13 from jcreek/1-add-state-to-localstorage
1 add state to localstorage
2022-10-08 17:20:26 +01:00
3 changed files with 41 additions and 11 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "SelectionWheel",
"version": "1.3.0",
"version": "1.4.0",
"description": "A fun and simple selection wheel.",
"main": "index.js",
"scripts": {
+27 -1
View File
@@ -26,6 +26,8 @@ const color = d3.scaleOrdinal(d3.schemeCategory10);
let data = [];
const testData = ['Person 1', 'Person 2', 'Person 3', 'Person 4'];
let imageUrlForSpinner = '';
// eslint-disable-next-line no-unused-vars
function rotTween(to) {
const i = d3.interpolate(oldrotation % 360, rotation);
@@ -57,13 +59,31 @@ function makeArrowAndCircle(
.attr('d', `M-${r * 0.15},0L0,${r * 0.05}L0,-${r * 0.05}Z`)
.style('fill', 'black');
// draw spin circle
if (imageUrlForSpinner.length > 0) {
const defs = svg.append('svg:defs');
defs.append('svg:pattern')
.attr('id', 'image')
.attr('width', 1)
.attr('height', 1)
.attr('patternContentUnits', 'objectBoundingBox')
.append('svg:image')
.attr('xlink:href', imageUrlForSpinner)
.attr('width', 1)
.attr('height', 1)
.attr('x', 0)
.attr('y', 0)
.attr('preserveAspectRatio', 'xMaxYMax slice');
}
container
.append('circle')
.attr('cx', 0)
.attr('cy', 0)
.attr('r', 60)
.style('fill', 'white')
.style('fill', 'url(#image)')
.style('cursor', 'pointer');
if (imageUrlForSpinner.length === 0) {
// spin text
container
.append('text')
@@ -74,6 +94,7 @@ function makeArrowAndCircle(
.style('font-weight', 'bold')
.style('font-size', '30px');
}
}
function drawWheel() {
const svg = d3
@@ -182,7 +203,7 @@ function startOver() {
function startSpinning() {
const textArea = <HTMLInputElement>document.getElementById('input-lines');
const inputData = textArea.value.trim()
? textArea.value.split('\n')
? textArea.value.split('\n').filter((elm) => elm)
: testData;
const tempData = [];
for (let index = 0; index < inputData.length; index += 1) {
@@ -237,6 +258,11 @@ textArea.addEventListener('keyup', () => {
window.localStorage.TextEditorData = textArea.value;
});
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('imgUrl')) {
imageUrlForSpinner = urlParams.get('imgUrl');
}
if (process.env.NODE_ENV === 'production') {
loadServiceWorker();
}
+4
View File
@@ -176,6 +176,10 @@ text{
margin-bottom: 50px;
}
#image{
width: 100%;
}
/* Buttons */
.button {