Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
commonMain.io.github.lyxnx.compose.pine.PineTypography.kt Maven / Gradle / Ivy
package io.github.lyxnx.compose.pine
import androidx.compose.runtime.Composable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp
import mono.compose.pine.generated.resources.Res
import mono.compose.pine.generated.resources.inter_black
import mono.compose.pine.generated.resources.inter_bold
import mono.compose.pine.generated.resources.inter_extrabold
import mono.compose.pine.generated.resources.inter_extralight
import mono.compose.pine.generated.resources.inter_light
import mono.compose.pine.generated.resources.inter_medium
import mono.compose.pine.generated.resources.inter_regular
import mono.compose.pine.generated.resources.inter_semibold
import mono.compose.pine.generated.resources.inter_thin
import mono.compose.pine.generated.resources.nunitosans_black
import mono.compose.pine.generated.resources.nunitosans_black_italic
import mono.compose.pine.generated.resources.nunitosans_bold
import mono.compose.pine.generated.resources.nunitosans_bold_italic
import mono.compose.pine.generated.resources.nunitosans_extrabold
import mono.compose.pine.generated.resources.nunitosans_extrabold_italic
import mono.compose.pine.generated.resources.nunitosans_extralight
import mono.compose.pine.generated.resources.nunitosans_extralight_italic
import mono.compose.pine.generated.resources.nunitosans_light
import mono.compose.pine.generated.resources.nunitosans_light_italic
import mono.compose.pine.generated.resources.nunitosans_regular
import mono.compose.pine.generated.resources.nunitosans_regular_italic
import mono.compose.pine.generated.resources.nunitosans_semibold
import mono.compose.pine.generated.resources.nunitosans_semibold_italic
import org.jetbrains.compose.resources.Font
internal val LocalTypography = staticCompositionLocalOf { PineTypographyImpl }
/**
* Represents the typography used within the theme
*/
public interface PineTypography {
/**
* Heading 1 - the largest heading, equivalent to ``
*/
@get:Composable
public val heading1: TextStyle
/**
* Heading 2 - equivalent to ``
*/
@get:Composable
public val heading2: TextStyle
/**
* Heading 3 - equivalent to ``
*/
@get:Composable
public val heading3: TextStyle
/**
* Heading 4 - equivalent to ``
*/
@get:Composable
public val heading4: TextStyle
/**
* Heading 5 - equivalent to ``
*/
@get:Composable
public val heading5: TextStyle
/**
* Heading 6 - the smallest heading, equivalent to ``
*/
@get:Composable
public val heading6: TextStyle
/**
* Large body style, used over [bodyMedium] when more emphasis is needed
*/
@get:Composable
public val bodyLarge: TextStyle
/**
* Medium body style - the default text style when no other text style is explicitly specified
*/
@get:Composable
public val bodyMedium: TextStyle
/**
* Small body - usually used for subtexts
*/
@get:Composable
public val bodySmall: TextStyle
/**
* Extra small body - usually used for small prints
*/
@get:Composable
public val bodyExtraSmall: TextStyle
}
internal object PineTypographyImpl : PineTypography {
private val baseHeading: TextStyle
@Composable
get() = TextStyle(
fontFamily = FontFamily(
Font(Res.font.nunitosans_extralight, weight = FontWeight.ExtraLight),
Font(Res.font.nunitosans_extralight_italic, weight = FontWeight.ExtraLight, style = FontStyle.Italic),
Font(Res.font.nunitosans_light, weight = FontWeight.Light),
Font(Res.font.nunitosans_light_italic, weight = FontWeight.Light, style = FontStyle.Italic),
Font(Res.font.nunitosans_regular, weight = FontWeight.Normal),
Font(Res.font.nunitosans_regular_italic, weight = FontWeight.Normal, style = FontStyle.Italic),
Font(Res.font.nunitosans_semibold, weight = FontWeight.SemiBold),
Font(Res.font.nunitosans_semibold_italic, weight = FontWeight.SemiBold, style = FontStyle.Italic),
Font(Res.font.nunitosans_bold, weight = FontWeight.Bold),
Font(Res.font.nunitosans_bold_italic, weight = FontWeight.Bold, style = FontStyle.Italic),
Font(Res.font.nunitosans_extrabold, weight = FontWeight.ExtraBold),
Font(Res.font.nunitosans_extrabold_italic, weight = FontWeight.ExtraBold, style = FontStyle.Italic),
Font(Res.font.nunitosans_black, weight = FontWeight.Black),
Font(Res.font.nunitosans_black_italic, weight = FontWeight.Black, style = FontStyle.Italic),
)
)
override val heading1: TextStyle
@Composable
get() = baseHeading.copy(fontSize = 36.sp, lineHeight = 2.75.em)
override val heading2: TextStyle
@Composable
get() = baseHeading.copy(fontSize = 32.sp, lineHeight = 2.5.em)
override val heading3: TextStyle
@Composable
get() = baseHeading.copy(fontSize = 28.sp, lineHeight = 2.25.em)
override val heading4: TextStyle
@Composable
get() = baseHeading.copy(fontSize = 24.sp, lineHeight = 2.em)
override val heading5: TextStyle
@Composable
get() = baseHeading.copy(fontSize = 20.sp, lineHeight = 1.75.em)
override val heading6: TextStyle
@Composable
get() = baseHeading.copy(fontSize = 18.sp, lineHeight = 1.5.em)
//
private val baseBody: TextStyle
@Composable
get() = TextStyle(
fontFamily = FontFamily(
Font(Res.font.inter_thin, weight = FontWeight.Thin),
Font(Res.font.inter_extralight, weight = FontWeight.ExtraLight),
Font(Res.font.inter_light, weight = FontWeight.Light),
Font(Res.font.inter_regular, weight = FontWeight.Normal),
Font(Res.font.inter_medium, weight = FontWeight.Medium),
Font(Res.font.inter_semibold, weight = FontWeight.SemiBold),
Font(Res.font.inter_bold, weight = FontWeight.Bold),
Font(Res.font.inter_extrabold, weight = FontWeight.ExtraBold),
Font(Res.font.inter_black, weight = FontWeight.Black),
)
)
override val bodyLarge: TextStyle
@Composable
get() = baseBody.copy(fontSize = 18.sp, lineHeight = 1.5.em)
override val bodyMedium: TextStyle
@Composable
get() = baseBody.copy(fontSize = 16.sp, lineHeight = 1.5.em)
override val bodySmall: TextStyle
@Composable
get() = baseBody.copy(fontSize = 14.sp, lineHeight = 1.25.em)
override val bodyExtraSmall: TextStyle
@Composable
get() = baseBody.copy(fontSize = 12.sp, lineHeight = 1.em)
}