0.2.1 • Published 5 years ago

vue-restricted-access v0.2.1

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

vue-restricted-access

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.

Codesandbox Demo

Edit Vue-restricted-access-demo

Example usecases:

  1. lock components and force user to login/signup to vue
  2. Users with insufficient permissions

How to install

npm install --save vue-restricted-access

How to use

Import in Components where you want to use the package
import VueRestrictedAccess from 'vue-restricted-access'
import "vue-restricted-access/dist/vue-restricted-access.css";
Register it as a component:
components: {
  RestrictedAccess: VueRestrictedAccess
}
Usage

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>

Customizable settings

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:

PropertyRequiredTypeDefaultDescription
strictfalseBooleanfalsestrict mode will fully remove the element from DOM instead of blurring it (for more sensitive contents)
opacityfalseNumber0.5Opacity of the overlay
blurfalseNumber3Blur radius
showLockfalseBooleantrueshow lock icon
statusTextfalseString''Status text to display on the restricted access component
statusTextColorfalseString#000Status text color
showStatusTextfalseBooleantrueshow status text
customStatusBoxfalseBooleanfalseIf you set custom status to true then you need use scoped slot with name custom-message to pass your own component
customStatusPositionCenterfalseBooleantrueIf this is passed true then your custom status box will be in the center

Example settings object

mySettingsObj = {
  strict: false,
  opacity: 0.5,
  blur: 3,
  showStatusText: true,
  statusText: 'Signup to access this content',
  statusTextColor: '#000',
  showLock: true,
  customStatusBox: false,
  customStatusPositionCenter: true
}

Notes:

  1. On strict mode, use a wrapper component over the <restricted-access> component and set width and height or override the CSS
0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago