This repository was archived by the owner on Nov 30, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 49
[WIP]: implement form component #36
Open
isneezy
wants to merge
14
commits into
tabler:master
Choose a base branch
from
isneezy:form-component
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
40cfc9a
add form component
isneezy 7552e43
remove Example component
isneezy 5b827ca
add labelSmall atrribute to FormLabel
isneezy 9c0eb18
add FormTextArea
isneezy 98c8457
update FormsPage
isneezy 11fae05
add FormInput validation states
isneezy 61d9867
add FormRadio component
isneezy de7d7b0
add FormCheckbox component
isneezy ac84370
fix FormInput dosen't support v-model
isneezy c0ac07d
add FormFileInput component
isneezy c614b02
add FormSelect component
isneezy e9d251e
add FormGroupAddon component
isneezy 28fa1e9
add FormInputIcon component
isneezy 3746ab9
add FormHelp component
isneezy 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 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,89 @@ | ||
<template> | ||
<page> | ||
<grid-row> | ||
<grid-col sm="12"> | ||
<card> | ||
<card-header title="Form elements"/> | ||
<card-body> | ||
<grid-row> | ||
<grid-col md="6" lg="4"> | ||
<form-group> | ||
<form-label>Static</form-label> | ||
<form-static-text value="Username"/> | ||
</form-group> | ||
<form-group> | ||
<form-label>Text</form-label> | ||
<form-input placeholder="Text.."/> | ||
</form-group> | ||
<form-group> | ||
<form-label>Disabled</form-label> | ||
<form-input disabled placeholder="Well, she turned me into a newt."/> | ||
</form-group> | ||
<form-group> | ||
<form-label>Readonly</form-label> | ||
<form-input readonly placeholder="Well, how'd you become king, then?" type="text"/> | ||
</form-group> | ||
<form-group> | ||
<form-label label="Textarea" label-small="56/100"/> | ||
<form-textarea rows="6" value="Oh! Come and see the violence inherent in the system! Help, help, I'm being repressed! We shall say 'Ni' again to you, if you do not appease us. I'm not a witch. I'm not a witch. Camelot!" /> | ||
</form-group> | ||
</grid-col> | ||
<grid-col md="6" lg="4"> | ||
<form-group> | ||
<form-label>Password</form-label> | ||
<form-input value="Username" type="password" placeholder="Password.."/> | ||
</form-group> | ||
<form-group> | ||
<form-label>Valid State</form-label> | ||
<form-input valid placeholder="Valid State.."/> | ||
<form-input tick class="mt-3" value="Valid state"/> | ||
</form-group> | ||
<form-group> | ||
<form-label>Invalid State</form-label> | ||
<form-input invalid placeholder="Invalid State.."/> | ||
<form-invalid-feedback feedback="Invalid feedback"/> | ||
<form-input cross class="mt-3" value="Invalid state"/> | ||
</form-group> | ||
<form-group> | ||
<form-label>Country</form-label> | ||
<select class="form-control custom-select"> | ||
<option value="">Germany</option> | ||
</select> | ||
</form-group> | ||
</grid-col> | ||
<grid-col md="6" lg="4"> | ||
<form-group> | ||
<form-label>Radios</form-label> | ||
<div class="custom-controls-stacked"> | ||
<form-radio checked name="example-radios" :value="1" label="Option 1"/> | ||
<form-radio name="example-radios" :value="2" label="Option 2"/> | ||
<form-radio name="example-radios" :value="3" disabled label="Option Disabled"/> | ||
<form-radio name="example-radios2" checked :value="4" disabled label="Option Disabled Checked"/> | ||
</div> | ||
</form-group> | ||
<form-group> | ||
<form-label>Inline Radios</form-label> | ||
<div class="custom-controls-stacked"> | ||
<form-radio checked name="example-radios" :value="1" label="Option 1" inline/> | ||
<form-radio name="example-radios" :value="2" label="Option 2" inline/> | ||
<form-radio name="example-radios" :value="3" label="Option 3" inline/> | ||
</div> | ||
</form-group> | ||
</grid-col> | ||
</grid-row> | ||
</card-body> | ||
</card> | ||
</grid-col> | ||
</grid-row> | ||
</page> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "forms-page" | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
|
||
</style> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<template> | ||
<div class="form-group"> | ||
<slot></slot> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "form-group" | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
|
||
</style> |
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,47 @@ | ||
<template> | ||
<input class="form-control" :class="className" v-model="internalValue" @input="onInput" > | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "form-input", | ||
props: { | ||
value: {}, | ||
invalid: { default: false, type: Boolean }, | ||
valid: { default: false, type: Boolean }, | ||
tick: {default: false, type: Boolean}, | ||
cross: {default: false, type: Boolean} | ||
}, | ||
|
||
data: () => ({ | ||
internalValue: null | ||
}), | ||
|
||
computed: { | ||
className () { | ||
const className = {} | ||
className['is-valid'] = this.valid | ||
className['state-valid'] = this.tick | ||
className['is-invalid'] = this.invalid | ||
className['state-invalid'] = this.cross | ||
return className | ||
} | ||
}, | ||
|
||
methods: { | ||
onInput() { | ||
this.$emit('input', this.internalValue) | ||
} | ||
}, | ||
|
||
watch: { | ||
value (value) { | ||
this.internalValue = value | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
|
||
</style> |
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,7 @@ | ||
export default { | ||
name: 'form-invalid-feedback', | ||
props: { | ||
feedback: {default: '', type: String} | ||
}, | ||
template: `<div class="invalid-feedback"><slot>{{ feedback }}</slot></div>` | ||
} |
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,18 @@ | ||
<template> | ||
<label class="form-label" :for="labelFor"><slot>{{ label }} <span v-if="labelSmall" class="form-label-small">{{ labelSmall }}</span></slot></label> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "form-label", | ||
props: { | ||
labelFor: {default: '', type: String}, | ||
label: {default: '', type: String}, | ||
labelSmall: {default: '', type: String}, | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
|
||
</style> |
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,44 @@ | ||
<template> | ||
<label class="custom-control custom-radio" :class="{'custom-control-inline': inline}"> | ||
<input class="custom-control-input" v-bind="{name, checked: isChecked, disabled, value: radioValue}" @change="onChange" type="radio"> | ||
<div class="custom-control-label">{{ label }}</div> | ||
</label> | ||
</template> | ||
|
||
<script> | ||
import FormInput from './FormInput' | ||
|
||
export default { | ||
name: "form-radio", | ||
props: { | ||
inline: {default: false, type: Boolean}, | ||
value: {type: [Boolean, String, Number]}, | ||
label: {type: String}, | ||
checked: {default: false, type: Boolean}, | ||
disabled: {default: false, type: Boolean}, | ||
name: {default: '', type: String} | ||
}, | ||
|
||
computed: { | ||
radioValue () { | ||
return this.$attrs.value | ||
}, | ||
|
||
isChecked () { | ||
return this.checked || this.radioValue === this.value | ||
} | ||
}, | ||
|
||
methods: { | ||
onChange () { | ||
this.$emit('input', this.radioValue) | ||
} | ||
}, | ||
|
||
components: {FormInput} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
|
||
</style> |
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,16 @@ | ||
<template> | ||
<div class="form-control-plaintext">{{value}}</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "form-static-text", | ||
props: { | ||
value:{} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
|
||
</style> |
Oops, something went wrong.
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.
How do we deal with this?
<div class="custom-controls-stacked">
ping @Nilpo @MUCHZER