|
1 | 1 | --- |
2 | | -# https://vitepress.dev/reference/default-theme-home-page |
3 | | -layout: home |
4 | | - |
5 | | -hero: |
6 | | - name: "Chord Charts" |
7 | | - text: "A NPM package to transpose and manage chord charts for music" |
8 | | - actions: |
9 | | - - theme: alt |
10 | | - text: Quickstart |
11 | | - link: /quickstart |
| 2 | +outline: deep |
| 3 | +sidebar: false |
12 | 4 | --- |
| 5 | + |
| 6 | +::: code-group |
| 7 | + |
| 8 | +```sh [npm] |
| 9 | +$ npm add -D @hrgui/chord-charts |
| 10 | +``` |
| 11 | + |
| 12 | +```sh [pnpm] |
| 13 | +$ pnpm add -D @hrgui/chord-charts |
| 14 | +``` |
| 15 | + |
| 16 | +```sh [yarn] |
| 17 | +$ yarn add -D @hrgui/chord-charts |
| 18 | +``` |
| 19 | + |
| 20 | +```sh [yarn (pnp)] |
| 21 | +$ yarn add -D @hrgui/chord-charts |
| 22 | +``` |
| 23 | + |
| 24 | +```sh [bun] |
| 25 | +$ bun add -D @hrgui/chord-charts |
| 26 | +``` |
| 27 | + |
| 28 | +::: |
| 29 | + |
| 30 | +Use it in the app in the following way: |
| 31 | + |
| 32 | +```ts |
| 33 | +import { transpose } from "@hrgui/chord-charts"; |
| 34 | + |
| 35 | +console.log( |
| 36 | + transpose( |
| 37 | + ` |
| 38 | + D G D |
| 39 | +Amazing Grace, how sweet the sound, |
| 40 | + A7 |
| 41 | +That saved a wretch like me. |
| 42 | + D G D |
| 43 | +I once was lost, but now im found, |
| 44 | + A7 D |
| 45 | +Was blind, but now I see. |
| 46 | +`, |
| 47 | + "D", |
| 48 | + "C", |
| 49 | + ), |
| 50 | +); |
| 51 | +``` |
| 52 | + |
| 53 | +<script setup> |
| 54 | +import { ref, useTemplateRef, watch } from 'vue' |
| 55 | + |
| 56 | +import { transpose, keys } from "@hrgui/chord-charts"; |
| 57 | + |
| 58 | + |
| 59 | +const count = ref(0) |
| 60 | +const previousKey = ref('D') |
| 61 | +const currentKey = ref('D') |
| 62 | + |
| 63 | +const text = ref(` |
| 64 | + D G D |
| 65 | + Amazing Grace, how sweet the sound, |
| 66 | + A7 |
| 67 | + That saved a wretch like me. |
| 68 | + D G D |
| 69 | + I once was lost, but now im found, |
| 70 | + A7 D |
| 71 | + Was blind, but now I see. |
| 72 | +`); |
| 73 | + |
| 74 | + |
| 75 | +function transposeChordChart(e) { |
| 76 | + text.value = transpose(text.value, previousKey.value, e.target.value); |
| 77 | + previousKey.value = e.target.value; |
| 78 | +} |
| 79 | + |
| 80 | +</script> |
| 81 | + |
| 82 | +## Working Example |
| 83 | + |
| 84 | +<select v-model="currentKey" class="border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 mb-2" @change="transposeChordChart"> |
| 85 | + |
| 86 | + <option v-for="key in keys" :value="key.name">{{key.name}}</option> |
| 87 | +</select> |
| 88 | + |
| 89 | +<div> |
| 90 | + |
| 91 | +<textarea v-model="text" class="chord-chart rounded" cols="40" rows="10"> |
| 92 | +</textarea> |
| 93 | +</div> |
| 94 | + |
| 95 | +<style module> |
| 96 | +.button { |
| 97 | + color: red; |
| 98 | + font-weight: bold; |
| 99 | +} |
| 100 | +</style> |
0 commit comments