Commit e033f9de authored by Zéfling's avatar Zéfling 🎨
Browse files

Start of project

parents
Pipeline #16 canceled with stages
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
#
# For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11
\ No newline at end of file
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# dependencies
/node_modules
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db
# Changelog of json2html-lib
## V0.1.2 (2020-05-04)
### Corrections
- fix alpha calculation for `toHEX()`
## V0.1.1 (2020-05-02)
### Feature
- new design for the demo
### Corrections
- fix calculation when no alpha
- fix alpha calculation with mask opacity
## V0.1.0 (2020-05-01)
### Feature
- add alpha support
### Corrections
- add more control
- fix blue additionnal
- fix bug with float values for rgb
- update demo
## V0.0.4 (2019-01-23)
### Feature
- add `reset()` method
## V0.0.3 (2019-01-22)
### Features
- add `maskColor` and `maskOpacity` params for `addColor()`
## V0.0.2 (2019-01-21)
### Features
- add `getRGB()` and `getHSV()` methods
## V0.0.1 (2019-01-20)
- initial release
MIT License
Copyright (c) 2020 json2html
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
[![npm version](https://badge.fury.io/js/json2html-lib.svg)](https://badge.fury.io/js/json2html-lib) [![Downloads](https://img.shields.io/npm/dm/json2html-lib.svg)](https://www.npmjs.com/package/json2html-lib) [![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://git.ikilote.net/angular/json2html/raw/master/LICENSE)
# json2html
## Installation
```
npm i json2html-lib --save
```
## Requirements
Only for demo:
- Angular 9.1.0 and more
## Demo
[See a live demonstation](http://test.ikilote.net/json2html-demo/)
## Usage
### Examples
#### changeLuminosity
```typescript
import {json2html} from 'json2html-lib';
const color = new json2html('red');
color.changeLuminosity(0.55);
console.log(color.toHEX()); // #ff8c8c
```
#### maskColor
```typescript
const color = new json2html('red');
color.maskColor('blue', 0.25);
console.log(color.toHEX()); // #bf0040
```
#### addColor
```typescript
const color = new json2html('red');
color.addColor({
h: -23,
v: 10,
alpha: -0.2
});
console.log(color.toHEX()); // #ff3381cc
```
## Publishing the library
```
ng build json2html --prod
cp *.md dist/json2html
cd dist/json2html
npm publish
```
## Publishing the demo
```
ng build --prod
```
## License
This module is released under the permissive MIT license. Your contributions are always welcome.
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"json2html-demo": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"aot": true,
"outputPath": "dist/json2html-demo",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "json2html-demo:build"
},
"configurations": {
"production": {
"browserTarget": "json2html-demo:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "json2html-demo:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.scss"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"json2html-demo-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "json2html-demo:serve"
},
"configurations": {
"production": {
"devServerTarget": "json2html-demo:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"json2html": {
"root": "projects/json2html",
"sourceRoot": "projects/json2html/src",
"projectType": "library",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/json2html/tsconfig.lib.json",
"project": "projects/json2html/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/json2html/tsconfig.lib.prod.json"
}
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/json2html/src/test.ts",
"tsConfig": "projects/json2html/tsconfig.spec.json",
"karmaConfig": "projects/json2html/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/json2html/tsconfig.lib.json",
"projects/json2html/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "json2html-demo",
"cli": {
"analytics": false
}
}
\ No newline at end of file
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
\ No newline at end of file
import { AppPage } from './app.po';
describe('workspace-project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('Welcome to json2html-demo!');
});
});
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo() {
return browser.get('/');
}
getParagraphText() {
return element(by.css('app-root h1')).getText();
}
}
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
}
\ No newline at end of file
This diff is collapsed.
{
"name": "json2html-demo",
"version": "0.0.3",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://git.ikilote.net/angular/json2html"
},
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~10.0.11",
"@angular/common": "~10.0.11",
"@angular/compiler": "~10.0.11",
"@angular/core": "~10.0.11",
"@angular/forms": "~10.0.11",
"@angular/platform-browser": "~10.0.11",
"@angular/platform-browser-dynamic": "~10.0.11",
"@angular/router": "~10.0.11",
"core-js": "^2.5.4",
"rxjs": "~6.6.2",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1000.7",
"@angular-devkit/build-ng-packagr": "~0.1000.7",
"@angular/cli": "~10.0.7",
"@angular/compiler-cli": "~10.0.11",
"@angular/language-service": "~10.0.11",
"@types/node": "^12.11.1",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~3.3.0",
"karma-jasmine-html-reporter": "^1.5.0",
"ng-packagr": "^10.0.0",
"protractor": "~7.0.0",
"ts-node": "~7.0.0",
"tslint": "~6.1.0",
"typescript": "~3.9.7"
}
}
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../../coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/json2html",
"lib": {
"entryFile": "src/public_api.ts"
}
}
\ No newline at end of file
{
"name": "json2html-lib",
"version": "0.0.1",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://git.ikilote.net/angular/json2html"
},
"peerDependencies": {},
"dependencies": {
"tslib": "^2.0.0"
}
}
\ No newline at end of file
export interface Json2htmlAttr { [key: string]: string | number | undefined | null }
export interface Json2htmlRef {
tag: string,
attrs?: Json2htmlAttr,
body?: (Json2htmlRef | string)[] | string
}
export interface Json2htmlOptions {
spaceType?: 'space' | 'tab',
spaceLength?: 4,
spaceBase?: 0,
maxLenght?: 0,
attrPosition?: 'inline' | 'space' | 'alignTag' | 'alignFirst',
type?: 'html' | 'xml'
}
export class Json2html {
readonly options: Json2htmlOptions = {
spaceType: 'space',
spaceLength: 4,
spaceBase: 0,
maxLenght: 0,
attrPosition: 'inline',
type: 'html'
}
constructor(
public json: Json2htmlRef,
option: Json2htmlOptions = {}