Skip to content

Commit

Permalink
Starting an idea for default theme engine without termwind
Browse files Browse the repository at this point in the history
  • Loading branch information
JustSteveKing committed May 12, 2023
1 parent d41af20 commit 14bc9f2
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 0 deletions.
73 changes: 73 additions & 0 deletions src/Theme/Catalog/DefaultTheme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

declare(strict_types=1);

namespace Minicli\Framework\Theme\Catalog;

use Minicli\Framework\Theme\Enums\Background;
use Minicli\Framework\Theme\Enums\Foreground;
use Minicli\Framework\Theme\ThemeContract;
use StringBackedEnum;

final class DefaultTheme implements ThemeContract
{
public function default(): array
{
return [
Foreground::WHITE,
];
}

public function alt(): array
{
return [
Foreground::BLACK,
Background::WHITE,
];
}

public function error(): array
{
return [
Foreground::RED,
];
}

public function errorAlt(): array
{
return [
Foreground::WHITE,
Background::RED,
];
}

public function success(): array
{
return [
Foreground::GREEN,
];
}

public function successAlt(): array
{
return [
Foreground::WHITE,
Background::GREEN,
];
}

public function info(): array
{
return [
Foreground::CYAN,
];
}

public function infoAlt(): array
{
return [
Foreground::WHITE,
Background::CYAN,
];
}
}
17 changes: 17 additions & 0 deletions src/Theme/Enums/Background.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Minicli\Framework\Theme\Enums;

enum Background: string
{
case BLACK = '40';
case WHITE = '47';
case RED = '41';
case GREEN = '42';
case BLUE = '44';
case CYAN = '46';
case MAGENTA = '45';
case YELLOW = '43';
}
15 changes: 15 additions & 0 deletions src/Theme/Enums/FontWeight.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Minicli\Framework\Theme\Enums;

enum FontWeight: string
{
case DEFAULT = '0';
case BOLD = '1';
case DIM = '2';
case ITALIC = '3';
case UNDERLINE = '4';
case INVERT = '7';
}
17 changes: 17 additions & 0 deletions src/Theme/Enums/Foreground.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Minicli\Framework\Theme\Enums;

enum Foreground: string
{
case BLACK = '0;30';
case WHITE = '1;37';
case RED = '0;31';
case GREEN = '0;32';
case BLUE = '1;34';
case CYAN = '0;36';
case MAGENTA = '0;35';
case YELLOW = '0;33';
}
58 changes: 58 additions & 0 deletions src/Theme/ThemeContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

namespace Minicli\Framework\Theme;

use StringBackedEnum;

interface ThemeContract
{
/**
* Default style
* @return array<int,StringBackedEnum>
*/
public function default(): array;

/**
* Alternative style for Default
* @return array<int,StringBackedEnum>
*/
public function alt(): array;

/**
* Error style
* @return array<int,StringBackedEnum>
*/
public function error(): array;

/**
* Alternative style for Error
* @return array<int,StringBackedEnum>
*/
public function errorAlt(): array;

/**
* Success style
* @return array<int,StringBackedEnum>
*/
public function success(): array;

/**
* Alternative style for Success
* @return array<int,StringBackedEnum>
*/
public function successAlt(): array;

/**
* Info style
* @return array<int,StringBackedEnum>
*/
public function info(): array;

/**
* Alternative style for Info
* @return array<int,StringBackedEnum>
*/
public function infoAlt(): array;
}

0 comments on commit 14bc9f2

Please sign in to comment.