Skip to content

Commit 494e29b

Browse files
committed
Merge branch 'master' of github.com:justbetter/statamic-glide-directive into feature/image-queue
2 parents d9270dc + ad8974a commit 494e29b

File tree

18 files changed

+322
-28
lines changed

18 files changed

+322
-28
lines changed

.github/workflows/analyse.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,35 @@ name: analyse
33
on: ['push', 'pull_request']
44

55
jobs:
6-
analyse:
7-
runs-on: ubuntu-latest
6+
test:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
os: [ubuntu-latest]
12+
php: [8.3]
13+
laravel: [11.*]
14+
stability: [prefer-stable]
15+
include:
16+
- laravel: 11.*
17+
testbench: 9.*
18+
19+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
20+
821
steps:
922
- name: Checkout code
1023
uses: actions/checkout@v4
1124

1225
- name: Setup PHP
1326
uses: shivammathur/setup-php@v2
1427
with:
15-
php-version: 8.3
28+
php-version: ${{ matrix.php }}
1629
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
1730
coverage: none
1831

1932
- name: Install dependencies
2033
run: |
21-
composer require "laravel/framework:10.*" "orchestra/testbench:8.*" --no-interaction --no-update
22-
composer update --prefer-stable --prefer-dist --no-interaction
34+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
35+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
2336
- name: Analyse
2437
run: composer analyse

.github/workflows/coverage.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: coverage
2+
3+
on: ['push', 'pull_request']
4+
5+
jobs:
6+
test:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
os: [ubuntu-latest]
12+
php: [8.3]
13+
laravel: [11.*]
14+
stability: [prefer-stable]
15+
include:
16+
- laravel: 11.*
17+
testbench: 9.*
18+
19+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php }}
29+
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, xdebug
30+
coverage: xdebug
31+
32+
- name: Install dependencies
33+
run: |
34+
composer config allow-plugins.pestphp/pest-plugin true
35+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
36+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
37+
- name: Execute tests
38+
run: XDEBUG_MODE=coverage php vendor/bin/pest --coverage --min=85

.github/workflows/tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: tests
2+
3+
on: [ 'push', 'pull_request' ]
4+
5+
jobs:
6+
test:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
os: [ ubuntu-latest ]
12+
php: [ 8.1, 8.2, 8.3 ]
13+
laravel: [ 11.* ]
14+
stability: [ prefer-lowest, prefer-stable ]
15+
include:
16+
- laravel: 11.*
17+
testbench: 9.*
18+
exclude:
19+
- laravel: 11.*
20+
php: 8.1
21+
22+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Setup PHP
29+
uses: shivammathur/setup-php@v2
30+
with:
31+
php-version: ${{ matrix.php }}
32+
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
33+
coverage: none
34+
35+
- name: Install dependencies
36+
run: |
37+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
38+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
39+
- name: Execute tests
40+
run: composer test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ composer.lock
33
node_modules
44
vendor
55
.php_cs.cache
6+
.phpunit.result.cache

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<a href="https://github.com/justbetter/statamic-glide-directive" title="JustBetter">
2+
<img src="./art/banner.png" alt="Banner">
3+
</a>
4+
15
# Statamic glide directive
26

37
> Blade directive to use glide with images

art/banner.png

31.4 KB
Loading

composer.json

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,33 @@
33
"description": "Addon that adds a glide blade directive",
44
"type": "package",
55
"require": {
6-
"php": "^8.2|^8.3",
6+
"php": "^8.1|^8.2|^8.3",
77
"laravel/framework": "^11.0",
88
"statamic/cms": "^5.0"
99
},
1010
"require-dev": {
1111
"laravel/pint": "^1.7",
1212
"larastan/larastan": "^2.5",
1313
"phpstan/phpstan-mockery": "^1.1",
14-
"orchestra/testbench": "^8.0|^9.0"
14+
"phpunit/phpunit": "^10.1",
15+
"orchestra/testbench": "^8.0|^9.0",
16+
"pestphp/pest": "^2.0"
1517
},
1618
"autoload": {
1719
"psr-4": {
1820
"JustBetter\\GlideDirective\\": "src/"
1921
}
2022
},
23+
"autoload-dev": {
24+
"psr-4": {
25+
"JustBetter\\GlideDirective\\Tests\\": "tests"
26+
}
27+
},
2128
"config": {
2229
"sort-packages": true,
2330
"allow-plugins": {
24-
"pixelfear/composer-dist-plugin": true
31+
"pixelfear/composer-dist-plugin": true,
32+
"pestphp/pest-plugin": true
2533
}
2634
},
2735
"extra": {
@@ -48,9 +56,15 @@
4856
}
4957
],
5058
"scripts": {
59+
"test": "phpunit",
5160
"analyse": "phpstan",
52-
"fix-style": "pint",
53-
"style": "pint --test"
61+
"style": "pint --test",
62+
"quality": [
63+
"@test",
64+
"@analyse",
65+
"@style"
66+
],
67+
"fix-style": "pint"
5468
},
5569
"minimum-stability": "dev"
5670
}

phpstan.neon

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ includes:
55
parameters:
66
paths:
77
- src
8+
- tests
89
level: 8
9-
checkMissingIterableValueType: false
10+
ignoreErrors:
11+
- identifier: missingType.iterableValue

phpunit.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
3+
<testsuites>
4+
<testsuite name="Tests">
5+
<directory>./tests/*</directory>
6+
</testsuite>
7+
</testsuites>
8+
<coverage/>
9+
<source>
10+
<include>
11+
<directory suffix=".php">./src</directory>
12+
</include>
13+
</source>
14+
</phpunit>
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<script>
22
window.responsiveResizeObserver = new ResizeObserver((entries) => {
33
entries.forEach(entry => {
4-
const imgWidth = entry.target.getBoundingClientRect().width;
5-
const imgHeight = entry.target.getBoundingClientRect().height;
4+
const bounds = entry.target.getBoundingClientRect();
5+
const imgWidth = bounds.width;
6+
const imgHeight = bounds.height;
67
const pixelRatio = window.devicePixelRatio * imgWidth;
78
8-
entry.target.parentNode.querySelectorAll('source').forEach((source) => {
9+
requestAnimationFrame(() => entry.target.parentNode.querySelectorAll('source').forEach((source) => {
910
source.sizes = pixelRatio + 'px';
10-
});
11+
}));
1112
});
1213
});
1314
</script>

0 commit comments

Comments
 (0)