-
-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add NeoRadio and NeoRadioButton
- Loading branch information
Showing
7 changed files
with
230 additions
and
40 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
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,110 @@ | ||
<template> | ||
<Story title="NeoRadio"> | ||
<Variant title="NeoRadio Base"> | ||
<section> | ||
<div class="block"> | ||
<NeoRadio v-model="radio" name="name" native-value="Flint"> | ||
Flint | ||
</NeoRadio> | ||
<NeoRadio v-model="radio" name="name" native-value="Silver"> | ||
Silver | ||
</NeoRadio> | ||
<NeoRadio v-model="radio" name="name" native-value="Jack"> | ||
Jack | ||
</NeoRadio> | ||
<NeoRadio v-model="radio" name="name" native-value="Vane" disabled> | ||
Vane | ||
</NeoRadio> | ||
</div> | ||
<p class="content"> | ||
<b>Selection:</b> | ||
{{ radio }} | ||
</p> | ||
</section> | ||
</Variant> | ||
|
||
<Variant title="NeoRadio Variant"> | ||
<section> | ||
<div class="field"> | ||
<NeoRadio v-model="radioVariant" native-value="default"> | ||
Default | ||
</NeoRadio> | ||
</div> | ||
<div class="field"> | ||
<NeoRadio v-model="radioVariant" native-value="info" variant="info"> | ||
Info | ||
</NeoRadio> | ||
</div> | ||
<div class="field"> | ||
<NeoRadio | ||
v-model="radioVariant" | ||
native-value="success" | ||
variant="success"> | ||
Success | ||
</NeoRadio> | ||
</div> | ||
<div class="field"> | ||
<NeoRadio | ||
v-model="radioVariant" | ||
native-value="danger" | ||
variant="danger"> | ||
Danger | ||
</NeoRadio> | ||
</div> | ||
<div class="field"> | ||
<NeoRadio | ||
v-model="radioVariant" | ||
native-value="warning" | ||
variant="warning"> | ||
Warning | ||
</NeoRadio> | ||
</div> | ||
</section> | ||
</Variant> | ||
|
||
<Variant title="NeoRadioButton"> | ||
<OField> | ||
<NeoRadioButton | ||
v-model="radioButton" | ||
native-value="Nope" | ||
type="is-danger is-light is-outlined"> | ||
<span>Nope</span> | ||
</NeoRadioButton> | ||
|
||
<NeoRadioButton | ||
v-model="radioButton" | ||
native-value="Yep" | ||
type="is-success is-light is-outlined"> | ||
<span>Yep</span> | ||
</NeoRadioButton> | ||
|
||
<NeoRadioButton | ||
v-model="radioButton" | ||
native-value="Default" | ||
type="is-primary is-light is-outlined"> | ||
Default | ||
</NeoRadioButton> | ||
|
||
<NeoRadioButton v-model="radioButton" native-value="Disabled" disabled> | ||
Disabled | ||
</NeoRadioButton> | ||
</OField> | ||
|
||
<p class="content"> | ||
<b>Selection:</b> | ||
{{ radioButton }} | ||
</p> | ||
</Variant> | ||
</Story> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ref } from 'vue' | ||
import { OField } from '@oruga-ui/oruga' | ||
import NeoRadio from './NeoRadio.vue' | ||
import NeoRadioButton from './NeoRadioButton.vue' | ||
const radioButton = ref('') | ||
const radio = ref('Jack') | ||
const radioVariant = ref('default') | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<script lang="ts"> | ||
import { ORadio } from '@oruga-ui/oruga' | ||
export default { | ||
extends: ORadio, | ||
} | ||
</script> | ||
|
||
<style lang="scss"> | ||
@import '@oruga-ui/oruga/src/scss/utilities/_expressions.scss'; | ||
@import '@oruga-ui/oruga/src/scss/utilities/_variables.scss'; | ||
@import '@oruga-ui/oruga/src/scss/utilities/_animations.scss'; | ||
@import '@oruga-ui/oruga/src/scss/utilities/_helpers.scss'; | ||
@import '@oruga-ui/oruga/src/scss/components/_radio.scss'; | ||
</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,89 @@ | ||
<template> | ||
<div class="control neo-radio-button" :class="{ 'is-expanded': expanded }"> | ||
<label | ||
ref="label" | ||
class="button" | ||
:class="labelClass" | ||
:disabled="disabled" | ||
@click="focus"> | ||
<slot /> | ||
<input | ||
ref="input" | ||
v-model="computedValue" | ||
type="radio" | ||
:disabled="disabled" | ||
:required="required" | ||
:name="name" | ||
:value="nativeValue" | ||
@click.stop | ||
@focus="isFocused = true" | ||
@blur="isFocused = false" /> | ||
</label> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import CheckRadioMixin from '@oruga-ui/oruga/src/utils/CheckRadioMixin' | ||
export default { | ||
name: 'NeoRadioButton', | ||
mixins: [CheckRadioMixin], | ||
props: { | ||
type: { | ||
type: String, | ||
default: 'is-primary', | ||
}, | ||
expanded: Boolean, | ||
}, | ||
data() { | ||
return { | ||
isFocused: false, | ||
} | ||
}, | ||
computed: { | ||
isSelected() { | ||
return this.newValue === this.nativeValue | ||
}, | ||
labelClass() { | ||
return [ | ||
this.isSelected ? this.type : null, | ||
this.size, | ||
{ | ||
'is-selected': this.isSelected, | ||
'is-disabled': this.disabled, | ||
'is-focused': this.isFocused, | ||
}, | ||
] | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss"> | ||
@import '../../scss/_theme.scss'; | ||
.neo-radio-button { | ||
input[type='radio'] { | ||
display: none; | ||
} | ||
label { | ||
display: flex; | ||
&.button { | ||
@include ktheme() { | ||
border-color: theme('k-primary'); | ||
border-right: none; | ||
border-bottom: none; | ||
border-left: none; | ||
} | ||
} | ||
&.is-selected { | ||
@include ktheme() { | ||
background-color: theme('k-primary'); | ||
} | ||
} | ||
} | ||
} | ||
</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