Skip to content

Commit

Permalink
#2 Add an option to center Card's content
Browse files Browse the repository at this point in the history
  • Loading branch information
alies-dev committed Jun 29, 2019
1 parent e36aeeb commit 0b79fb0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public function cards()
```

## Options
- `->html('string')`: Set HTML or plain content.
- `->markdown('string')`: Set Markdown content that will be converted into HTML.
- `->view('path.to.view', [])`: Specify blade view file and optionally pass an array of data to view.
- Set content
- `->html('string')`: Set HTML or plain content.
- `->markdown('string')`: Set Markdown content that will be converted into HTML.
- `->view('path.to.view', [])`: Specify blade view file and optionally pass an array of data to view.
- Styling
- `->center(true)`: Center card's content.
2 changes: 1 addition & 1 deletion dist/js/card.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion resources/js/components/Card.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<card class="flex flex-col items-center justify-center">
<card class="flex flex-col justify-center" :class="cardClassList">
<div class="px-3 py-3">
<section v-html="card.content">
</section>
Expand All @@ -12,7 +12,19 @@
props: [
'card',
],
computed: {
textClassList() {
return this.card.center ? 'text-center' : '';
},
cardClassList() {
const classes = [];
if (this.card.center) {
classes.push('items-center');
}
return classes.join(' ');
},
},
mounted() {
//
},
Expand Down
13 changes: 13 additions & 0 deletions src/HtmlCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function __construct($component = null)
parent::__construct($component);

$this->withMeta([
'center' => false,
'content' => '',
]);
}
Expand Down Expand Up @@ -75,4 +76,16 @@ public function view(string $view, array $viewData = [])

return $this->html($htmlContent);
}

/**
* Center card's content
*
* @param bool $boolean
*
* @return HtmlCard
*/
public function center($boolean = true)
{
return $this->withMeta(['center' => $boolean]);
}
}

0 comments on commit 0b79fb0

Please sign in to comment.