From b4825e085e270ca176de0517636392ea262bddf9 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Fri, 27 Aug 2021 10:40:40 -0500 Subject: [PATCH] fix table snippet spacing in editor --- .../snippetbar/snippets/classtable.gen.js | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/client/homebrew/editor/snippetbar/snippets/classtable.gen.js b/client/homebrew/editor/snippetbar/snippets/classtable.gen.js index 0c72ac898..0055adf65 100644 --- a/client/homebrew/editor/snippetbar/snippets/classtable.gen.js +++ b/client/homebrew/editor/snippetbar/snippets/classtable.gen.js @@ -52,14 +52,14 @@ const getFeature = (level)=>{ const maxes = [4, 3, 3, 3, 3, 2, 2, 1, 1]; -const drawSlots = function(Slots, rows){ +const drawSlots = function(Slots, rows, padding){ let slots = Number(Slots); return _.times(rows, function(i){ const max = maxes[i]; - if(slots < 1) return '—'; + if(slots < 1) return _.pad('—', padding); const res = _.min([max, slots]); slots -= res; - return res; + return _.pad(res.toString(), padding); }).join(' | '); }; @@ -72,17 +72,17 @@ module.exports = { let spells = 1; let slots = 2; return `{{${classes}\n##### The ${classname}\n` + - `| Level | Proficiency | Features | Cantrips | Spells | --- Spell Slots Per Spell Level --- |||||||||\n`+ - `| ^| Bonus ^| ^| Known ^| Known ^| 1st | 2nd | 3rd | 4th | 5th | 6th | 7th | 8th | 9th |\n`+ - `|:-----:|:-----------:|:---------|:--------:|:------:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|\n${ + `| Level | Proficiency | Features | Cantrips | Spells | --- Spell Slots Per Spell Level --- |||||||||\n`+ + `| ^| Bonus ^| ^| Known ^| Known ^| 1st | 2nd | 3rd | 4th | 5th | 6th | 7th | 8th | 9th |\n`+ + `|:-----:|:-----------:|:--------------------------------------------------------|:--------:|:------:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|\n${ _.map(levels, function(levelName, level){ const res = [ - levelName, - `+${profBonus[level]}`, - getFeature(level), - cantrips, - spells, - drawSlots(slots, 9) + _.pad(levelName, 5), + _.pad(`+${profBonus[level]}`, 11), + _.padEnd(getFeature(level), 55), + _.pad(cantrips.toString(), 8), + _.pad(spells.toString(), 6), + drawSlots(slots, 9, 3), ].join(' | '); cantrips += _.random(0, 1); @@ -98,14 +98,14 @@ module.exports = { let featureScore = 1; return `{{${classes}\n##### The ${classname}\n` + - `| Level | Proficiency Bonus | Features | ${_.sample(features)}|\n` + - `|:---:|:---:|:---|:---:|\n${ + `| Level | Proficiency Bonus | Features | ${_.pad(_.sample(features), 26)} |\n` + + `|:-----:|:-----------------:|:--------------------------------------------------------|:--------------------------:|\n${ _.map(levels, function(levelName, level){ const res = [ - levelName, - `+${profBonus[level]}`, - getFeature(level), - `+${featureScore}` + _.pad(levelName, 5), + _.pad(`+${profBonus[level]}`, 17), + _.padEnd(getFeature(level), 55), + _.pad(`+${featureScore}`, 26), ].join(' | '); featureScore += _.random(0, 1); @@ -121,15 +121,15 @@ module.exports = { let spells = 1; let slots = 2; return `{{${classes}\n##### ${classname} Spellcasting\n` + - `| Class | Cantrips | Spells | --- Spells Slots per Spell Level --- ||||\n` + - `| Level ^| Known ^| Known ^| 1st | 2nd | 3rd | 4th |\n` + - `|:---:|:---:|:---:|:---:|:---:|:---:|:---:|\n${ + `| Class | Cantrips | Spells | --- Spells Slots per Spell Level --- ||||\n` + + `| Level ^| Known ^| Known ^| 1st | 2nd | 3rd | 4th |\n` + + `|:------:|:--------:|:-------:|:--------:|:--------:|:--------:|:--------:|\n${ _.map(levels, function(levelName, level){ const res = [ - levelName, - cantrips, - spells, - drawSlots(slots, 4) + _.pad(levelName, 6), + _.pad(cantrips.toString(), 8), + _.pad(spells.toString(), 7), + drawSlots(slots, 4, 8), ].join(' | '); cantrips += _.random(0, 1);