Skip to content

Support for custom root tag in the MqLayout component #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ In addition to `$mq` property this plugin provide a wrapper component to facilit
<span> Display on sm and lg </span>
</mq-layout>
```
**Props**
mq => required : String | Array
**Props**:
`mq`: (required) String | Array
`tag`: (required) String, default to `div`

*Important*: note that you can append a `+` modifier at the end of the string to specify that the conditional rendering happens for all greater breakpoints.
*Important*: note that you can append a `+` modifier at the end of the `mq` string to specify that the conditional rendering happens for all greater breakpoints.

## SSR Support
v1.0+ now supports SSR. You can customize the `defaultBreakpoint` which let you set the breakpoint used by the server-side-rendering
Expand Down
7 changes: 6 additions & 1 deletion src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const component = {
mq: {
required: true,
type: [String, Array],
},
tag: {
required: true,
type: String,
default: 'div'
}
},
computed: {
Expand All @@ -22,7 +27,7 @@ const component = {
},
render(h, props) {
const shouldRenderChildren = this.activeBreakpoints.includes(this.$mq)
return shouldRenderChildren ? h('div', this.$slots.default) : h()
return shouldRenderChildren ? h(this.tag, this.$slots.default) : h()
},
}

Expand Down