This package is useful when you need to block certain elements/components on the page from the user to access it.
This package is fully customizable, you can change the background color, blur, opacity, status message etc by passing apropriate values to the settings
object. The package also allows the users to implement their own custom status box.
- lock components and force user to login/signup to vue
- Users with insufficient permissions
npm install --save vue-restricted-access
import VueRestrictedAccess from 'vue-restricted-access'
import "vue-restricted-access/dist/vue-restricted-access.css";
components: {
RestrictedAccess: VueRestrictedAccess
}
Just wrap the component which you need to restrict the users from viewing and pass the restricted
param as true
<resrticted-access :restricted="true">
<my-component></my-component>
</restricted-access>
You can also send an additional settings object with any of these parameters
<restricted-access :restricted="true" :settings="mySettingsObj">
settings
object will take the following properties:
Property | Required | Type | Default | Description |
---|---|---|---|---|
strict | false | Boolean | false | strict mode will fully remove the element from DOM instead of blurring it (for more sensitive contents) |
opacity | false | Number | 0.5 | Opacity of the overlay |
blur | false | Number | 3 | Blur radius |
showLock | false | Boolean | true | show lock icon |
statusText | false | String | '' | Status text to display on the restricted access component |
statusTextColor | false | String | #000 | Status text color |
showStatusText | false | Boolean | true | show status text |
customStatusBox | false | Boolean | false | If you set custom status to true then you need use scoped slot with name custom-message to pass your own component |
customStatusPositionCenter | false | Boolean | true | If this is passed true then your custom status box will be in the center |
mySettingsObj = {
strict: false,
opacity: 0.5,
blur: 3,
showStatusText: true,
statusText: 'Signup to access this content',
statusTextColor: '#000',
showLock: true,
customStatusBox: false,
customStatusPositionCenter: true
}
- On strict mode, use a wrapper component over the
<restricted-access>
component and setwidth
andheight
or override the CSS