Font Picker

Font Picker #

The font-picker field creates a font picker field populated by the Google Fonts Api. The output is a string with a Font Family name.

Font Picker

Font Picker

Properties #

propertyvalue typeoptionaldescription
keystringmandatoryKeys are for internal use and must be unique
titlestringoptionalThe title of the element
tipstringoptional (default: null)Text entered here with markdown formatting is displayed as context help in an overlay box
defaultstringoptional (default: null)default value when the key is not set yet
autoSavebooleanoptional (default: false)Form data is automatically saved after changing the value
limitintegeroptional (default: 50)Max. amount of fonts to load, the most populair fonts are loaded
familiesarray of stringsoptional (default: null)Array with Font Family names. If set, only these fonts are loaded
categoriesarray of stringsoptional (default: null)Array with Font Catogories. If set, only these fonts from these categories are loaded. “sans-serif”, “serif”, “display”, “handwriting”, “monospace”

Sample #

Configuration #

./quiqr/model/base.
     
default: roboto
families:
- roboto
- roboto condensed
- lato
- open sans
key: sample_field
title: Sample field
type: font-picker
default = "roboto"
families = ["roboto", "roboto condensed", "lato", "open sans"]
key = "sample_field"
title = "Sample field"
type = "font-picker"
{
   "default": "roboto",
   "families": [
      "roboto",
      "roboto condensed",
      "lato",
      "open sans"
   ],
   "key": "sample_field",
   "title": "Sample field",
   "type": "font-picker"
}

Output #

sample_field: lato

Sample 2 #

Configuration #

./quiqr/model/base.
     
categories:
- handwriting
default: roboto
key: sample_field
limit: 40
title: Sample field
type: font-picker
categories = ["handwriting"]
default = "roboto"
key = "sample_field"
limit = 40
title = "Sample field"
type = "font-picker"
{
   "categories": [
      "handwriting"
   ],
   "default": "roboto",
   "key": "sample_field",
   "limit": 40,
   "title": "Sample field",
   "type": "font-picker"
}

Output #

sample_field: lato

Hugo Theme Template Implementation #

This is an example implementation for managing 3 fonts with Quiqr in your Hugo Theme. The video shows the result applied to the vex-theme.

Create a partial model file with the path SITEROOT/quiqr/model/partials/single_design.yaml Add this configuration:

---
file: data/design.json
title: Design
fields:
  - key: "primary_font"
    title: "Main Text Font"
    type: "font-picker"
    tip: "choose your font"
    limit: 50
    categories:
      - sans-serif

  - key: "headings_font"
    title: "Headings Font"
    type: "font-picker"
    tip: "choose your font"
    limit: 300

Add partial to your singles file with the path SITEROOT/quiqr/model/include/singles.yaml`

- key: design
  _mergePartial: single_design

Add single to your menu file with the path SITEROOT/quiqr/model/include/menu.yaml`

- key: Settings
  menuItems:
    - key: design
  title: Settings

Create a partial template in your hugo theme called style-fonts-import.html and include this the <head> of your Hugo Theme.

<style>

@import url('https://fonts.googleapis.com/css2?family={{ $.Site.Data.design.primary_font }}:ital,wght@0,300;0,400;0,700;0,900;1,300;1,400;1,700;1,900&display=swap');
@import url('https://fonts.googleapis.com/css2?family={{ $.Site.Data.design.secondary_font }}:ital,wght@0,300;0,400;0,700;0,900;1,300;1,400;1,700;1,900&display=swap');
@import url('https://fonts.googleapis.com/css2?family={{ $.Site.Data.design.headings_font }}:ital,wght@0,300;0,400;0,700;0,900;1,300;1,400;1,700;1,900&display=swap');

Create a partial template in your hugo theme called style-overrides.html and include this the <head> of your Hugo Theme.

<style>

body {
  font-family: '{{$.Site.Data.design.primary_font }}', sans-serif;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: '{{ $.Site.Data.design.headings_font }}', serif;
}
.testimonials .testimonial-block p {
  font-family: '{{ $.Site.Data.design.secondary_font }}', serif;
}
</style>

Credits #

Font Picker is based on Font Picker React.