Skip to content

convert three digit hex to six #976

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

Merged
merged 5 commits into from
Oct 23, 2020
Merged

convert three digit hex to six #976

merged 5 commits into from
Oct 23, 2020

Conversation

lidord-wix
Copy link
Contributor

Description

Colors.rgba returned wrong values when getting 3 digit hex,
I've added function to convert 3 digit hex to 6 digit hex inside validateHex
Bug description: #946

Changelog

fix bug in Colors.rgba

@lidord-wix lidord-wix requested a review from ethanshar October 11, 2020 13:23
@ethanshar ethanshar linked an issue Oct 14, 2020 that may be closed by this pull request
@lidord-wix lidord-wix requested a review from ethanshar October 14, 2020 09:48
Comment on lines 213 to 217
function threeDigitHexToSix(value: string) {
return value.replace(/./g, '$&$&');
const firstDigit = value[0];
const secondDigit = value[1];
const thirdDigit = value[2];
return firstDigit.concat(firstDigit, secondDigit, secondDigit, thirdDigit, thirdDigit);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just return value + value ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to double each letter:
threeDigitHexToSix(123) should return 112233 and not 123123

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are completely right! my bad :(
In that case the regex solution is definitely preferable...
apologies for the trouble

@lidord-wix lidord-wix requested a review from ethanshar October 20, 2020 07:43
@ethanshar ethanshar removed their request for review October 21, 2020 06:43
@lidord-wix lidord-wix requested a review from ethanshar October 21, 2020 07:52
@ethanshar ethanshar merged commit 3514695 into master Oct 23, 2020
M-i-k-e-l added a commit that referenced this pull request Oct 25, 2020
* master:
  Fix missed issue with migrating Picker API - PickerItem needs to retrieve the correct value format
  Add Slider testID (#999)
  Remove declaration of ref type on TouchableOpacity
  convert three digit hex to six (#976)
  Fix/text field right icon alignment (#997)
  migrate Switch to TS (#991)
  Move from KeyboardAwareListView to KeyboardAwareFlatList (#960)
  Update constants typings
  migrate ActionBar to TS (#987)
  Do not notify the user onPageChange for the fake page (fix autoscroll on Android bug) (#994)
  Add progress type for ProgressBarProps (#996)
  Fix generated JS files to include propTypes (#995)

# Conflicts:
#	generatedTypes/components/touchableOpacity/index.d.ts
@lidord-wix lidord-wix deleted the fix/rgba_bug branch November 17, 2020 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

src/style/colors.ts has bug
2 participants