pattern-lab / styleguidekit-assets-default

The static assets for the default StyleguideKit for Pattern Lab. Contains styles and mark-up for Pattern Lab's front-end.
http://patternlab.io/
MIT License
35 stars 67 forks source link

ishViewportRange doesn't exist in config object provided by PatternLab PHP #63

Closed notacouch closed 7 years ago

notacouch commented 7 years ago

My local instance of PatternLab is via a fork of Phase2's drupal starter kit. I was excited to see the recent release of viewport range support in 3.5.0 so had successfully updated this particular dependency via composer.

However, after modifying pattern-lab/config/config.yml, the values were still not respected.

I edited pattern-lab/public/styleguide/js/patternlab-viewer.min.js to see where things were falling apart and added a console.log to observe the value for config. It looks something like this:

{
    cacheBuster: 1495725687,
    defaultPattern: "styleguide-styleguide",
    defaultShowPatternInfo: false,
    ishMaximum: "2600",
    ishMinimum: "240",
    outputFileSuffixes: Object,
    plugins: Object
}

ishViewportRange is not there.

Further investigation, the node packages see it, PHP Pattern Lab sees it... ultimately it seems only exposedOptions manually configured in patternlab-php-core are provided to config in pattern-lab/public/styleguide/data/patternlab-data.js.

See Config.php (2.7.0 is what I am currently using): https://github.com/pattern-lab/patternlab-php-core/blob/v2.7.0/src/PatternLab/Config.php#L240

        // which of these should be exposed in the front-end?
        self::$options["exposedOptions"] = array();
        self::setExposedOption("cacheBuster");
        self::setExposedOption("defaultPattern");
        self::setExposedOption("defaultShowPatternInfo");
        self::setExposedOption("ishFontSize");
        self::setExposedOption("ishMaximum");
        self::setExposedOption("ishMinimum");
        self::setExposedOption("outputFileSuffixes");
        self::setExposedOption("plugins");

and Builder.php https://github.com/pattern-lab/patternlab-php-core/blob/v2.7.0/src/PatternLab/Builder.php#L103

        // load and write out the config options
        $config                         = array();
        $exposedOptions                 = Config::getOption("exposedOptions");
        foreach ($exposedOptions as $exposedOption) {
            $config[$exposedOption]     = Config::getOption($exposedOption);
        }
        $output     .= "var config = ".json_encode($config).";\n";

Am I on to something here or is there something up with my setup?

bmuenzenmeyer commented 7 years ago

thanks for the sleuthing. I had assumed that PL PHP would allow any new config entries to pass through...

this is a bug in patternlab-php-core then. I do not maintain that library anymore, but I am sure someone can patch it without too much trouble.

bmuenzenmeyer commented 7 years ago

created an issue over there.