-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow label
, helpText
, prefix
and suffix
as params
#154
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c5e32d4
feat: allow label, prefix and suffix param as well as slot for simpli…
tarwin 03eb066
Merge pull request #1 from ownego/master
tarwin f32ae41
chore: ignore Demo.vue
tarwin 0666e25
feat: support prefix, suffix, helpText and label params on components…
tarwin 9dadde5
Merge pull request #2 from ownego/master
tarwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,12 +10,15 @@ DualThumb( | |
template(#label, v-if="slots.label || label") | ||
slot(v-if="slots.label", name="label") | ||
template(v-else) {{ label }} | ||
template(#help-text, v-if="slots['help-text']") | ||
slot(name="help-text") | ||
template(#prefix, v-if="slots.prefix") | ||
slot(name="prefix") | ||
template(#suffix, v-if="slots.suffix") | ||
slot(name="suffix") | ||
template(#help-text, v-if="slots['help-text']" || helpText) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mistake |
||
slot(v-if="slots['help-text']" name="help-text") | ||
template(v-else) {{ helpText }} | ||
template(#prefix, v-if="slots.prefix || prefix") | ||
slot(v-if="slots.prefix" name="prefix") | ||
template(v-else) {{ prefix }} | ||
template(#suffix, v-if="slots.suffix || suffix") | ||
slot(v-if="slots.suffix" name="suffix") | ||
template(v-else) {{ suffix }} | ||
SingleThumb( | ||
v-else, | ||
v-model="singleValue", | ||
|
@@ -27,12 +30,15 @@ SingleThumb( | |
template(#label, v-if="slots.label || label") | ||
slot(v-if="slots.label", name="label") | ||
template(v-else) {{ label }} | ||
template(#help-text, v-if="slots['help-text']") | ||
slot(name="help-text") | ||
template(#prefix, v-if="slots.prefix") | ||
slot(name="prefix") | ||
template(#suffix, v-if="slots.suffix") | ||
slot(name="suffix") | ||
template(#help-text, v-if="slots['help-text'] || helpText") | ||
slot(v-if="slots['help-text']" name="help-text") | ||
template(v-else) {{ helpText }} | ||
template(#prefix, v-if="slots.prefix || prefix") | ||
slot(v-if="slots.prefix" name="prefix") | ||
template(v-else) {{ prefix }} | ||
template(#suffix, v-if="slots.suffix || suffix") | ||
slot(v-if="slots.suffix" name="suffix") | ||
template(v-else) {{ suffix }} | ||
</template> | ||
<script setup lang="ts"> | ||
import { computed, useSlots } from 'vue'; | ||
|
@@ -59,10 +65,16 @@ interface RangeSliderProps { | |
step?: number; | ||
/** Provide a tooltip while sliding, indicating the current value */ | ||
output?: boolean; | ||
/** Additional text to aid in use */ | ||
helpText?: string; | ||
/** Display an error message */ | ||
error?: ErrorType; | ||
/** Disable input */ | ||
disabled?: boolean; | ||
/** Element to display before the input */ | ||
prefix?: string; | ||
/** Element to display after the input */ | ||
suffix?: string; | ||
} | ||
|
||
const props = withDefaults(defineProps<RangeSliderProps>(), { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ Labelled( | |
:action="labelAction", | ||
:labelHidden="labelHidden", | ||
:requiredIndicator="requiredIndicator", | ||
:label="label", | ||
:help-text="helpText", | ||
) | ||
template(#label, v-if="slots.label") | ||
slot(name="label") | ||
|
@@ -20,12 +22,15 @@ Labelled( | |
@click="handleClick", | ||
) | ||
div( | ||
v-if="slots.prefix", | ||
v-if="slots.prefix || prefix", | ||
:id="`${id}Prefix`", | ||
:class="styles.Prefix", | ||
ref="prefixRef", | ||
) | ||
slot(name="prefix") | ||
slot(name="prefix" v-if="slots.prefix") | ||
template(v-else-if="prefix") | ||
| {{ prefix }} | ||
|
||
div( | ||
v-if="slots['vertical-content']" | ||
:class="styles.VerticalContent", | ||
|
@@ -37,6 +42,8 @@ Labelled( | |
component( | ||
:is="multiline ? 'textarea' : 'input'", | ||
:id="id", | ||
:label="label", | ||
:help-text="helpText", | ||
:name="name", | ||
:disabled="disabled", | ||
:readonly="readOnly", | ||
|
@@ -78,6 +85,8 @@ Labelled( | |
v-else, | ||
:is="multiline ? 'textarea' : 'input'", | ||
:id="id", | ||
:label="label", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nah, why do we need this prop here? |
||
:help-text="helpText", | ||
:name="name", | ||
:disabled="disabled", | ||
:readonly="readOnly", | ||
|
@@ -116,12 +125,14 @@ Labelled( | |
) | ||
template(v-if="multiline") {{ modelValue }} | ||
div( | ||
v-if="slots.suffix", | ||
v-if="slots.suffix || suffix", | ||
:id="`${id}Suffix`", | ||
:class="styles.Suffix", | ||
ref="suffixRef", | ||
) | ||
slot(name="suffix") | ||
slot(name="suffix" v-if="slots.suffix") | ||
template(v-else-if="suffix") | ||
| {{ suffix }} | ||
div( | ||
v-if="showCharacterCount", | ||
:class="characterCountClassName", | ||
|
@@ -206,10 +217,14 @@ interface NonMutuallyExclusiveProps { | |
placeholder?: string; | ||
/** Initial value for the input */ | ||
modelValue?: string; | ||
/** Label for the input: overridden by #label slot */ | ||
label?: string; | ||
/** Adds an action to the label */ | ||
labelAction?: LabelledProps['action']; | ||
/** Visually hide the label */ | ||
labelHidden?: boolean; | ||
/** Additional hint text to display: overridden by #label slot */ | ||
helpText?: string; | ||
/** Disable the input */ | ||
disabled?: boolean; | ||
/** Show a clear text button in the input */ | ||
|
@@ -274,6 +289,10 @@ interface NonMutuallyExclusiveProps { | |
monospaced?: boolean; | ||
/** Indicates whether or not the entire input/text area text should be selected on focus */ | ||
selectTextOnFocus?: boolean; | ||
/** */ | ||
suffix?:string | ||
/** */ | ||
prefix?:string | ||
} | ||
|
||
const i18n = UseI18n(); | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we just need
v-else
here