Skip to content

Commit

Permalink
refactor: add NeoRadio and NeoRadioButton
Browse files Browse the repository at this point in the history
  • Loading branch information
preschian committed May 15, 2023
1 parent f3102e8 commit 3e98ea9
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 40 deletions.
12 changes: 6 additions & 6 deletions components/rmrk/Gallery/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="content is-hidden-mobile">
<b-field :position="position">
<b-tooltip :label="$t('tooltip.largeDisplay')">
<b-radio-button
<NeoRadioButton
v-model="preferenceLayout"
type="is-primary"
class="collection-radio-btn"
Expand All @@ -12,10 +12,10 @@
<span>
<NeoIcon icon="th-large" />
</span>
</b-radio-button>
</NeoRadioButton>
</b-tooltip>
<b-tooltip :label="$t('tooltip.smallDisplay')">
<b-radio-button
<NeoRadioButton
v-model="preferenceLayout"
type="is-primary"
class="collection-radio-btn"
Expand All @@ -25,7 +25,7 @@
<span>
<NeoIcon icon="th" />
</span>
</b-radio-button>
</NeoRadioButton>
</b-tooltip>
</b-field>
</div>
Expand All @@ -35,9 +35,9 @@
import { Component, Prop, Vue } from 'nuxt-property-decorator'
import { RmrkType } from '@/components/rmrk/service/scheme'
import { usePreferencesStore } from '@/stores/preferences'
import { NeoIcon } from '@kodadot1/brick'
import { NeoIcon, NeoRadioButton } from '@kodadot1/brick'
@Component({ components: { NeoIcon } })
@Component({ components: { NeoIcon, NeoRadioButton } })
export default class Layout extends Vue {
@Prop({ default: 'nftDetail' }) public type!: string
@Prop({ default: 'rmrk/detail' }) public link!: string
Expand Down
29 changes: 0 additions & 29 deletions components/series/SeriesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,6 @@
</div>
</b-field> -->

<!-- <b-field
position="is-left"
expanded
>
<b-radio-button
v-model="nbDays"
native-value="24"
type="is-outlined"
>
24h
</b-radio-button>
<b-radio-button
v-model="nbDays"
native-value="7"
type="is-outlined"
>
7d
</b-radio-button>
<b-radio-button
v-model="nbDays"
native-value="30"
type="is-outlined"
>
30d
</b-radio-button>
</b-field> -->

<b-field class="has-text-right" expanded>
<b-select v-model="nbRows">
<option value="10">10</option>
Expand Down
12 changes: 7 additions & 5 deletions components/shared/input/selectable/RadioSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:is="separated ? 'div' : 'b-field'"
v-if="options"
:class="{ 'columns is-multiline': separated }">
<b-radio-button
<NeoRadioButton
v-if="showEmpty"
:value="value"
native-value=""
Expand All @@ -12,8 +12,8 @@
:class="{ 'column is-half': separated }"
@input="handleInput">
<span><b>NONE</b></span>
</b-radio-button>
<b-radio-button
</NeoRadioButton>
<NeoRadioButton
v-for="option in options"
:key="option"
:value="value"
Expand All @@ -23,14 +23,16 @@
:class="{ 'column is-half': separated }"
@input="handleInput">
<span>{{ option }}</span>
</b-radio-button>
</NeoRadioButton>
</component>
</template>

<script setup lang="ts">
import { NeoRadioButton } from '@kodadot1/brick'
const emit = defineEmits(['input'])
const props = defineProps<{
defineProps<{
value: string
options: string[]
showEmpty?: boolean
Expand Down
110 changes: 110 additions & 0 deletions libs/ui/src/components/NeoRadio/NeoRadio.story.vue
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>
15 changes: 15 additions & 0 deletions libs/ui/src/components/NeoRadio/NeoRadio.vue
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>
89 changes: 89 additions & 0 deletions libs/ui/src/components/NeoRadio/NeoRadioButton.vue
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>
3 changes: 3 additions & 0 deletions libs/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ export { default as NeoCarouselItem } from './components/NeoCarousel/NeoCarousel

export { default as NeoDatepicker } from './components/NeoDatepicker/NeoDatepicker.vue'

export { default as NeoRadio } from './components/NeoRadio/NeoRadio.vue'
export { default as NeoRadioButton } from './components/NeoRadio/NeoRadioButton.vue'

export { default as Neo } from '@oruga-ui/oruga'

0 comments on commit 3e98ea9

Please sign in to comment.