generated from pagevamp/copilot-custom-app-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
97 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export function updateColor(rgbaColor: any, newOpacity: number) { | ||
// Parse the input RGBA color string | ||
const colorRegex = /^rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)$/; | ||
const match = rgbaColor.match(colorRegex); | ||
|
||
if (!match) { | ||
// Invalid input format, return the original color | ||
return rgbaColor; | ||
} | ||
|
||
// Extract color components | ||
const [, red, green, blue] = match; | ||
|
||
// Build the updated RGBA color string with the new opacity | ||
const updatedColor = `rgba(${red}, ${green}, ${blue}, ${newOpacity})`; | ||
|
||
return updatedColor; | ||
} |