getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony

Home Page:https://getgrav.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typhoon Theme Extending

Eggeriley opened this issue · comments

I am getting an error message when I switch over to the new theme I created which is a direct copy of the typhoon theme. I used the devtools plugin and followed all steps in this article: https://getgrav.org/premium/typhoon/docs

**/Users/Rileyegge_1/Documents/CodeProjects/access-grav/user/plugins/color-tools/vendor/mexitek/phpcolors/src/Mexitek/PHPColors/Color.php**

private $_hsl;

/**
 * @var array
 */
private $_rgb;

/**
 * Auto darkens/lightens by 10% for sexily-subtle gradients.
 * Set this to FALSE to adjust automatic shade to be between given color
 * and black (for darken) or white (for lighten)
 */
public const DEFAULT_ADJUST = 10;

/**
 * Instantiates the class with a HEX value
 * @param string $hex
 * @throws Exception
 */
public function __construct(string $hex)
{
    $color = self::sanitizeHex($hex);
    $this->_hex = $color;
    $this->_hsl = self::hexToHsl($color);
    $this->_rgb = self::hexToRgb($color);
}

/**
 * Given a HEX string returns a HSL array equivalent.
 * @param string $color
 * @return array HSL associative array
 * @throws Exception
 */
public static function hexToHsl(string $color): array
{
    // Sanity check
    $color = self::sanitizeHex($color);

    // Convert HEX to DEC
    $R = hexdec($color[0] . $color[1]);

Arguments

1. "Mexitek\PHPColors\Color::__construct(): Argument #1 ($hex) must be of type string, null given, called in /Users/Rileyegge_1/Documents/CodeProjects/access-grav/u ▶"

I am getting this color helper PHP function issue when I try to use a new copied theme of typhoon. 

I had same problem. I fixed this with replace the content under the streams section in your [inherit-typhoon].yml from all content in typhoon.yml.

streams:
 schemes:                                                                                                        
   theme:
     type: ReadOnlyStream
     prefixes:
       '':
         - 'user://themes/inherit-typhoon'
         - 'user://themes/typhoon'
         
# !!!!!! Replace all of this with original content from typhoon.yml
enabled: true                                                       # Enable the theme
external_in_new_tab: false                                          # Open external URLs in new tab

The problem is dev-tools working incorrect.

getgrav/grav-premium-issues#50

@Eggeriley If you do a full 'copy' it should work fine. I just test a test with a theme I called "Typhoon 2" and it created the theme as typhoon-2. After switching to the new theme, everything works great, no issues. Are you on the latest version of devtools plugin? There have been some fixes in recent months.

➜ bin/plugin devtools new-theme --email=trilby@email.com --github=trilbymedia --dev="Trilby Media"

 Enter Theme Name:
 > Typhoon 2

 Enter Theme Description:
 > test

 Please choose an option:
  [pure-blank ] Basic Theme using Pure.css
  [tailwind   ] Basic Theme using tailwind.css
  [inheritance] Inherit from another theme
  [copy       ] Copy another theme
 > copy

 Please choose a theme to copy:
  [0] anico
  [1] bootstrap4
  [2] quark
  [3] test1
  [4] typhoon
 > typhoon

/home/me/web/user/themes/typhoon
SUCCESS theme Typhoon 2 -> Created Successfully

Path: /home/me/web/user/themes/typhoon-2

@YenLung-Huang You will need to copy over the defaults in the theme .yaml file as those are not merged with the original. This is actually intentional as those serve as the 'theme' defaults and you might want to remove extra items. Merging will not know if an option is intended to be removed or just use the default value from the previous theme.

So, I installed the latest dev tools, that was no it.

The issue was fixed once I went into the theme settings and clicked "save"

After that, everything started working perfectly. I'll try it again and see if I can replicate this issue. If it happens it may just need to be added to the docs that saving the theme settings is required to get up and running.

@Eggeriley If you do a full 'copy' it should work fine. I just test a test with a theme I called "Typhoon 2" and it created the theme as typhoon-2. After switching to the new theme, everything works great, no issues. Are you on the latest version of devtools plugin? There have been some fixes in recent months.

➜ bin/plugin devtools new-theme --email=trilby@email.com --github=trilbymedia --dev="Trilby Media"

 Enter Theme Name:
 > Typhoon 2

 Enter Theme Description:
 > test

 Please choose an option:
  [pure-blank ] Basic Theme using Pure.css
  [tailwind   ] Basic Theme using tailwind.css
  [inheritance] Inherit from another theme
  [copy       ] Copy another theme
 > copy

 Please choose a theme to copy:
  [0] anico
  [1] bootstrap4
  [2] quark
  [3] test1
  [4] typhoon
 > typhoon

/home/me/web/user/themes/typhoon
SUCCESS theme Typhoon 2 -> Created Successfully

Path: /home/me/web/user/themes/typhoon-2

@YenLung-Huang You will need to copy over the defaults in the theme .yaml file as those are not merged with the original. This is actually intentional as those serve as the 'theme' defaults and you might want to remove extra items. Merging will not know if an option is intended to be removed or just use the default value from the previous theme.

I followed the instructions in the typhoon theme docs about extending the theme. I created a full copy, as you mentioned. The issue was fixed when I went into the copies theme settings and then saved them.