Skip to content

Commit

Permalink
feat: create basic framework for feature content component #81
Browse files Browse the repository at this point in the history
  • Loading branch information
Lev Z Király authored and Lev Z Király committed Nov 23, 2023
1 parent bd48447 commit 671d796
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
36 changes: 36 additions & 0 deletions components/feature-window-content.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<script lang="ts" setup>
interface Props {
params: TextWindowItem["params"];
}
const props = defineProps<Props>();
const { params } = toRefs(props);
const { data, isPending, isPlaceholderData } = useProfileById(params);
const openNewWindowFromAnchor = useAnchorClickHandler();
const isLoading = computed(() => {
return isPending.value || isPlaceholderData.value;
});
</script>

<template>
<div
class="relative isolate grid h-full w-full overflow-auto"
:class="{ 'opacity-50 grayscale': isLoading }"
>
<!-- eslint-disable-next-line vue/no-v-html, vuejs-accessibility/click-events-have-key-events, vuejs-accessibility/no-static-element-interactions -->
<div v-if="data" class="prose max-w-3xl p-8" @click="openNewWindowFromAnchor" v-html="data" />

<Centered v-if="isLoading">
<LoadingIndicator />
</Centered>
</div>
</template>

<style>
/* stylelint-disable-next-line selector-class-pattern */
.tbHeader {
margin: 0;
}
</style>
1 change: 1 addition & 0 deletions components/window-content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ const props = defineProps<Props>();
<GeoMapWindowContent v-if="props.item.kind === 'geo-map'" :params="props.item.params" />
<TextWindowContent v-if="props.item.kind === 'text'" :params="props.item.params" />
<ProfileWindowContent v-if="props.item.kind === 'profile'" :params="props.item.params" />
<FeatureWindowContent v-if="props.item.kind === 'feature'" :params="props.item.params" />
<pre v-else>{{ props }}</pre>
</template>
8 changes: 8 additions & 0 deletions stores/use-windows-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ export interface ProfileWindowItem extends WindowItemBase {
};
}

export interface FeatureWindowItem extends WindowItemBase {
kind: "feature";
params: {
id: string;
};
}

export type WindowItem =
| BibliographyQueryWindowItem
| CorpusQueryWindowItem
Expand All @@ -79,6 +86,7 @@ export type WindowItem =
| DataListWindowItem
| DictionaryEntryWindowItem
| DictionaryQueryWindowItem
| FeatureWindowItem
| GeoMapWindowItem
| ProfileWindowItem
| SampleTextWindowItem
Expand Down
1 change: 1 addition & 0 deletions utils/is-window-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const windowTypeMap: Record<WindowType, WindowItemKind> = {
Text: "text",
WMap: "geo-map",
Profile: "profile",
Feature: "feature",
};

export function isWindowType(value: string | undefined): value is WindowType {
Expand Down

0 comments on commit 671d796

Please sign in to comment.