Radiobutton doc added

pull/12/head
Merve Özçifçi 2019-03-26 11:58:40 +03:00
parent a21e497376
commit e658d5ac77
3 changed files with 255 additions and 11 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="p-radiobutton p-component" @click="onClick($event)"> <div class="p-radiobutton p-component" @click="onClick($event)">
<div class="p-hidden-accessible"> <div class="p-hidden-accessible">
<input ref="input" :id="inputId" type="radio" :name="name" :checked="checked" :disabled="disabled" @focus="onFocus()" @blur="onBlur()" <input ref="input" :id="inputId" type="radio" :name="name" :checked="checked" :disabled="disabled" @focus="onFocus($event)" @blur="onBlur($event)"
:autocomplete="autocomplete" :autofocus="autofocus"> :autocomplete="autocomplete" :autofocus="autofocus">
</div> </div>
<div ref="box" :class="['p-radiobutton-box p-component', {'p-highlight': checked, 'p-disabled': disabled, 'p-focus': focused}]"> <div ref="box" :class="['p-radiobutton-box p-component', {'p-highlight': checked, 'p-disabled': disabled, 'p-focus': focused}]">
@ -11,17 +11,17 @@
</template> </template>
<script> <script>
import ObjectUtils from '../utils/ObjectUtils'; import ObjectUtils from '../utils/ObjectUtils';
export default { export default {
props: { props: {
value: null, inputId: String,
modelValue: null, name: String,
name: String, value: null,
inputId: String, disabled: Boolean,
autofocus: Boolean, modelValue: null,
autocomplete: String, autofocus: Boolean,
disabled: Boolean autocomplete: String
}, },
model: { model: {
prop: 'modelValue', prop: 'modelValue',
@ -48,7 +48,7 @@ export default {
this.focused = true; this.focused = true;
this.$emit('focus', event); this.$emit('focus', event);
}, },
onBlur() { onBlur(event) {
this.focused = false; this.focused = false;
this.$emit('blur', event); this.$emit('blur', event);
} }

View File

@ -38,10 +38,14 @@
</div> </div>
<p>Selected Theme: <span style="font-weight: bold">{{this.selectedTheme}}</span></p> <p>Selected Theme: <span style="font-weight: bold">{{this.selectedTheme}}</span></p>
</div> </div>
<RadioButtonDoc/>
</div> </div>
</template> </template>
<script> <script>
import RadioButtonDoc from './RadioButtonDoc';
export default { export default {
data() { data() {
return { return {
@ -52,6 +56,9 @@ export default {
}, },
created() { created() {
this.selectedTheme = this.themes[1]; this.selectedTheme = this.themes[1];
},
components: {
'RadioButtonDoc': RadioButtonDoc
} }
} }
</script> </script>

View File

@ -0,0 +1,237 @@
<template>
<div class="content-section documentation">
<TabView>
<TabPanel header="Documentation">
<h3>Import</h3>
<CodeHighlight lang="javascript">
import RadioButton from 'primevue/radiobutton';
</CodeHighlight>
<h3>Getting Started</h3>
<p>Two-way value binding is defined using the standard v-model directive.</p>
<CodeHighlight>
&lt;RadioButton inputId=&quot;city1&quot; name=&quot;city&quot; value=&quot;Chicago&quot; v-model=&quot;city&quot; /&gt;
&lt;RadioButton inputId=&quot;city2&quot; name=&quot;city&quot; value=&quot;Los Angeles&quot; v-model=&quot;city&quot; /&gt;
</CodeHighlight>
<CodeHighlight lang="js">
export default {
data() {
return {
city: null
}
}
}
</CodeHighlight>
<p>As model is two-way binding enabled, giving a default value to the model is enough to display a radio button as checked by default.</p>
<CodeHighlight lang="js">
export default {
data() {
return {
city: 'Chicago'
}
}
}
</CodeHighlight>
<h3>Properties</h3>
<div class="doc-tablewrapper">
<table class="doc-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>inputId</td>
<td>string</td>
<td>null</td>
<td>Unique identifier of the inner native radiobutton.</td>
</tr>
<tr>
<td>name</td>
<td>string</td>
<td>null</td>
<td>Name of the checkbox element .</td>
</tr>
<tr>
<td>value</td>
<td>any</td>
<td>null</td>
<td>Value of the radiobutton.</td>
</tr>
<tr>
<td>disabled</td>
<td>boolean</td>
<td>false</td>
<td>When present, it specifies that the element value cannot be altered.</td>
</tr>
<tr>
<td>modelValue</td>
<td>any</td>
<td>null</td>
<td>Value of the checkbox.</td>
</tr>
<tr>
<td>autofocus</td>
<td>boolean</td>
<td>null</td>
<td>When present, it specifies that the element should automatically get focus when the page loads.</td>
</tr>
<tr>
<td>autocomplete</td>
<td>string</td>
<td>null</td>
<td>When specifies, whether or not an the element should have autocomplete enabled.</td>
</tr>
</tbody>
</table>
</div>
<h3>Events</h3>
<div class="doc-tablewrapper">
<table class="doc-table">
<thead>
<tr>
<th>Name</th>
<th>Parameters</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>change</td>
<td>event: Browser event</td>
<td>Callback to invoke on value change.</td>
</tr>
<tr>
<td>input</td>
<td>event: Value of checkbox</td>
<td>Callback to invoke on click.</td>
</tr>
<tr>
<td>click</td>
<td>event: Browser event</td>
<td>Callback to invoke click.</td>
</tr>
<tr>
<td>focus</td>
<td>event: Browser event</td>
<td>Callback to invoke on focus.</td>
</tr>
<tr>
<td>blur</td>
<td>event: Browser event</td>
<td>Callback to invoke on blur.</td>
</tr>
</tbody>
</table>
</div>
<h3>Styling</h3>
<p>Following is the list of structural style classes, for theming classes visit <router-link to="/theming">theming</router-link> page.</p>
<div class="doc-tablewrapper">
<table class="doc-table">
<thead>
<tr>
<th>Name</th>
<th>Element</th>
</tr>
</thead>
<tbody>
<tr>
<td>p-radiobutton</td>
<td>Container element</td>
</tr>
<tr>
<td>p-radiobutton-box</td>
<td>Container of icon.</td>
</tr>
<tr>
<td>p-radiobutton-icon</td>
<td>Icon element.</td>
</tr>
<tr>
<td>p-radiobutton-label</td>
<td>Label element.</td>
</tr>
</tbody>
</table>
</div>
<h3>Dependencies</h3>
<p>None.</p>
</TabPanel>
<TabPanel header="Source">
<a href="https://github.com/primefaces/primevue/tree/master/src/views/radiobutton" class="btn-viewsource" target="_blank" rel="noopener noreferrer">
<span>View on GitHub</span>
</a>
<CodeHighlight>
<template v-pre>
&lt;template&gt;
&lt;div&gt;
&lt;div class=&quot;content-section introduction&quot;&gt;
&lt;div class=&quot;feature-intro&quot;&gt;
&lt;h1&gt;RadioButton&lt;/h1&gt;
&lt;p&gt;RadioButton is an extension to standard radio button element with theming.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;content-section implementation&quot;&gt;
&lt;h3 class=&quot;first&quot;&gt;Basic&lt;/h3&gt;
&lt;div class=&quot;p-grid&quot;&gt;
&lt;div class=&quot;p-col-12&quot;&gt;
&lt;RadioButton inputId=&quot;city1&quot; name=&quot;city&quot; value=&quot;Chicago&quot; v-model=&quot;city&quot; /&gt;
&lt;label for=&quot;city1&quot; class=&quot;p-radiobutton-label&quot;&gt;Chicago&lt;/label&gt;
&lt;/div&gt;
&lt;div class=&quot;p-col-12&quot;&gt;
&lt;RadioButton inputId=&quot;city2&quot; name=&quot;city&quot; value=&quot;Los Angeles&quot; v-model=&quot;city&quot; /&gt;
&lt;label for=&quot;city2&quot; class=&quot;p-radiobutton-label&quot;&gt;Los Angeles&lt;/label&gt;
&lt;/div&gt;
&lt;div class=&quot;p-col-12&quot;&gt;
&lt;RadioButton inputId=&quot;city3&quot; name=&quot;city&quot; value=&quot;New York&quot; v-model=&quot;city&quot; /&gt;
&lt;label for=&quot;city3&quot; class=&quot;p-radiobutton-label&quot;&gt;New York&lt;/label&gt;
&lt;/div&gt;
&lt;div class=&quot;p-col-12&quot;&gt;
&lt;RadioButton inputId=&quot;city4&quot; name=&quot;city&quot; value=&quot;San Francisco&quot; v-model=&quot;city&quot; /&gt;
&lt;label for=&quot;city4&quot; class=&quot;p-radiobutton-label&quot;&gt;San Francisco&lt;/label&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Selected City: &lt;span style=&quot;font-weight: bold&quot;&gt;{{this.city}}&lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;Dynamic Values, Preselection, Value Binding and Disabled Option&lt;/h3&gt;
&lt;div class=&quot;p-grid&quot;&gt;
&lt;div v-for=&quot;theme of themes&quot; :key=&quot;theme.key&quot; class=&quot;p-col-12&quot;&gt;
&lt;RadioButton :inputId=&quot;theme.key&quot; name=&quot;theme&quot; :value=&quot;theme&quot; v-model=&quot;selectedTheme&quot; :disabled=&quot;theme.key === 'U'&quot; /&gt;
&lt;label :for=&quot;theme.key&quot; class=&quot;p-radiobutton-label&quot;&gt;{{theme.name}}&lt;/label&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Selected Theme: &lt;span style=&quot;font-weight: bold&quot;&gt;{{this.selectedTheme}}&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/template&gt;
</template>
</CodeHighlight>
<CodeHighlight lang="javascript">
export default {
data() {
return {
city: null,
themes: [{name: 'Apollo', key: 'A'}, {name: 'Babylon', key: 'B'}, {name: 'Serenity', key: 'S'}, {name: 'Ultima', key: 'U'}],
selectedTheme: null
}
},
created() {
this.selectedTheme = this.themes[1];
}
}
</CodeHighlight>
</TabPanel>
</TabView>
</div>
</template>