Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout of model entry form is broken when latex expressions are too long #5177

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,64 +1,67 @@
<template>
<section>
<h6>{{ symbol }}</h6>
<span class="name">
<template v-if="featureConfig.isPreview">{{ item.name }}</template>
<tera-input-text
v-else
placeholder="Add a name"
:model-value="item.name ?? ''"
@update:model-value="$emit('update-item', { key: 'name', value: $event })"
/>
</span>
<span class="unit">
<template v-if="item.input && item.output">
<span><label>Input:</label> {{ item.input }}</span>
<span class="ml-"><label>Output:</label> {{ item.output }}</span>
</template>
<!--amr_to_mmt doesn't like unit expressions with spaces, removing them here before they are saved to the amr-->
<template v-else-if="showUnit">
<template v-if="featureConfig.isPreview"><label>Unit</label>{{ item.unitExpression }}</template>
<section class="flex flex-column gap-3">
<span class="flex align-items-center gap-3">
<h6>{{ symbol }}</h6>
<span class="name">
<template v-if="featureConfig.isPreview">{{ item.name }}</template>
<tera-input-text
v-else
label="Unit"
placeholder="Add a unit"
:characters-to-reject="[' ']"
:model-value="item.unitExpression ?? ''"
@update:model-value="$emit('update-item', { key: 'unitExpression', value: $event })"
placeholder="Add a name"
:model-value="item.name ?? ''"
@update:model-value="$emit('update-item', { key: 'name', value: $event })"
/>
</template>
</span>
<span v-if="!featureConfig.isPreview" class="ml-auto flex gap-3">
<!-- Three states of description buttons: Hide / Show / Add description -->
<Button
v-if="(item.description && showDescription) || (!item.description && showDescription)"
text
size="small"
label="Hide description"
@click="showDescription = false"
/>
<Button
v-else-if="!showDescription"
text
size="small"
:label="item.description ? 'Show description' : 'Add description'"
@click="showDescription = true"
/>
<span v-if="showConcept" class="concept">
<label>Concept</label>
<template v-if="featureConfig.isPreview">{{ query }}</template>
<AutoComplete
v-else
</span>
<span class="unit">
<template v-if="item.input && item.output">
<span><label>Input:</label> {{ item.input }}</span>
<span class="ml-"><label>Output:</label> {{ item.output }}</span>
</template>
<!--amr_to_mmt doesn't like unit expressions with spaces, removing them here before they are saved to the amr-->
<template v-else-if="showUnit">
<template v-if="featureConfig.isPreview"><label>Unit</label>{{ item.unitExpression }}</template>
<tera-input-text
v-else
label="Unit"
placeholder="Add a unit"
:characters-to-reject="[' ']"
:model-value="item.unitExpression ?? ''"
@update:model-value="$emit('update-item', { key: 'unitExpression', value: $event })"
/>
</template>
</span>

<span v-if="!featureConfig.isPreview" class="flex ml-auto gap-3">
<!-- Three states of description buttons: Hide / Show / Add description -->
<Button
v-if="(item.description && showDescription) || (!item.description && showDescription)"
text
size="small"
label="Hide description"
@click="showDescription = false"
/>
<Button
v-else-if="!showDescription"
text
size="small"
placeholder="Search concepts"
v-model="query"
:suggestions="results"
optionLabel="name"
@complete="async () => (results = await searchCuriesEntities(query))"
@item-select="$emit('update-item', { key: 'concept', value: $event.value.curie })"
@keyup.enter="applyValidConcept"
@blur="applyValidConcept"
:label="item.description ? 'Show description' : 'Add description'"
@click="showDescription = true"
/>
<span v-if="showConcept" class="concept">
<label>Concept</label>
<template v-if="featureConfig.isPreview">{{ query }}</template>
<AutoComplete
v-else
size="small"
placeholder="Search concepts"
v-model="query"
:suggestions="results"
optionLabel="name"
@complete="async () => (results = await searchCuriesEntities(query))"
@item-select="$emit('update-item', { key: 'concept', value: $event.value.curie })"
@keyup.enter="applyValidConcept"
@blur="applyValidConcept"
/>
</span>
</span>
</span>
<katex-element
Expand Down Expand Up @@ -135,63 +138,25 @@ if (props.item.description) showDescription.value = true;

<style scoped>
section {
display: grid;
grid-template-areas:
'symbol name unit . concept'
'expression expression expression expression expression'
'description description description description description';
grid-template-columns: max-content max-content max-content auto max-content;
Comment on lines -139 to -143
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just adding a grid-template-rows to make the expression as tall as needed?

grid-auto-flow: dense;
max-width: 100%;
overflow: auto;
gap: var(--gap-1) var(--gap-2);
align-items: center;
font-size: var(--font-caption);

& > *:empty {
display: none;
}
}

label {
label,
.description {
color: var(--text-color-subdued);
}

h6 {
grid-area: symbol;
justify-self: center;
&::after {
content: '|';
color: var(--text-color-light);
margin-left: var(--gap-2);
}
}

.name {
grid-area: name;
}

.description {
grid-area: description;
color: var(--text-color-subdued);
margin-right: var(--gap-2);
h6::after {
content: '|';
color: var(--text-color-light);
margin-left: var(--gap-2);
}

.unit {
grid-area: unit;
max-width: 20rem;
overflow: auto;
}

.expression {
grid-area: expression;
font-size: var(--font-body-small);
}

.concept {
grid-area: concept;
}

.unit,
.concept {
display: flex;
Expand Down