mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Makes the hex value editable in the color select
Summary: - reuses the textInput form the editableLabel module - adds a isValidHex utility function to gutil Test Plan: - Adds test to the project test Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2744
This commit is contained in:
@@ -777,6 +777,15 @@ export function isColorDark(hexColor: string, isDarkBelow: number = 220): boolea
|
||||
return luma < isDarkBelow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if val is a valid hex color value. For instance: #aabbaa is valid, #aabba is not. Do
|
||||
* not accept neither short notation nor hex with transparency, ie: #aab, #aabb and #aabbaabb are
|
||||
* invalid.
|
||||
*/
|
||||
export function isValidHex(val: string): boolean {
|
||||
return /^#([0-9A-F]{6})$/i.test(val);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a promise that resolves to true if promise takes longer than timeoutMsec to resolve. If not
|
||||
|
||||
Reference in New Issue
Block a user