PHP code example of webx-ui / themes

1. Go to this page and download the library: Download webx-ui/themes library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webx-ui / themes example snippets


use WebxUi\Themes\ThemeIcons;

app(ThemeIcons::class)->names();      // every icon of the chain
app(ThemeIcons::class)->has('phone');

theme_token('color-accent');            // '#0e6b5c'
theme_token('color-danger', '#e11d48'); // the default when the chain gives no value
theme_token('font-heading');            // 'Inter, system-ui, …' — a reference to another token resolved

use WebxUi\Themes\ThemeChain;

$chain = app(ThemeChain::class);

$chain->layers;      // list<ThemeManifest>, top first
$chain->top();       // the theme the site configured, or null
$chain->viewPaths(); // every layer's views/ directory
$chain->

$report = app(\WebxUi\Themes\ThemeReport::class)->toArray();
$report['tokens']['color-accent']; // ['type' => 'color', 'value' => '#1f5fbf', 'resolved' => null, 'from' => 'webx-ui/theme-default']
$report['views'];                  // [['view' => 'components/header.blade.php', 'from' => 'theme', 'hides' => ['webx-ui/theme-default']], …]
$report['preset'];                 // the preset a manifest names, or null

use WebxUi\Themes\Checks\CssCheck;
use WebxUi\Themes\Vocabulary;

foreach (CssCheck::check($css, Vocabulary::base()) as $finding) {
    $finding->line;      // where
    $finding->problem;   // CssProblem: literal colour or font, unknown token, fallback, @media by width
    $finding->message(); // what and why, in a line
}

use WebxUi\Themes\Testing\ModuleThemeContract;

final class ThemeContractTest extends \PHPUnit\Framework\TestCase
{
    use ModuleThemeContract;

    protected function modulePath(): string { return dirname(__DIR__); }
}

app(\WebxUi\Themes\ThemeLocator::class)->register('acme/theme-north', base_path('../theme-north'));

use WebxUi\Themes\Testing\ThemeContract;

final class ThemeTest extends TestCase
{
    use ThemeContract;

    protected function themePath(): string { return dirname(__DIR__); }
}