|
| 1 | +<template> |
| 2 | + <b-row> |
| 3 | + <b-col> |
| 4 | + <b-container fluid> |
| 5 | + <b-row> |
| 6 | + <b-col> |
| 7 | + <b-form-input v-model="searchQuery" placeholder="Search" /> |
| 8 | + </b-col> |
| 9 | + </b-row> |
| 10 | + <b-row> |
| 11 | + <b-col> |
| 12 | + <b-button variant="danger" @click="clearActiveList">Clear all</b-button> |
| 13 | + <b-button |
| 14 | + v-for="(comp, index) in filteredSearch" |
| 15 | + :key="index" |
| 16 | + class="m-1" |
| 17 | + :disabled="comp.disabled" |
| 18 | + :variant="active.includes(comp.name) ? 'primary' : 'secondary'" |
| 19 | + @click="switchActive(comp.name)" |
| 20 | + > |
| 21 | + {{ comp.name }} |
| 22 | + </b-button> |
| 23 | + </b-col> |
| 24 | + </b-row> |
| 25 | + <b-row> |
| 26 | + <b-col> |
| 27 | + <b-container v-for="(comp, index) in filteredActive" :key="index" fluid> |
| 28 | + <b-row> |
| 29 | + <b-col> |
| 30 | + <h1>{{ comp.name }}</h1> |
| 31 | + </b-col> |
| 32 | + </b-row> |
| 33 | + <b-row> |
| 34 | + <b-col> |
| 35 | + <component :is="comp.is" /> |
| 36 | + </b-col> |
| 37 | + </b-row> |
| 38 | + <b-row> |
| 39 | + <b-col> |
| 40 | + <hr /> |
| 41 | + </b-col> |
| 42 | + </b-row> |
| 43 | + </b-container> |
| 44 | + </b-col> |
| 45 | + </b-row> |
| 46 | + </b-container> |
| 47 | + </b-col> |
| 48 | + </b-row> |
| 49 | +</template> |
| 50 | + |
| 51 | +<script setup lang="ts"> |
| 52 | +import {computed, onMounted, ref} from 'vue' |
| 53 | +import TAccordion from '../components/Comps/TAccordion.vue' |
| 54 | +import TAlert from '../components/Comps/TAlert.vue' |
| 55 | +import TAvatar from '../components/Comps/TAvatar.vue' |
| 56 | +import TBadge from '../components/Comps/TBadge.vue' |
| 57 | +import TBLink from '../components/Comps/TBLink.vue' |
| 58 | +import TBreadcrumb from '../components/Comps/TBreadcrumb.vue' |
| 59 | +import TButton from '../components/Comps/TButton.vue' |
| 60 | +import TCard from '../components/Comps/TCard.vue' |
| 61 | +import TCarousel from '../components/Comps/TCarousel.vue' |
| 62 | +import TDropdown from '../components/Comps/TDropdown.vue' |
| 63 | +import TForm from '../components/Comps/TForm.vue' |
| 64 | +import TFormCheckbox from '../components/Comps/TFormCheckbox.vue' |
| 65 | +import TFormCheckboxGroup from '../components/Comps/TFormCheckboxGroup.vue' |
| 66 | +import TFormFloatingLabel from '../components/Comps/TFormFloatingLabel.vue' |
| 67 | +import TFormGroup from '../components/Comps/TFormGroup.vue' |
| 68 | +import TFormInput from '../components/Comps/TFormInput.vue' |
| 69 | +import TFormRadio from '../components/Comps/TFormRadio.vue' |
| 70 | +import TFormRadioGroup from '../components/Comps/TFormRadioGroup.vue' |
| 71 | +import TFormSelect from '../components/Comps/TFormSelect.vue' |
| 72 | +import TFormTextarea from '../components/Comps/TFormTextarea.vue' |
| 73 | +import TImg from '../components/Comps/TImg.vue' |
| 74 | +import TInputGroup from '../components/Comps/TInputGroup.vue' |
| 75 | +import TLayout from '../components/Comps/TLayout.vue' |
| 76 | +import TListGroup from '../components/Comps/TListGroup.vue' |
| 77 | +import TModal from '../components/Comps/TModal.vue' |
| 78 | +import TNav from '../components/Comps/TNav.vue' |
| 79 | +import TOverlay from '../components/Comps/TOverlay.vue' |
| 80 | +import TPagination from '../components/Comps/TPagination.vue' |
| 81 | +import TPopover from '../components/Comps/TPopover.vue' |
| 82 | +import TSkeleton from '../components/Comps/TSkeleton.vue' |
| 83 | +import TSkeletonIcon from '../components/Comps/TSkeletonIcon.vue' |
| 84 | +import TSkeletonTable from '../components/Comps/TSkeletonTable.vue' |
| 85 | +import TSkeletonWrapper from '../components/Comps/TSkeletonWrapper.vue' |
| 86 | +import TTable from '../components/Comps/TTable.vue' |
| 87 | +import TTableSimple from '../components/Comps/TTableSimple.vue' |
| 88 | +import TTabs from '../components/Comps/TTabs.vue' |
| 89 | +import TToast from '../components/Comps/TToast.vue' |
| 90 | +import TTooltip from '../components/Comps/TTooltip.vue' |
| 91 | +import TVisible from '../components/Directives/TVisible.vue' |
| 92 | +
|
| 93 | +const comps: Array<{name: string; is: unknown; disabled?: true}> = [ |
| 94 | + {name: 'Visible', is: TVisible, disabled: true}, |
| 95 | + {name: 'Accordion', is: TAccordion}, |
| 96 | + {name: 'Alert', is: TAlert}, |
| 97 | + {name: 'Avatar', is: TAvatar}, |
| 98 | + {name: 'TBadge', is: TBadge}, |
| 99 | + {name: 'BLink', is: TBLink}, |
| 100 | + {name: 'Breadcrumb', is: TBreadcrumb}, |
| 101 | + {name: 'Button', is: TButton}, |
| 102 | + {name: 'Card', is: TCard}, |
| 103 | + {name: 'Carousel', is: TCarousel}, |
| 104 | + {name: 'Dropdown', is: TDropdown}, |
| 105 | + {name: 'Form', is: TForm}, |
| 106 | + {name: 'FormCheckbox', is: TFormCheckbox}, |
| 107 | + {name: 'FormCheckboxGroup', is: TFormCheckboxGroup}, |
| 108 | + {name: 'FormFloatingLabel', is: TFormFloatingLabel}, |
| 109 | + {name: 'FormGroup', is: TFormGroup}, |
| 110 | + {name: 'FormInput', is: TFormInput}, |
| 111 | + {name: 'FormRadio', is: TFormRadio}, |
| 112 | + {name: 'FormRadioGroup', is: TFormRadioGroup}, |
| 113 | + {name: 'FormSelect', is: TFormSelect}, |
| 114 | + {name: 'FormTextarea', is: TFormTextarea}, |
| 115 | + {name: 'Img', is: TImg}, |
| 116 | + {name: 'InputGroup', is: TInputGroup}, |
| 117 | + {name: 'ListGroup', is: TListGroup}, |
| 118 | + {name: 'Layout', is: TLayout}, |
| 119 | + {name: 'Modal', is: TModal}, |
| 120 | + {name: 'Nav', is: TNav}, |
| 121 | + {name: 'Overlay', is: TOverlay}, |
| 122 | + {name: 'Pagination', is: TPagination}, |
| 123 | + {name: 'Popover', is: TPopover}, |
| 124 | + {name: 'Skeleton', is: TSkeleton}, |
| 125 | + {name: 'SkeletonIcon', is: TSkeletonIcon}, |
| 126 | + {name: 'SkeletonTable', is: TSkeletonTable}, |
| 127 | + {name: 'SkeletonWrapper', is: TSkeletonWrapper}, |
| 128 | + {name: 'Table', is: TTable}, |
| 129 | + {name: 'TableSimple', is: TTableSimple}, |
| 130 | + {name: 'Tabs', is: TTabs}, |
| 131 | + {name: 'Toast', is: TToast}, |
| 132 | + {name: 'Tooltip', is: TTooltip}, |
| 133 | +] |
| 134 | +
|
| 135 | +const searchQuery = ref('') |
| 136 | +
|
| 137 | +const active = ref<Array<string>>([]) |
| 138 | +
|
| 139 | +const filteredSearch = computed(() => |
| 140 | + searchQuery.value.trim() !== '' |
| 141 | + ? comps.filter((item) => |
| 142 | + searchQuery.value |
| 143 | + .toLowerCase() |
| 144 | + .split(' ') |
| 145 | + .every((v) => item.name.toLowerCase().includes(v)) |
| 146 | + ) |
| 147 | + : comps |
| 148 | +) |
| 149 | +
|
| 150 | +const filteredActive = computed(() => comps.filter((el) => active.value.includes(el.name))) |
| 151 | +
|
| 152 | +const switchActive = (name: string): void => { |
| 153 | + const comp = comps.find((el) => el.name === name) |
| 154 | + if (comp === undefined || comp.disabled === true) return |
| 155 | + const value = comp.name |
| 156 | + const ind = active.value.findIndex((el) => el === value) |
| 157 | + ind !== -1 ? active.value.splice(ind, 1) : active.value.push(value) |
| 158 | + if (active.value.length === 0) { |
| 159 | + localStorage.removeItem('bv3-playground-dev-active-list') |
| 160 | + return |
| 161 | + } |
| 162 | + localStorage.setItem('bv3-playground-dev-active-list', JSON.stringify(active.value)) |
| 163 | +} |
| 164 | +
|
| 165 | +const clearActiveList = () => { |
| 166 | + localStorage.removeItem('bv3-playground-dev-active-list') |
| 167 | + active.value = [] |
| 168 | +} |
| 169 | +
|
| 170 | +onMounted(() => { |
| 171 | + const activeList = localStorage.getItem('bv3-playground-dev-active-list') |
| 172 | + if (activeList !== null) { |
| 173 | + active.value = JSON.parse(activeList) |
| 174 | + } |
| 175 | +}) |
| 176 | +</script> |
0 commit comments