Skip to content
Font picker form field with preview for SilverStripe CMS
JavaScript PHP CSS Scheme
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
_config Always require bundles, as it wouldn't work the other way Jul 21, 2019
client
src/Forms Always require bundles, as it wouldn't work the other way Jul 21, 2019
templates/SilverStripe/Fontpicker/Forms First commit Jul 10, 2019
tests/Forms Fix tests to ... actually pass Jul 25, 2019
.editorconfig First commit Jul 10, 2019
.eslintrc.js
.gitattributes
.gitignore
.scrutinizer.yml First commit Jul 10, 2019
.travis.yml
LICENSE.md First commit Jul 10, 2019
code-of-conduct.md First commit Jul 10, 2019
composer.json
package.json
phpunit.xml.dist
readme.md Fixed badges Jul 24, 2019
webpack.config.js First commit Jul 10, 2019
yarn.lock First commit Jul 10, 2019

readme.md

Fontpicker Module

Build Status Scrutinizer Code Quality codecov

This module adds a font picker field which can be added anywhere and is used to pick and preview a font.

Usage

To add a FontPickerField you can write the following:

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $fonts = [
            'nunito-sans' => 'Nunito Sans',
            'fira-sans' => 'Fira Sans',
            'merriweather' => 'Merriweather',
        ];

        // Import each font via the google fonts api to render font preview
        foreach ($fonts as $fontTitle) {
            $fontFamilyName = str_replace(' ', '+', $fontTitle);
            Requirements::css("//fonts.googleapis.com/css?family=$fontFamilyName");
        }

        $fields->addFieldsToTab(
            'Root.Main',
            [
                FontPickerField::create(
                    'MainFontFamily',
                    _t(
                        __CLASS__ . '.MainFontFamily',
                        'Main font family'
                    ),
                    $fonts
                )
            ]
        );
        
        return $fields;
    }

See silverstripe/theme-fontpicker for an example.

Versioning

This library follows Semver. According to Semver, you will be able to upgrade to any minor or patch version of this library without any breaking changes to the public API. Semver also requires that we clearly define the public API for this library.

All methods, with public visibility, are part of the public API. All other methods are not part of the public API. Where possible, we'll try to keep protected methods backwards-compatible in minor/patch versions, but if you're overriding methods then please test your work before upgrading.

You can’t perform that action at this time.