Skip to content

Commit

Permalink
Add example page
Browse files Browse the repository at this point in the history
  • Loading branch information
vsaienko committed Sep 2, 2019
1 parent 52b37ec commit f2f99b8
Show file tree
Hide file tree
Showing 8 changed files with 3,693 additions and 173 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.cache
node_modules
coverage
dist
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.cache
.coverage
.travis.yml
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@ You can pass the following properties to `options`:
| Name | Type | Default | Description |
| -------------- | ------ | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| `errorMessage` | String | Looks like you've disabled \<StorageType\>. Enable it to avoid this warning. | Error message printed to the browser console when storage is not available |

## Development

To test the library in a browser run:

```bash
npm install
npm start
```
13 changes: 13 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Test storage</title>
</head>
<body>
<div id="root"></div>
<script src="script.js"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions example/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { createSafeLocalStorage, createSafeSessionStorage } from '../src'

const safeLocaleStorage = createSafeLocalStorage()
const safeSessionStorage = createSafeSessionStorage()

function renderStorageData(storage) {
return `
<section>
<h2>${storage._storageType}</h2>
<div>isNativeStorageUsed: <em>${storage.isNativeStorageUsed}</em></div>
<div>isInMemoryStorageUsed: <em>${storage.isInMemoryStorageUsed}</em></div>
</section>
`
}

function renderApp() {
const html =
renderStorageData(safeLocaleStorage) + renderStorageData(safeSessionStorage)

document.getElementById('root').innerHTML = html
}

renderApp()
Loading

0 comments on commit f2f99b8

Please sign in to comment.