Skip to content

Commit 0b79fb0

Browse files
committed
#2 Add an option to center Card's content
1 parent e36aeeb commit 0b79fb0

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public function cards()
2424
```
2525

2626
## Options
27-
- `->html('string')`: Set HTML or plain content.
28-
- `->markdown('string')`: Set Markdown content that will be converted into HTML.
29-
- `->view('path.to.view', [])`: Specify blade view file and optionally pass an array of data to view.
27+
- Set content
28+
- `->html('string')`: Set HTML or plain content.
29+
- `->markdown('string')`: Set Markdown content that will be converted into HTML.
30+
- `->view('path.to.view', [])`: Specify blade view file and optionally pass an array of data to view.
31+
- Styling
32+
- `->center(true)`: Center card's content.

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.

resources/js/components/Card.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<card class="flex flex-col items-center justify-center">
2+
<card class="flex flex-col justify-center" :class="cardClassList">
33
<div class="px-3 py-3">
44
<section v-html="card.content">
55
</section>
@@ -12,7 +12,19 @@
1212
props: [
1313
'card',
1414
],
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+
}
1524
25+
return classes.join(' ');
26+
},
27+
},
1628
mounted() {
1729
//
1830
},

src/HtmlCard.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function __construct($component = null)
2525
parent::__construct($component);
2626

2727
$this->withMeta([
28+
'center' => false,
2829
'content' => '',
2930
]);
3031
}
@@ -75,4 +76,16 @@ public function view(string $view, array $viewData = [])
7576

7677
return $this->html($htmlContent);
7778
}
79+
80+
/**
81+
* Center card's content
82+
*
83+
* @param bool $boolean
84+
*
85+
* @return HtmlCard
86+
*/
87+
public function center($boolean = true)
88+
{
89+
return $this->withMeta(['center' => $boolean]);
90+
}
7891
}

0 commit comments

Comments
 (0)