-
Notifications
You must be signed in to change notification settings - Fork 39
feat: Update color converter page (HEX / RGB Converter) #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hex Color converter is now Color Converter to convert not just only Hex to RGB but even more.
adding HSV to this would potentially increase interest from the luau community |
Thanks for creating this PR! I'm on vacation until 9th September, after that I'm going to have a look! |
|
||
export type ColorValue = RGBValues | HSLValues | CMYKValues | HSVValues | string; | ||
|
||
export const isValidHex = (hex: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a couple of unit tests for this function wouldn't hurt
return !isNaN(value) && value >= 0 && value <= 255; | ||
}; | ||
|
||
export const convertToRGB = (hex: string): RGBValues => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As well as for other conversion functions
return { r, g, b }; | ||
}; | ||
|
||
export const convertToHex = (r: string, g: string, b: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why three named parameters and not just RGBValues
as input?
}; | ||
|
||
export const toCss = (rgb: RGBValues) => { | ||
if (!rgb || typeof rgb.r === 'undefined' || typeof rgb.g === 'undefined' || typeof rgb.b === 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be possible in the first place
const valueToFixed = (value: string) => (parseInt(value) / 255).toFixed(2); | ||
|
||
export const toIOS = (rgb: RGBValues, lang: "swift" | "c"): string => { | ||
if (!rgb || typeof rgb.r === 'undefined' || typeof rgb.g === 'undefined' || typeof rgb.b === 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some point on unnecessary checks here
@@ -0,0 +1,222 @@ | |||
export interface RGBValues { | |||
r: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use number
here in the first place?
Hey team,
I've made some significant improvements to the Color Converter tool (HEX / RGB Converter). Instead of just handling HEX to RGB conversions, it now supports conversions between HEX, RGB, HSL, and CMYK formats.
Here's what's new:
I think this update will make the tool much more useful for our team and potentially save us some time when working with various color systems.
I'd appreciate it if you could take a look and let me know your thoughts. If it seems valuable to you too, I'd love to get this merged into the main branch.
Looking forward to your feedback! 🔥