Skip to content

Commit

Permalink
feat: added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Capevace committed Oct 20, 2024
1 parent 834d1ce commit 2b91d2a
Show file tree
Hide file tree
Showing 12 changed files with 8,373 additions and 97 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Tests

on: ['push', 'pull_request']

jobs:
ci:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: composer:v2
coverage: xdebug

- name: Install Dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader

- name: Tests
run: ./vendor/bin/pest --ci
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ Homestead.yaml
Homestead.json
/.vagrant
.phpunit.result.cache
.aider*
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,27 @@

use Mateffy\Color;

$color = Color::fromHex('#ff0000')
$color = Color::hex('#ff0000')
->hue(25, add: true) // Adds 25 to the current hue
->saturation(0.5) // Sets the current saturation to 0.5
->alpha(0.5); // Sets the current alpha to 0.5

$rgb = $color->toRgb(); // [255, 0, 0]
$hsl = $color->toHsl(); // [1, 1, 0.5]
/* Hex */
$hex1 = $color->toHex(); // '#ff0000'
$hex2 = $color->toHex(alpha: true); // '#ff0000ff'

/* RGB */
$rgb = $color->toRgb(); // [255, 0, 0]
$rgba = $color->toRgba(); // [255, 0, 0, 0.5]
$rgbString = $color->toRgbString(); // 'rgb(255, 0, 0)'
$rgbValueString = $color->toRgbValueString(); // '255, 0, 0' for Tailwind and Filament

/* HSL */
$hsl = $color->toHsl(); // [1, 1, 0.5]
$hsla = $color->toHsla(); // [1, 1, 0.5, 0.5]
$hslString = $color->toHslString(); // 'hsl(1, 1%, 50%)'
$hslValueString = $color->toHslaString(); // 'hsla(1, 1%, 50%, 0.5)'

/**
* Shades functionality
*/
Expand Down
12 changes: 10 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@
"email": "[email protected]"
}
],
"require": {
},
"autoload": {
"psr-4": {
"Mateffy\\": "src/"
}
},
"require-dev": {
"pestphp/pest": "^3.4",
"pestphp/pest-plugin": "^3.0",
"pestphp/pest-plugin-laravel": "^3.0"
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
}
}
}
Loading

0 comments on commit 2b91d2a

Please sign in to comment.