-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: integrate vue-docgen-api in preview (#6)
* integrate vue-docgen-api in preview * chore: update deps * feat: add collapse of left panel * fix: remove weird margin at bottom of body * feat: first rendering of docs * rename docs folder to "docsParts" * documentation release #1
- Loading branch information
1 parent
a4dd96d
commit d851b96
Showing
16 changed files
with
717 additions
and
168 deletions.
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,100 @@ | ||
<template> | ||
<div> | ||
<input | ||
ref="input" | ||
v-model="val" | ||
@input="updateValue($event.target.value)" | ||
@change="emitChange" | ||
/> | ||
<button @click="fireEvent()">Fire example event!</button> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
/** | ||
* An input field with a button | ||
*/ | ||
export default { | ||
name: 'Input', | ||
model: { | ||
prop: 'value', | ||
}, | ||
props: { | ||
value: { | ||
default: null, | ||
type: [Number, String], | ||
}, | ||
/** | ||
* Using for: String.prototype.replace(regexp, replacement) | ||
*/ | ||
regExp: { | ||
type: RegExp, | ||
default: null, | ||
}, | ||
/** | ||
* Using for: String.prototype.replace(regexp, replacement) | ||
*/ | ||
replacement: { | ||
type: String, | ||
default: '', | ||
}, | ||
}, | ||
data() { | ||
return { | ||
val: '', | ||
}; | ||
}, | ||
watch: { | ||
// watch value prop | ||
value(val) { | ||
this.updateValue(val); | ||
}, | ||
}, | ||
mounted() { | ||
this.updateValue(this.value); | ||
}, | ||
methods: { | ||
// format the value of input | ||
formatValue(val) { | ||
const formattedValue = !val ? '' : val.toString().replace(this.regExp, this.replacement); | ||
return formattedValue; | ||
}, | ||
updateValue(val) { | ||
const formattedValue = this.formatValue(val); | ||
this.val = formattedValue; | ||
this.emitInput(formattedValue); | ||
}, | ||
emitInput(val) { | ||
/** | ||
* Input event | ||
* @event input | ||
* @type {number|string} | ||
* @property {number} called - test called | ||
* @property {boolean} isPacked - Indicates whether the snowball is tightly packed. | ||
*/ | ||
this.$emit('input', val, 1, false); | ||
}, | ||
// emit change event | ||
emitChange() { | ||
/** | ||
* Change event | ||
* @event change | ||
*/ | ||
this.$emit('change', this.val); | ||
}, | ||
fireEvent() { | ||
/** | ||
* Fire event | ||
* @event fire | ||
* @type {string} | ||
*/ | ||
this.$emit('fire', 'hello fire!!'); | ||
}, | ||
}, | ||
}; | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<template> | ||
<div class="docs"> | ||
<h2>{{ docValue.displayName }}</h2> | ||
<p>{{ docValue.description }}</p> | ||
<Props v-if="docValue.props" :props="docValue.props" /> | ||
<Events v-if="docValue.events" :events="docValue.events" /> | ||
<Slots v-if="docValue.slots" :slots="docValue.slots" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { ref } from 'vue'; | ||
import Slots from './docsParts/Slots.vue'; | ||
import Events from './docsParts/Events.vue'; | ||
import Props from './docsParts/Props.vue'; | ||
export default { | ||
components: { Props, Events, Slots }, | ||
props: { | ||
docsSupplier: { | ||
type: Function, | ||
required: true, | ||
}, | ||
}, | ||
async setup({ docsSupplier }) { | ||
const mod = await docsSupplier(); | ||
return { docValue: mod.default }; | ||
}, | ||
}; | ||
</script> |
Oops, something went wrong.