From 5ae4650b0f56b8c3a60efe313bc730136e89ede3 Mon Sep 17 00:00:00 2001
From: Kenny Carlile Guitar Diagrams JS - Testing
Testing
Preface - Setup
tags, or it could be in its own JavaScript file that you include or reference in some other way.
To give Guitar Diagrams JS a place to add the drawing, you'll need to specify a block-level element with an ID, such as the following:
-<div id="diagram1"></div>
- That div's ID doesn't need to be diagram1 as shown, but it needs to be a unique name that +
<div id="diagram-1"></div>
+ That div's ID doesn't need to be diagram-1 as shown, but it needs to be a unique name that you will reference later on in your code, like this:
-gdj1.addCanvas('diagram1');
+ gdj1.addCanvas('diagram-1');
This example demonstrates the most basic usage with a vertical fretboard and no additional options.
let gdj1 = new GuitarDiagramsJS();
-gdj1.config.canvasID = 'diagram1Canvas'; // specify the canvas element's an ID
-gdj1.addCanvas('diagram1'); // add the canvas to the specified element ID on the page
+gdj1.config.canvasID = 'diagram-1-canvas'; // specify the canvas element's an ID
+gdj1.addCanvas('diagram-1'); // add the canvas to the specified element ID on the page
gdj1.drawNeck(); // draw the fretboard
This example shows a vertical fretboard with the following configuration options:
@@ -60,9 +60,9 @@let gdj2 = new GuitarDiagramsJS();
-gdj2.config.canvasID = 'diagram2Canvas';
+gdj2.config.canvasID = 'diagram-2-canvas';
gdj2.config.stringNamesEnabled = true;
-gdj2.addCanvas('diagram2');
+gdj2.addCanvas('diagram-2');
gdj2.drawNeck();
gdj2.addMarker(1, 1, '1', GuitarDiagramsJS.Shape.Square); // add a square marker on string 1, fret 1, text '1'
gdj2.addMarker(2, 2, '2', GuitarDiagramsJS.Shape.Triangle); // add a triangle marker on string 2, fret 2, text '2'
@@ -79,7 +79,7 @@ Code
Example 3 - Changing string and fret count with custom string names and horizontal orientation
-
+
This example shows a horizontal fretboard with the following configuration options:
@@ -93,13 +93,13 @@ Example 3 - Changing string and fret cou
Code
let gdj3 = new GuitarDiagramsJS();
-gdj3.config.canvasID = 'diagram3Canvas';
+gdj3.config.canvasID = 'diagram-3-canvas';
gdj3.config.stringNamesEnabled = true; // set string names enabled
gdj3.config.orientHorizontally = true; // set horizontal orientation
gdj3.config.fretStartingNumber = 3; // set starting fret
gdj3.config.stringNames = ['D','A','D','G']; // set string names and count
gdj3.config.fretCount = 3; // set starting fret
-gdj3.addCanvas('diagram3');
+gdj3.addCanvas('diagram-3');
gdj3.drawNeck();
gdj3.addMarker(1, 1, '1', GuitarDiagramsJS.Shape.Square);
gdj3.addMarker(2, 2, '2', GuitarDiagramsJS.Shape.Triangle);
@@ -123,7 +123,7 @@ Code
Example 4 - Scaling
-
+
This example shows a vertical fretboard with the following configuration options:
@@ -133,9 +133,9 @@ Example 4 - Scaling
Code
let gdj4 = new GuitarDiagramsJS();
-gdj4.config.canvasID = 'diagram4Canvas';
+gdj4.config.canvasID = 'diagram-4-canvas';
gdj4.config.scaleFactor = .6; // set scaling factor (.6 == 60%)
-gdj4.addCanvas('diagram4');
+gdj4.addCanvas('diagram-4');
gdj4.drawNeck();
gdj4.addMarker(1, 1, '1', GuitarDiagramsJS.Shape.Square);
gdj4.addMarker(2, 2, '2', GuitarDiagramsJS.Shape.Triangle);
@@ -152,7 +152,7 @@ Code
Example 5 - Customizing visuals
-
+
This example, while _intentionally_ not very visually appealing, shows a vertical fretboard that has been customized with varying visual configuration options as shown below:
@@ -176,9 +176,9 @@ Example 5 - Customizing visuals
Code
let gdj5 = new GuitarDiagramsJS();
+gdj5.config.canvasID = 'diagram-5-canvas';
gdj5.config.stringNamesEnabled = true;
gdj5.config.fretStartingNumber = 2;
-gdj5.config.canvasID = 'diagram5Canvas';
gdj5.config.colorFretboard = '#FFE0B2'; // specify the fretboard background color
gdj5.config.colorNut = '#FFFFFF'; // specify the nut color
gdj5.config.colorNutOutline = '#7E5109'; // specify the nut outline color
@@ -189,7 +189,7 @@ Code
gdj5.config.colorLabel = '#FFFFFF'; // specify the label color for string names and starting fret
gdj5.config.markerStrokeWidth = 1; // specify the marker's stroke width
gdj5.config.markerFontSize = 10; // specify the marker text's font size
-gdj5.addCanvas('diagram5');
+gdj5.addCanvas('diagram-5');
gdj5.drawNeck();
gdj5.addMarker(1, 1, '1', GuitarDiagramsJS.Shape.Square);
gdj5.addMarker(2, 2, '2', GuitarDiagramsJS.Shape.Triangle);
@@ -202,6 +202,37 @@ Code
+
+ Example 6 - Controls
+
+
+
+
+
+ This example demonstrates some configuration options for controls as shown below:
+
+ - String names are enabled
+ - Image download button is enabled
+ - Adds the same 7 markers of various shapes with one blank marker (the same as the previous examples)
+
+ Code
+ let gdj6 = new GuitarDiagramsJS();
+gdj6.config.canvasID = 'diagram-6-canvas';
+gdj6.config.stringNamesEnabled = true;
+gdj6.config.downloadImageEnabled = true;
+gdj6.addCanvas('diagram-6');
+gdj6.drawNeck();
+gdj6.addMarker(1, 1, '1', GuitarDiagramsJS.Shape.Square);
+gdj6.addMarker(2, 2, '2', GuitarDiagramsJS.Shape.Triangle);
+gdj6.addMarker(3, 3, '3', GuitarDiagramsJS.Shape.Diamond);
+gdj6.addMarker(4, 4, '4');
+gdj6.addMarker(5, 5, '5');
+gdj6.addMarker(6, 4, '6');
+gdj6.addMarker(3, 1);
+gdj6.drawAllMarkers();
+
+
+
Guitar Diagram JS
diff --git a/docs/examples/js/main.js b/docs/examples/js/main.js
index 45b1ea0..ce86af4 100644
--- a/docs/examples/js/main.js
+++ b/docs/examples/js/main.js
@@ -12,16 +12,16 @@ import { GuitarDiagramsJS } from './guitar-diagrams-js/guitar-diagrams.js';
// ========== BEGIN example 1
let gdj1 = new GuitarDiagramsJS();
-gdj1.config.canvasID = 'diagram1Canvas'; // specify the canvas element's an ID
-gdj1.addCanvas('diagram1'); // add the canvas to the specified element ID on the page
+gdj1.config.canvasID = 'diagram-1-canvas'; // specify the canvas element's an ID
+gdj1.addCanvas('diagram-1'); // add the canvas to the specified element ID on the page
gdj1.drawNeck(); // draw the fretboard
// ========== END example 1
// ========== BEGIN example 2
let gdj2 = new GuitarDiagramsJS();
-gdj2.config.canvasID = 'diagram2Canvas';
+gdj2.config.canvasID = 'diagram-2-canvas';
gdj2.config.stringNamesEnabled = true;
-gdj2.addCanvas('diagram2');
+gdj2.addCanvas('diagram-2');
gdj2.drawNeck();
gdj2.addMarker(1, 1, '1', GuitarDiagramsJS.Shape.Square); // add a square marker on string 1, fret 1, text '1'
gdj2.addMarker(2, 2, '2', GuitarDiagramsJS.Shape.Triangle); // add a triangle marker on string 2, fret 2, text '2'
@@ -35,13 +35,13 @@ gdj2.drawAllMarkers(); // draw the markers
// ========== BEGIN example 3
let gdj3 = new GuitarDiagramsJS();
-gdj3.config.canvasID = 'diagram3Canvas';
+gdj3.config.canvasID = 'diagram-3-canvas';
gdj3.config.stringNamesEnabled = true; // set string names enabled
gdj3.config.orientHorizontally = true; // set horizontal orientation
gdj3.config.fretStartingNumber = 3; // set starting fret
gdj3.config.stringNames = ['D','A','D','G']; // set string names and count
gdj3.config.fretCount = 3; // set starting fret
-gdj3.addCanvas('diagram3');
+gdj3.addCanvas('diagram-3');
gdj3.drawNeck();
gdj3.addMarker(1, 1, '1', GuitarDiagramsJS.Shape.Square);
gdj3.addMarker(2, 2, '2', GuitarDiagramsJS.Shape.Triangle);
@@ -55,9 +55,9 @@ gdj3.drawAllMarkers();
// ========== BEGIN example 4
let gdj4 = new GuitarDiagramsJS();
-gdj4.config.canvasID = 'diagram4Canvas';
+gdj4.config.canvasID = 'diagram-4-canvas';
gdj4.config.scaleFactor = .6; // set scaling factor (.6 == 60%)
-gdj4.addCanvas('diagram4');
+gdj4.addCanvas('diagram-4');
gdj4.drawNeck();
gdj4.addMarker(1, 1, '1', GuitarDiagramsJS.Shape.Square);
gdj4.addMarker(2, 2, '2', GuitarDiagramsJS.Shape.Triangle);
@@ -71,9 +71,9 @@ gdj4.drawAllMarkers();
// ========== BEGIN example 5
let gdj5 = new GuitarDiagramsJS();
+gdj5.config.canvasID = 'diagram-5-canvas';
gdj5.config.stringNamesEnabled = true;
gdj5.config.fretStartingNumber = 2;
-gdj5.config.canvasID = 'diagram5Canvas';
gdj5.config.colorFretboard = '#FFE0B2'; // specify the fretboard background color
gdj5.config.colorNut = '#FFFFFF'; // specify the nut color
gdj5.config.colorNutOutline = '#7E5109'; // specify the nut outline color
@@ -84,7 +84,7 @@ gdj5.config.colorDiagramBackground = '#000000'; // specify the diagram backgroun
gdj5.config.colorLabel = '#FFFFFF'; // specify the label color for string names and starting fret
gdj5.config.markerStrokeWidth = 1; // specify the marker's stroke width
gdj5.config.markerFontSize = 10; // specify the marker text's font size
-gdj5.addCanvas('diagram5');
+gdj5.addCanvas('diagram-5');
gdj5.drawNeck();
gdj5.addMarker(1, 1, '1', GuitarDiagramsJS.Shape.Square);
gdj5.addMarker(2, 2, '2', GuitarDiagramsJS.Shape.Triangle);
@@ -95,3 +95,20 @@ gdj5.addMarker(6, 4, '6');
gdj5.addMarker(3, 1);
gdj5.drawAllMarkers();
// ========== END example 5
+
+// ========== BEGIN example 6
+let gdj6 = new GuitarDiagramsJS();
+gdj6.config.canvasID = 'diagram-6-canvas';
+gdj6.config.stringNamesEnabled = true;
+gdj6.config.downloadImageEnabled = true;
+gdj6.addCanvas('diagram-6');
+gdj6.drawNeck();
+gdj6.addMarker(1, 1, '1', GuitarDiagramsJS.Shape.Square);
+gdj6.addMarker(2, 2, '2', GuitarDiagramsJS.Shape.Triangle);
+gdj6.addMarker(3, 3, '3', GuitarDiagramsJS.Shape.Diamond);
+gdj6.addMarker(4, 4, '4');
+gdj6.addMarker(5, 5, '5');
+gdj6.addMarker(6, 4, '6');
+gdj6.addMarker(3, 1);
+gdj6.drawAllMarkers();
+// ========== END example 6
diff --git a/docs/examples/js/testing.js b/docs/examples/js/testing.js
index 3a9190d..93a3dae 100644
--- a/docs/examples/js/testing.js
+++ b/docs/examples/js/testing.js
@@ -12,7 +12,7 @@ import { GuitarDiagramsJS } from '../../../guitar-diagrams.js';
// ========== BEGIN testing
let gdjTesting = new GuitarDiagramsJS();
-gdjTesting.config.canvasID = 'diagramTestingCanvas';
+gdjTesting.config.canvasID = 'diagram-testing-canvas';
gdjTesting.config.stringNamesEnabled = true;
gdjTesting.config.orientHorizontally = true;
//gdj4.config.fretStartingNumber = 3;
diff --git a/guitar-diagrams.js b/guitar-diagrams.js
index 451f009..235ca1c 100644
--- a/guitar-diagrams.js
+++ b/guitar-diagrams.js
@@ -562,7 +562,7 @@ export class GuitarDiagramsJS {
let downloadButton = document.createElement('input');
downloadButton.type = 'button';
- downloadButton.id = this.#config.canvasID + 'DownloadButton';
+ downloadButton.id = this.#config.canvasID + '-download-button';
downloadButton.style = 'display: block;';
downloadButton.classList.add('guitar-diagrams-button-download');
downloadButton.value = String.fromCodePoint(0x1F4BE);
From 21949527cf8bf598a6a4029330a2c8aa736fc580 Mon Sep 17 00:00:00 2001
From: Kenny Carlile
Date: Thu, 30 May 2024 13:28:31 -0700
Subject: [PATCH 7/8] Changing linting to PR and push for main, develop
---
.github/workflows/linting.yml | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml
index 797a9b8..766b2bb 100644
--- a/.github/workflows/linting.yml
+++ b/.github/workflows/linting.yml
@@ -1,8 +1,14 @@
name: Linting
on: # yamllint disable-line rule:truthy
- push: null
- pull_request: null
+ push:
+ branches:
+ - main
+ - develop
+ pull_request:
+ branches:
+ - main
+ - develop
permissions: { }
From 9e8cae050cdbd33790fc7748c3f8f0b0a9a222cb Mon Sep 17 00:00:00 2001
From: Kenny Carlile
Date: Thu, 30 May 2024 13:30:57 -0700
Subject: [PATCH 8/8] Fixing missing closing line
---
.config/linters/stylelint.config.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.config/linters/stylelint.config.json b/.config/linters/stylelint.config.json
index 576f38c..6613d10 100644
--- a/.config/linters/stylelint.config.json
+++ b/.config/linters/stylelint.config.json
@@ -2,4 +2,4 @@
"rules": {
"block-no-empty": true
}
-}
\ No newline at end of file
+}