Skip to content

Commit

Permalink
Merge branch 'master' into feat/geolocation
Browse files Browse the repository at this point in the history
  • Loading branch information
pikax committed Jan 21, 2020
2 parents e4f5a8a + 57b6840 commit bfdf71e
Show file tree
Hide file tree
Showing 59 changed files with 2,092 additions and 442 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,5 @@ $RECYCLE.BIN/

# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
dist
temp
temp
!docs/.vuepress/public/
36 changes: 34 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,42 @@
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

<!-- ## [Unreleased]
## [Unreleased]

--- -->
---

### Changed

- Axios: Allow calling exec with a string

## 1.0.0-dev.7

_2020-01-19_

---

### Changed

- Fix readme storage links

## 1.0.0-dev.6

_2020-01-19_

---

### Added

- [Online](<[composable/web](https://pikax.me/vue-composable/composable/web)/online>) - reactive `navigator.onLine` wrapper
- [PageVisibility](https://pikax.me/vue-composable/composable/web/pageVisibility) - reactive `Page Visibility API`
- [Language](https://pikax.me/vue-composable/composable/web/language) - reactive `NavigatorLanguage`
- [WebStorage](composable/misc/webStorage) - Reactive access to `Storage API`, `useLocalStorage` and `useSessionStorage` use this
- [storage](composable/misc/storage) - uses `localStorage` or on safari private it uses `sessionStorage`
- [sessionStorage](composable/misc/sessionStorage) - Reactive access to a `sessionStorage`

### Changed

- [localStorage](composable/misc/localStorage) - refractor implementation to `useWebStorage` and added tab sync functionality

## 1.0.0-dev.4

Expand Down
24 changes: 24 additions & 0 deletions docs/.vuepress/components/LanguageExample.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<div>
<h3>
Language: <b>{{ language }}</b>
</h3>
<div>
<h4>Preferred Languages</h4>
<ul>
<li v-for="l in languages" :key="l">
{{ l }}
</li>
</ul>
</div>
</div>
</template>

<script>
import { useLanguage } from "vue-composable";
export default {
setup() {
return useLanguage();
}
};
</script>
32 changes: 27 additions & 5 deletions docs/.vuepress/components/LocalStorageExample.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,50 @@
<template>
<div>
localStorage: {{storage}}
localStorage: {{ storage }}
<p>
<b>Check the value in the dev tools: `{{key}}`</b>
supported:
<b :class="{ green: supported, red: !supported }">{{ supported }}</b>
</p>
<p>
<b>Check the value in the dev tools: `{{ key }}`</b>
</p>
<label for="storage">
<input name="storage" v-model="storage" />
</label>

<div>
<p>Enable tab sync? <input type="checkbox" v-model="tabSync" /></p>
<p v-if="tabSync">
Now this tab is listening for changes, please change the storage value
in other tab
</p>
</div>
<div>
<button @click="remove">Remove</button>
</div>
</div>
</template>

<script>
import { useLocalStorage } from "vue-composable";
import { ref, watch } from "@vue/composition-api";
export default {
name: "local-storage-example",
setup() {
const key = "__vue_localStorage_example";
const { storage } = useLocalStorage(key, 1);
const tabSync = ref(false);
const { supported, storage, setSync, remove } = useLocalStorage(key, 1);
watch(tabSync, setSync);
return {
key,
storage
supported,
tabSync,
storage,
remove
};
}
};
</script>
</script>
23 changes: 23 additions & 0 deletions docs/.vuepress/components/OnlineExample.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<div>
<h1>Is Online?</h1>

<h3>
Online: <b :class="{ green: online, red: !online }">{{ online }}</b>
</h3>
<h4>
Supported: <b>{{ supported }}</b>
</h4>

<p>To test open dev tools and set your browser to offline (Network tab)</p>
</div>
</template>

<script>
import { useOnline } from "vue-composable";
export default {
setup() {
return useOnline();
}
};
</script>
36 changes: 36 additions & 0 deletions docs/.vuepress/components/PageVisibilityExample.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<div>
<h4>
Hidden: <b>{{ hidden }}</b>
</h4>
<h4>
State: <b>{{ visibility }}</b>
</h4>
<p>You can change the state by switching tab - Check console</p>
<p>
<a
href="https://sqa.stackexchange.com/a/32355"
target="_blank"
rel="noopener noreferrer"
>Check this link</a
>
</p>
</div>
</template>

<script>
import { usePageVisibility, unwrap } from "vue-composable";
import { watch, reactive } from "@vue/composition-api";
export default {
setup() {
const { visibility, hidden } = usePageVisibility();
watch(visibility, () => {
console.log("visibility changed", {
visibility: visibility.value,
hidden: hidden.value
});
});
return { visibility, hidden };
}
};
</script>
41 changes: 41 additions & 0 deletions docs/.vuepress/components/SessionStorageExample.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
<div>
sessionStorage: {{ storage }}
<p>
supported:
<b :class="{ green: supported, red: !supported }">{{ supported }}</b>
</p>
<p>
<b>Check the value in the dev tools: `{{ key }}`</b>
</p>
<label for="storage">
<input name="storage" v-model="storage" />
</label>

<div>
<button @click="remove">Remove</button>
</div>
</div>
</template>

<script>
import { useSessionStorage } from "vue-composable";
import { ref, watch } from "@vue/composition-api";
export default {
name: "session-storage-example",
setup() {
const key = "__vue_sessionStorage_example";
const tabSync = ref(false);
const { supported, storage, remove } = useSessionStorage(key, 1);
return {
key,
supported,
tabSync,
storage,
remove
};
}
};
</script>
59 changes: 59 additions & 0 deletions docs/.vuepress/components/StorageExample.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>
<div>
storage: {{ storage }}
<p>
supported:
<b :class="{ green: supported, red: !supported }">{{ supported }}</b>
</p>
<p>
<b>Check the value in the dev tools: `{{ key }}`</b>
</p>
<label for="storage">
<input name="storage" v-model="storage" />
</label>

<div>
<p>Sync supported: {{ supportedSync }}</p>
<p>Enable tab sync? <input type="checkbox" v-model="tabSync" /></p>
<p v-if="tabSync">
Now this tab is listening for changes, please change the storage value
in other tab
</p>
</div>
<div>
<button @click="remove">Remove</button>
</div>
</div>
</template>

<script>
import { useLocalStorage, useStorage } from "vue-composable";
import { ref, watch } from "@vue/composition-api";
export default {
name: "storage-example",
setup() {
const key = "__vue_storage_example";
const tabSync = ref(false);
const supportedSync = ref(true);
const { supported, storage, setSync, remove } = useStorage(key, 1);
watch(tabSync, s => {
if (setSync(s) === false) {
supportedSync.value = false;
}
});
return {
key,
supported,
supportedSync,
tabSync,
storage,
remove
};
}
};
</script>
17 changes: 15 additions & 2 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,21 @@ module.exports = {
sidebarDepth: 1,
collapsable: false,
children: [
["composable/misc/localStorage", "localStorage"],
["composable/misc/matchMedia", "matchMedia"],
["composable/misc/breakpoint", "breakpoint"]
]
},
{
title: "Storage",
sidebarDepth: 1,
collapsable: false,
children: [
["composable/storage/webStorage", "WebStorage"],
["composable/storage/storage", "Storage"],
["composable/storage/localStorage", "localStorage"],
["composable/storage/sessionStorage", "sessionStorage"]
]
},
{
title: "Pagination",
collapsable: false,
Expand All @@ -202,7 +212,10 @@ module.exports = {
["composable/web/fetch", "fetch"],
["composable/web/webSocket", "webSocket"],
["composable/web/intersectionObserver", "IntersectionObserver"],
["composable/web/networkInformation", "NetworkInformation"]
["composable/web/networkInformation", "NetworkInformation"],
["composable/web/online", "Navigator.onLine"],
["composable/web/pageVisibility", "PageVisibilityAPI"],
["composable/web/language", "Language"]
]
},
{
Expand Down
Binary file added docs/.vuepress/public/localStorage.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/.vuepress/styles/index.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

.red {
color: red;
}
.green {
color: green;
}
11 changes: 10 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ Check out the [examples folder](examples) or start hacking on [codesandbox](http

### MISC

- [localStorage](composable/misc/localStorage) - Reactive access to a `localStorage`
- [MatchMedia](composable/misc/matchMedia) - reactive `MatchMedia`
- [Breakpoint](composable/misc/breakpoint) - reactive `breakpoints` based on `window.innerWidth`

### Storage

- [WebStorage](composable/storage/webStorage) - Reactive access to `Storage API`, `useLocalStorage` and `useSessionStorage` use this
- [storage](composable/storage/storage) - uses `localStorage` or on safari private it uses `sessionStorage`
- [localStorage](composable/storage/localStorage) - Reactive access to a `localStorage`
- [sessionStorage](composable/storage/sessionStorage) - Reactive access to a `sessionStorage`

### Pagination

- [Pagination](composable/pagination/pagination) - Generic reactive pagination controls
Expand All @@ -75,6 +81,9 @@ Check out the [examples folder](examples) or start hacking on [codesandbox](http
- [WebSocket](composable/web/webSocket) - reactive `WebSocket` wrapper
- [IntersectionObserver](composable/web/intersectionObserver) - reactive `IntersectionObserver`
- [NetworkInformation](composable/web/networkInformation) - reactive `NetworkInformation` wrapper
- [Online](composable/web/online) - reactive `navigator.onLine` wrapper
- [PageVisibility](composable/web/pageVisibility) - reactive `Page Visibility API`
- [Language](composable/web/language) - reactive `NavigatorLanguage`

### External

Expand Down
8 changes: 4 additions & 4 deletions docs/composable/external/axios.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ import { useAxios } from "@vue-composable/axios";
const { exec, cancel } = useAxios();
```
| Signature | Description |
| ------------------ | ------------------------ |
| `exec(request)` | Executes axios request |
| `cancel(message?)` | Cancels the last request |
| Signature | Description |
| --------------------------- | ------------------------ |
| `exec(AxiosRequest|string)` | Executes axios request |
| `cancel(message?)` | Cancels the last request |
## Example
Expand Down

0 comments on commit bfdf71e

Please sign in to comment.