Skip to content

Commit 2fbe0ff

Browse files
committed
Init commit
0 parents  commit 2fbe0ff

File tree

12 files changed

+227
-0
lines changed

12 files changed

+227
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.idea
2+
/vendor
3+
/node_modules
4+
package-lock.json
5+
composer.phar
6+
composer.lock
7+
phpunit.xml
8+
.phpunit.result.cache
9+
.DS_Store
10+
Thumbs.db

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) 2019 The Interaction Design Foundation
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: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Nova HTML Card
2+
3+
Adds a card to the Nova dashboard with any arbitrary HTML content.
4+
5+
## Installation
6+
7+
You can install the package in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer:
8+
9+
```bash
10+
composer require idf/nova-html-card
11+
```
12+
13+
Then, register your new link in the `cards` method of the `NovaServiceProvider` or your `ResourceTool` class.
14+
15+
```php
16+
public function cards()
17+
{
18+
return [
19+
(new HtmlCard())->width('1/3')->html('<h1>Hello!</h1>'),
20+
(new HtmlCard())->width('1/3')->markdown('# Hello!'),
21+
];
22+
}
23+
```
24+
25+
## Options
26+
- `->html('string')`: Set HTML or plain content.
27+
- `->markdown('string')`: Set Markdown content that will be converted into HTML.

composer.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "idf/nova-html-card",
3+
"description": "A Laravel Nova card to display arbitrary HTML content",
4+
"keywords": [
5+
"laravel",
6+
"nova",
7+
"card",
8+
"html",
9+
"text",
10+
"markdown"
11+
],
12+
"license": "MIT",
13+
"require": {
14+
"php": ">=7.1.0"
15+
},
16+
"autoload": {
17+
"psr-4": {
18+
"IDF\\HtmlCard\\": "src/"
19+
}
20+
},
21+
"extra": {
22+
"laravel": {
23+
"providers": [
24+
"IDF\\HtmlCard\\CardServiceProvider"
25+
]
26+
}
27+
},
28+
"config": {
29+
"sort-packages": true
30+
},
31+
"minimum-stability": "dev",
32+
"prefer-stable": true
33+
}

dist/js/card.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mix-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"/js/card.js": "/js/card.js"
3+
}

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "npm run development",
5+
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
6+
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
7+
"watch-poll": "npm run watch -- --watch-poll",
8+
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
9+
"prod": "npm run production",
10+
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
11+
},
12+
"devDependencies": {
13+
"cross-env": "^5.0.0",
14+
"laravel-mix": "^1.0"
15+
},
16+
"dependencies": {
17+
"vue": "^2.5.0"
18+
}
19+
}

resources/js/card.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Nova.booting((Vue, router, store) => {
2+
Vue.component('html-card', require('./components/Card'))
3+
})

resources/js/components/Card.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
<card class="flex flex-col items-center justify-center">
3+
<div class="px-3 py-3">
4+
<section v-html="card.content">
5+
</section>
6+
</div>
7+
</card>
8+
</template>
9+
10+
<script>
11+
export default {
12+
props: [
13+
'card',
14+
],
15+
16+
mounted() {
17+
//
18+
},
19+
}
20+
</script>

src/CardServiceProvider.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace IDF\HtmlCard;
4+
5+
use Laravel\Nova\Nova;
6+
use Laravel\Nova\Events\ServingNova;
7+
use Illuminate\Support\Facades\Route;
8+
use Illuminate\Support\ServiceProvider;
9+
10+
class CardServiceProvider extends ServiceProvider
11+
{
12+
/**
13+
* Bootstrap any application services.
14+
*
15+
* @return void
16+
*/
17+
public function boot()
18+
{
19+
Nova::serving(function (ServingNova $event) {
20+
Nova::script('html-card', __DIR__.'/../dist/js/card.js');
21+
});
22+
}
23+
}

0 commit comments

Comments
 (0)