Documentation
¶
Overview ¶
Package css is responsible for the generation of CSS.
Index ¶
- Variables
- func ApproxTone(rgb int, tone int) int
- type Color
- func (color Color) Channels() (a, r, g, b int)
- func (color Color) Darken(units int) Color
- func (color Color) Hover() Color
- func (color Color) HoverActive() Color
- func (color Color) IsBright() bool
- func (color Color) IsDark() bool
- func (color Color) Lighten(units int) Color
- func (color Color) Mix(mixin Color, mixinWeightPct int) Color
- func (color Color) Rotate(degrees int) Color
- func (color Color) String() string
- func (color Color) Tone(tone int) Color
- type Font
- type KeyColors
- type TypeFace
- type TypeScale
Constants ¶
This section is empty.
Variables ¶
var DefaultKeyColors = PresetKeyColors[0]
var DefaultTypeFace = TypeFace{
Brand: "'Roboto Flex', system-ui, sans-serif",
Plain: "'Roboto Flex', system-ui, sans-serif",
WeightRegular: 400,
WeightMedium: 600,
}
var DefaultTypeScale = TypeScale{ DisplayLarge: Font{DefaultTypeFace.Brand, 48, 42.75, 0, DefaultTypeFace.WeightRegular}, DisplayMedium: Font{DefaultTypeFace.Brand, 39, 33.75, 0, DefaultTypeFace.WeightRegular}, DisplaySmall: Font{DefaultTypeFace.Brand, 33, 27, 0, DefaultTypeFace.WeightRegular}, HeadlineLarge: Font{DefaultTypeFace.Brand, 30, 24, 0, DefaultTypeFace.WeightRegular}, HeadlineMedium: Font{DefaultTypeFace.Brand, 27, 21, 0, DefaultTypeFace.WeightRegular}, HeadlineSmall: Font{DefaultTypeFace.Brand, 24, 18, 0, DefaultTypeFace.WeightRegular}, TitleLarge: Font{DefaultTypeFace.Brand, 21, 16.5, 0, DefaultTypeFace.WeightRegular}, TitleMedium: Font{DefaultTypeFace.Plain, 18, 12, 0.15, DefaultTypeFace.WeightMedium}, TitleSmall: Font{DefaultTypeFace.Plain, 15, 10.5, 0.1, DefaultTypeFace.WeightMedium}, LabelLarge: Font{DefaultTypeFace.Plain, 15, 10.5, 0.1, DefaultTypeFace.WeightMedium}, LabelMedium: Font{DefaultTypeFace.Plain, 12, 9, 0.5, DefaultTypeFace.WeightMedium}, LabelSmall: Font{DefaultTypeFace.Plain, 12, 8.25, 0.5, DefaultTypeFace.WeightMedium}, BodyLarge: Font{DefaultTypeFace.Plain, 18, 12, 0.5, DefaultTypeFace.WeightRegular}, BodyMedium: Font{DefaultTypeFace.Brand, 15, 10.5, 0.25, DefaultTypeFace.WeightRegular}, BodySmall: Font{DefaultTypeFace.Brand, 12, 9, 0.4, DefaultTypeFace.WeightRegular}, }
var PresetKeyColors = []KeyColors{ { Name: "Green", Primary: ParseColor("#426915"), Secondary: ParseColor("#57624a"), Tertiary: ParseColor("#386663"), Neutral: ParseColor("#5e5f59"), NeutralVariant: ParseColor("#5c6054"), Error: ParseColor("#ba1a1a"), OK: ParseColor("#1aba1a"), }, { Name: "Blue", Primary: ParseColor("#215fa6"), Secondary: ParseColor("#555f71"), Tertiary: ParseColor("#6e5676"), Neutral: ParseColor("#5e5e62"), NeutralVariant: ParseColor("#5b5e66"), Error: ParseColor("#ba1a1a"), OK: ParseColor("#1aba1a"), }, { Name: "Yellow", Primary: ParseColor("#636100"), Secondary: ParseColor("#616042"), Tertiary: ParseColor("#3e6656"), Neutral: ParseColor("#605e58"), NeutralVariant: ParseColor("#605f51"), Error: ParseColor("#ba1a1a"), OK: ParseColor("#1aba1a"), }, { Name: "Red", Primary: ParseColor("#a03f28"), Secondary: ParseColor("#77574f"), Tertiary: ParseColor("#6d5d2e"), Neutral: ParseColor("#655c5a"), NeutralVariant: ParseColor("#6c5b57"), Error: ParseColor("#ba1a1a"), OK: ParseColor("#1aba1a"), }, { Name: "Violet", Primary: ParseColor("#715573"), Secondary: ParseColor("#005ac1"), Tertiary: ParseColor("#575e71"), Neutral: ParseColor("#5e5e62"), NeutralVariant: ParseColor("#5c5e66"), Error: ParseColor("#ba1a1a"), OK: ParseColor("#1aba1a"), }, { Name: "Olive", Primary: ParseColor("#705d00"), Secondary: ParseColor("#675e40"), Tertiary: ParseColor("#44664e"), Neutral: ParseColor("#615e57"), NeutralVariant: ParseColor("#635e50"), Error: ParseColor("#ba1a1a"), OK: ParseColor("#1aba1a"), }, { Name: "Meadow", Primary: ParseColor("#006496"), Secondary: ParseColor("#50606f"), Tertiary: ParseColor("#66587b"), Neutral: ParseColor("#5d5e61"), NeutralVariant: ParseColor("#595f65"), Error: ParseColor("#ba1a1a"), OK: ParseColor("#1aba1a"), }, { Name: "Roses", Primary: ParseColor("#9b4429"), Secondary: ParseColor("#77574d"), Tertiary: ParseColor("#6b5e2f"), Neutral: ParseColor("#655c5a"), NeutralVariant: ParseColor("#6c5b56"), Error: ParseColor("#ba1a1a"), OK: ParseColor("#1aba1a"), }, { Name: "Byzantine", Primary: ParseColor("#8e437e"), Secondary: ParseColor("#6f5767"), Tertiary: ParseColor("#815341"), Neutral: ParseColor("#635d60"), NeutralVariant: ParseColor("#675b62"), Error: ParseColor("#ba1a1a"), OK: ParseColor("#1aba1a"), }, { Name: "New Mexico", Primary: ParseColor("#705d00"), Secondary: ParseColor("#675e40"), Tertiary: ParseColor("#44664e"), Neutral: ParseColor("#615e57"), NeutralVariant: ParseColor("#635e50"), Error: ParseColor("#bd082f"), OK: ParseColor("#1aba1a"), }, { Name: "Miami Dolphins", Primary: ParseColor("#006970"), Secondary: ParseColor("#00658b"), Tertiary: ParseColor("#4f5e7d"), Neutral: ParseColor("#5d5f5a"), NeutralVariant: ParseColor("#5b6056"), Error: ParseColor("#ae3100"), OK: ParseColor("#1aba1a"), }, }
Functions ¶
func ApproxTone ¶
ApproxTone calculates an approximation of the HCT tonal level for a given color. It used a pre-calculated tonal map with a granularity of 0x08. Tone must be a number between 0 and 100.
Types ¶
type Color ¶
type Color int
Color is an immutable structure that holds an ARGB color value.
func ParseColor ¶
ParseColor parses a color string in the format "#FF0000", "FF0000" or "rgba(255,0,0,1.0)".
func (Color) HoverActive ¶
Hover adjusts the color to highlight an element that is hovered.
func (Color) Mix ¶
Mix creates a new color that is a weighted average of two colors. The percentage gives weight to the mixin color. A percentage greater than 50 gives more weight to the mixin color. A percentage smaller than 50 gives more weight to the original color. A percentage of 50 averages the two colors equally.
type Font ¶
Font is used to customize the style of the page. LineHeight and Size are in CSS points (pt). The Material design defaults use the px-equivalent values scaled by 12/16 (1pt = 1/72 in ≈ 1.333px at 96 dpi, so 12pt ≈ 16px).
type KeyColors ¶
type KeyColors struct {
Name string
Primary Color
Secondary Color
Tertiary Color
Neutral Color
NeutralVariant Color
Error Color
OK Color
}
KeyColors are the Material key colors of the color scheme from which all the color tones are derived. https://m3.material.io/styles/color/the-color-system/key-colors-tones .
func KeyColorsFromString ¶
KeyColorsFromString deserializes the key colors from a string.
func (KeyColors) WriteCSSThemes ¶
WriteCSSThemes writes the Material variables of the light and dark themes.
type TypeScale ¶
type TypeScale struct {
DisplayLarge Font
DisplayMedium Font
DisplaySmall Font
HeadlineLarge Font
HeadlineMedium Font
HeadlineSmall Font
TitleLarge Font
TitleMedium Font
TitleSmall Font
LabelLarge Font
LabelMedium Font
LabelSmall Font
BodyLarge Font
BodyMedium Font
BodySmall Font
}
TypeScale is a selection of font styles that can be used across an app, ensuring a flexible, yet consistent, style that accommodates a range of purposes. The Material Design type scale is a combination of 15 styles, each with an intended application and meaning. They’re assigned based on use (such as display or headline), and grouped more broadly into categories based on scale (such as large or small). Material Design’s default type scale uses Roboto for all titles, labels, and body text, creating a cohesive typography experience.