Coder Social home page Coder Social logo

streaver / vue-preferences Goto Github PK

View Code? Open in Web Editor NEW
96.0 5.0 3.0 7.4 MB

The coolest and easiest way to manage your user's preferences on the client side with your preferred storage. Check out sample app here:

Home Page: https://vue-preferences.netlify.com

License: MIT License

JavaScript 100.00%
vue preference settings user localstorage

vue-preferences's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar fedekau avatar flarra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vue-preferences's Issues

Add a sync option to allow tab syncs to happen

Investigate the possibility of adding a synchronize option to allow synching of the preferences when other tabs write to the storage.

Use the StorageEvent for synchronization when using localStorage or sessionStorage

Additional quotes around strings

Describe the bug
It seems like when a string value is stored, it's being stored with additional quotes around the string.

To Reproduce
Steps to reproduce the behavior:

  1. Create the computed variable:
computed: {
    applicationTheme: preference('applicationTheme', { defaultValue: 'default' }),
}
  1. Set it to something:
methods: {
    toggleDarkTheme() {
        this.applicationTheme = this.applicationTheme === 'default' ? 'dark' : 'default';
    }
}
  1. Get the value from local storage (not using Vue/Vue-Preferences):
const applicationTheme = localStorage.getItem("applicationTheme");
// Value is equal to "default" or "dark", not default or dark

Expected behavior
The value shouldn't be surrounded by quotes.

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version latest

Update the sample-app UI

The sample app UI could be better. Since the one we have is kind of bad almost anything that is better would be accepted as a PR ๐Ÿ™„

Vue3 Property "_isVue" was accessed during render on Reactive preferences

Describe the bug
When updating a reactive preference, the change is not reflected. The console contains warning containing the above error.

To Reproduce
Steps to reproduce the behavior:

  1. Setup a vue3 project (I am using vite-cli -> vue + typescript)
  2. Install vue-preferences then create a reactive preference
  3. Update the preference.
  4. See console

Expected behavior
The value should have reactively updated without requiring a refresh.

Error

runtime-core.esm-bundler.js:38 [Vue warn]: Property "_isVue" was accessed during render but is not defined on instance. 
  at <Content> 
  at <App>
warn @ runtime-core.esm-bundler.js:38
get @ runtime-core.esm-bundler.js:6877
s.J @ preference-object.js:58
s.get @ preference-object.js:36
get @ preference.js:12
reactiveEffect @ reactivity.esm-bundler.js:42
get value @ reactivity.esm-bundler.js:876
get @ runtime-core.esm-bundler.js:3090
_sfc_render @ Content.vue:2

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser Webview2 [edge]
  • "vue": "^3.0.5",
    "vue-preferences": "^3.0.0"
    

Additional context
Here is what my code approx looks like, but I get the error on almost all instances of updating preference. To reflect the changes elsewhere. I need a full reload.

<button round @click="theme = theme == 'dark' ? 'light' : 'dark'">

<script>
computed: {
  theme: preference('activeTheme', { defaultValue: 'dark' })
}
</script>

I also tried the programmatic approach but the value doesnt update.

defaultValue gives null for Boolean

When using false as defaultValue, the default value is null instead of false.
I have another preference which is of type string and it works properly for that preference.
Using: localStorage

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.