-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
171 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<template> | ||
<component :is="formGroup" | ||
id="checkbox-group-1" | ||
v-model="localValue" | ||
:name="name" | ||
stacked | ||
> | ||
<component :is="formInput" v-for="(option,index) in options" :key="index" :value="option.value"> | ||
<page-settings-entry :text="option.text" :icon="option.icon" /> | ||
</component> | ||
</component> | ||
</template> | ||
|
||
<script setup> | ||
import {computed, ref} from "vue"; | ||
import {PhosphorIcon} from "@icij/murmur-next"; | ||
import PageSettingsEntry from "@/components/PageSettingsEntry.vue"; | ||
import {BFormCheckbox, BFormCheckboxGroup, BFormRadio, BFormRadioGroup} from "bootstrap-vue-next"; | ||
defineOptions({ | ||
name:"PageSettingsSection" | ||
}) | ||
const RADIO = "radio" | ||
const CHECKBOX = "checkbox" | ||
const props = defineProps({ | ||
type: { | ||
type: String, | ||
required: true, | ||
validator: (inputType) => [RADIO, CHECKBOX].includes(inputType) | ||
}, | ||
name: { | ||
type: String, | ||
default: 'settings' | ||
}, | ||
options: { | ||
type: Object, | ||
required: true | ||
} | ||
}) | ||
const modelValue = defineModel({ | ||
type: [String, Array], | ||
default: () => [], | ||
}) | ||
const formGroup = computed(() => { | ||
return props.type === RADIO ? BFormRadioGroup : BFormCheckboxGroup | ||
}) | ||
const formInput = computed(() => { | ||
return props.type === RADIO ? BFormRadio : BFormCheckbox | ||
}) | ||
const localValue = computed({ | ||
get: () => modelValue.value, | ||
set: (newVal) => { | ||
modelValue.value = newVal | ||
} | ||
}) | ||
</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,42 @@ | ||
<template> | ||
<b-form-group ref="form-group"> | ||
<template #label> | ||
<div class="d-flex justify-content-between">{{label}}<phosphor-icon class="d-inline-flex" :name="caretIcon" @click="toggleSection"/></div> | ||
</template> | ||
<slot v-bind="{open}"></slot> | ||
</b-form-group> | ||
</template> | ||
|
||
<script setup> | ||
import {computed, ref} from "vue"; | ||
import {PhosphorIcon} from "@icij/murmur-next"; | ||
import PageSettingsEntry from "@/components/PageSettingsEntry.vue"; | ||
import {BFormCheckbox, BFormCheckboxGroup, BFormRadio, BFormRadioGroup} from "bootstrap-vue-next"; | ||
import PageSettingsSection from "@/components/PageSettingsSection.vue"; | ||
defineOptions({ | ||
name:"PageSettingsSectionLabel" | ||
}) | ||
const props = defineProps({ | ||
label: { | ||
type: String, | ||
default: 'Settings' | ||
}, | ||
show:{ | ||
type:Boolean, | ||
default:true | ||
} | ||
}) | ||
const open = defineModel({ | ||
type:Boolean, | ||
default:true | ||
}) | ||
const caretIcon = computed(()=> open.value?'caret-up':'caret-down') | ||
function toggleSection(){ | ||
open.value = !open.value | ||
} | ||
</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,65 @@ | ||
import PageSettingsSectionLabel from '@/components/PageSettingsSectionLabel' | ||
import PageSettingsSection from '@/components/PageSettingsSection' | ||
import {ref} from "vue"; | ||
|
||
export default { | ||
title: 'Components/PageSettings/Section', | ||
tags: ['autodocs'], | ||
argTypes: { | ||
type: { | ||
control: { type: 'radio' }, | ||
options: ['radio','checkbox'] | ||
}, | ||
}, | ||
render: (args) => ({ | ||
components: { | ||
PageSettingsSection,PageSettingsSectionLabel | ||
}, | ||
setup: () => { | ||
const selected = ref("") | ||
return {selected,args} | ||
}, | ||
template: ` | ||
<page-settings-section-label :title="args.label" v-slot="{open}"> | ||
<page-settings-section v-show="open" v-bind="args"></page-settings-section> | ||
</page-settings-section-label> | ||
Selection {{args.modelValue}} | ||
` | ||
}) | ||
} | ||
const props = {label: 'Show in document details', | ||
name:'document-details', | ||
type:"checkbox", | ||
options:[ | ||
{ | ||
value: "thumbnail", | ||
text: "Thumbnail", | ||
icon: 'image-square' | ||
}, | ||
{ | ||
value: "path", | ||
text: "Path", | ||
icon: 'tree-structure' | ||
}, | ||
{ | ||
value: "creation-date", | ||
text: "Creation date", | ||
icon: 'calendar-blank' | ||
}, | ||
{ | ||
value: "highlight", | ||
text: "Highlight", | ||
icon: 'quotes' | ||
} | ||
]} | ||
export const Default = { | ||
args: { | ||
...props,modelValue:[] | ||
} | ||
} | ||
export const Radio = { | ||
args: { | ||
...props,type:"radio",modelValue:'' | ||
} | ||
} |