@@ -537,43 +537,33 @@ function colorIsUnified(blcd: BrandColorLightDark) {
537537}
538538export function brandIsUnified ( brand : BrandUnified ) : boolean {
539539 if ( brand . color ) {
540- if (
541- Array . from ( Zod . BrandNamedThemeColor . options ) . some (
542- ( colorName ) => {
543- if ( ! brand . color ! [ colorName ] ) {
544- return false ;
545- }
546- return colorIsUnified ( brand . color ! [ colorName ] ) ;
547- } ,
548- )
549- ) {
550- return true ;
540+ for ( const colorName of Zod . BrandNamedThemeColor . options ) {
541+ if ( ! brand . color [ colorName ] ) {
542+ continue ;
543+ }
544+ if ( colorIsUnified ( brand . color ! [ colorName ] ) ) {
545+ return true ;
546+ }
551547 }
552548 }
553549 if ( brand . typography ) {
554- if (
555- Array . from ( Zod . BrandNamedTypographyElements . options ) . some (
556- ( elementName ) => {
557- const element = brand . typography ! [ elementName ] ;
558- if ( ! element || typeof element === "string" ) {
559- return false ;
560- }
561- if (
562- "background-color" in element && element [ "background-color" ] &&
563- colorIsUnified ( element [ "background-color" ] )
564- ) {
565- return true ;
566- }
567- if (
568- "color" in element && element [ "color" ] &&
569- colorIsUnified ( element [ "color" ] )
570- ) {
571- return true ;
572- }
573- } ,
574- )
575- ) {
576- return true ;
550+ for ( const elementName of Zod . BrandNamedTypographyElements . options ) {
551+ const element = brand . typography ! [ elementName ] ;
552+ if ( ! element || typeof element === "string" ) {
553+ continue ;
554+ }
555+ if (
556+ "background-color" in element && element [ "background-color" ] &&
557+ colorIsUnified ( element [ "background-color" ] )
558+ ) {
559+ return true ;
560+ }
561+ if (
562+ "color" in element && element [ "color" ] &&
563+ colorIsUnified ( element [ "color" ] )
564+ ) {
565+ return true ;
566+ }
577567 }
578568 }
579569 return false ;
@@ -584,22 +574,20 @@ function sharedTypography(
584574 const ret : BrandTypographySingle = {
585575 fonts : unified . fonts ,
586576 } ;
587- Array . from ( Zod . BrandNamedTypographyElements . options ) . forEach (
588- ( element ) => {
589- if ( ! unified [ element ] ) {
590- return ;
591- }
592- if ( typeof unified [ element ] === "string" ) {
593- ret [ element ] = unified [ element ] ;
594- return ;
595- }
596- ret [ element ] = Object . fromEntries (
597- Object . entries ( unified [ element ] ) . filter (
598- ( [ key , _ ] ) => ! [ "color" , "background-color" ] . includes ( key ) ,
599- ) ,
600- ) ;
601- } ,
602- ) ;
577+ for ( const elementName of Zod . BrandNamedTypographyElements . options ) {
578+ if ( ! unified [ elementName ] ) {
579+ continue ;
580+ }
581+ if ( typeof unified [ elementName ] === "string" ) {
582+ ret [ elementName ] = unified [ elementName ] ;
583+ continue ;
584+ }
585+ ret [ elementName ] = Object . fromEntries (
586+ Object . entries ( unified [ elementName ] ) . filter (
587+ ( [ key , _ ] ) => ! [ "color" , "background-color" ] . includes ( key ) ,
588+ ) ,
589+ ) ;
590+ }
603591 return ret ;
604592}
605593function splitUnifiedBrand (
@@ -756,17 +744,15 @@ function splitUnifiedBrand(
756744 defaults : unifiedBrand . defaults ,
757745 } ;
758746 if ( unifiedBrand . color ) {
759- Array . from ( Zod . BrandNamedThemeColor . options ) . forEach (
760- ( colorName ) => {
761- if ( ! unifiedBrand . color ! [ colorName ] ) {
762- return ;
763- }
764- ( {
765- light : lightBrand . color ! [ colorName ] ,
766- dark : darkBrand . color ! [ colorName ] ,
767- } = splitColorLightDark ( unifiedBrand . color ! [ colorName ] ) ) ;
768- } ,
769- ) ;
747+ for ( const colorName of Zod . BrandNamedThemeColor . options ) {
748+ if ( ! unifiedBrand . color [ colorName ] ) {
749+ continue ;
750+ }
751+ ( {
752+ light : lightBrand . color ! [ colorName ] ,
753+ dark : darkBrand . color ! [ colorName ] ,
754+ } = splitColorLightDark ( unifiedBrand . color ! [ colorName ] ) ) ;
755+ }
770756 }
771757 return {
772758 light : new Brand ( lightBrand , brandDir , projectDir ) ,
0 commit comments