Skip to content

Complete PR 68 - Add Generic Font Families #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based
Breaking changes:

New features:
- Add smart constructors for generic font families (#68, #136 by @Unisay and @JordanMartinez)

Bugfixes:

Expand Down
36 changes: 36 additions & 0 deletions src/CSS/Font.purs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,45 @@ derive instance ordGenericFontFamily :: Ord GenericFontFamily
instance valGenericFontFamily :: Val GenericFontFamily where
value (GenericFontFamily v) = v

serif :: GenericFontFamily
serif = GenericFontFamily $ fromString "serif"

sansSerif :: GenericFontFamily
sansSerif = GenericFontFamily $ fromString "sans-serif"

cursive :: GenericFontFamily
cursive = GenericFontFamily $ fromString "cursive"

monospace :: GenericFontFamily
monospace = GenericFontFamily $ fromString "monospace"

fantasy :: GenericFontFamily
fantasy = GenericFontFamily $ fromString "fantasy"

systemUi :: GenericFontFamily
systemUi = GenericFontFamily $ fromString "system-ui"

uiSerif :: GenericFontFamily
uiSerif = GenericFontFamily $ fromString "ui-serif"

uiSansSerif :: GenericFontFamily
uiSansSerif = GenericFontFamily $ fromString "ui-sans-serif"

uiMonospace :: GenericFontFamily
uiMonospace = GenericFontFamily $ fromString "ui-monospace"

uiRounded :: GenericFontFamily
uiRounded = GenericFontFamily $ fromString "ui-rounded"

emoji :: GenericFontFamily
emoji = GenericFontFamily $ fromString "emoji"

math :: GenericFontFamily
math = GenericFontFamily $ fromString "math"

fangsong :: GenericFontFamily
fangsong = GenericFontFamily $ fromString "fangsong"

fontFamily :: Array String -> NonEmpty Array GenericFontFamily -> CSS
fontFamily a b = key (fromString "font-family") <<< value $ (value <<< quote <$> a) <> oneOf (value <$> b)

Expand Down