Skip to content

ColorSliderGroup - allow sending translation to the labels #782

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
May 25, 2020

Conversation

M-i-k-e-l
Copy link
Collaborator

No description provided.

* In case you would like to change the default labels (translations etc.), you can provide
* a function that received the type (one of GradientSlider.types without DEFAULT) and returns a string.
*/
getLabel: PropTypes.func,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't be simpler to allow passing a map of labels
{hue: ..., lightness:..., Saturation: ..} ?
You can set here the default map in default props
in our private config you can override the defaultProps (not using ThemeManager)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure what the best solution.
In your example you have {hue: ..., lightness:..., Saturation: ..} - lower case 'h', lower case 'l' and upper case 's' (which will cause something not to work), that is less likely to happen if you are using types (and I can't set the key to that in a simple readable way).
I started with:
labels = {};
labels[GradientSlider.types.HUE] = 'Hue';
...
But that seemed less clean.

What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a very small feature and I think it's best to got with the minimum changes possible.

In my example I meant everything to be lower case, it's clearly a mistake.
I don't see any reason to add types and extra function prop just for that.
I would usually use functions for dynamic values, the title texts are static, you set them once and don't need to touch them again

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to defaultProps

@@ -62,18 +71,29 @@ export default class ColorSliderGroup extends PureBaseComponent {
_.invoke(this.props, 'onValueChange', value);
}

getSlider = (type) => {
Copy link
Collaborator

@ethanshar ethanshar May 25, 2020

Choose a reason for hiding this comment

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

I think it's better to rename the function renderSlider like we usually do for render functions

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed :S

@M-i-k-e-l M-i-k-e-l requested a review from ethanshar May 25, 2020 07:11
@ethanshar ethanshar merged commit 92e321a into master May 25, 2020
@M-i-k-e-l M-i-k-e-l deleted the feat/color-slider-group-allow-sending-translation branch September 21, 2020 10:04
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.

2 participants