This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
generated from MetaMask/metamask-module-template
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: resolving conflicts from main
- Loading branch information
1 parent
d3b0a10
commit 04e54c7
Showing
11 changed files
with
152 additions
and
144 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
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,19 @@ | ||
/** | ||
* Recursively collects color values and their names from a JavaScript color object using dot notation. | ||
* | ||
* @param obj - The color object to traverse. | ||
* @param parentKey - The parent key to use for dot notation. | ||
* @returns An array of objects containing color value and name. | ||
*/ | ||
export const getJSColors = ( | ||
obj: any, | ||
parentKey = '', | ||
): { name: string; color: string }[] => { | ||
return Object.entries(obj).flatMap(([key, value]) => { | ||
const newKey = parentKey ? `${parentKey}.${key}` : key; | ||
if (typeof value === 'string') { | ||
return [{ name: newKey, color: value }]; | ||
} | ||
return getJSColors(value, newKey); | ||
}); | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { getCSSVariablesFromStylesheet } from './getCSSVariablesFromStylesheet'; | ||
export { getContrastYIQ } from './getContrastYIQ'; | ||
export { getJSColors } from './getJSColors'; | ||
export { useJsonColor } from './useJsonColor'; |
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
Oops, something went wrong.