-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2723 from plotly/slider-tips
Add Slider/RangeSlider tooltip.format and tooltip.style.
- Loading branch information
Showing
9 changed files
with
197 additions
and
15 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
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
5 changes: 5 additions & 0 deletions
5
components/dash-core-components/src/components/css/sliders.css
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,5 @@ | ||
/* Fix the default tooltip style height conflicting with the actual size of the tooltip. */ | ||
.rc-slider-tooltip-content > .rc-slider-tooltip-inner { | ||
height: unset; | ||
min-height: 20px; | ||
} |
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
19 changes: 19 additions & 0 deletions
19
components/dash-core-components/src/utils/formatSliderTooltip.js
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,19 @@ | ||
import {replace, path, split, concat, pipe} from 'ramda'; | ||
|
||
export const formatSliderTooltip = (template, value) => { | ||
return replace('{value}', value, template); | ||
}; | ||
|
||
export const transformSliderTooltip = (funcName, value) => { | ||
const func = pipe( | ||
split('.'), | ||
s => concat(['dccFunctions'], s), | ||
s => path(s, window) | ||
)(funcName); | ||
if (!func) { | ||
throw new Error( | ||
`Invalid func for slider tooltip transform: ${funcName}` | ||
); | ||
} | ||
return func(value); | ||
}; |
4 changes: 4 additions & 0 deletions
4
components/dash-core-components/tests/integration/sliders/assets/transform.js
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,4 @@ | ||
window.dccFunctions = window.dccFunctions || {}; | ||
window.dccFunctions.transformTooltip = function(value) { | ||
return "Transformed " + value | ||
} |
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