diff --git a/packages/base/src/dialogs/symbology/components/color_ramp/CanvasSelectComponent.tsx b/packages/base/src/dialogs/symbology/components/color_ramp/CanvasSelectComponent.tsx index 062c21577..31877b530 100644 --- a/packages/base/src/dialogs/symbology/components/color_ramp/CanvasSelectComponent.tsx +++ b/packages/base/src/dialogs/symbology/components/color_ramp/CanvasSelectComponent.tsx @@ -21,6 +21,8 @@ const CanvasSelectComponent: React.FC = ({ const containerRef = useRef(null); const [isOpen, setIsOpen] = useState(false); const [colorMaps, setColorMaps] = useState([]); + const canvasWidth = 512; + const canvasHeight = 30; useColorMapList(setColorMaps); @@ -64,13 +66,16 @@ const CanvasSelectComponent: React.FC = ({ const ramp = colorMaps.filter(c => c.name === rampName); + canvas.width = canvasWidth; + canvas.height = canvasHeight; + for (let i = 0; i <= 255; i++) { ctx.beginPath(); const color = ramp[0].colors[i]; ctx.fillStyle = color; - ctx.fillRect(i * 2, 0, 2, 50); + ctx.fillRect(i * 2, 0, 2, canvasHeight); } canvas.style.visibility = 'initial'; }; @@ -89,11 +94,15 @@ const CanvasSelectComponent: React.FC = ({ onClick={toggleDropdown} className="jp-Dialog-button jp-gis-canvas-button" > - +
+ {selectedRamp} + +
= ({ colorMap, onClick, }) => { + const canvasWidth = 512; const canvasHeight = 30; useEffect(() => { @@ -20,6 +21,9 @@ const ColorRampEntry: React.FC = ({ if (!canvas) { return; } + canvas.width = canvasWidth; + canvas.height = canvasHeight; + const ctx = canvas.getContext('2d'); if (!ctx) { @@ -45,6 +49,7 @@ const ColorRampEntry: React.FC = ({ {colorMap.name} diff --git a/packages/base/style/symbologyDialog.css b/packages/base/style/symbologyDialog.css index 557fb416c..0019a214d 100644 --- a/packages/base/style/symbologyDialog.css +++ b/packages/base/style/symbologyDialog.css @@ -158,9 +158,9 @@ select option { border: var(--jp-border-width) solid var(--jp-input-border-color); border-radius: 0; outline: none; - appearance: none; -webkit-appearance: none; -moz-appearance: none; + appearance: none; } .jp-gis-open { @@ -172,20 +172,25 @@ select option { align-items: center; font-size: var(--jp-ui-font-size2); color: var(--jp-ui-font-color0); - appearance: none; text-transform: capitalize; cursor: pointer; + position: relative; -webkit-appearance: none; -moz-appearance: none; + appearance: none; } .jp-gis-color-label { color: white; + padding-left: 10px; position: absolute; + text-shadow: 0px 0px 4px black; + transition: transform 0.3s ease; + transform-origin: left bottom; } -.jp-gis-color-ramp-entry:hover .jp-gis-color-label { +.jp-gis-color-ramp-entry:not(.jp-gis-selected-entry):hover .jp-gis-color-label { transform: scale(1.2); } @@ -215,8 +220,11 @@ select option { } #jp-gis-canvas-button.jp-gis-canvas-button { - visibility: hidden; margin: 0; padding: 0 1px 0 0; width: 100%; } + +.jp-gis-selected-entry { + width: 100%; +}