Skip to content

Commit 2025d72

Browse files
committed
➕ Add handling for two digit verse numbers
1 parent 97be251 commit 2025d72

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

frontend/src/partials/SongContent.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div
3-
class="w-full flex flex-wrap overflow-y-auto"
3+
class="w-full flex flex-wrap "
44
:class="{
55
'flex-row gap-8': !presentation,
66
'flex-col xs:flex-row gap-7 xs:gap-0 pb-10 xs:pb-0': presentation
@@ -16,10 +16,11 @@
1616
:part="part.number"
1717
class="relative overflow-visible"
1818
:class="{
19-
'relative before:absolute before:top-1 before:font-fira before:font-light before:content-[attr(part)]': part.class === 'verse' && part.number > 0,
19+
'relative before:absolute before:top-1 before:font-fira before:font-light before:content-[attr(part)] before:w-12 before:-left-6 before:text-right': part.class === 'verse' && part.number > 0,
2020
'font-fira text-2xl': !chords,
21-
'pl-8 before:text-4xl before:left-1': !presentation,
22-
'inline-block leading-[1.4] pl-6 md:pl-8 before:left-0 md:before:left-1 before:text-3xl md:before:text-4xl before:-left-0.5': presentation,
21+
'pl-8 before:text-4xl': !presentation,
22+
'inline-block leading-[1.4] pl-6 md:pl-8 before:text-3xl md:before:text-4xl before:-left-8 md:before:-left-6': presentation,
23+
'pl-0!': part.class === 'chorus',
2324
}"
2425
><div
2526
v-for="(line, l) in part.content.split('\n')" :key="l"
@@ -39,7 +40,7 @@ const props = defineProps({
3940
presentation: Boolean, // flag if song is displayed in presentation mode
4041
});
4142
42-
// methods
43+
// Makes font size per song part as big as possible
4344
const maximizeFontsize = () => {
4445
// config
4546
const WIDTH_MARGIN = 20;
@@ -91,5 +92,5 @@ const maximizeFontsize = () => {
9192
}
9293
};
9394
94-
defineExpose({ maximizeFontsize })
95+
defineExpose({ maximizeFontsize });
9596
</script>

frontend/src/utils.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,42 +108,43 @@ const parsedContent = (content, tuning, showChords, twoColumns) => {
108108
}
109109
// handle song part marker (e.g. --V1)
110110
else {
111+
const n = line.trim().substring(3);
111112
// add class to part
112113
switch (line.charAt(2).toLowerCase()) {
113114
case 'v':
114115
types.push('v');
115116
classes.push('verse');
116-
numbers.push((!isNaN(parseInt(line.trim().charAt(3)))) ? line.trim().charAt(3) : '0');
117+
numbers.push((!isNaN(parseInt(n))) ? n : '0');
117118
break;
118119
case 'p':
119120
types.push('p');
120121
classes.push('prechorus');
121-
numbers.push((!isNaN(parseInt(line.trim().charAt(3)))) ? line.trim().charAt(3) : '0');
122+
numbers.push((!isNaN(parseInt(n))) ? n : '0');
122123
break;
123124
case 'c':
124125
types.push('c');
125126
classes.push('chorus');
126-
numbers.push((!isNaN(parseInt(line.trim().charAt(3)))) ? line.trim().charAt(3) : '0');
127+
numbers.push((!isNaN(parseInt(n))) ? n : '0');
127128
break;
128129
case 'b':
129130
types.push('b');
130131
classes.push('bridge');
131-
numbers.push((!isNaN(parseInt(line.trim().charAt(3)))) ? line.trim().charAt(3) : '0');
132+
numbers.push((!isNaN(parseInt(n))) ? n : '0');
132133
break;
133134
case 'i':
134135
types.push('i');
135136
classes.push('intro');
136-
numbers.push((!isNaN(parseInt(line.trim().charAt(3)))) ? line.trim().charAt(3) : '0');
137+
numbers.push((!isNaN(parseInt(n))) ? n : '0');
137138
break;
138139
case 'm':
139140
types.push('m');
140141
classes.push('mitro');
141-
numbers.push((!isNaN(parseInt(line.trim().charAt(3)))) ? line.trim().charAt(3) : '0');
142+
numbers.push((!isNaN(parseInt(n))) ? n : '0');
142143
break;
143144
case 'o':
144145
types.push('o');
145146
classes.push('outro');
146-
numbers.push((!isNaN(parseInt(line.trim().charAt(3)))) ? line.trim().charAt(3) : '0');
147+
numbers.push((!isNaN(parseInt(n))) ? n : '0');
147148
break;
148149
default:
149150
// a non existent part tag was found

0 commit comments

Comments
 (0)