From f3eff8e3107ac7b6bad988d34f5af9f92e18ccf5 Mon Sep 17 00:00:00 2001 From: Benjamin Sherriff Date: Mon, 23 Oct 2023 20:52:22 -0400 Subject: [PATCH] Fixed capitalize classes --- ui/src/app/spells/page.tsx | 71 ++++++++++++++++++++++++++++++++ ui/src/components/SpellModal.tsx | 7 +++- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/ui/src/app/spells/page.tsx b/ui/src/app/spells/page.tsx index 1cf1dad..2862034 100644 --- a/ui/src/app/spells/page.tsx +++ b/ui/src/app/spells/page.tsx @@ -73,6 +73,77 @@ export default function Page() { }} />
+ s.name.toLowerCase().includes(searchName.toLowerCase()))} + onClick={(spell) => { + setActiveSpell(spell); + setIsOpen(true); + }} + /> +
+ s.name.toLowerCase().includes(searchName.toLowerCase()))} + onClick={(spell) => { + setActiveSpell(spell); + setIsOpen(true); + }} + /> +
+ s.name.toLowerCase().includes(searchName.toLowerCase()))} + onClick={(spell) => { + setActiveSpell(spell); + setIsOpen(true); + }} + /> +
+ s.name.toLowerCase().includes(searchName.toLowerCase()))} + onClick={(spell) => { + setActiveSpell(spell); + setIsOpen(true); + }} + /> +
+ s.name.toLowerCase().includes(searchName.toLowerCase()))} + onClick={(spell) => { + setActiveSpell(spell); + setIsOpen(true); + }} + /> +
+ s.name.toLowerCase().includes(searchName.toLowerCase()))} + onClick={(spell) => { + setActiveSpell(spell); + setIsOpen(true); + }} + /> +
+ s.name.toLowerCase().includes(searchName.toLowerCase()))} + onClick={(spell) => { + setActiveSpell(spell); + setIsOpen(true); + }} + /> +
+ s.name.toLowerCase().includes(searchName.toLowerCase()))} + onClick={(spell) => { + setActiveSpell(spell); + setIsOpen(true); + }} + /> {activeSpell && setIsOpen(false)} />} ); diff --git a/ui/src/components/SpellModal.tsx b/ui/src/components/SpellModal.tsx index 385da29..aee0b7e 100644 --- a/ui/src/components/SpellModal.tsx +++ b/ui/src/components/SpellModal.tsx @@ -95,8 +95,10 @@ function parseText(text: string, capitalizeFirst?: boolean): (string | JSX.Eleme const matches = text.matchAll(regex); const result = []; let lastIndex = 0; + let noMatches = true; for (const match of matches) { + noMatches = false; const key = crypto.randomUUID(); const [full, type, name] = match; result.push({text.slice(lastIndex, match.index)}); @@ -108,7 +110,7 @@ function parseText(text: string, capitalizeFirst?: boolean): (string | JSX.Eleme ); } else if (type == 'scaledice') { - // scaledice format is {@scaledice 1d6|1-9|1d6|}. Parse this out into dice, levels, and dice again. + // scaledice format is {@scaledice 1d6|1-9}. Parse this out into dice, levels, and dice again. const [dice, levels] = name.split('|'); result.push( handleLink('dice', dice)} className='link' key={key}> @@ -134,7 +136,8 @@ function parseText(text: string, capitalizeFirst?: boolean): (string | JSX.Eleme lastIndex = match.index + full.length; } } - result.push({text.slice(lastIndex)}); + const lastString = text.slice(lastIndex); + result.push({noMatches ? capitalize(lastString) : lastString}); return result; }