Skip to content

Commit

Permalink
Rename format -> template.
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Jan 30, 2024
1 parent f4ea5e4 commit cd9c523
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ RangeSlider.propTypes = {
'bottomRight',
]),
/**
* Format to apply to the tooltip
* The string must contain `{value}`
* Template string to display the tooltip in.
* Must contain `{value}`, which will be replaced with either
* the default string representation of the value or the result of the
* transform function if there is one.
*/
format: PropTypes.string,
template: PropTypes.string,
/**
* Custom style for the tooltip.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ Slider.propTypes = {
'bottomRight',
]),
/**
* Format to apply to the tooltip
* The string must contain `{value}`
* Template string to display the tooltip in.
* Must contain `{value}`, which will be replaced with either
* the default string representation of the value or the result of the
* transform function if there is one.
*/
format: PropTypes.string,
template: PropTypes.string,
/**
* Custom style for the tooltip.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ export default class RangeSlider extends Component {
*/
tipProps = pipe(
assoc('visible', tooltip.always_visible),
omit(['always_visible', 'format', 'style', 'transform'])
omit(['always_visible', 'template', 'style', 'transform'])
)(tooltip);
if (tooltip.format || tooltip.style || tooltip.transform) {
if (tooltip.template || tooltip.style || tooltip.transform) {
tipFormatter = tipValue => {
let t = tipValue;
if (tooltip.transform) {
Expand All @@ -96,7 +96,7 @@ export default class RangeSlider extends Component {
return (
<div style={tooltip.style}>
{formatSliderTooltip(
tooltip.format || '{value}',
tooltip.template || '{value}',
t
)}
</div>
Expand Down
6 changes: 3 additions & 3 deletions components/dash-core-components/src/fragments/Slider.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ export default class Slider extends Component {
*/
tipProps = pipe(
assoc('visible', tooltip.always_visible),
omit(['always_visible', 'format', 'style', 'transform'])
omit(['always_visible', 'template', 'style', 'transform'])
)(tooltip);
if (tooltip.format || tooltip.style || tooltip.transform) {
if (tooltip.template || tooltip.style || tooltip.transform) {
tipFormatter = tipValue => {
let t = tipValue;
if (tooltip.transform) {
Expand All @@ -96,7 +96,7 @@ export default class Slider extends Component {
return (
<div style={tooltip.style}>
{formatSliderTooltip(
tooltip.format || '{value}',
tooltip.template || '{value}',
t
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def test_sls016_sliders_format_tooltips(dash_dcc):
max=100,
id="slider",
tooltip={
"format": "Custom tooltip: {value}",
"template": "Custom tooltip: {value}",
"always_visible": True,
"style": {"padding": "8px"},
},
Expand All @@ -581,7 +581,7 @@ def test_sls016_sliders_format_tooltips(dash_dcc):
min=20,
max=100,
id="range-slider",
tooltip={"format": "Custom tooltip: {value}", "always_visible": True},
tooltip={"template": "Custom tooltip: {value}", "always_visible": True},
),
dcc.Slider(
min=20,
Expand Down

0 comments on commit cd9c523

Please sign in to comment.