import { culture , lifestyle , news , neutral , opinion , specialReport , sport , labs , } from "@guardian/source-foundations" ; import { ArticleDesign , ArticleDisplay , ArticleFormat , ArticlePillar , ArticleSpecial } from "@guardian/libs" ; type Colour = string ; interface Palette { text : { headline : Colour ; headlineDark : Colour ; standfirst : Colour ; standfirstDark : Colour ; standfirstLink : Colour ; seriesTitle : Colour ; } ; background : { headline : Colour ; headlineDark : Colour ; standfirst : Colour ; standfirstDark : Colour ; } ; border : { articleLink : Colour ; articleLinkDark : Colour ; standfirstLink : Colour ; standfirstLinkDark : Colour ; } ; fill : { icon : Colour ; iconDark : Colour ; } ; } const textHeadline = ( format ) : Colour => { if ( format . display === ArticleDisplay . Immersive || format . design === ArticleDesign . Media || format . design === ArticleDesign . LiveBlog ) { return neutral [ 100 ] ; } if ( format . design === ArticleDesign . DeadBlog ) { return neutral [ 7 ] ; } if ( format . design === ArticleDesign . Feature || format . design === ArticleDesign . Review ) { switch ( format . theme ) { case ArticlePillar . Opinion : return opinion [ 300 ] ; case ArticlePillar . Sport : return sport [ 300 ] ; case ArticlePillar . Culture : return culture [ 300 ] ; case ArticlePillar . Lifestyle : return lifestyle [ 300 ] ; default : return news [ 300 ] ; } } return neutral [ 7 ] ; } ; const textHeadlineDark = ( format ) : Colour => { switch ( format . design ) { case ArticleDesign . LiveBlog : return format . theme === ArticlePillar . Culture ? neutral [ 86 ] : neutral [ 93 ] ; case ArticleDesign . DeadBlog : return neutral [ 93 ] ; default : return neutral [ 86 ] ; } } ; const textStandfirst = ( { design } ) : Colour => { switch ( design ) { case ArticleDesign . LiveBlog : return neutral [ 100 ] ; case ArticleDesign . Media : return neutral [ 86 ] ; default : return neutral [ 7 ] ; } } ; const textStandfirstDark = ( { design } ) : Colour => { switch ( design ) { case ArticleDesign . LiveBlog : case ArticleDesign . DeadBlog : return neutral [ 93 ] ; default : return neutral [ 60 ] ; } } ; const textStandfirstLink = ( format ) : Colour => { switch ( format . design ) { case ArticleDesign . LiveBlog : return neutral [ 100 ] ; case ArticleDesign . DeadBlog : switch ( format . theme ) { case ArticlePillar . News : return news [ 400 ] ; case ArticlePillar . Lifestyle : return lifestyle [ 400 ] ; case ArticlePillar . Sport : return sport [ 400 ] ; case ArticlePillar . Culture : return culture [ 300 ] ; case ArticlePillar . Opinion : return opinion [ 300 ] ; case ArticleSpecial . Labs : return labs [ 300 ] ; case ArticleSpecial . SpecialReport : return specialReport [ 300 ] ; } case ArticleDesign . Media : switch ( format . theme ) { case ArticlePillar . News : return news [ 500 ] ; case ArticlePillar . Culture : return culture [ 500 ] ; case ArticlePillar . Lifestyle : return lifestyle [ 500 ] ; case ArticlePillar . Sport : return sport [ 500 ] ; case ArticlePillar . Opinion : return opinion [ 500 ] ; case ArticleSpecial . Labs : return labs [ 300 ] ; case ArticleSpecial . SpecialReport : return specialReport [ 500 ] ; } default : { switch ( format . theme ) { case ArticlePillar . News : return news [ 400 ] ; case ArticlePillar . Culture : return culture [ 400 ] ; case ArticlePillar . Lifestyle : return lifestyle [ 400 ] ; case ArticlePillar . Sport : return sport [ 400 ] ; case ArticlePillar . Opinion : return opinion [ 400 ] ; case ArticleSpecial . Labs : return labs [ 300 ] ; case ArticleSpecial . SpecialReport : return specialReport [ 400 ] ; } } } } ; const textSeriesTitle = ( format ) : Colour => { switch ( format . theme ) { case ArticlePillar . News : return news [ 400 ] ; case ArticlePillar . Lifestyle : return lifestyle [ 400 ] ; case ArticlePillar . Sport : return sport [ 400 ] ; case ArticlePillar . Culture : return culture [ 300 ] ; case ArticlePillar . Opinion : return opinion [ 300 ] ; case ArticleSpecial . Labs : return labs [ 300 ] ; case ArticleSpecial . SpecialReport : return specialReport [ 300 ] ; } } ; const backgroundHeadline = ( format ) : Colour => { if ( format . display === ArticleDisplay . Immersive ) { return neutral [ 7 ] ; } else if ( format . design === ArticleDesign . DeadBlog ) { return neutral [ 97 ] ; } else if ( format . design === ArticleDesign . LiveBlog ) { switch ( format . theme ) { case ArticlePillar . Culture : return culture [ 300 ] ; case ArticlePillar . Sport : return sport [ 300 ] ; case ArticlePillar . Lifestyle : return lifestyle [ 300 ] ; case ArticlePillar . Opinion : return opinion [ 300 ] ; case ArticlePillar . News : return news [ 300 ] ; default : return news [ 300 ] ; } } else if ( format . design === ArticleDesign . Comment || format . design === ArticleDesign . Letter || format . design === ArticleDesign . Editorial ) { return opinion [ 800 ] ; } else if ( format . design === ArticleDesign . Media ) { return neutral [ 10 ] ; } return neutral [ 100 ] ; } ; const backgroundHeadlineDark = ( format ) : Colour => { if ( format . design === ArticleDesign . LiveBlog || format . design === ArticleDesign . DeadBlog ) { switch ( format . theme ) { case ArticlePillar . Culture : return culture [ 200 ] ; case ArticlePillar . Sport : return sport [ 200 ] ; case ArticlePillar . Lifestyle : return lifestyle [ 200 ] ; case ArticlePillar . Opinion : return opinion [ 200 ] ; case ArticlePillar . News : return news [ 200 ] ; default : return news [ 200 ] ; } } return neutral [ 10 ] ; } ; const borderArticleLink = ( format ) : Colour => { switch ( format . theme ) { case ArticlePillar . Opinion : return opinion [ 400 ] ; case ArticlePillar . Sport : return sport [ 400 ] ; case ArticlePillar . Culture : return culture [ 400 ] ; case ArticlePillar . Lifestyle : return lifestyle [ 400 ] ; case ArticlePillar . News : default : return news [ 400 ] ; } } ; const borderArticleLinkDark = borderArticleLink ; const borderStandfirstLink = ( format ) : Colour => { if ( format . design === ArticleDesign . LiveBlog ) { return neutral [ 100 ] ; } if ( format . theme === ArticleSpecial . SpecialReport ) { return specialReport [ 400 ] ; } return neutral [ 86 ] ; } ; const borderStandfirstLinkDark = ( format ) : Colour => { return neutral [ 46 ] ; } ; const backgroundStandfirst = ( { design , theme , } ) : Colour => { if ( design === ArticleDesign . DeadBlog ) { return neutral [ 93 ] ; } if ( design === ArticleDesign . LiveBlog ) { switch ( theme ) { case ArticlePillar . Opinion : return opinion [ 200 ] ; case ArticlePillar . Sport : return sport [ 100 ] ; case ArticlePillar . Culture : return culture [ 200 ] ; case ArticlePillar . Lifestyle : return lifestyle [ 200 ] ; case ArticlePillar . News : default : return news [ 200 ] ; } } return neutral [ 100 ] ; } ; const backgroundStandfirstDark = ( { design , theme , } ) : Colour => { switch ( design ) { case ArticleDesign . DeadBlog : return neutral [ 10 ] ; case ArticleDesign . LiveBlog : switch ( theme ) { case ArticlePillar . Opinion : return opinion [ 100 ] ; case ArticlePillar . Sport : return sport [ 100 ] ; case ArticlePillar . Culture : return culture [ 100 ] ; case ArticlePillar . Lifestyle : return lifestyle [ 100 ] ; case ArticlePillar . News : default : return news [ 100 ] ; } default : return neutral [ 10 ] ; } } ; const fillIcon = ( format ) : Colour => { switch ( format . theme ) { case ArticlePillar . Opinion : return opinion [ 400 ] ; case ArticlePillar . Sport : return sport [ 400 ] ; case ArticlePillar . Culture : return culture [ 400 ] ; case ArticlePillar . Lifestyle : return lifestyle [ 400 ] ; case ArticleSpecial . SpecialReport : return specialReport [ 500 ] ; case ArticlePillar . News : default : return news [ 400 ] ; } } ; const fillIconDark = ( format ) : Colour => { switch ( format . theme ) { case ArticlePillar . Opinion : return opinion [ 500 ] ; case ArticlePillar . Sport : return sport [ 500 ] ; case ArticlePillar . Culture : return culture [ 500 ] ; case ArticlePillar . Lifestyle : return lifestyle [ 500 ] ; case ArticleSpecial . SpecialReport : return specialReport [ 500 ] ; case ArticlePillar . News : default : return news [ 500 ] ; } } ; const text = { headline : textHeadline , headlineDark : textHeadlineDark , standfirst : textStandfirst , standfirstDark : textStandfirstDark , standfirstLink : textStandfirstLink , seriesTitle : textSeriesTitle } ; const background = { headline : backgroundHeadline , headlineDark : backgroundHeadlineDark , standfirst : backgroundStandfirst , standfirstDark : backgroundStandfirstDark } ; const border = { articleLink : borderArticleLink , articleLinkDark : borderArticleLinkDark , standfirstLink : borderStandfirstLink , standfirstLinkDark : borderStandfirstLinkDark } ; const fill = { icon : fillIcon , iconDark : fillIconDark } ; const palette = ( format ) : Palette => ( { text : { headline : text . headline ( format ) , headlineDark : text . headlineDark ( format ) , standfirst : text . standfirst ( format ) , standfirstDark : text . standfirstDark ( format ) , standfirstLink : text . standfirstLink ( format ) , seriesTitle : text . seriesTitle ( format ) } , background : { headline : background . headline ( format ) , headlineDark : background . headlineDark ( format ) , standfirst : background . standfirst ( format ) , standfirstDark : backgroundStandfirstDark ( format ) } , border : { articleLink : border . articleLink ( format ) , articleLinkDark : border . articleLinkDark ( format ) , standfirstLink : border . standfirstLink ( format ) , standfirstLinkDark : border . standfirstLinkDark ( format ) } , fill : { icon : fill . icon ( format ) , iconDark : fill . iconDark ( format ) } } ) ; export type { Colour } ; export { text , background , border , fill , palette } ;