Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

Commit 9a9b743

Browse files
authored
Merge pull request #68 from leonardortlima/dynamic-fill-stroke-text
Allow to change Stroke and Fill color picker texts.
2 parents ce2c120 + 83b39c8 commit 9a9b743

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ In the html file, you can insert the Canvas Whiteboard
8383
[redoButtonText]="'Redo'"
8484
[redoButtonEnabled]="true"
8585
[colorPickerEnabled]="true"
86+
[fillColorPickerText]="'Fill'"
87+
[strokeColorPickerText]="'Stroke'"
8688
[saveDataButtonEnabled]="true"
8789
[saveDataButtonText]="'Save'"
8890
[lineWidth]="5"
@@ -121,6 +123,8 @@ Code:
121123
redoButtonText: "Redo",
122124
redoButtonEnabled: true,
123125
colorPickerEnabled: true,
126+
fillColorPickerText: "Fill",
127+
strokeColorPickerText: "Stroke",
124128
saveDataButtonEnabled: true,
125129
saveDataButtonText: "Save",
126130
lineWidth: 5,
@@ -238,9 +242,15 @@ and the original colors will be used when redrawing
238242
##### `fillColorPickerEnabled: boolean` (default: false)
239243
This shows/hides the fill color picker. Note: if this field has been to `false`, but the `colorPickerEnabled` field has been to `true`, the color picker will be shown, as per reverse-compat needs.
240244
245+
##### `fillColorPickerText: string` (default: 'Fill')
246+
Specify the text to add to the fill color picker button. Default is 'Fill' for reverse-compat needs.
247+
241248
##### `strokeColorPickerEnabled: boolean` (default: false)
242249
This shows/hides the stroke color picker. Note: if this field has been to `false`, but the `colorPickerEnabled` field has been set to `true`, the color picker will be shown, as per reverse-compat needs.
243250
251+
##### `strokeColorPickerText: string` (default: 'Stroke')
252+
Specify the text to add to the stroke color picker button. Default is 'Stroke' for reverse-compat needs.
253+
244254
##### `lineWidth: number` (default: 2)
245255
This input controls the drawing pencil size
246256

projects/ng2-canvas-whiteboard/src/lib/canvas-whiteboard-options.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export interface CanvasWhiteboardOptions {
2222
/** @deprecated. Replaced with strokeColorPickerEnabled and fillColorPickerEnabled inputs */
2323
colorPickerEnabled?: boolean;
2424
strokeColorPickerEnabled?: boolean;
25+
strokeColorPickerText?: string;
2526
fillColorPickerEnabled?: boolean;
27+
fillColorPickerText?: string;
2628
shouldDownloadDrawing?: boolean;
2729
startingColor?: string;
2830
scaleFactor?: number;

projects/ng2-canvas-whiteboard/src/lib/canvas-whiteboard.component.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ import { cloneDeep, isEqual } from 'lodash-es';
3434
(onShapeSelected)="selectShape($event)"></canvas-whiteboard-shape-selector>
3535
3636
<canvas-whiteboard-colorpicker *ngIf="colorPickerEnabled || fillColorPickerEnabled"
37-
[previewText]="'Fill'"
37+
[previewText]="fillColorPickerText"
3838
[showColorPicker]="showFillColorPicker"
3939
[selectedColor]="fillColor"
4040
(onToggleColorPicker)="toggleFillColorPicker($event)"
4141
(onColorSelected)="changeFillColor($event)">
4242
</canvas-whiteboard-colorpicker>
4343
4444
<canvas-whiteboard-colorpicker *ngIf="colorPickerEnabled || strokeColorPickerEnabled"
45-
[previewText]="'Stroke'"
45+
[previewText]="strokeColorPickerText"
4646
[showColorPicker]="showStrokeColorPicker"
4747
[selectedColor]="strokeColor"
4848
(onToggleColorPicker)="toggleStrokeColorPicker($event)"
@@ -113,6 +113,8 @@ export class CanvasWhiteboardComponent implements OnInit, AfterViewInit, OnChang
113113
@Input() undoButtonText = '';
114114
@Input() redoButtonText = '';
115115
@Input() saveDataButtonText = '';
116+
@Input() strokeColorPickerText = 'Stroke';
117+
@Input() fillColorPickerText = 'Fill';
116118
@Input() drawButtonEnabled = true;
117119
@Input() clearButtonEnabled = true;
118120
@Input() undoButtonEnabled = false;
@@ -263,6 +265,12 @@ export class CanvasWhiteboardComponent implements OnInit, AfterViewInit, OnChang
263265
if (!this._isNullOrUndefined(options.saveDataButtonText)) {
264266
this.saveDataButtonText = options.saveDataButtonText;
265267
}
268+
if (!this._isNullOrUndefined(options.strokeColorPickerText)) {
269+
this.strokeColorPickerText = options.strokeColorPickerText;
270+
}
271+
if (!this._isNullOrUndefined(options.fillColorPickerText)) {
272+
this.fillColorPickerText = options.fillColorPickerText;
273+
}
266274
if (!this._isNullOrUndefined(options.drawButtonEnabled)) {
267275
this.drawButtonEnabled = options.drawButtonEnabled;
268276
}

0 commit comments

Comments
 (0)