Skip to content

Commit

Permalink
Merge pull request #65 from bohoffi/feature/62-directive-utilizing-co…
Browse files Browse the repository at this point in the history
…ntrolvalueaccessor

Release 6.0
  • Loading branch information
bohoffi authored Mar 10, 2024
2 parents 95ea16c + d71802e commit 160627d
Show file tree
Hide file tree
Showing 74 changed files with 4,960 additions and 4,407 deletions.
29 changes: 29 additions & 0 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Action for setting up node
description: Setup Node.js

inputs:
node-version:
description: Node.js version
required: false
default: 18.x

runs:
using: composite
steps:
- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
cache: npm

- name: Cache NPM dependencies
uses: actions/cache@v3
id: cache-npm-dependencies
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}

- name: Install Dependencies
if: steps.cache-npm-dependencies.outputs.cache-hit != 'true'
shell: bash
run: npm ci
10 changes: 2 additions & 8 deletions .github/workflows/MANUAL_github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,15 @@ jobs:
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm i
uses: ./.github/actions/setup-node

- name: Build the docs
run: npm run docs

- name: Upload Artifacts
uses: actions/upload-pages-artifact@v1
with:
path: docs
path: docs/browser

deploy:
name: Deploys the artifact to Github Pages
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/RELEASE_github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,15 @@ jobs:
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm i
uses: ./.github/actions/setup-node

- name: Build the docs
run: npm run docs

- name: Upload Artifacts
uses: actions/upload-pages-artifact@v1
with:
path: docs
path: docs/browser

deploy:
name: Deploys the artifact to Github Pages
Expand Down
29 changes: 9 additions & 20 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,16 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3

- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Setup node
uses: ./.github/actions/setup-node

- name: Install dependencies
run: |
npm ci
npm run lint
npm run test
- name: Lint
run: npm run lint

- name: Test
run: npm run test
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ Thumbs.db

.angular

.nx/cache
.nx/cache

# NgDoc files
/ng-doc
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
<a name="6.0.0"></a>

# [6.0.0](https://github.com/bohoffi/ngx-localstorage/compare/5.1.0...6.0.0) (2024-03-10)

### 🚀 Features

