14 Commits

Author SHA1 Message Date
Josh Creek ff58967c8c Merge pull request #21 from jcreek/19-add-touchclick-to-spin-help-text-depending-on-device
doc(#19): Add click to spin help text
2022-10-09 19:47:12 +01:00
Josh Creek d15f55b94b doc(#19): Add click to spin help text 2022-10-09 19:40:39 +01:00
Josh Creek d411a76c49 Merge pull request #20 from jcreek/17-when-highlightedgreyed-out-invert-the-name-text-to-white
feat(#17): Change colour of selected names
2022-10-09 19:37:30 +01:00
Josh Creek 546c647234 feat(#17): Change colour of selected names 2022-10-09 19:36:42 +01:00
Josh Creek e7f80e1885 Merge branch 'master' of https://github.com/jcreek/SelectionWheel 2022-10-09 19:28:45 +01:00
Josh Creek 5dc201eac7 chore(*): Remove navigation preload
This is unnecessary as there are only two pages.
2022-10-09 15:34:57 +01:00
Josh Creek bd7ef970b9 chore(*): Update package version 2022-10-09 12:54:21 +01:00
Josh Creek 0d641c4f66 fix(*): Fix ability to click circle to spin 2022-10-09 12:53:47 +01:00
Josh Creek 983b097a3c fix(*): Include missing assets 2022-10-08 23:50:22 +01:00
Josh Creek 86b94e2e6a docs(*): Add custom image to explainer text 2022-10-08 23:09:48 +01:00
Josh Creek 9e56971116 Merge pull request #15 from jcreek/2-add-image-querystring-functionality-for-centre-of-spinner
feat(#2): Add image customisation for mid-spinner
2022-10-08 22:36:41 +01:00
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
5 changed files with 56 additions and 21 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "SelectionWheel", "name": "SelectionWheel",
"version": "1.3.1", "version": "1.4.1",
"description": "A fun and simple selection wheel.", "description": "A fun and simple selection wheel.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
+44 -16
View File
@@ -4,6 +4,9 @@ import loadServiceWorker from './loadServiceWorker';
require('./assets/favicon.ico'); require('./assets/favicon.ico');
require('./assets/android-chrome-192x192.png'); require('./assets/android-chrome-192x192.png');
require('./assets/android-chrome-512x512.png'); require('./assets/android-chrome-512x512.png');
require('./assets/apple-touch-icon.png');
require('./assets/favicon-16x16.png');
require('./assets/favicon-32x32.png');
require('./styles/main.scss'); require('./styles/main.scss');
const padding = { const padding = {
@@ -26,6 +29,8 @@ const color = d3.scaleOrdinal(d3.schemeCategory10);
let data = []; let data = [];
const testData = ['Person 1', 'Person 2', 'Person 3', 'Person 4']; const testData = ['Person 1', 'Person 2', 'Person 3', 'Person 4'];
let imageUrlForSpinner = '';
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
function rotTween(to) { function rotTween(to) {
const i = d3.interpolate(oldrotation % 360, rotation); const i = d3.interpolate(oldrotation % 360, rotation);
@@ -57,22 +62,39 @@ function makeArrowAndCircle(
.attr('d', `M-${r * 0.15},0L0,${r * 0.05}L0,-${r * 0.05}Z`) .attr('d', `M-${r * 0.15},0L0,${r * 0.05}L0,-${r * 0.05}Z`)
.style('fill', 'black'); .style('fill', 'black');
// draw spin circle // draw spin circle
container if (imageUrlForSpinner.length > 0) {
.append('circle') const defs = svg.append('svg:defs');
.attr('cx', 0)
.attr('cy', 0) defs.append('svg:pattern')
.attr('r', 60) .attr('id', 'image')
.style('fill', 'white') .attr('width', 1)
.style('cursor', 'pointer'); .attr('height', 1)
// spin text .attr('patternContentUnits', 'objectBoundingBox')
container .append('svg:image')
.append('text') .attr('xlink:href', imageUrlForSpinner)
.attr('x', 0) .attr('width', 1)
.attr('y', 10) .attr('height', 1)
.attr('text-anchor', 'middle') .attr('x', 0)
.text('SPIN') .attr('y', 0)
.style('font-weight', 'bold') .attr('preserveAspectRatio', 'xMaxYMax slice');
.style('font-size', '30px');
container
.append('circle')
.attr('cx', 0)
.attr('cy', 0)
.attr('r', 60)
.style('fill', 'white')
.style('fill', 'url(#image)')
.style('cursor', 'pointer');
} else {
container
.append('circle')
.attr('cx', 0)
.attr('cy', 0)
.attr('r', 60)
.style('fill', 'white')
.style('cursor', 'pointer');
}
} }
function drawWheel() { function drawWheel() {
@@ -158,6 +180,7 @@ function drawWheel() {
.on('end', () => { .on('end', () => {
// mark question as seen // mark question as seen
d3.select(`.slice:nth-child(${picked + 1}) path`).attr('fill', '#111'); d3.select(`.slice:nth-child(${picked + 1}) path`).attr('fill', '#111');
d3.select(`.slice:nth-child(${picked + 1}) text`).attr('fill', '#ffffff');
// populate question // populate question
d3.select('#question h1').text(data[picked].label.trim()); d3.select('#question h1').text(data[picked].label.trim());
oldrotation = rotation; oldrotation = rotation;
@@ -237,6 +260,11 @@ textArea.addEventListener('keyup', () => {
window.localStorage.TextEditorData = textArea.value; 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') { if (process.env.NODE_ENV === 'production') {
loadServiceWorker(); loadServiceWorker();
} }
-3
View File
@@ -7,9 +7,6 @@ import { registerRoute, NavigationRoute, Route } from 'workbox-routing';
// eslint-disable-next-line no-underscore-dangle, no-restricted-globals // eslint-disable-next-line no-underscore-dangle, no-restricted-globals
precacheAndRoute(self.__WB_MANIFEST); precacheAndRoute(self.__WB_MANIFEST);
// Enable navigation preload - this should reduce navigation latency
navigationPreload.enable();
const navigationRoute = new NavigationRoute(new NetworkFirst({ const navigationRoute = new NavigationRoute(new NetworkFirst({
cacheName: 'navigations', cacheName: 'navigations',
})); }));
+4
View File
@@ -176,6 +176,10 @@ text{
margin-bottom: 50px; margin-bottom: 50px;
} }
#image{
width: 100%;
}
/* Buttons */ /* Buttons */
.button { .button {
+7 -1
View File
@@ -40,7 +40,13 @@
<div id="input-container"> <div id="input-container">
<textarea id="input-lines" class="input-items" rows="15" cols="60" name="text" <textarea id="input-lines" class="input-items" rows="15" cols="60" name="text"
placeholder="Enter names to be shuffled, one per line. Leave this area empty in order to use a default set of generated names."></textarea> placeholder="Enter names to be shuffled, one per line. Leave this area empty in order to use a default set of generated names.
Click or tap on the wheel to spin it.
You can also customise the centre of the spinner with an image. Just put ?imgUrl= at the end of the web address and the URL of the image you want to use.
For example, https://wheel.jcreek.co.uk/?imgUrl=https://www.mammal.org.uk/wp-content/uploads/2021/09/red-fox-300x300.jpg"></textarea>
<button id="startSpinning" class="input-items button button-green" role="button">Start spinning</button> <button id="startSpinning" class="input-items button button-green" role="button">Start spinning</button>
</div> </div>