Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 6 additions & 3 deletions docgen/src/guides/v3-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -788,9 +788,12 @@ Widget removed.

#### Options

| Before | After |
| --------------- | ----------- |
| `attributeName` | `attribute` |
| Before | After |
| ------------------ | ------------------------- |
| `attributeName` | `attribute` |
| `labels` | `templates` |
| `labels.separator` | `templates.separatorText` |
| `labels.submit` | `templates.submitText` |

#### CSS classes

Expand Down
39 changes: 26 additions & 13 deletions src/components/RangeInput/RangeInput.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'preact-compat';
import PropTypes from 'prop-types';
import cx from 'classnames';
import Template from '../Template/Template';

class RangeInput extends Component {
constructor(props) {
Expand Down Expand Up @@ -33,7 +34,7 @@ class RangeInput extends Component {

render() {
const { min: minValue, max: maxValue } = this.state;
const { min, max, step, cssClasses, labels } = this.props;
const { min, max, step, cssClasses, templateProps } = this.props;
const isDisabled = min >= max;

const hasRefinements = Boolean(minValue || maxValue);
Expand All @@ -59,7 +60,14 @@ class RangeInput extends Component {
/>
</label>

<span className={cssClasses.separator}>{labels.separator}</span>
<Template
{...templateProps}
templateKey="separatorText"
rootTagName="span"
rootProps={{
className: cssClasses.separator,
}}
/>

<label className={cssClasses.label}>
<input
Expand All @@ -75,13 +83,16 @@ class RangeInput extends Component {
/>
</label>

<button
type="submit"
className={cssClasses.submit}
disabled={isDisabled}
>
{labels.submit}
</button>
<Template
{...templateProps}
templateKey="submitText"
rootTagName="button"
rootProps={{
type: 'submit',
className: cssClasses.submit,
disabled: isDisabled,
}}
/>
</form>
</div>
);
Expand All @@ -107,10 +118,12 @@ RangeInput.propTypes = {
separator: PropTypes.string.isRequired,
submit: PropTypes.string.isRequired,
}).isRequired,
labels: PropTypes.shape({
separator: PropTypes.string.isRequired,
submit: PropTypes.string.isRequired,
}).isRequired,
templateProps: PropTypes.shape({
templates: PropTypes.shape({
separatorText: PropTypes.string.isRequired,
submitText: PropTypes.string.isRequired,
}).isRequired,
}),
refine: PropTypes.func.isRequired,
};

Expand Down
8 changes: 5 additions & 3 deletions src/components/RangeInput/__tests__/RangeInput-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ describe('RangeInput', () => {
separator: 'separator',
submit: 'submit',
},
labels: {
separator: 'to',
submit: 'Go',
templatesProps: {
templates: {
separatorText: 'to',
submitText: 'Go',
},
},
refine: () => {},
};
Expand Down
Loading