instruments-chords 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,22 @@
1
1
  import { getChord } from './getChord';
2
2
  import { renderBase } from './svg/base';
3
- import { SVG_HEIGTH, SVG_WIDTH } from './svg/constants';
4
3
  import { renderMarkers } from './svg/markers';
4
+ import { SVG_WIDTH, SVG_HEIGHT } from './svg/constants';
5
5
  export function getChordSvg(root, quality) {
6
6
  const chord = getChord(root, quality);
7
- if (chord === null)
7
+ if (!chord)
8
8
  return null;
9
9
  const base = renderBase();
10
10
  const markers = renderMarkers(chord);
11
11
  return `
12
- <svg
13
- width="${SVG_WIDTH}
14
- heigth="${SVG_HEIGTH}
15
- viewBox="0 0 ${SVG_WIDTH} ${SVG_HEIGTH}"
16
- xmlns="http"://www.w3.org/2000/svg"
17
- >
18
- ${base}
19
- ${markers}
20
- </svg>
21
- `.trim();
12
+ <svg
13
+ width="${SVG_WIDTH}"
14
+ height="${SVG_HEIGHT}"
15
+ viewBox="0 0 ${SVG_WIDTH} ${SVG_HEIGHT}"
16
+ xmlns="http://www.w3.org/2000/svg"
17
+ >
18
+ ${base}
19
+ ${markers}
20
+ </svg>
21
+ `.trim();
22
22
  }
package/dist/svg/base.js CHANGED
@@ -1,8 +1,8 @@
1
- import { FRET_COUNT, FRET_SPACING, START_X, START_Y, STRING_COUNT, STRING_SPACING } from './constants';
1
+ import { STRING_COUNT, FRET_COUNT, STRING_SPACING, FRET_SPACING, START_X, START_Y, } from './constants';
2
2
  export function renderBase() {
3
3
  let svg = '';
4
4
  // cuerdas
5
- for (let i = 0; i <= STRING_COUNT; i++) {
5
+ for (let i = 0; i < STRING_COUNT; i++) {
6
6
  const x = START_X + i * STRING_SPACING;
7
7
  svg += `<line x1="${x}" y1="${START_Y}" x2="${x}" y2="${START_Y + FRET_SPACING * FRET_COUNT}" stroke="black"/>`;
8
8
  }
@@ -1,5 +1,5 @@
1
1
  export declare const SVG_WIDTH = 120;
2
- export declare const SVG_HEIGTH = 160;
2
+ export declare const SVG_HEIGHT = 160;
3
3
  export declare const STRING_COUNT = 6;
4
4
  export declare const FRET_COUNT = 5;
5
5
  export declare const STRING_SPACING = 20;
@@ -1,5 +1,5 @@
1
1
  export const SVG_WIDTH = 120;
2
- export const SVG_HEIGTH = 160;
2
+ export const SVG_HEIGHT = 160;
3
3
  export const STRING_COUNT = 6;
4
4
  export const FRET_COUNT = 5;
5
5
  export const STRING_SPACING = 20;
@@ -1,18 +1,18 @@
1
- import { getFretY, getStringX } from './utils';
1
+ import { getStringX, getFretY } from './utils';
2
2
  export function renderMarkers(chord) {
3
3
  let svg = '';
4
4
  for (const [string, fret] of Object.entries(chord)) {
5
5
  const s = Number(string);
6
6
  const x = getStringX(s);
7
7
  if (fret === 'x') {
8
- svg += `<text x1="${x}" y="20" text-anchor="middle">x</text>`;
8
+ svg += `<text x="${x}" y="20" text-anchor="middle">x</text>`;
9
9
  }
10
10
  else if (fret === 0) {
11
- svg += `<cicle cx="${x}" cy="20" r="5" fill="none" stroke="black" />`;
11
+ svg += `<circle cx="${x}" cy="20" r="5" fill="none" stroke="black"/>`;
12
12
  }
13
13
  else {
14
14
  const y = getFretY(fret);
15
- svg += `<cicle cx="${x}" cy="${y}" r="6" fill="black" />`;
15
+ svg += `<circle cx="${x}" cy="${y}" r="6" fill="black"/>`;
16
16
  }
17
17
  }
18
18
  return svg;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instruments-chords",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Guitar chords database for developers",