lovasoa / SQLpage

SQL-only webapp builder, empowering data analysts to build websites and applications quickly
https://sql.ophir.dev
MIT License
880 stars 62 forks source link

Enhanced Font Management with Local and Google Fonts In the shell component #439

Closed amrutadotorg closed 1 week ago

amrutadotorg commented 1 week ago

Pull Request Summary: Enhanced Font Management with Local and Google Fonts

Description

This pull request enhances the font management capabilities by refining the handling of the font variable to support both local fonts and Google Fonts seamlessly. It ensures backward compatibility with existing configurations while offering enhanced flexibility in font selection.

Key Changes

  1. Unified Font Variable:

    • Consolidated font management under the font variable, supporting both single fonts and lists.
    • Automatically wraps single font strings in an array to simplify configuration.
  2. Local Font Support:

    • Introduced support for local fonts by detecting paths starting with /.
    • Dynamically generates @font-face rules for each local font in various formats (WOFF2, WOFF, TTF, OTF, EOT, SVG).
  3. Google Fonts Integration:

    • Continued seamless integration with Google Fonts.
    • Generated <link> tags to import specified Google Fonts into the project.
  4. CSS Variable Enhancements:

    • Created CSS variables for each custom font to facilitate consistent and flexible font styling across the application.
    • Appended _custom to the names of local fonts in CSS variables to distinguish them from Google Fonts.

Detailed Changes

Example Usage

Single Font (Backward Compatible):

{{!-- Existing usage, no changes needed --}}
{{set "font" "Roboto"}}

Multiple Fonts with Local and Google Fonts:

{{!-- New usage, specifying multiple fonts including local --}}
{{set "font" (array "Roboto" "/path/to/local/font" "Open+Sans")}}

Benefits

Impact

This pull request significantly improves font management capabilities, offering users more flexibility and control while maintaining compatibility with existing configurations. It enhances the ability to incorporate both local and Google Fonts seamlessly into projects, ensuring consistent and appealing typography.

amrutadotorg commented 1 week ago

please take a look if you like it then I can update the docs.

for the font property it will be:

Specifies the font or fonts to be used for text display. This can be a valid font name from Google Fonts (e.g., 'Roboto', 'Open Sans') or a path to a local font file starting with '/'. Multiple fonts can be specified as an array, allowing for flexible typography options.

lovasoa commented 1 week ago

This actually completely broke SQLPage, because the startsWith handlebars helper does not exist. I'll fix it, but it is a sign that I really need to add better CI tests.

and @amrutadotorg , you should probably test your changes before proposing them ;)

amrutadotorg commented 1 week ago

Thank you, will do that next time.