module FF.CSS.Spec.Safe.Syntax where

open import Agda.Builtin.String using (String)

open import FF.CSS.Core using (Declaration; declare)
open import FF.CSS.Spec.Safe public

infix 2 _:=_

_:=_ : (propertyName : PropertyName) -> CssValue propertyName -> DeclarationT
propertyName := value = declare propertyName value

pxLength : String -> Length
pxLength value = length (dimension (number value) px)

remLength : String -> Length
remLength value = length (dimension (number value) rem)

percent : String -> Percentage
percent = percentage

lp : Length -> LengthPercentage
lp = lengthValue

pct : Percentage -> LengthPercentage
pct = percentageValue

autoValue : LengthPercentageAuto
autoValue = auto

lpAuto : LengthPercentage -> LengthPercentageAuto
lpAuto = lengthPercentageValue

inset-lp : LengthPercentage -> InsetOffset
inset-lp = insetLengthPercentage

size-lp : LengthPercentage -> PreferredSize
size-lp value = preferredSize (sizeLengthPercentage value)

margin-lp : LengthPercentage -> MarginSize
margin-lp = marginLengthPercentage

keyword : {propertyName : PropertyName} -> GlobalKeyword -> CssValue propertyName
keyword = wide

value : {propertyName : PropertyName} -> PropertyValue propertyName -> CssValue propertyName
value = specific

color : Color -> DeclarationT
color value = colorProp := specific (colorValue value)

background-color : Color -> DeclarationT
background-color value = backgroundColorProp := specific (backgroundColorValue value)

display : Display -> DeclarationT
display value = displayProp := specific (displayValue value)

position : Position -> DeclarationT
position value = positionProp := specific (positionValue value)

width : PreferredSize -> DeclarationT
width value = widthProp := specific (widthValue value)

height : PreferredSize -> DeclarationT
height value = heightProp := specific (heightValue value)

margin : BoxSides MarginSize -> DeclarationT
margin value = marginProp := specific (marginValue value)

padding : BoxSides LengthPercentage -> DeclarationT
padding value = paddingProp := specific (paddingValue value)

font-size : LengthPercentage -> DeclarationT
font-size value = fontSizeProp := specific (fontSizeValue value)

text-align : TextAlign -> DeclarationT
text-align value = textAlignProp := specific (textAlignValue value)

flex-direction : FlexDirection -> DeclarationT
flex-direction value = flexDirectionProp := specific (flexDirectionValue value)

gap-value : LengthPercentage -> GapValue
gap-value = gapLengthPercentage

gap : OneOrTwo GapValue -> DeclarationT
gap value = gapProp := specific (gapValue value)