update documentation
This commit is contained in:
parent
f9f922d232
commit
3dc330bb09
@ -2,17 +2,32 @@
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "designestate",
|
||||
"gitrepo": "navigation",
|
||||
"shortDescription": "a module for opinionated navigation abstraction",
|
||||
"npmPackagename": "@designestate/navigation",
|
||||
"license": "MIT",
|
||||
"projectDomain": "design.estate"
|
||||
"projectDomain": "design.estate",
|
||||
"description": "A navigation management library enabling opinionated abstraction of navigation structures within applications.",
|
||||
"keywords": [
|
||||
"navigation",
|
||||
"abstraction",
|
||||
"TypeScript",
|
||||
"module",
|
||||
"navigation management",
|
||||
"compiled navigation",
|
||||
"navigation entry",
|
||||
"reactive programming",
|
||||
"observables"
|
||||
]
|
||||
}
|
||||
},
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
15
package.json
15
package.json
@ -2,7 +2,7 @@
|
||||
"name": "@designestate/navigation",
|
||||
"version": "1.0.6",
|
||||
"private": false,
|
||||
"description": "a module for opinionated navigation abstraction",
|
||||
"description": "A navigation management library enabling opinionated abstraction of navigation structures within applications.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"author": "Lossless GmbH",
|
||||
@ -37,5 +37,16 @@
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"keywords": [
|
||||
"navigation",
|
||||
"abstraction",
|
||||
"TypeScript",
|
||||
"module",
|
||||
"navigation management",
|
||||
"compiled navigation",
|
||||
"navigation entry",
|
||||
"reactive programming",
|
||||
"observables"
|
||||
]
|
||||
}
|
||||
}
|
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
134
readme.md
134
readme.md
@ -1,39 +1,119 @@
|
||||
# @designestate/navigation
|
||||
a module for opinionated navigation abstraction
|
||||
A module for opinionated navigation abstraction.
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@designestate/navigation)
|
||||
* [gitlab.com (source)](https://gitlab.com/designestate/navigation)
|
||||
* [github.com (source mirror)](https://github.com/designestate/navigation)
|
||||
* [docs (typedoc)](https://designestate.gitlab.io/navigation/)
|
||||
## Install
|
||||
To use `@designestate/navigation` in your project, run:
|
||||
|
||||
## Status for master
|
||||
```bash
|
||||
npm install @designestate/navigation --save
|
||||
```
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [![pipeline status](https://gitlab.com/designestate/navigation/badges/master/pipeline.svg)](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/designestate/navigation/badges/master/coverage.svg)](https://lossless.cloud)
|
||||
npm | [![npm downloads per month](https://badgen.net/npm/dy/@designestate/navigation)](https://lossless.cloud)
|
||||
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/designestate/navigation)](https://lossless.cloud)
|
||||
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
|
||||
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@designestate/navigation)](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@designestate/navigation)](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@designestate/navigation)](https://lossless.cloud)
|
||||
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
|
||||
This will install the package and add it to your project's dependencies.
|
||||
|
||||
## Usage
|
||||
The `@designestate/navigation` module is designed to simplify the creation and management of navigational structures in your application. It provides a way to abstract navigation into manageable components, allowing for a more modular and maintainable codebase. Below are examples and explanations on how to utilize this module effectively in your projects.
|
||||
|
||||
This module addresses single layer navigations.
|
||||
### Getting Started
|
||||
First, ensure that you import the necessary classes from the module:
|
||||
|
||||
## Contribution
|
||||
```typescript
|
||||
import { NavigationManager, NavigationEntry } from '@designestate/navigation';
|
||||
```
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
### Creating a Navigation Manager
|
||||
The `NavigationManager` acts as the central point for managing navigation entries and can be linked with other navigation managers to create a more complex navigation structure. Here's how you can initialize a new `NavigationManager`:
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
```typescript
|
||||
const myNavigationManager = new NavigationManager();
|
||||
```
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
### Adding Navigation Entries
|
||||
`NavigationEntry` instances represent individual navigational elements. These can be pages, links, or any other components that you navigate to in your application. You can add navigation entries to the navigation manager like this:
|
||||
|
||||
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
|
||||
```typescript
|
||||
import { NavigationEntry } from '@designestate/navigation';
|
||||
|
||||
const dashboardNavEntry = new NavigationEntry();
|
||||
dashboardNavEntry.level = 0;
|
||||
dashboardNavEntry.group = 'main';
|
||||
dashboardNavEntry.groupRanking = 1;
|
||||
dashboardNavEntry.iconUrl = 'path/to/icon/url';
|
||||
dashboardNavEntry.id = 'dashboard';
|
||||
dashboardNavEntry.name = 'Dashboard';
|
||||
dashboardNavEntry.callBack = (idArg?: string) => {
|
||||
console.log(`Navigating to ${idArg}`);
|
||||
};
|
||||
|
||||
myNavigationManager.addNavigationEntry(dashboardNavEntry);
|
||||
```
|
||||
|
||||
### Compiling Navigation
|
||||
Once you have added all necessary navigation entries, you can compile the navigation structure. This process transforms the added entries into a `CompiledNavigation` instance, which can be used to render navigational components or manage routing:
|
||||
|
||||
```typescript
|
||||
myNavigationManager.compile().then(compiledNavigation => {
|
||||
// Use the compiledNavigation instance as needed
|
||||
});
|
||||
```
|
||||
|
||||
### Observing Navigation Changes
|
||||
`NavigationManager` provides an observable you can subscribe to for reacting to navigation changes. Whenever the navigation structure is compiled or updated, the observable emits a `CompiledNavigation` instance:
|
||||
|
||||
```typescript
|
||||
myNavigationManager.compiledNavigationObservable.subscribe(compiledNavigation => {
|
||||
// Handle navigation change
|
||||
});
|
||||
```
|
||||
|
||||
### Advanced Usage
|
||||
#### Hierarchical Navigation
|
||||
For complex applications, you might need hierarchical navigation. You can add a `NavigationManager` instance to another `NavigationManager`, enabling hierarchical navigation management:
|
||||
|
||||
```typescript
|
||||
const subNavigationManager = new NavigationManager();
|
||||
// Configure subNavigationManager
|
||||
|
||||
myNavigationManager.addNavigationManager(subNavigationManager);
|
||||
|
||||
// When you compile myNavigationManager, it will also include navigation entries from subNavigationManager
|
||||
```
|
||||
|
||||
#### Dynamic Navigation Entries
|
||||
Navigation entries can be dynamically added or removed based on application state or user permissions. This allows for a flexible and adaptive navigation structure:
|
||||
|
||||
```typescript
|
||||
const adminNavEntry = new NavigationEntry();
|
||||
// Configure adminNavEntry for admin level access
|
||||
|
||||
if (user.isAdmin) {
|
||||
myNavigationManager.addNavigationEntry(adminNavEntry);
|
||||
}
|
||||
|
||||
// You can also remove entries dynamically if needed
|
||||
```
|
||||
|
||||
## Conclusion
|
||||
The `@designestate/navigation` module offers a powerful and flexible way to manage navigation in your applications. By abstracting navigation into manageable components, it facilitates better organization and maintenance of your codebase. With the ability to create hierarchical and dynamic navigations, this module can cater to a wide range of application structures and scenarios.
|
||||
|
||||
Remember, the above examples are just the starting point. Explore the module further to harness its full capabilities in building intuitive and maintainable navigation structures for your applications.
|
||||
|
||||
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user