Skip to content

Commit 873086f

Browse files
authored
Merge pull request #158 from ownego/dev
HOTFIX: rangeslider prefix & suffix prop
2 parents 59c5648 + 2574318 commit 873086f

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/components/RangeSlider/components/DualThumb/DualThumb.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ Labelled(
1010
template(#help-text, v-if="hasSlot(slots['help-text'])")
1111
slot(name="help-text")
1212
div(:class="classNames(styles.DualThumb, sharedStyles.RangeSlider)")
13-
div(v-if="slots.prefix", :class="styles.Prefix")
14-
slot(name="prefix")
13+
div(v-if="hasSlot(slots.prefix) || prefix", :class="styles.Prefix")
14+
slot(v-if="hasSlot(slots.prefix)", name="prefix")
15+
template(v-else) {{ prefix }}
1516
div(
1617
:class="trackWrapperClassName",
1718
ref="trackWrapper",
@@ -79,8 +80,9 @@ Labelled(
7980
)
8081
div(:class="styles.OutputBubble")
8182
span(:class="styles.OutputText") {{ value[1] }}
82-
div(v-if="slots.suffix", :class="styles.Suffix")
83-
slot(name="suffix")
83+
div(v-if="hasSlot(slots.suffix) || suffix", :class="styles.Suffix")
84+
slot(v-if="hasSlot(slots.suffix)", name="suffix")
85+
template(v-else) {{ suffix }}
8486
EventListener(
8587
event="resize",
8688
:handler="setTrackPosition",
@@ -121,6 +123,10 @@ interface DualThumbProps {
121123
error?: ErrorType;
122124
/** Disable input */
123125
disabled?: boolean;
126+
/** Element to display before the input. This prop will be overriden by `prefix` slot. */
127+
prefix?: string;
128+
/** Element to display after the input. This prop will be overriden by `suffix` slot. */
129+
suffix?: string;
124130
}
125131
126132
interface KeyHandlers {

src/components/RangeSlider/components/SingleThumb/SingleThumb.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ Labelled(
1313
:class="className",
1414
:style="cssVars",
1515
)
16-
div(v-if="hasSlot(slots.prefix)", :class="styles.Prefix")
17-
slot(name="prefix")
16+
div(v-if="hasSlot(slots.prefix) || prefix", :class="styles.Prefix")
17+
slot(v-if="hasSlot(slots.prefix)", name="prefix")
18+
template(v-else) {{ prefix }}
19+
1820
div(:class="styles.InputWrapper")
1921
input(
2022
type="range",
@@ -43,8 +45,9 @@ Labelled(
4345
div(:class="styles.OutputBubble")
4446
span(:class="styles.OutputText")
4547
| {{ clampedValue }}
46-
div(v-if="hasSlot(slots.suffix)", :class="styles.Suffix")
47-
slot(name="suffix")
48+
div(v-if="hasSlot(slots.suffix) || suffix", :class="styles.Suffix")
49+
slot(v-if="hasSlot(slots.suffix)", name="suffix")
50+
template(v-else) {{ suffix }}
4851
</template>
4952

5053
<script setup lang="ts">
@@ -83,6 +86,10 @@ interface SingleThumbProps {
8386
error?: ErrorType;
8487
/** Disable input */
8588
disabled?: boolean;
89+
/** Element to display before the input. This prop will be overriden by `prefix` slot. */
90+
prefix?: string;
91+
/** Element to display after the input. This prop will be overriden by `suffix` slot. */
92+
suffix?: string;
8693
}
8794
8895
const props = defineProps<SingleThumbProps>();

0 commit comments

Comments
 (0)