Skip to content

Commit 96874ae

Browse files
authored
Merge pull request #16 from uwpsych/nova-4-support
Nova 4 support
2 parents 165e179 + 7b59b38 commit 96874ae

10 files changed

Lines changed: 57 additions & 41 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public function cards()
4646
- Styling
4747
- `->center(false)`: Center card's content. `false` by default.
4848
- `->withoutCardStyles(true)`: Whether to use standard Nova Card styles for a card (background, padding, etc). `false` by default.
49-
- `->forceFullWidth(true)`: Force the card to be full width. A fix for [nova cards order](https://github.com/laravel/nova-issues/issues/1895).
5049

5150

5251
## Why this package?

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"license": "MIT",
1313
"require": {
1414
"php": ">=8.0",
15-
"laravel/nova": "^3.0"
15+
"laravel/nova": "^4.0"
1616
},
1717
"require-dev": {
1818
"mockery/mockery": "^1.4",

dist/js/card.js

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

dist/mix-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"/js/card.js": "/js/card.js?id=b29fdbc6a04f01db20f0"
3-
}
2+
"/js/card.js": "/js/card.js?id=591c45f787ce8b18b6c3724b2c083b88"
3+
}

nova.mix.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const mix = require('laravel-mix')
2+
const webpack = require('webpack')
3+
const path = require('path')
4+
5+
class NovaExtension {
6+
name() {
7+
return 'nova-extension'
8+
}
9+
10+
register(name) {
11+
this.name = name
12+
}
13+
14+
webpackConfig(webpackConfig) {
15+
webpackConfig.externals = {
16+
vue: 'Vue',
17+
}
18+
19+
webpackConfig.resolve.alias = {
20+
...(webpackConfig.resolve.alias || {}),
21+
'laravel-nova': path.join(
22+
__dirname,
23+
'../../vendor/laravel/nova/resources/js/mixins/packages.js'
24+
),
25+
}
26+
27+
webpackConfig.output = {
28+
uniqueName: this.name,
29+
}
30+
}
31+
}
32+
33+
mix.extend('nova', new NovaExtension())

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
},
66
"scripts": {
77
"dev": "npm run development",
8-
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
9-
"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",
10-
"watch-poll": "npm run watch -- --watch-poll",
11-
"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",
8+
"development": "mix",
9+
"watch": "mix watch",
10+
"watch-poll": "mix watch --watch-options-poll=1000",
11+
"hot": "mix watch --hot",
1212
"prod": "npm run production",
13-
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
13+
"production": "mix --production"
1414
},
1515
"devDependencies": {
16-
"cross-env": "^5.0.0",
17-
"laravel-mix": "^1.0"
16+
"laravel-mix": "^6.0",
17+
"vue-loader": "^16.8.3"
1818
},
1919
"dependencies": {
20-
"vue": "^2.5.0"
20+
"vue": "^3.0.0"
2121
}
2222
}

resources/js/card.js

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

resources/js/components/Card.vue

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
</div>
55
</div>
66

7-
<card v-else class="htmlCard" :class="cardClassList">
7+
<Card v-else class="htmlCard" :class="cardClassList">
88
<div class="px-3 py-3">
99
<div v-html="card.content" class="htmlCard__content">
1010
</div>
1111
</div>
12-
</card>
12+
</Card>
1313
</template>
1414

1515
<script>
@@ -27,19 +27,10 @@
2727
return classes;
2828
},
2929
},
30-
mounted() {
31-
if (this.card.forceFullWidth) {
32-
this.$parent.$el.classList.remove('w-5/6');
33-
this.$parent.$el.classList.add('w-full');
34-
}
35-
},
3630
}
3731
</script>
3832

3933
<style>
40-
.htmlCard {
41-
height: auto;
42-
}
4334
.htmlCard__content > p:not(:last-child) {
4435
margin-bottom: 1em;
4536
}

src/HtmlCard.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public function __construct($component = null)
2424
$this->withMeta([
2525
'center' => false,
2626
'withoutCardStyles' => false,
27-
'forceFullWidth' => false,
2827
'content' => '',
2928
]);
3029
}
@@ -67,18 +66,6 @@ public function center(bool $centerContent = true): static
6766
return $this->withMeta(['center' => $centerContent]);
6867
}
6968

70-
/**
71-
* Force Nova to apply full width for a card.
72-
* Nova has undocumented feature to auto-order cards based on width and put
73-
* full-width cards at the bottom. If you want to display full-width cards
74-
* not at the end, you should use with=1/3 or 2/3 and this method.
75-
* @see https://github.com/laravel/nova-issues/issues/1895#issuecomment-543684472
76-
*/
77-
public function forceFullWidth(bool $forceFullWidth = true): static
78-
{
79-
return $this->withMeta(['forceFullWidth' => $forceFullWidth]);
80-
}
81-
8269
/** Whether to use standard Nova Card styles for a card (background, padding, etc). */
8370
public function withoutCardStyles(bool $withoutStyles = true): static
8471
{

webpack.mix.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
let mix = require('laravel-mix')
22

3+
require('./nova.mix')
4+
35
mix
4-
.setPublicPath('dist')
5-
.js('resources/js/card.js', 'js')
6+
.setPublicPath('dist')
7+
.js('resources/js/card.js', 'js')
8+
.vue({ version: 3 })
9+
.nova('interaction-design-foundation/nova-html-card')
610

711
if (mix.inProduction()) {
812
mix.version();

0 commit comments

Comments
 (0)