-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make scheme card compoent more atomic re. pr feedback #16
- Loading branch information
1 parent
f04058e
commit 4b042a5
Showing
3 changed files
with
56 additions
and
43 deletions.
There are no files selected for viewing
46 changes: 34 additions & 12 deletions
46
arches_lingo/src/arches_lingo/components/scheme/SchemeCard.vue
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 |
---|---|---|
@@ -1,43 +1,65 @@ | ||
<script setup lang="ts"> | ||
import { inject } from "vue"; | ||
import { getDescriptors } from "@/arches_vue_utils/utils.ts"; | ||
import { systemLanguageKey } from "@/arches_lingo/constants.ts"; | ||
import { routeNames } from "@/arches_lingo/routes.ts"; | ||
import type { Language } from "@/arches_vue_utils/types"; | ||
import type { SchemeDescriptor } from "@/arches_lingo/types"; | ||
import type { SchemeResource, ResourceDescriptor } from "@/arches_lingo/types"; | ||
const systemLanguage = inject(systemLanguageKey) as Language; | ||
const { scheme } = defineProps<{ scheme: SchemeDescriptor }>(); | ||
const { scheme } = defineProps<{ scheme: SchemeResource }>(); | ||
const schemeURL = { | ||
name: routeNames.scheme, | ||
params: { id: scheme.resourceinstanceid }, | ||
}; | ||
const [schemeName, schemeDescription] = getDescriptors( | ||
scheme.descriptors, | ||
systemLanguage.code, | ||
); | ||
const schemeDescriptor: ResourceDescriptor = (() => { | ||
const descriptors = scheme.descriptors; | ||
if (!scheme) { | ||
return { | ||
name: "", | ||
description: "", | ||
}; | ||
} | ||
const descriptor = | ||
descriptors[systemLanguage.code] ?? | ||
descriptors[Object.keys(descriptors)[0]]; | ||
return { | ||
name: descriptor.name ?? "", | ||
description: descriptor.description ?? "", | ||
}; | ||
})(); | ||
</script> | ||
|
||
<template> | ||
<RouterLink | ||
:to="schemeURL" | ||
class="existing-scheme-card {" | ||
class="scheme-card" | ||
> | ||
<p>{{ schemeName }}</p> | ||
<p>{{ schemeDescription }}</p> | ||
<p>{{ schemeDescriptor.name }}</p> | ||
<p>{{ schemeDescriptor.description }}</p> | ||
</RouterLink> | ||
</template> | ||
|
||
<style scoped> | ||
.existing-scheme-card { | ||
p { | ||
text-align: center; | ||
} | ||
.scheme-card { | ||
text-decoration: none; | ||
color: var(--p-text-color); | ||
width: inherit; | ||
width: 15rem; | ||
height: 15rem; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
margin: 0.5rem; | ||
border: 1px solid var(--p-menubar-border-color); | ||
background-color: var(--p-primary-400); | ||
} | ||
.scheme-card:hover { | ||
background-color: var(--p-button-primary-hover-background); | ||
cursor: pointer; | ||
} | ||
</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