Skip to content

Commit

Permalink
Merge pull request #1 from WendellAdriel/theme-style
Browse files Browse the repository at this point in the history
Theme Style class and Static Analysis fix
  • Loading branch information
JustSteveKing committed May 16, 2023
2 parents 14bc9f2 + 9e72e1f commit 247de8f
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* text=auto

/.art export-ignore
/.github export-ignore
/tests export-ignore
.editorconfig export-ignore
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Minicli Framework
<div align="center">
<p>
<img src="https://github.com/minicli/framework/raw/main/art/minicli.png" alt="Minicli" width="150"/>
<h1>Minicli Framework</h1>
</p>
</div>

This repo contains the source code for the Minicli Framework - a great way to extend the core minicli application.
Binary file added art/minicli.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 53 additions & 37 deletions src/Theme/Catalog/DefaultTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,85 @@
namespace Minicli\Framework\Theme\Catalog;

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

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

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

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

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

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

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

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

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

public function info(): ThemeStyle
{
return ThemeStyle::make(Foreground::CYAN);
}

public function infoAlt(): ThemeStyle
{
return ThemeStyle::make(Foreground::WHITE, Background::CYAN);
}

public function bold(): ThemeStyle
{
return ThemeStyle::make(FontWeight::BOLD);
}

public function dim(): ThemeStyle
{
return ThemeStyle::make(FontWeight::DIM);
}

public function italic(): ThemeStyle
{
return ThemeStyle::make(FontWeight::ITALIC);
}

public function underline(): ThemeStyle
{
return ThemeStyle::make(FontWeight::UNDERLINE);
}

public function invert(): ThemeStyle
{
return ThemeStyle::make(FontWeight::INVERT);
}
}
61 changes: 43 additions & 18 deletions src/Theme/ThemeContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,80 @@

namespace Minicli\Framework\Theme;

use StringBackedEnum;

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

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

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

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

/**
* Warning style
*/
public function warning(): ThemeStyle;

/**
* Alternative style for Warning
*/
public function warningAlt(): ThemeStyle;

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

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

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

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

/**
* Bold style
*/
public function bold(): ThemeStyle;

/**
* Dim style
*/
public function dim(): ThemeStyle;

/**
* Italic style
*/
public function italic(): ThemeStyle;

/**
* Underline style
*/
public function underline(): ThemeStyle;

/**
* Invert style
*/
public function invert(): ThemeStyle;
}
23 changes: 23 additions & 0 deletions src/Theme/ThemeStyle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Minicli\Framework\Theme;

use Minicli\Framework\Theme\Enums\Background;
use Minicli\Framework\Theme\Enums\FontWeight;
use Minicli\Framework\Theme\Enums\Foreground;

final class ThemeStyle
{
public function __construct(
public readonly FontWeight|Foreground $foreground,
public readonly ?Background $background = null
) {
}

public static function make(FontWeight|Foreground $foreground, ?Background $background = null): self
{
return new self($foreground, $background);
}
}

0 comments on commit 247de8f

Please sign in to comment.