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

Xstream 112 edit new format attribut color #298

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Kekelgrs marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,17 @@ function StandardCell({cellData, values}: ISimpleCellProps): JSX.Element {
);
case AttributeFormat.color:
if(!isEmpty(displayedValues)){
const colorHexValue = "#" + displayedValues;
let tagStyle: React.CSSProperties;

const hexToRGB = (Values) => {
Values = '0x' + Values
const red = Values >> 16 & 0xFF
const green = Values >> 8 & 0xFF
const blue = Values & 0xFF
tagStyle = ((red*0.299 + green*0.587 + blue*0.114) > 186 ) ? {
color:"black"
} : {
color:"white"
};
return tagStyle;
const colorHexValue = "#" + displayedValues;

const hexToRGB = (values : string) => {
const red = parseInt(values.slice(1, 3), 16);
const green = parseInt(values.slice(3, 5), 16);
const blue = parseInt(values.slice(5, 7), 16);
return (red*0.299 + green*0.587 + blue*0.114) > 186 ? { color:"black"} : { color:"white" };
Kekelgrs marked this conversation as resolved.
Show resolved Hide resolved
}

return (
<Tag bordered={true} color={colorHexValue} style={hexToRGB(displayedValues)}>{colorHexValue}</Tag>
<Tag bordered={true} color={colorHexValue} style={hexToRGB(colorHexValue)}>{colorHexValue}</Tag>
);
}
else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ function StandardFieldValue({
const _getInput = (): JSX.Element => {
if (!fieldValue.isEditing && attribute.format !== AttributeFormat.boolean) {
let displayedValue = String(fieldValue.displayValue);
if(attribute.format == AttributeFormat.color && (fieldValue.value == null || fieldValue.value.value == null)){
if(attribute.format === AttributeFormat.color && (fieldValue.value === null || fieldValue.value.value === null)){
fieldValue.value = null;
}
const hasValue = fieldValue.value !== null;
Expand Down