-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andy
authored and
Andy
committed
Apr 29, 2024
1 parent
16a19dc
commit 248a7b8
Showing
5 changed files
with
71 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import classNames from "classnames"; | ||
|
||
import { Note, Scale } from "../../types"; | ||
|
||
interface NotesProps { | ||
activeNotes: Note[]; | ||
activeScale: Scale; | ||
} | ||
|
||
export default function Notes({ activeNotes, activeScale }: NotesProps) { | ||
function isNoteInScale(id: number): boolean { | ||
if (activeScale?.notes.includes(id)) return true; | ||
return false; | ||
} | ||
|
||
function mapNotesToLabelsMajor(i: number): string { | ||
const help = ["I", "ii", "iii", "IV", "V", "VI", "VII"]; | ||
const plusOne = i; | ||
|
||
return help[plusOne]; | ||
} | ||
|
||
function getNoteClass(note: Note): string { | ||
const { id, is_accidental } = note; | ||
return classNames("rounded-md m-2", { | ||
"!bg-orange-400": is_accidental && isNoteInScale(note.id), | ||
"bg-sky-500": activeScale.root_note_id === id, | ||
"bg-sky-500/50": isNoteInScale(id) && activeScale.root_note_id !== id, | ||
}); | ||
} | ||
return ( | ||
<div className="flex flex-row items-baseline justify-evenly mb-8"> | ||
{activeNotes.map((note, i) => ( | ||
<div className="flex flex-col basis-1/4"> | ||
<button key={note.id} className={getNoteClass(note)}> | ||
{note.string} | ||
</button> | ||
<div className="self-center">{mapNotesToLabelsMajor(i)} </div> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ export type Scale = { | |
name: string; | ||
id: number; | ||
notes: number[]; | ||
root_note_id: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,29 @@ | ||
/** @type {import('tailwindcss').Config} */ | ||
|
||
const colors = require("tailwindcss/colors"); | ||
|
||
export default { | ||
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"], | ||
theme: { | ||
extend: {}, | ||
colors: { | ||
transparent: "transparent", | ||
current: "currentColor", | ||
orange: colors.orange, | ||
black: colors.black, | ||
sky: colors.sky, | ||
green: colors.lime, | ||
white: colors.white, | ||
gray: colors.gray, | ||
emerald: colors.emerald, | ||
indigo: colors.indigo, | ||
red: colors.red, | ||
yellow: colors.yellow, | ||
amber: colors.amber, | ||
stone: colors.stone, | ||
slate: colors.slate, | ||
lime: colors.lime, | ||
}, | ||
}, | ||
plugins: [], | ||
}; |