Skip to content

Commit 9fab1d0

Browse files
committed
#6 Add an option to ignore standard Nova card styling
1 parent 04f1463 commit 9fab1d0

File tree

5 files changed

+56
-34
lines changed

5 files changed

+56
-34
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,22 @@ public function cards()
3232

3333
### Options
3434
- Set content
35-
- `->html('string')`: Set HTML or plain content.
36-
- `->markdown('string')`: Set Markdown content that will be converted into HTML.
35+
- `->html('<h1>Hello!</h1>')`: Set HTML or plain content.
36+
- `->markdown('# Hello!')`: Set Markdown content that will be converted into HTML.
3737
- `->view('path.to.view', [])`: Specify blade view file and optionally pass an array of data to view.
3838
- Styling
39-
- `->center(boolean)`: Center card's content.
39+
- `->center(false)`: Center card's content. `false` by default.
40+
- `->withoutCardStyles(true)`: Whether to use standard Nova Card styles for a card (background, padding, etc). `false` by default.
4041

4142

42-
### Changelog
43+
## Why this package?
44+
There are a few packages with similar functionality.
45+
Our package provides an API to cover all cases covered by these packages plus additionally provides some unique features like:
46+
- markdown support
47+
- easy switch between class Nova-card look and raw-HTML look
48+
- Simple, Laravel-like API
49+
50+
## Changelog
4351

4452
Please see [Releases](https://github.com/InteractionDesignFoundation/nova-html-card/releases) for more information on what has changed recently.
4553

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"/js/card.js": "/js/card.js?id=3f77fbcf19a5dc9cd000"
2+
"/js/card.js": "/js/card.js?id=a9bc40bde6cb473bb382"
33
}

resources/js/components/Card.vue

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
<template>
2-
<card class="flex flex-col justify-center htmlCard" :class="cardClassList">
2+
<div v-if="card.withoutCardStyles" class="htmlCard" :class="cardClassList">
3+
<div v-html="card.content" class="htmlCard__content">
4+
</div>
5+
</div>
6+
7+
<card v-else class="htmlCard htmlCard--hasDefaultHeight" :class="cardClassList">
38
<div class="px-3 py-3">
4-
<section v-html="card.content" class="htmlCard__content">
5-
</section>
9+
<div v-html="card.content" class="htmlCard__content">
10+
</div>
611
</div>
712
</card>
813
</template>
914

1015
<script>
11-
export default {
12-
props: [
13-
'card',
14-
],
15-
computed: {
16-
textClassList() {
17-
return this.card.center ? 'text-center' : '';
18-
},
19-
cardClassList() {
20-
const classes = [];
21-
if (this.card.center) {
22-
classes.push('items-center');
23-
}
16+
export default {
17+
props: [
18+
'card',
19+
],
20+
computed: {
21+
cardClassList() {
22+
let classes = '';
23+
if (this.card.center) {
24+
classes += ' flex flex-col justify-center text-center';
25+
}
2426
25-
return classes.join(' ');
26-
},
27-
},
28-
mounted() {
29-
//
30-
},
31-
}
27+
return classes;
28+
},
29+
}
30+
}
3231
</script>
3332

3433
<style>
@@ -38,8 +37,10 @@
3837
</style>
3938

4039
<style scoped>
41-
.card-panel {
42-
min-height: 150px;
40+
.htmlCard {
4341
height: auto;
4442
}
43+
.htmlCard--hasDefaultHeight {
44+
min-height: 150px;
45+
}
4546
</style>

src/HtmlCard.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function __construct($component = null)
2626

2727
$this->withMeta([
2828
'center' => false,
29+
'withoutCardStyles' => false,
2930
'content' => '',
3031
]);
3132
}
@@ -80,12 +81,24 @@ public function view(string $view, array $viewData = [])
8081
/**
8182
* Center card's content
8283
*
83-
* @param bool $boolean
84+
* @param bool $centerContent
8485
*
8586
* @return HtmlCard
8687
*/
87-
public function center($boolean = true)
88+
public function center(bool $centerContent = true)
8889
{
89-
return $this->withMeta(['center' => $boolean]);
90+
return $this->withMeta(['center' => $centerContent]);
91+
}
92+
93+
/**
94+
* Whether to use standard Nova Card styles for a card (background, padding, etc)
95+
*
96+
* @param bool $withoutStyles
97+
*
98+
* @return HtmlCard
99+
*/
100+
public function withoutCardStyles(bool $withoutStyles = true)
101+
{
102+
return $this->withMeta(['withoutCardStyles' => $withoutStyles]);
90103
}
91104
}

0 commit comments

Comments
 (0)