mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Working conversion
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
<ng-template #popContent>
|
||||
<div style="min-width: 200px;" class="pb-3">
|
||||
<color-slider [color]="value" (onChangeComplete)="sliderChanged($event)"></color-slider>
|
||||
<color-slider [color]="value" (onChangeComplete)="colorChanged($event.color.hex)"></color-slider>
|
||||
</div>
|
||||
|
||||
</ng-template>
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { Component, Input, forwardRef } from '@angular/core';
|
||||
import { Component, forwardRef } from '@angular/core';
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { ColorEvent, ColorMode } from 'ngx-color';
|
||||
import { randomColor, hslToHex } from 'src/app/utils/color';
|
||||
import { randomColor } from 'src/app/utils/color';
|
||||
import { AbstractInputComponent } from '../abstract-input';
|
||||
|
||||
@Component({
|
||||
@@ -16,26 +15,16 @@ import { AbstractInputComponent } from '../abstract-input';
|
||||
})
|
||||
export class ColorComponent extends AbstractInputComponent<string> {
|
||||
|
||||
@Input()
|
||||
colorMode: ColorMode = ColorMode.HEX
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
randomize() {
|
||||
const color = randomColor(this.colorMode)
|
||||
let colorHex = color
|
||||
if (this.colorMode == ColorMode.HSL) {
|
||||
const hsl = color.split(',')
|
||||
colorHex = hslToHex(+hsl[0], +hsl[1], +hsl[2])
|
||||
}
|
||||
this.value = colorHex
|
||||
this.onChange(color)
|
||||
this.colorChanged(randomColor())
|
||||
}
|
||||
|
||||
sliderChanged(colorEvent:ColorEvent) {
|
||||
this.value = colorEvent.color.hex
|
||||
this.onChange(colorEvent.color[this.colorMode].toString())
|
||||
colorChanged(value) {
|
||||
this.value = value
|
||||
this.onChange(value)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user