- add support for `formControl` ([68406fc](https://github.com/bohoffi/ngx-localstorage/commit/68406fc))
- expose library version token ([8040c85](https://github.com/bohoffi/ngx-localstorage/commit/8040c85))

### BREAKING CHANGES

- update to Angular 17 ([3942bee](https://github.com/bohoffi/ngx-localstorage/commit/3942bee))

### ❤️ Thank You

- bohoffi @bohoffi

<a name="5.1.0"></a>

# [5.1.0](https://github.com/bohoffi/ngx-localstorage/compare/5.0.0...5.1.0) (2023-10-29)
Expand Down
119 changes: 23 additions & 96 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,105 +1,25 @@
<img src="https://raw.githubusercontent.com/bohoffi/ngx-localstorage/develop/assets/logo.svg" width="150">

[![npm version](https://img.shields.io/npm/v/ngx-localstorage.svg)](https://www.npmjs.com/package/ngx-localstorage)
<div align=center>
<img src="https://raw.githubusercontent.com/bohoffi/ngx-localstorage/develop/assets/logo.svg" width="150">
<h1>ngx-localstorage</h1>

<p align=center>
An Angular wrapper for localstorage/sessionstorage access
<br />
[![NPM][npm-shield]][npm-url]
[![License][license-shield]][license-url]
[![Release Workflow Status][build-shield]][build-url]
</p>
</div>

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

![PR-builder](https://github.com/bohoffi/ngx-localstorage/workflows/PR-builder/badge.svg)

# ngx-localstorage

An Angular wrapper for localstorage/sessionstorage access.

- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [Serialization](#serialization)

Feel free to take a look at the [DEMO / API](https://bohoffi.github.io/ngx-localstorage/).

## Installation

Install via npm:

```
npm install ngx-localstorage
```

## Usage

If you want to use the `ngxLocalStorage` directive you have to import it either in your module or component/directive.

#### Import `LocalStorageDirective`

```ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { LocalStorageDirective } from 'ngx-localstorage';

@NgModule({
imports: [BrowserModule, LocalStorageDirective],
bootstrap: [AppComponent]
})
export class AppModule {}
```

### Configuration

For configuration provide it using the `NGX_LOCAL_STORAGE_CONFIG` InjectionToken or use the `provideNgxLocalstorage()` helper method (which optionally allows providing additional features as well).

- **prefix**
- Type: `string?`
- Determines the key prefix.
- Default: **undefined**
- **allowNull**
- Type: `boolean?`
- Determines if _null | 'null'_ values should be stored.
- Default: **true**
- **storageType**
- Type: `StorageType?`
- Determines the storage type.
- Default: **'localStorage'**
- **delimiter**
- Type: `string?`
- Determines the delimiter in between prefix and key.
- Default: **underscore('\_')**

### Serialization

#### Default serialization

The library utilizes the `JSON.stringify()/JSON.parse()` mechanics to pass values (of any type) to and from localstorage per default.
If you wish you can override that behaviour by injecting your own custom serializer (app wide) or pass one per stoage call.

#### App wide serializer

Inject your custom serializer implentation using the provided injection token or pass it to the `provideNgxLocalstorage()` helper method:

```ts
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {NGX_LOCAL_STORAGE_SERIALIZER} from 'ngx-localstorage';
[![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors-)

@NgModule({
imports: [
BrowserModule
],
bootstrap: [AppComponent],
providers: [
{
provide: NGX_LOCAL_STORAGE_SERIALIZER,
useClass: <custom serializer implementing StorageSerializer>
}
]
})
export class AppModule { }
```
<!-- ALL-CONTRIBUTORS-BADGE:END -->

##### Per call serializer
## Installation / Usage

Every `set()/get()` call on `LocalstorageService` now supports to pass an optional (de)seriaizer. If none is provided the app wide (or default) one is used.
All information about installation and usage can be found in our [documentation](https://bohoffi.github.io/ngx-localstorage/)

## Contributors ✨

Expand Down Expand Up @@ -132,3 +52,10 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

[npm-shield]: https://img.shields.io/npm/v/ngx-localstorage?style=for-the-badge
[npm-url]: https://www.npmjs.com/package/ngx-localstorage
[license-shield]: https://img.shields.io/github/license/bohoffi/ngx-localstorage?style=for-the-badge
[license-url]: https://github.com/bohoffi/ngx-localstorage/blob/main/LICENSE
[build-shield]: https://img.shields.io/github/actions/workflow/status/bohoffi/ngx-localstorage/RELEASE_github-pages.yml?style=for-the-badge
[build-url]: https://github.com/bohoffi/ngx-localstorage/actions/workflows/RELEASE_github-pages.yml
49 changes: 28 additions & 21 deletions apps/ngx-localstorage-demo/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,37 @@
"prefix": "ngx-localstorage",
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:browser",
"executor": "@ng-doc/builder:application",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/ngx-localstorage-demo",
"index": "apps/ngx-localstorage-demo/src/index.html",
"main": "apps/ngx-localstorage-demo/src/main.ts",
"polyfills": "apps/ngx-localstorage-demo/src/polyfills.ts",
"browser": "apps/ngx-localstorage-demo/src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "apps/ngx-localstorage-demo/tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": ["apps/ngx-localstorage-demo/src/favicon.ico", "apps/ngx-localstorage-demo/src/assets"],
"assets": [
{
"glob": "**/*",
"input": "node_modules/@ng-doc/app/assets",
"output": "assets/ng-doc/app"
},
{
"glob": "**/*",
"input": "node_modules/@ng-doc/ui-kit/assets",
"output": "assets/ng-doc/ui-kit"
},
{
"glob": "**/*",
"input": "ng-doc/ngx-localstorage-demo/assets",
"output": "assets/ng-doc"
},
"apps/ngx-localstorage-demo/src/favicon.ico",
"apps/ngx-localstorage-demo/src/assets"
],
"styles": [
"node_modules/@ng-doc/app/styles/global.css",
"apps/ngx-localstorage-demo/src/styles.scss",
"apps/ngx-localstorage-demo/src/demo-theme.scss",
"node_modules/prismjs/themes/prism-tomorrow.min.css",
"node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss",
"node_modules/@fortawesome/fontawesome-free/scss/brands.scss"
Expand All @@ -27,15 +45,16 @@
"node_modules/marked/marked.min.js",
"node_modules/prismjs/prism.js",
"node_modules/prismjs/components/prism-typescript.min.js"
]
],
"allowedCommonJsDependencies": ["@ng-doc/core"]
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
"maximumWarning": "1.2mb",
"maximumError": "1.5mb"
},
{
"type": "anyComponentStyle",
Expand All @@ -52,9 +71,7 @@
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
Expand All @@ -63,7 +80,7 @@
"defaultConfiguration": "production"
},
"serve": {
"executor": "@angular-devkit/build-angular:dev-server",
"executor": "@ng-doc/builder:dev-server",
"configurations": {
"production": {
"buildTarget": "ngx-localstorage-demo:build:production"
Expand All @@ -73,16 +90,6 @@
}
},
"defaultConfiguration": "development"
},
"lint": {
"executor": "@nx/eslint:lint"
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/apps/ngx-localstorage-demo"],
"options": {
"jestConfig": "apps/ngx-localstorage-demo/jest.config.ts"
}
}
},
"tags": []
Expand Down
Loading

0 comments on commit 160627d

Please sign in to comment.