Skip to content

Commit 575e251

Browse files
committed
start from skeleton
1 parent 875e10a commit 575e251

16 files changed

+387
-0
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at https://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
indent_size = 4
9+
indent_style = space
10+
end_of_line = lf
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
[*.yml]
18+
indent_size = 2

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
build
2+
composer.lock
3+
docs
4+
vendor
5+
coverage
6+
.phpunit.result.cache
7+
.idea
8+
.php_cs.cache
9+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Martin M.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# laravel-dashboard-npm
2+
> Show npm packages stats
3+
4+
5+
## Installation
6+
You can install the package via composer:
7+
```
8+
composer require skydiver/laravel-dashboard-npm
9+
```
10+
11+
12+
## npm package tile
13+
```
14+
<x-dashboard>
15+
<livewire:npm-package-tile
16+
position="e1"
17+
package="vue"
18+
type="last-week"
19+
cache-timeout="60"
20+
:force-refresh="false"
21+
:show-logo="true"
22+
/>
23+
</x-dashboard>
24+
```
25+
26+
27+
## npm packages table tile
28+
```
29+
<x-dashboard>
30+
<livewire:npm-packages-table-tile
31+
position="e1"
32+
packages="vue,react,jquery"
33+
type="last-week"
34+
cache-timeout="60"
35+
:force-refresh="false"
36+
:show-logo="false"
37+
/>
38+
</x-dashboard>
39+
```
40+
41+
## Shared options
42+
| Option | Description | Valid Options | Default |
43+
|---------------|-------------------------------------------------------|---------------------------------|------------|
44+
| type | type of download | last-day, last-week, last-month | last-month |
45+
| cache-timeout | seconds to refresh package info | - | 600 |
46+
| force-refresh | force refrsh package info (useful during development) | true, false | false |
47+
| show-logo | show npm logo at top right conrner | true, false | true |
48+
49+
50+
## Demo
51+
* npm-package-tile
52+
53+
![npm-package-tile](demo/npm-package-tile.png)
54+
55+
* npm-packages-table-tile
56+
57+
![npm-packages-table-tile](demo/npm-packages-table-tile.png)

composer.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "skydiver/laravel-dashboard-npm",
3+
"description": "Show npm packages stats",
4+
"keywords": [
5+
"skydiver",
6+
"laravel-dashboard-npm"
7+
],
8+
"homepage": "https://github.com/skydiver/laravel-dashboard-npm",
9+
"license": "MIT",
10+
"authors": [
11+
{
12+
"name": "Martín M.",
13+
"email": "skydiver@users.noreply.github.com",
14+
"homepage": "https://github.com/skydiver/",
15+
"role": "Developer"
16+
}
17+
],
18+
"require": {
19+
"php": "^7.4",
20+
"spatie/laravel-dashboard": "^1.0"
21+
},
22+
"require-dev": {
23+
"phpunit/phpunit": "^9.0"
24+
},
25+
"autoload": {
26+
"psr-4": {
27+
"Skydiver\\LaravelDashboardNpm\\": "src"
28+
}
29+
},
30+
"scripts": {
31+
"test": "vendor/bin/phpunit",
32+
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
33+
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
34+
},
35+
"config": {
36+
"sort-packages": true
37+
},
38+
"extra": {
39+
"laravel": {
40+
"providers": [
41+
"Skydiver\\LaravelDashboardNpm\\NpmTileServiceProvider"
42+
]
43+
}
44+
},
45+
"minimum-stability": "dev",
46+
"prefer-stable": true
47+
}

demo/npm-package-tile.png

17.3 KB
Loading

demo/npm-packages-table-tile.png

18.7 KB
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@if ($type === 'last-day')
2+
<span>Last Day Downloads</span>
3+
@endif
4+
@if ($type === 'last-week')
5+
<span>Last Week Downloads</span>
6+
@endif
7+
@if ($type === 'last-month')
8+
<span>Monthly Downloads</span>
9+
@endif

resources/views/npm-logo.blade.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="absolute top-0 right-0 mt-4 mr-4">
2+
<svg class="w-6" viewBox="0 0 780 250">
3+
<path fill="#CC3534" d="M240,250h100v-50h100V0H240V250z M340,50h50v100h-50V50z M480,0v200h100V50h50v150h50V50h50v150h50V0H480z M0,200h100V50h50v150h50V0H0V200z"></path>
4+
</svg>
5+
</div>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<x-dashboard-tile :position="$position">
2+
@includeWhen($showLogo, 'dashboard-npm-tile::npm-logo')
3+
<div class="relative h-full flex items-center">
4+
<div class="w-full text-center text-gray-800">
5+
<div class="text-gray-600">{{ $package }}</div>
6+
<div class="text-xs text-gray-500" style="font-size: 0.5rem">
7+
@include('dashboard-npm-tile::header-type', ['type' => $type])
8+
</div>
9+
<div class="my-3 font-semibold text-3xl tracking-wide leading-none">{{ number_format($packageInfo['downloads']) }}</div>
10+
<div class="text-xs text-gray-600" style="font-size: 0.6rem">
11+
@if ($packageInfo['start'] !== $packageInfo['end'])
12+
<span>{{ $packageInfo['start'] }} ~ {{ $packageInfo['end'] }}</span>
13+
@else
14+
<span>{{ $packageInfo['start'] }}</span>
15+
@endif
16+
</div>
17+
</div>
18+
<div class="absolute bottom-0 right-0 text-xs text-gray-500 text-right" style="font-size: 0.5rem">Updated at: {{ $packageInfo['updated_at'] }}</div>
19+
</div>
20+
</x-dashboard-tile>

0 commit comments

Comments
 (0)