Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/split.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
package:
- { src: 'Apple', repo: 'apple-colors' }
- { src: 'Bootstrap', repo: 'bootstrap-colors' }
- { src: 'Dracula', repo: 'dracula-colors' }
- { src: 'Material', repo: 'material-colors' }
- { src: 'Nord', repo: 'nord-colors' }
- { src: 'OpenColor', repo: 'open-color' }
- { src: 'Pico', repo: 'pico-colors' }
- { src: 'Primer', repo: 'primer-colors' }
- { src: 'Tailwind', repo: 'tailwind-colors' }
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@

## Packages

| Name | Composer install | Description |
|--------------------------------------|-----------------------------|--------------------------------------|
| [Apple](src/Apple/README.md) | `phpcolor/apple-colors` | Apple color palettes & scales |
| [Bootstrap](src/Bootstrap/README.md) | `phpcolor/bootstrap-colors` | Bootstrap 5 color palettes & scales |
| [Pico](src/Pico/README.md) | `phpcolor/pico-colors` | Pico CSS color palettes & scales |
| [Primer](src/Primer/README.md) | `phpcolor/primer-colors` | Primer color palettes & scales |
| [Tailwind](src/Tailwind/README.md) | `phpcolor/tailwind-colors` | Tailwind CSS color palettes & scales |
| Name | Composer install | Description |
|--------------------------------------|-----------------------------|--------------------------------------------------|
| [Apple](src/Apple/README.md) | `phpcolor/apple-colors` | Apple color palettes & scales |
| [Bootstrap](src/Bootstrap/README.md) | `phpcolor/bootstrap-colors` | Bootstrap 5 color palettes & scales |
| [Dracula](src/Dracula/README.md) | `phpcolor/dracula-colors` | Dracula dark theme color palette |
| [Material](src/Material/README.md) | `phpcolor/material-colors` | Material Design color palette |
| [Nord](src/Nord/README.md) | `phpcolor/nord-colors` | Nord arctic, north-bluish color scheme |
| [Open Color](src/OpenColor/README.md)| `phpcolor/open-color` | Open Color palette optimized for UI design |
| [Pico](src/Pico/README.md) | `phpcolor/pico-colors` | Pico CSS color palettes & scales |
| [Primer](src/Primer/README.md) | `phpcolor/primer-colors` | Primer color palettes & scales |
| [Tailwind](src/Tailwind/README.md) | `phpcolor/tailwind-colors` | Tailwind CSS color palettes & scales |

## License

Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
"replace": {
"phpcolor/apple-colors": "self.version",
"phpcolor/bootstrap-colors": "self.version",
"phpcolor/dracula-colors": "self.version",
"phpcolor/material-colors": "self.version",
"phpcolor/nord-colors": "self.version",
"phpcolor/open-color": "self.version",
"phpcolor/pico-colors": "self.version",
"phpcolor/primer-colors": "self.version",
"phpcolor/tailwind-colors": "self.version"
Expand Down
77 changes: 77 additions & 0 deletions src/Dracula/DraculaColors.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

declare(strict_types=1);

/*
* This file is part of the PHPColor library.
*
* (c) Simon André & Raphaël Geffroy
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace PhpColor\Colors\Dracula;

/**
* @implements \IteratorAggregate<string, string>
*/
final class DraculaColors extends \stdClass implements \IteratorAggregate, \Countable
{
public static function colors(): self
{
return new self(require __DIR__.'/Resources/colors.php');
}

/**
* @param array<string, array{string, int[]}> $colors
*/
private function __construct(private readonly array $colors)
{
}

public function has(string $name): bool
{
return array_key_exists($name, $this->colors);
}

public function get(string $name): string
{
if (!$this->has($name)) {
throw new \InvalidArgumentException(sprintf('The color "%s" does not exist.', $name));
}

return $this->colors[$name][0];
}

/**
* @return list<string>
*/
public function getNames(): array
{
return array_keys($this->colors);
}

/**
* @return \ArrayIterator<string, string>
*/
public function getIterator(): \Iterator
{
return new \ArrayIterator(array_map(fn ($a) => $a[0], $this->colors));
}

public function count(): int
{
return count($this->colors);
}

public function __get(string $name): string
{
return $this->get($name);
}

public function __set(string $name, mixed $value): void
{
throw new \BadMethodCallException('DraculaColors are read-only.');
}
}
21 changes: 21 additions & 0 deletions src/Dracula/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024-present Simon André & Raphaël Geffroy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
50 changes: 50 additions & 0 deletions src/Dracula/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Dracula Colors

This package provides access to the Dracula color palette, a dark theme for code editors and terminal applications.

## Installation

```bash
composer require phpcolor/dracula-colors
```

## Usage

### Create Colors Instance

```php
use PhpColor\Colors\Dracula\DraculaColors as Dracula;

$colors = Dracula::colors();
```

### Color Names

```php
use PhpColor\Colors\Dracula\DraculaColors as Dracula;

$colors = Dracula::colors();

$names = $colors->getNames();
// 'background', 'currentLine', 'foreground', 'comment',
// 'cyan', 'green', 'orange', 'pink', 'purple', 'red', 'yellow'
```

### Color Values

```php
use PhpColor\Colors\Dracula\DraculaColors as Dracula;

$colors = Dracula::colors();

echo $colors->purple; // #BD93F9
echo $colors->get('cyan'); // #8BE9FD
```

## Credits

The colors listed in this project are based on the [Dracula Theme](https://draculatheme.com/).

## License

This [PHPColor](https://phpcolor.dev) package is released under the [MIT license](LICENSE).
26 changes: 26 additions & 0 deletions src/Dracula/Resources/colors.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

/*
* This file is part of the PHPColor library.
*
* (c) Simon André & Raphaël Geffroy
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

return [
'background' => ['#282A36', [40, 42, 54]],
'currentLine' => ['#44475A', [68, 71, 90]],
'foreground' => ['#F8F8F2', [248, 248, 242]],
'comment' => ['#6272A4', [98, 114, 164]],
'cyan' => ['#8BE9FD', [139, 233, 253]],
'green' => ['#50FA7B', [80, 250, 123]],
'orange' => ['#FFB86C', [255, 184, 108]],
'pink' => ['#FF79C6', [255, 121, 198]],
'purple' => ['#BD93F9', [189, 147, 249]],
'red' => ['#FF5555', [255, 85, 85]],
'yellow' => ['#F1FA8C', [241, 250, 140]],
];
36 changes: 36 additions & 0 deletions src/Dracula/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "phpcolor/dracula-colors",
"description": "Dracula Colors - PHP Color Palette",
"license": "MIT",
"type": "library",
"keywords": [
"dracula",
"color",
"palette",
"theme",
"dark"
],
"authors": [
{
"name": "Simon André",
"email": "smn.andre@gmail.com"
},
{
"name": "Raphaël Geffroy",
"email": "raphael@geffroy.dev"
}
],
"homepage": "https://phpcolor.dev/",
"require": {
"php": ">=8.3"
},
"autoload": {
"psr-4": { "PhpColor\\Colors\\Dracula\\": "" }
},
"extra": {
"thanks": {
"name": "phpcolor/colors",
"url": "https://github.com/phpcolor/colors"
}
}
}
21 changes: 21 additions & 0 deletions src/Material/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024-present Simon André & Raphaël Geffroy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading