-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Support adding static label to document layer Signed-off-by: Junqiu Lei <junqiu@amazon.com> * Update label type Signed-off-by: Junqiu Lei <junqiu@amazon.com> --------- Signed-off-by: Junqiu Lei <junqiu@amazon.com> (cherry picked from commit 28e0429) Co-authored-by: Junqiu Lei <junqiu@amazon.com>
- Loading branch information
1 parent
cf0e49d
commit 30e018c
Showing
11 changed files
with
936 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
public/components/layer_config/documents_config/style/color_picker.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React, { memo, useEffect } from 'react'; | ||
import { EuiColorPicker, EuiFormRow, useColorPickerState } from '@elastic/eui'; | ||
|
||
export interface ColorPickerProps { | ||
originColor: string; | ||
label: string; | ||
selectedLayerConfigId: string; | ||
setIsUpdateDisabled: Function; | ||
onColorChange: (color: string) => void; | ||
} | ||
|
||
export const ColorPicker = memo( | ||
({ | ||
originColor, | ||
label, | ||
selectedLayerConfigId, | ||
setIsUpdateDisabled, | ||
onColorChange, | ||
}: ColorPickerProps) => { | ||
const [color, setColor, colorErrors] = useColorPickerState(originColor); | ||
|
||
useEffect(() => { | ||
onColorChange(String(color)); | ||
}, [color]); | ||
|
||
useEffect(() => { | ||
setIsUpdateDisabled(!!colorErrors); | ||
}, [colorErrors]); | ||
|
||
// It's used to update the style color when switch layer config between different document layers | ||
useEffect(() => { | ||
setColor(originColor, !!colorErrors ? { isValid: false } : { isValid: true }); | ||
}, [selectedLayerConfigId]); | ||
|
||
return ( | ||
<EuiFormRow label={label} fullWidth={true} isInvalid={!!colorErrors} error={colorErrors}> | ||
<EuiColorPicker | ||
color={color} | ||
onChange={setColor} | ||
isInvalid={!!colorErrors} | ||
fullWidth={true} | ||
data-test-subj={label} | ||
/> | ||
</EuiFormRow> | ||
); | ||
} | ||
); |
Oops, something went wrong.