Skip to content

Commit

Permalink
feat: support customize placeholder class
Browse files Browse the repository at this point in the history
  • Loading branch information
storyn26383 committed Feb 25, 2022
1 parent 9b9da32 commit 13f9d0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ eg, show a loading indicator.
</script>
```

By default the placeholder will be wrapped in a `div` tag, however you can use `placeholderTag` prop to customize it:
By default the placeholder will be wrapped in a `div` tag with `client-only-placeholder` class, however you can use `placeholderTag` and `placeholderClass` prop to customize it:

```vue
<client-only placeholder="loading" placeholder-tag="span">
<client-only placeholder="loading" placeholder-tag="span" placeholder-class="my-placeholder-class">
<comments />
</client-only>
```

And you get:

```html
<span class="client-only-placeholder">
<span class="my-placeholder-class">
loading
</span>
```
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export default {
placeholderTag: {
type: String,
default: 'div'
},
placeholderClass: {
type: String,
default: 'client-only-placeholder'
}
},
render(h, { parent, slots, props }) {
Expand All @@ -23,7 +27,7 @@ export default {
return h(
props.placeholderTag,
{
class: ['client-only-placeholder']
class: [props.placeholderClass]
},
props.placeholder || placeholderSlot
)
Expand Down

0 comments on commit 13f9d0c

Please sign in to comment.