@@ -5,12 +5,14 @@ import Image from "next/image"
55import { ReactElement , useState } from "react"
66import ReactMarkdown from "react-markdown"
77import FormattedLink from "../../components/FormattedLink"
8+ import Guides from "../../components/Guides"
89import Icon from "../../components/Icon"
910import Main from "../../components/Main"
11+ import { MaterialCost , MaterialImage } from "../../components/Material"
1012import YouTube from "../../components/YouTube"
1113import { CharacterCurves , CostTemplates , getCharacterCurves , getCharacters , getCostTemplates } from "../../utils/data-cache"
1214import { Character , CharacterFull , Constellation , CostTemplate , CurveEnum , Meta , Passive , Skill , Skills , TalentTable , TalentValue } from "../../utils/types"
13- import { elements , ElementType , getCharStatsAt , getCostsFromTemplate , getGuidesFor , getLinkToGuide , image , isFullCharacter , isValueTable , stat , urlify , weapons } from "../../utils/utils"
15+ import { elements , ElementType , getCharStatsAt , getCostsFromTemplate , getGuidesFor , getLinkToGuide , getStarColor , image , isFullCharacter , isValueTable , stat , urlify , weapons } from "../../utils/utils"
1416import styles from "../style.module.css"
1517
1618interface Props {
@@ -23,9 +25,7 @@ interface Props {
2325export default function CharacterWebpage ( { char, location, characterCurves, costTemplates, guides } : Props & { location : string } ) {
2426 const charElems = char . skills ?. map ( skill => skill . ult ?. type ) . filter ( x => x ) as ElementType [ ] ?? [ char . meta . element ]
2527 const multiskill = ( char . skills ?. length ?? 0 ) > 1
26- let color = ""
27- if ( char . star == 5 ) color = "bg-amber-600 dark:bg-amber-700"
28- if ( char . star == 4 ) color = "bg-purple-700 dark:bg-purple-800"
28+ const color = getStarColor ( char . star ?? 0 )
2929
3030 return (
3131 < Main >
@@ -36,7 +36,7 @@ export default function CharacterWebpage({ char, location, characterCurves, cost
3636 < meta property = "og:description" content = { `View ${ char . name } information` } />
3737 </ Head >
3838 < h2 className = "font-semibold" >
39- < FormattedLink href = "/characters/" location = { location } font = " semibold" size = " lg">
39+ < FormattedLink href = "/characters/" location = { location } className = "font- semibold text- lg">
4040 Characters
4141 </ FormattedLink >
4242 </ h2 >
@@ -60,7 +60,7 @@ export default function CharacterWebpage({ char, location, characterCurves, cost
6060 </ > ) ) }
6161 </ div >
6262
63- < div className = "grid grid-flow-col" >
63+ < div className = "grid grid-flow-col justify-start " >
6464 < div className = "sm:w-36 mr-2 w-0 " >
6565 < Icon icon = { char } className = { `${ color } rounded-xl` } />
6666 </ div >
@@ -110,7 +110,7 @@ export default function CharacterWebpage({ char, location, characterCurves, cost
110110function TOC ( { href, title, depth = 0 } : { href : string , title : string , depth ?: number } ) {
111111 const size = depth > 0 ? "sm" : "base"
112112 return < div >
113- < FormattedLink href = { href } size = { size } style = { ( { marginLeft : ( 0.25 * depth ) + "rem" } ) } > { title } </ FormattedLink >
113+ < FormattedLink href = { href } className = { `text- ${ size } ` } style = { ( { marginLeft : ( 0.25 * depth ) + "rem" } ) } > { title } </ FormattedLink >
114114 </ div >
115115}
116116
@@ -123,9 +123,7 @@ function AscensionCosts({ costs }: { costs: CostTemplate }) {
123123 ] . filter ( x => x )
124124 return < div className = "flex flex-wrap items-center" >
125125 < div className = "text-base font-semibold pt-1 inline-block pr-1 h-9" > Ascension materials:</ div >
126- { ascensionCosts . map ( e => < div className = "inline-block pr-1 w-6 h-6 md:h-8 md:w-8" key = { e } >
127- < img src = { image ( "material" , e ) } alt = { e } width = { 256 } height = { 256 } />
128- </ div > ) }
126+ { ascensionCosts . map ( e => < MaterialImage key = { e } name = { e } /> ) }
129127 </ div >
130128}
131129
@@ -135,7 +133,7 @@ function FullAscensionCosts({ template, costTemplates }: { template: CostTemplat
135133
136134 return < >
137135 < h3 className = "text-lg font-bold pt-1" id = "ascensions" > Ascensions:</ h3 >
138- < table className = { `table-auto w-full ${ styles . table } mb-2 ${ expanded ? "" : "cursor-pointer" } sm:text-sm md:text-base text-xs` } onClick = { ( ) => setExpanded ( true ) } >
136+ < table className = { `table-auto w-full ${ styles . table } mb-2 ${ expanded ? "" : "cursor-pointer" } sm:text-sm md:text-base text-xs` } onClick = { ( e ) => setExpanded ( true ) } >
139137 < thead className = "font-semibold divide-x divide-gray-200 dark:divide-gray-500" >
140138 < td > Asc.</ td >
141139 < td > Mora</ td >
@@ -152,13 +150,7 @@ function FullAscensionCosts({ template, costTemplates }: { template: CostTemplat
152150 < td > A{ ind + 1 } </ td >
153151 < td className = "text-right" > { mora } </ td >
154152 { newItems . map ( ( { count, name } ) => < td key = { name } >
155- { count > 0 &&
156- < div className = "flex flex-row align-middle items-center" >
157- < div > { count } ×</ div >
158- < div className = "pr-1 w-8 h-8 sm:h-6 sm:w-6 md:h-8 md:w-8" >
159- < img src = { image ( "material" , name ) } alt = { name } width = { 256 } height = { 256 } />
160- </ div >
161- < div className = "md:text-sm lg:text-base sm:not-sr-only sr-only text-xs" > { name } </ div > </ div > }
153+ { count > 0 && < MaterialCost name = { name } count = { count } /> }
162154 </ td > ) }
163155 </ tr >
164156 } )
@@ -197,9 +189,7 @@ function TalentCosts({ skills }: { skills: Skills[] }) {
197189 const all = [ ...books , ...mats , ...drops ] as string [ ]
198190 return < div className = "flex flex-wrap items-center" >
199191 < div className = "text-base font-semibold pt-1 inline-block pr-1 h-9" > Talent materials:</ div >
200- { all . map ( e => < div className = "inline-block pr-1 w-6 h-6 md:h-8 md:w-8" key = { e } >
201- < img src = { image ( "material" , e ) } alt = { e } width = { 256 } height = { 256 } />
202- </ div > ) }
192+ { all . map ( e => < MaterialImage key = { e } name = { e } /> ) }
203193 </ div >
204194}
205195
@@ -248,7 +238,7 @@ function Meta({ meta }: { meta: Meta }) {
248238 < table className = { `table-auto ${ styles . table } mb-2 w-full` } >
249239 < tbody className = "divide-y divide-gray-200 dark:divide-gray-500" >
250240 { meta . title && < tr > < td > Title</ td > < td > { meta . title } </ td > </ tr > }
251- { meta . birthDay && meta . birthMonth && < tr > < td > Title </ td > < td > {
241+ { meta . birthDay && meta . birthMonth && < tr > < td > Birthday </ td > < td > {
252242 new Date ( Date . UTC ( 2020 , meta . birthMonth - 1 , meta . birthDay ) )
253243 . toLocaleString ( "en-UK" , {
254244 timeZone : "UTC" ,
@@ -290,15 +280,6 @@ function Video({ name, link }: { name: string, link: string }) {
290280 </ div >
291281}
292282
293- function Guides ( { guides } : { guides : string [ ] [ ] } ) {
294- const multiple = guides . length > 1
295-
296- return < >
297- < h3 className = "text-lg font-bold pt-1" id = "guides" > { multiple ? "Guides" : "Guide" } :</ h3 >
298- { guides . map ( ( [ name , link ] ) => < div key = { name } > < FormattedLink href = { link } size = "base" > { name } </ FormattedLink > </ div > ) }
299- </ >
300- }
301-
302283function CharacterSkills ( { skills, costTemplates } : { skills : Skills [ ] , costTemplates : CostTemplates } ) {
303284 return < >
304285 { skills . map ( ( skill , i ) => {
@@ -358,14 +339,7 @@ function TalentCost({ template, costTemplates }: { template: CostTemplate, costT
358339 < td > { ind + 1 } →{ ind + 2 } </ td >
359340 < td className = "text-right" > { mora } </ td >
360341 { items . map ( ( { count, name } , i , arr ) => < td key = { name } colSpan = { i == arr . length - 1 ? maxCostWidth - i : 1 } >
361- { count > 0 &&
362- < div className = "flex flex-row align-middle items-center" >
363- < div > { count } ×</ div >
364- < div className = "pr-1 w-8 h-8 sm:h-6 sm:w-6 md:h-8 md:w-8" >
365- < img src = { image ( "material" , name ) } alt = { name } width = { 256 } height = { 256 } />
366- </ div >
367- < div className = "md:text-sm lg:text-base sm:not-sr-only sr-only text-xs" > { name } </ div >
368- </ div > }
342+ { count > 0 && < MaterialCost name = { name } count = { count } /> }
369343 </ td > ) }
370344 </ tr >
371345 )
@@ -386,7 +360,7 @@ function TalentTable({ table }: { table: (TalentTable | TalentValue)[] }) {
386360
387361 function hint ( input : string ) : ReactElement {
388362 return < >
389- { input . split ( "" ) . map ( x => < > { x } { x . match ( / [ + / % ] / ) && < wbr /> } </ > ) }
363+ { input . split ( "" ) . map ( x => < span key = { x } > { x } { x . match ( / [ + / % ] / ) && < wbr /> } </ span > ) }
390364 </ >
391365 }
392366 function countUp < T > ( arr : T [ ] , v : T , i : number ) : number {
@@ -405,7 +379,7 @@ function TalentTable({ table }: { table: (TalentTable | TalentValue)[] }) {
405379 < table className = { `${ maxLevel > 3 ? "table-auto" : "table-fixed" } w-full ${ styles . table } mb-2 sm:text-sm md:text-base text-xs` } >
406380 < thead className = "font-semibold divide-x divide-gray-200 dark:divide-gray-500" >
407381 < td > Name</ td >
408- { levels . map ( ( i ) => < td key = { i } > Lv. { i + 1 } </ td > ) }
382+ { levels . map ( ( i ) => < td key = { i + 1 } > Lv. { i + 1 } </ td > ) }
409383 </ thead >
410384 < tbody className = "divide-y divide-gray-200 dark:divide-gray-500" >
411385 { table
@@ -446,7 +420,7 @@ function Constellation({ c }: { c: Constellation }) {
446420}
447421
448422export async function getStaticProps ( context : GetStaticPropsContext ) : Promise < GetStaticPropsResult < Props > > {
449- const charName = context . params ?. name
423+ const charName = context . params ?. char
450424 const data = await getCharacters ( )
451425
452426 const char = Object . values ( data ?? { } ) . find ( g => urlify ( g . name , false ) == charName )
@@ -499,8 +473,8 @@ export async function getStaticProps(context: GetStaticPropsContext): Promise<Ge
499473export async function getStaticPaths ( ) : Promise < GetStaticPathsResult > {
500474 const data = await getCharacters ( )
501475 return {
502- paths : Object . values ( data ?? { } ) . map ( g => ( {
503- params : { name : urlify ( g . name , false ) }
476+ paths : Object . values ( data ?? { } ) . map ( c => ( {
477+ params : { char : urlify ( c . name , false ) }
504478 } ) ) ?? [ ] ,
505479 fallback : "blocking"
506480 }
0 commit comments