2024-08-26 16:53:27 -07:00
|
|
|
<template>
|
|
|
|
|
<ButtonStyled>
|
|
|
|
|
<PopoutMenu
|
2025-02-08 18:31:38 +00:00
|
|
|
v-if="options.length > 1 || showAlways"
|
2024-08-26 16:53:27 -07:00
|
|
|
v-bind="$attrs"
|
|
|
|
|
:disabled="disabled"
|
|
|
|
|
:position="position"
|
|
|
|
|
:direction="direction"
|
App redesign (#2946)
* Start of app redesign
* format
* continue progress
* Content page nearly done
* Fix recursion issues with content page
* Fix update all alignment
* Discover page progress
* Settings progress
* Removed unlocked-size hack that breaks web
* Revamp project page, refactor web project page to share code with app, fixed loading bar, misc UI/UX enhancements, update ko-fi logo, update arrow icons, fix web issues caused by floating-vue migration, fix tooltip issues, update web tooltips, clean up web hydration issues
* Ads + run prettier
* Begin auth refactor, move common messages to ui lib, add i18n extraction to all apps, begin Library refactor
* fix ads not hiding when plus log in
* rev lockfile changes/conflicts
* Fix sign in page
* Add generated
* (mostly) Data driven search
* Fix search mobile issue
* profile fixes
* Project versions page, fix typescript on UI lib and misc fixes
* Remove unused gallery component
* Fix linkfunction err
* Search filter controls at top, localization for locked filters
* Fix provided filter names
* Fix navigating from instance browse to main browse
* Friends frontend (#2995)
* Friends system frontend
* (almost) finish frontend
* finish friends, fix lint
* Fix lint
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
* Refresh macOS app icon
* Update web search UI more
* Fix link opens
* Fix frontend build
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
Co-authored-by: Jai A <jaiagr+gpg@pm.me>
Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
2024-12-11 19:54:18 -08:00
|
|
|
:dropdown-id="dropdownId"
|
2025-02-08 18:31:38 +00:00
|
|
|
:dropdown-class="dropdownClass"
|
|
|
|
|
:tooltip="tooltip"
|
2024-08-27 21:48:44 +02:00
|
|
|
@open="
|
|
|
|
|
() => {
|
|
|
|
|
searchQuery = ''
|
|
|
|
|
}
|
|
|
|
|
"
|
2024-08-26 16:53:27 -07:00
|
|
|
>
|
|
|
|
|
<slot />
|
|
|
|
|
<DropdownIcon class="h-5 w-5 text-secondary" />
|
|
|
|
|
<template #menu>
|
App redesign (#2946)
* Start of app redesign
* format
* continue progress
* Content page nearly done
* Fix recursion issues with content page
* Fix update all alignment
* Discover page progress
* Settings progress
* Removed unlocked-size hack that breaks web
* Revamp project page, refactor web project page to share code with app, fixed loading bar, misc UI/UX enhancements, update ko-fi logo, update arrow icons, fix web issues caused by floating-vue migration, fix tooltip issues, update web tooltips, clean up web hydration issues
* Ads + run prettier
* Begin auth refactor, move common messages to ui lib, add i18n extraction to all apps, begin Library refactor
* fix ads not hiding when plus log in
* rev lockfile changes/conflicts
* Fix sign in page
* Add generated
* (mostly) Data driven search
* Fix search mobile issue
* profile fixes
* Project versions page, fix typescript on UI lib and misc fixes
* Remove unused gallery component
* Fix linkfunction err
* Search filter controls at top, localization for locked filters
* Fix provided filter names
* Fix navigating from instance browse to main browse
* Friends frontend (#2995)
* Friends system frontend
* (almost) finish frontend
* finish friends, fix lint
* Fix lint
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
* Refresh macOS app icon
* Update web search UI more
* Fix link opens
* Fix frontend build
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
Co-authored-by: Jai A <jaiagr+gpg@pm.me>
Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
2024-12-11 19:54:18 -08:00
|
|
|
<div v-if="search" class="iconified-input mb-2 w-full">
|
2024-08-26 16:53:27 -07:00
|
|
|
<label for="search-input" hidden>Search...</label>
|
|
|
|
|
<SearchIcon aria-hidden="true" />
|
2024-08-27 21:48:44 +02:00
|
|
|
<input
|
|
|
|
|
id="search-input"
|
App redesign (#2946)
* Start of app redesign
* format
* continue progress
* Content page nearly done
* Fix recursion issues with content page
* Fix update all alignment
* Discover page progress
* Settings progress
* Removed unlocked-size hack that breaks web
* Revamp project page, refactor web project page to share code with app, fixed loading bar, misc UI/UX enhancements, update ko-fi logo, update arrow icons, fix web issues caused by floating-vue migration, fix tooltip issues, update web tooltips, clean up web hydration issues
* Ads + run prettier
* Begin auth refactor, move common messages to ui lib, add i18n extraction to all apps, begin Library refactor
* fix ads not hiding when plus log in
* rev lockfile changes/conflicts
* Fix sign in page
* Add generated
* (mostly) Data driven search
* Fix search mobile issue
* profile fixes
* Project versions page, fix typescript on UI lib and misc fixes
* Remove unused gallery component
* Fix linkfunction err
* Search filter controls at top, localization for locked filters
* Fix provided filter names
* Fix navigating from instance browse to main browse
* Friends frontend (#2995)
* Friends system frontend
* (almost) finish frontend
* finish friends, fix lint
* Fix lint
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
* Refresh macOS app icon
* Update web search UI more
* Fix link opens
* Fix frontend build
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
Co-authored-by: Jai A <jaiagr+gpg@pm.me>
Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
2024-12-11 19:54:18 -08:00
|
|
|
ref="searchInput"
|
2024-08-27 21:48:44 +02:00
|
|
|
v-model="searchQuery"
|
|
|
|
|
placeholder="Search..."
|
|
|
|
|
type="text"
|
|
|
|
|
@keydown.enter="
|
|
|
|
|
() => {
|
|
|
|
|
toggleOption(filteredOptions[0])
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
2024-08-26 16:53:27 -07:00
|
|
|
</div>
|
2024-08-27 21:48:44 +02:00
|
|
|
<ScrollablePanel v-if="search" class="h-[17rem]">
|
2024-08-26 16:53:27 -07:00
|
|
|
<Button
|
|
|
|
|
v-for="(option, index) in filteredOptions"
|
|
|
|
|
:key="`option-${index}`"
|
|
|
|
|
:transparent="!manyValues.includes(option)"
|
|
|
|
|
:action="() => toggleOption(option)"
|
|
|
|
|
class="!w-full"
|
|
|
|
|
:color="manyValues.includes(option) ? 'secondary' : 'default'"
|
|
|
|
|
>
|
App redesign (#2946)
* Start of app redesign
* format
* continue progress
* Content page nearly done
* Fix recursion issues with content page
* Fix update all alignment
* Discover page progress
* Settings progress
* Removed unlocked-size hack that breaks web
* Revamp project page, refactor web project page to share code with app, fixed loading bar, misc UI/UX enhancements, update ko-fi logo, update arrow icons, fix web issues caused by floating-vue migration, fix tooltip issues, update web tooltips, clean up web hydration issues
* Ads + run prettier
* Begin auth refactor, move common messages to ui lib, add i18n extraction to all apps, begin Library refactor
* fix ads not hiding when plus log in
* rev lockfile changes/conflicts
* Fix sign in page
* Add generated
* (mostly) Data driven search
* Fix search mobile issue
* profile fixes
* Project versions page, fix typescript on UI lib and misc fixes
* Remove unused gallery component
* Fix linkfunction err
* Search filter controls at top, localization for locked filters
* Fix provided filter names
* Fix navigating from instance browse to main browse
* Friends frontend (#2995)
* Friends system frontend
* (almost) finish frontend
* finish friends, fix lint
* Fix lint
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
* Refresh macOS app icon
* Update web search UI more
* Fix link opens
* Fix frontend build
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
Co-authored-by: Jai A <jaiagr+gpg@pm.me>
Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
2024-12-11 19:54:18 -08:00
|
|
|
<slot name="option" :option="option">{{ displayName?.(option) }}</slot>
|
2024-08-27 21:48:44 +02:00
|
|
|
<CheckIcon
|
|
|
|
|
class="h-5 w-5 text-contrast ml-auto transition-opacity"
|
|
|
|
|
:class="{ 'opacity-0': !manyValues.includes(option) }"
|
|
|
|
|
/>
|
2024-08-26 16:53:27 -07:00
|
|
|
</Button>
|
|
|
|
|
</ScrollablePanel>
|
2024-08-27 21:48:44 +02:00
|
|
|
<div v-else class="flex flex-col gap-1">
|
2024-08-26 16:53:27 -07:00
|
|
|
<Button
|
|
|
|
|
v-for="(option, index) in filteredOptions"
|
|
|
|
|
:key="`option-${index}`"
|
|
|
|
|
:transparent="!manyValues.includes(option)"
|
|
|
|
|
:action="() => toggleOption(option)"
|
|
|
|
|
class="!w-full"
|
|
|
|
|
:color="manyValues.includes(option) ? 'secondary' : 'default'"
|
|
|
|
|
>
|
App redesign (#2946)
* Start of app redesign
* format
* continue progress
* Content page nearly done
* Fix recursion issues with content page
* Fix update all alignment
* Discover page progress
* Settings progress
* Removed unlocked-size hack that breaks web
* Revamp project page, refactor web project page to share code with app, fixed loading bar, misc UI/UX enhancements, update ko-fi logo, update arrow icons, fix web issues caused by floating-vue migration, fix tooltip issues, update web tooltips, clean up web hydration issues
* Ads + run prettier
* Begin auth refactor, move common messages to ui lib, add i18n extraction to all apps, begin Library refactor
* fix ads not hiding when plus log in
* rev lockfile changes/conflicts
* Fix sign in page
* Add generated
* (mostly) Data driven search
* Fix search mobile issue
* profile fixes
* Project versions page, fix typescript on UI lib and misc fixes
* Remove unused gallery component
* Fix linkfunction err
* Search filter controls at top, localization for locked filters
* Fix provided filter names
* Fix navigating from instance browse to main browse
* Friends frontend (#2995)
* Friends system frontend
* (almost) finish frontend
* finish friends, fix lint
* Fix lint
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
* Refresh macOS app icon
* Update web search UI more
* Fix link opens
* Fix frontend build
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
Co-authored-by: Jai A <jaiagr+gpg@pm.me>
Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
2024-12-11 19:54:18 -08:00
|
|
|
<slot name="option" :option="option">{{ displayName?.(option) }}</slot>
|
2024-08-27 21:48:44 +02:00
|
|
|
<CheckIcon
|
|
|
|
|
class="h-5 w-5 text-contrast ml-auto transition-opacity"
|
|
|
|
|
:class="{ 'opacity-0': !manyValues.includes(option) }"
|
|
|
|
|
/>
|
2024-08-26 16:53:27 -07:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
<slot name="footer" />
|
|
|
|
|
</template>
|
|
|
|
|
</PopoutMenu>
|
|
|
|
|
</ButtonStyled>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
2024-12-12 13:25:25 -08:00
|
|
|
import { CheckIcon, DropdownIcon, SearchIcon } from '@modrinth/assets'
|
2024-08-26 16:53:27 -07:00
|
|
|
import { ButtonStyled, PopoutMenu, Button } from '../index'
|
|
|
|
|
import { computed, ref } from 'vue'
|
|
|
|
|
import ScrollablePanel from './ScrollablePanel.vue'
|
|
|
|
|
|
|
|
|
|
type Option = string | number | object
|
|
|
|
|
|
|
|
|
|
const props = withDefaults(
|
|
|
|
|
defineProps<{
|
2024-08-27 21:48:44 +02:00
|
|
|
modelValue: Option[]
|
2024-08-26 16:53:27 -07:00
|
|
|
options: Option[]
|
|
|
|
|
disabled?: boolean
|
|
|
|
|
position?: string
|
2024-08-27 21:48:44 +02:00
|
|
|
direction?: string
|
|
|
|
|
displayName?: (option: Option) => string
|
2024-08-26 16:53:27 -07:00
|
|
|
search?: boolean
|
App redesign (#2946)
* Start of app redesign
* format
* continue progress
* Content page nearly done
* Fix recursion issues with content page
* Fix update all alignment
* Discover page progress
* Settings progress
* Removed unlocked-size hack that breaks web
* Revamp project page, refactor web project page to share code with app, fixed loading bar, misc UI/UX enhancements, update ko-fi logo, update arrow icons, fix web issues caused by floating-vue migration, fix tooltip issues, update web tooltips, clean up web hydration issues
* Ads + run prettier
* Begin auth refactor, move common messages to ui lib, add i18n extraction to all apps, begin Library refactor
* fix ads not hiding when plus log in
* rev lockfile changes/conflicts
* Fix sign in page
* Add generated
* (mostly) Data driven search
* Fix search mobile issue
* profile fixes
* Project versions page, fix typescript on UI lib and misc fixes
* Remove unused gallery component
* Fix linkfunction err
* Search filter controls at top, localization for locked filters
* Fix provided filter names
* Fix navigating from instance browse to main browse
* Friends frontend (#2995)
* Friends system frontend
* (almost) finish frontend
* finish friends, fix lint
* Fix lint
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
* Refresh macOS app icon
* Update web search UI more
* Fix link opens
* Fix frontend build
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
Co-authored-by: Jai A <jaiagr+gpg@pm.me>
Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
2024-12-11 19:54:18 -08:00
|
|
|
dropdownId?: string
|
2025-02-08 18:31:38 +00:00
|
|
|
dropdownClass?: string
|
|
|
|
|
showAlways?: boolean
|
|
|
|
|
tooltip?: string
|
2024-08-26 16:53:27 -07:00
|
|
|
}>(),
|
|
|
|
|
{
|
|
|
|
|
disabled: false,
|
|
|
|
|
position: 'auto',
|
|
|
|
|
direction: 'auto',
|
|
|
|
|
displayName: (option: Option) => option as string,
|
|
|
|
|
search: false,
|
2025-02-08 18:31:38 +00:00
|
|
|
dropdownId: '',
|
|
|
|
|
dropdownClass: '',
|
|
|
|
|
showAlways: false,
|
|
|
|
|
tooltip: '',
|
2024-08-26 16:53:27 -07:00
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
2024-08-27 21:48:44 +02:00
|
|
|
const emit = defineEmits(['update:modelValue', 'change'])
|
2024-08-26 16:53:27 -07:00
|
|
|
const selectedValues = ref(props.modelValue || [])
|
2024-08-27 21:48:44 +02:00
|
|
|
const searchInput = ref()
|
2024-08-26 16:53:27 -07:00
|
|
|
|
|
|
|
|
const searchQuery = ref('')
|
|
|
|
|
|
|
|
|
|
const manyValues = computed({
|
|
|
|
|
get() {
|
|
|
|
|
return props.modelValue || selectedValues.value
|
|
|
|
|
},
|
|
|
|
|
set(newValue) {
|
|
|
|
|
emit('update:modelValue', newValue)
|
|
|
|
|
emit('change', newValue)
|
|
|
|
|
selectedValues.value = newValue
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const filteredOptions = computed(() => {
|
2024-08-27 21:48:44 +02:00
|
|
|
return props.options.filter(
|
|
|
|
|
(x) =>
|
|
|
|
|
!searchQuery.value ||
|
|
|
|
|
props.displayName(x).toLowerCase().includes(searchQuery.value.toLowerCase()),
|
|
|
|
|
)
|
2024-08-26 16:53:27 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
|
inheritAttrs: false,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function toggleOption(id: Option) {
|
|
|
|
|
if (manyValues.value.includes(id)) {
|
|
|
|
|
manyValues.value = manyValues.value.filter((x) => x !== id)
|
|
|
|
|
} else {
|
|
|
|
|
manyValues.value = [...manyValues.value, id]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|