File: colors.php

package info (click to toggle)
php-nunomaduro-termwind 2.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,172 kB
  • sloc: php: 3,969; makefile: 34
file content (28 lines) | stat: -rw-r--r-- 722 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php

use Termwind\Exceptions\InvalidColor;

use function Termwind\parse;
use function Termwind\style;

it('allows the creation of colors', function () {
    style('black')->color('#101010');

    $html = parse('<span class="bg-black text-black">text</span>');

    expect($html)->toBe('<bg=#101010;fg=#101010>text</>');
});

it('can be used in a style', function () {
    style('blue-100')->color('#101010');
    style('btn')->apply('text-blue-100');

    $html = parse('<span class="btn">text</span>');

    expect($html)->toBe('<fg=#101010>text</>');
});

it('fails to create a color if is invalid', function () {
    expect(fn () => style('black')->color('#invalidcolor'))
        ->toThrow(InvalidColor::class);
});