Skip to content

Commit

Permalink
Merge pull request #72 from whitep4nth3r/control-panel
Browse files Browse the repository at this point in the history
Added a new control panel to the fretboard with highlightable 1, 3, 5 degrees of the scale and note names/note numbers toggle
  • Loading branch information
whitep4nth3r authored Jul 5, 2020
2 parents cf6ac2f + e4bc83e commit 3c456fc
Show file tree
Hide file tree
Showing 50 changed files with 1,285 additions and 1,032 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
ModeSelectorObjects,
NoteToStringAndFretMap,
Octave,
ScaleDegrees,
ScaleDegreeNames,
StandardModePatterns
} from '../../util/constants';
import { JamTracksData } from '../../data/jamTracks';
Expand Down Expand Up @@ -330,16 +330,17 @@ export class FretMapService {

const modeMap = origModeMap.map((noteObject, index) => ({
...noteObject,
degree: ScaleDegrees[index]
degree: ScaleDegreeNames[index],
}));

return modeMap
.map((note) =>
.map((note, index) =>
NoteToStringAndFretMap[this.convertNoteToFretMapKey(note)]
.map((thisNote: NoteObject) => ({
...thisNote,
displayName: note.displayName,
degree: note.degree
degree: note.degree,
degreeNumber: index + 1
})))
.flat()
.reduce((acc, curr) => [...acc, curr], [])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="configure__controls">
<div class="button__group">
<button class="fretboard__toggleButton twelve"
[class.fretboard__toggleButton--active]="fretMode === FretModes.twelve"
(click)="setFretModeClick(FretModes.twelve)">12 frets
</button>
<button class="fretboard__toggleButton twentyFour"
[class.fretboard__toggleButton--active]="fretMode === FretModes.twentyFour"
(click)="setFretModeClick(FretModes.twentyFour)">24 frets
</button>
</div>
<div class="button__group">
<button class="fretboard__toggleButton left"
[class.fretboard__toggleButton--active]="orientation === Orientations.left"
(click)="setOrientationClick(Orientations.left)">
Left handed
</button>
<button class="fretboard__toggleButton right"
[class.fretboard__toggleButton--active]="orientation === Orientations.right"
(click)="setOrientationClick(Orientations.right)">
Right handed
</button>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@import "../../../../styles/vars";
@import "../../../../styles/functions";
@import "../../../../styles/mixins";
@import "../../../../styles/typography";

.configure__controls {
display: flex;
flex-direction: column;
}

.button__group {
display: flex;
flex-direction: row;
justify-content: center;
margin-bottom: pxToRem($grid-unit * 2);

&:last-of-type {
margin-bottom: 0;
}

@media screen and (min-width: $screen-med) {
justify-content: flex-end;
}
}

.fretboard__toggleButton {
@include chip_button_base();
padding: pxToRem($grid-unit * 1.5);
border-color: var(--fretboard-toggle-button-border-color);
}

.fretboard__toggleButton--active {
background-color: var(--chip-background-color-active);
color: var(--chip-foreground-color-active);
}

.fretboard__toggleButton:first-of-type {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-right-width: calc(var(--border-width-button) / 2);
}

.fretboard__toggleButton:last-of-type {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-left-width: calc(var(--border-width-button) / 2);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FretboardConfigComponent } from './fretboard-config.component';
import { Component } from '@angular/core';
import { FretboardConfigModule } from './fretboard-config.module';

describe('FretboardConfigComponent', () => {
@Component({
selector: 'app-fretboard-config-spec',
template: `
<app-fretboard-config></app-fretboard-config>
`
})
class FretboardConfigComponentSpec {
}

let component: FretboardConfigComponentSpec;
let fixture: ComponentFixture<FretboardConfigComponentSpec>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ FretboardConfigComponentSpec ],
imports: [FretboardConfigModule]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(FretboardConfigComponentSpec);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FretModes, Orientations } from '../fretboard/fretboard.component';

@Component({
selector: 'app-fretboard-config',
templateUrl: './fretboard-config.component.html',
styleUrls: ['./fretboard-config.component.scss']
})
export class FretboardConfigComponent {
@Input() fretMode;
@Input() orientation;

@Output() setFretMode = new EventEmitter<FretModes>();
@Output() setOrientation = new EventEmitter<Orientations>();

setFretModeClick(fretMode: FretModes) {
this.setFretMode.emit(fretMode);
}

setOrientationClick(orientation: Orientations) {
this.setOrientation.emit(orientation);
}

get FretModes() {
return FretModes;
}

get Orientations() {
return Orientations;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FretboardConfigComponent } from './fretboard-config.component';


@NgModule({
declarations: [FretboardConfigComponent],
exports: [
FretboardConfigComponent
],
imports: [
CommonModule
],
})
export class FretboardConfigModule {
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
[attr.data-string]="string"
[attr.data-fret]="fret"
[attr.data-degree]="(fretMap | getFretFromFretMap: stringName:fret:stringNamesAreCaseSensitive)?.degree"
[attr.data-display-note]="(fretMap | getFretFromFretMap: stringName:fret:stringNamesAreCaseSensitive)?.displayName"
[attr.data-display-note]="noteNameDisplay === NoteDisplays.noteNames ? ((fretMap | getFretFromFretMap: stringName:fret:stringNamesAreCaseSensitive)?.displayName) : ((fretMap | getFretFromFretMap: stringName:fret:stringNamesAreCaseSensitive)?.degreeNumber)"
[attr.data-mode]="mode"
[attr.data-highlight]="highlightedDegrees.has((fretMap | getFretFromFretMap: stringName:fret:stringNamesAreCaseSensitive)?.degree)"
(click)="playbackService.playNote(stringName, fret)"
></div>
</ng-container>
Expand All @@ -22,42 +23,18 @@
</ng-container>
</ng-template>

<div class="fretboard__toggle">
<button class="fretboard__toggleButton fretboard__toggleButton--left"
[class.fretboard__toggleButton--active]="fretMode === fretModes.twelve"
(click)="setFretMode(fretModes.twelve)">12 frets
</button>
<button class="fretboard__toggleButton fretboard__toggleButton--middle-left"
[class.fretboard__toggleButton--active]="fretMode === fretModes.twentyFour"
(click)="setFretMode(fretModes.twentyFour)">24 frets
</button>
<button class="fretboard__toggleButton fretboard__toggleButton--middle-right"
[class.fretboard__toggleButton--active]="orientation === orientations.left"
(click)="setOrientation(orientations.left)">
<span class="toggle__shortLabel">LH</span>
<span class="toggle__longLabel">Left handed</span>
</button>
<button class="fretboard__toggleButton fretboard__toggleButton--right"
[class.fretboard__toggleButton--active]="orientation === orientations.right"
(click)="setOrientation(orientations.right)">
<span class="toggle__shortLabel">RH</span>
<span class="toggle__longLabel">Right handed</span>
</button>
</div>

<div class="arrowHint">
<span class="arrowHint__arrow"
[class.fretboard__flip]="orientation === orientations.left"></span>
[class.fretboard__flip]="orientation === Orientations.left"></span>
</div>

<div class="fretboard__container"
[class.fretboard__flip]="orientation === orientations.left"
[class.fretboard__wide]="fretMode === fretModes.twentyFour">

[class.fretboard__flip]="orientation === Orientations.left"
[class.fretboard__wide]="fretMode === FretModes.twentyFour">

<div class="fretboard"
[class.fretboard__leftHanded]="orientation === orientations.left"
[class.fretboard__24]="fretMode === fretModes.twentyFour">
[class.fretboard__leftHanded]="orientation === Orientations.left"
[class.fretboard__24]="fretMode === FretModes.twentyFour">

<ng-container
[ngTemplateOutlet]="string"
Expand Down Expand Up @@ -88,22 +65,50 @@
[ngTemplateOutlet]="string"
[ngTemplateOutletContext]="{ stringName: 'E', string: 'E' }"
></ng-container>

</div>


<div class="fretboard"
[class.fretboard__leftHanded]="orientation === orientations.left"
[class.fretboard__24]="fretMode === fretModes.twentyFour">
[class.fretboard__leftHanded]="orientation === Orientations.left"
[class.fretboard__24]="fretMode === FretModes.twentyFour">
<ng-container
[ngTemplateOutlet]="fretboardHelp"
></ng-container>
</div>
</div>

<p class="fretonator__playCta">
<span class="fretonator__playCtaIcon">
<app-speaker-svg></app-speaker-svg>
</span>
Tap notes on the fretboard for sound!
</p>
<div class="controlPanel">
<div class="controlPanel__section">
<span class="controlPanel__title" *ngIf="!(mode | displayScaleDegrees)">Configure scale degrees</span>
<span class="controlPanel__title" *ngIf="mode | displayScaleDegrees">Highlight scale degrees</span>
<app-scale-degrees
*ngIf="mode | displayScaleDegrees"
[tonicActive]="highlightedDegrees.has(ScaleDegrees.tonic)"
[mediantActive]="highlightedDegrees.has(ScaleDegrees.mediant)"
[dominantActive]="highlightedDegrees.has(ScaleDegrees.dominant)"
(setTonicHighlight)="toggleHighlight(ScaleDegrees.tonic)"
(setMediantHighlight)="toggleHighlight(ScaleDegrees.mediant)"
(setDominantHighlight)="toggleHighlight(ScaleDegrees.dominant)"
></app-scale-degrees>

<div class="button__group">
<button class="fretboard__toggleButton"
[class.fretboard__toggleButton--active]="noteNameDisplay === NoteDisplays.noteNames"
(click)="toggleNoteDisplay(NoteDisplays.noteNames)">Note names
</button>
<button (click)="toggleNoteDisplay(NoteDisplays.numbers)"
class="fretboard__toggleButton"
[class.fretboard__toggleButton--active]="noteNameDisplay === NoteDisplays.numbers">Note numbers
</button>
</div>
</div>

<div class="controlPanel__section">
<span class="controlPanel__title controlPanel__title--right">Configure fretboard</span>
<app-fretboard-config
[fretMode]="fretMode"
[orientation]="orientation"
(setFretMode)="setFretMode($event)"
(setOrientation)="setOrientation($event)"
></app-fretboard-config>
</div>
</div>
Loading

0 comments on commit 3c456fc

Please sign in to comment.