Skip to content
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

[Performance] Improve tint and shade performance #626

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/color/shade.js
Expand Up @@ -27,7 +27,7 @@ import mix from './mix'

function shade(percentage: number | string, color: string): string {
if (color === 'transparent') return color
return mix(parseFloat(percentage), 'rgb(0, 0, 0)', color)
return mix(parseFloat(percentage), '#000000', color)
Copy link
Contributor

@bhough bhough Oct 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thadeucity Any reason that we shouldn't send this as a shorthand #000?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The the shorthand one will have two extra Regex validations and two extra if validations (because the first check is for the normal 6 digit hex and the second one is for the 8 digit hex.

}

// prettier-ignore
Expand Down
2 changes: 1 addition & 1 deletion src/color/tint.js
Expand Up @@ -27,7 +27,7 @@ import mix from './mix'

function tint(percentage: number | string, color: string): string {
if (color === 'transparent') return color
return mix(parseFloat(percentage), 'rgb(255, 255, 255)', color)
return mix(parseFloat(percentage), '#FFFFFF', color)
Copy link
Contributor

@bhough bhough Oct 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thadeucity Same as with mix, should we send the shorthand #fff?

}

// prettier-ignore
Expand Down