-
Notifications
You must be signed in to change notification settings - Fork 6
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
8 changed files
with
204 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,78 @@ | ||
<template> | ||
<n-dropdown show-arrow trigger="manual" placement="right" :disabled="!enabled" :show="show" :options="options" | ||
:render-icon="renderIcon" :render-label="renderLabel" @select="onSelect" @clickoutside="onClickOutside"> | ||
<slot /> | ||
</n-dropdown> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { | ||
type VNode, | ||
computed, | ||
defineEmits, | ||
defineProps, | ||
h, | ||
} from 'vue'; | ||
import { | ||
type DropdownOption, | ||
NDropdown, | ||
} from 'naive-ui'; | ||
import BSPopoverIcon from './BSPopoverIcon.vue'; | ||
import BSPopoverLabel from './BSPopoverLabel.vue'; | ||
const props = defineProps<{ | ||
row: number; | ||
offset: number; | ||
ratio: number; | ||
icons: { | ||
part: string; | ||
offset: number; | ||
}[]; | ||
params: string[] | undefined; | ||
}>(); | ||
const emit = defineEmits<{ | ||
(e: 'select', offset: number, length: number): void; | ||
}>(); | ||
const show = defineModel<boolean>('show'); | ||
type BSCellPopoverOption = DropdownOption & { | ||
offset: number; | ||
}; | ||
const enabled = computed(() => props.icons.length > 0); | ||
const options = computed(() => props.icons.map(({ part, offset }) => ({ | ||
label: part, | ||
key: `${offset}_${part}`, | ||
offset: offset, | ||
} as BSCellPopoverOption))); | ||
function renderLabel(option: DropdownOption): VNode { | ||
return h(BSPopoverLabel, { | ||
src: option.label as string, | ||
}); | ||
} | ||
function renderIcon(option: DropdownOption): VNode { | ||
return h(BSPopoverIcon, { | ||
src: option.label as string, | ||
ratio: props.ratio, | ||
params: props.params?.[0], | ||
}); | ||
} | ||
function onSelect(_key: string, option: DropdownOption): void { | ||
const { label, offset } = option as BSCellPopoverOption; | ||
const src = (label as string).split('__')[0]; | ||
emit('select', offset, src.length); | ||
show.value = false; | ||
} | ||
function onClickOutside(): void { | ||
show.value = false; | ||
} | ||
</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,35 @@ | ||
<template> | ||
<div :class="$style.cell" :style="style"> | ||
<BSIcon :src="props.src" /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { type CSSProperties, computed, defineProps } from 'vue'; | ||
import styleFromParams from '@/utils/styleFromParams'; | ||
import BSIcon from './BSIcon.vue'; | ||
const props = defineProps<{ | ||
src: string; | ||
ratio: number | undefined; | ||
params: string | undefined; | ||
}>(); | ||
const style = computed(() => ({ | ||
...styleFromParams(props.params, true), | ||
'--bs-map-cell-ratio': (props.ratio == 1 ? undefined : props.ratio), | ||
}) as CSSProperties); | ||
</script> | ||
|
||
|
||
<style lang="scss" module> | ||
.cell { | ||
--bs-map-size: 20; | ||
width: calc(var(--bs-map-size) * var(--bs-map-cell-ratio, 1) * 1px); | ||
height: calc(var(--bs-map-size) * 1px); | ||
line-height: calc(var(--bs-map-size) * 1px); | ||
border: 1px solid #ddd; | ||
} | ||
</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,55 @@ | ||
<template> | ||
<div :class="$style.item"> | ||
<div :class="$style.name">{{ src }}</div> | ||
<n-button v-if="isIcon" :class="$style.open" quaternary block @click.stop="onClick"> | ||
<n-icon> | ||
<OpenOutline /> | ||
</n-icon> | ||
</n-button> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { computed, defineProps } from 'vue'; | ||
import { NButton, NIcon } from 'naive-ui'; | ||
import { OpenOutline } from '@vicons/ionicons5'; | ||
const props = defineProps<{ | ||
src: string; | ||
}>(); | ||
const src = computed(() => props.src.split('__')[0]); | ||
const isIcon = computed(() => !props.src.includes('*')); | ||
function onClick(): void { | ||
window.open(`https://commons.wikimedia.org/wiki/File:BSicon_${src.value}.svg`); | ||
} | ||
</script> | ||
|
||
<style lang="scss" module> | ||
.item { | ||
display: flex; | ||
width: auto; | ||
margin-right: calc(var(--n-option-suffix-width) * -1 + 2px); | ||
.name { | ||
flex: 1 1 auto; | ||
user-select: none; | ||
font-family: monospace; | ||
margin-right: 16px; | ||
} | ||
.open { | ||
flex: 0 0 20px; | ||
opacity: 0; | ||
transition: opacity 200ms; | ||
} | ||
&:hover { | ||
.open { | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
</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
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