responsivness adjusted

This commit is contained in:
2026-07-05 18:09:59 +02:00
parent 0c3db967b0
commit 1eaf8f8c8f
3 changed files with 479 additions and 455 deletions
@@ -71,27 +71,29 @@
(expandedChange)="onSubfieldLegendExpandedChange($event)">
</app-topic-legend>
}
@if (extractedKeywordsExist()) {
<div class="toolbar-wrapper">
<!-- Manual input is ALWAYS available, independent of extraction state -->
<div class="toolbar-wrapper">
@if (keywordsExist()) {
<div class="toolbar-controls thick-border">
<div class="toolbar-group toolbar-group--select">
@if (areAllExtractedSelected()) {
<div class="toolbar-group toolbar-group--view">
@if (areAllSelected()) {
<button
mat-stroked-button
color="primary"
(click)="deselectAllExtracted()">
(click)="deselectAll()">
<mat-icon>select_all</mat-icon>
<span class="btn-label">Alle abwählen</span>
<span>Alle abwählen</span>
</button>
} @else {
<button
mat-stroked-button
color="primary"
[disabled]="isExtracting()"
(click)="selectAllExtracted()"
(click)="selectAll()"
matTooltip="Alle extrahierten Keywords auswählen">
<mat-icon>select_all</mat-icon>
<span class="btn-label">Alle auswählen</span>
<span>Alle auswählen</span>
</button>
}
</div>
@@ -126,170 +128,216 @@
</button>
</div>
</div>
<div class="spacer toolbar-controls">
<app-topic-autocomplete
label="z. B. Knowledge Graphs"
placeholder="Thema suchen oder eintippen..."
(topicSelected)="addKeywordFromInput($event)" />
</div>
} @else {
<!-- Empty placeholder keeps grid column 1 occupied so
the autocomplete below stays fixed in column 2 -->
<div
class="toolbar-controls toolbar-controls--placeholder"></div>
}
<div class="spacer toolbar-controls manual-input-controls">
<app-topic-autocomplete
label="z. B. Knowledge Graphs"
placeholder="Thema suchen oder eintippen..."
(topicSelected)="addKeywordFromInput($event)" />
</div>
</div>
</div>
<!-- ===== Reusable chip stack templates ===== -->
<ng-template
#keywordChipStack
let-keywords="keywords"
let-emptyText="emptyText">
@if (keywords.length > 0) {
<div class="keyword-chip-stack">
@for (keyword of keywords; track keyword.llm_keyword.keyword) {
<app-topic-chip
[label]="getChipLabel(keyword)"
[count]="
keywordView() === 'topic' ? getChipCount(keyword) : null
"
[description]="getChipDescription(keyword)"
[subfieldName]="getChipSubfieldName(keyword)"
[fieldName]="getChipFieldName(keyword)"
[domainName]="getChipDomainName(keyword)"
[color]="getTopicColor(keyword.topic_mapping?.topic)"
[active]="isKeywordSelected(keyword)"
countIcon="article"
descriptionTooltipTarget="button"
(chipClick)="toggleKeywordSelection(keyword)">
</app-topic-chip>
}
</div>
} @else {
<p class="empty-state small">{{ emptyText }}</p>
}
</div>
<!-- Table-like keyword grid -->
<div class="keyword-table">
<!-- Header: group title + own-keyword input as column subheader -->
<div class="table-head">
<div class="head-cell sub-cell broad-sub">Breite Keywords</div>
<div class="head-cell sub-cell coarse-sub">Coarse Keywords</div>
<div class="head-cell sub-cell fine-sub thick-border">
Fine Keywords
</div>
<div class="head-cell sub-cell manual-sub">Eigene Keywords</div>
</ng-template>
<ng-template #manualChipStack>
<div class="keyword-chip-stack manual-stack">
@if (manualKeywords().length > 0) {
@for (
keyword of manualKeywords();
track keyword.llm_keyword.keyword
) {
<div class="manual-chip-row">
<app-topic-chip
[label]="getChipLabel(keyword)"
[count]="
keywordView() === 'topic' ? getChipCount(keyword) : null
"
[description]="getChipDescription(keyword)"
[subfieldName]="getChipSubfieldName(keyword)"
[fieldName]="getChipFieldName(keyword)"
[domainName]="getChipDomainName(keyword)"
[color]="getTopicColor(keyword.topic_mapping?.topic)"
[active]="isKeywordSelected(keyword)"
countIcon="article"
descriptionTooltipTarget="button"
(chipClick)="toggleKeywordSelection(keyword)">
</app-topic-chip>
<button
mat-icon-button
type="button"
color="warn"
aria-label="Manuelles Keyword entfernen"
(click)="removeManualKeyword(keyword)">
<mat-icon>cancel</mat-icon>
</button>
</div>
}
} @else if (loadingNewKeyword()) {
<div class="manual-chip-row">
<app-topic-chip [label]="'Neues Keyword wird hinzugefügt...'">
</app-topic-chip>
</div>
} @else {
<p class="empty-state small">Nichts hinzugefügt</p>
}
</div>
</ng-template>
<!-- Body: 4 aligned columns -->
<div class="table-body">
<div class="table-col broad-col">
@if (broadKeywords().length > 0) {
<div class="keyword-chip-stack">
<!-- we track the original keywords -->
@for (
keyword of broadKeywords();
track keyword.llm_keyword.keyword
) {
<app-topic-chip
[label]="getChipLabel(keyword)"
[count]="
keywordView() === 'topic'
? getChipCount(keyword)
: null
"
[description]="getChipDescription(keyword)"
[subfieldName]="getChipSubfieldName(keyword)"
[fieldName]="getChipFieldName(keyword)"
[domainName]="getChipDomainName(keyword)"
[color]="getTopicColor(keyword.topic_mapping?.topic)"
[active]="isKeywordSelected(keyword)"
countIcon="article"
descriptionTooltipTarget="button"
(chipClick)="toggleKeywordSelection(keyword)">
</app-topic-chip>
}
</div>
} @else {
<p class="empty-state small">Nichts extrahiert</p>
}
<!-- ===== Desktop / tablet table view ===== -->
@if (!isMobile()) {
<div class="keyword-table">
<div class="table-head">
<div class="head-cell sub-cell broad-sub">Breite Keywords</div>
<div class="head-cell sub-cell coarse-sub">Coarse Keywords</div>
<div class="head-cell sub-cell fine-sub thick-border">
Fine Keywords
</div>
<div class="head-cell sub-cell manual-sub">Eigene Keywords</div>
</div>
<div class="table-col coarse-col">
@if (coarseKeywords().length > 0) {
<div class="keyword-chip-stack">
@for (
keyword of coarseKeywords();
track keyword.llm_keyword.keyword
) {
<app-topic-chip
[label]="getChipLabel(keyword)"
[count]="
keywordView() === 'topic'
? getChipCount(keyword)
: null
"
[description]="getChipDescription(keyword)"
[subfieldName]="getChipSubfieldName(keyword)"
[fieldName]="getChipFieldName(keyword)"
[domainName]="getChipDomainName(keyword)"
[color]="getTopicColor(keyword.topic_mapping?.topic)"
[active]="isKeywordSelected(keyword)"
countIcon="article"
descriptionTooltipTarget="button"
(chipClick)="toggleKeywordSelection(keyword)">
</app-topic-chip>
}
</div>
} @else {
<p class="empty-state small">Nichts extrahiert</p>
}
</div>
<div class="table-body">
<div class="table-col broad-col">
<ng-container
*ngTemplateOutlet="
keywordChipStack;
context: {
keywords: broadKeywords(),
emptyText: 'Nichts extrahiert',
}
"></ng-container>
</div>
<div class="table-col fine-col">
@if (fineKeywords().length > 0) {
<div class="keyword-chip-stack">
@for (
keyword of fineKeywords();
track keyword.llm_keyword.keyword
) {
<app-topic-chip
[label]="getChipLabel(keyword)"
[count]="
keywordView() === 'topic'
? getChipCount(keyword)
: null
"
[description]="getChipDescription(keyword)"
[subfieldName]="getChipSubfieldName(keyword)"
[fieldName]="getChipFieldName(keyword)"
[domainName]="getChipDomainName(keyword)"
[color]="getTopicColor(keyword.topic_mapping?.topic)"
[active]="isKeywordSelected(keyword)"
countIcon="article"
descriptionTooltipTarget="button"
(chipClick)="toggleKeywordSelection(keyword)">
</app-topic-chip>
}
</div>
} @else {
<p class="empty-state small">Nichts extrahiert</p>
}
</div>
<div class="table-col own-col">
<div class="keyword-chip-stack manual-stack">
@if (manualKeywords().length > 0) {
@for (
keyword of manualKeywords();
track keyword.llm_keyword.keyword
) {
<div class="manual-chip-row">
<app-topic-chip
[label]="getChipLabel(keyword)"
[count]="
keywordView() === 'topic'
? getChipCount(keyword)
: null
"
[description]="getChipDescription(keyword)"
[subfieldName]="getChipSubfieldName(keyword)"
[fieldName]="getChipFieldName(keyword)"
[domainName]="getChipDomainName(keyword)"
[color]="getTopicColor(keyword.topic_mapping?.topic)"
[active]="isKeywordSelected(keyword)"
countIcon="article"
descriptionTooltipTarget="button"
(chipClick)="toggleKeywordSelection(keyword)">
</app-topic-chip>
<button
mat-icon-button
type="button"
color="warn"
aria-label="Manuelles Keyword entfernen"
(click)="removeManualKeyword(keyword)">
<mat-icon>cancel</mat-icon>
</button>
</div>
}
} @else if (loadingNewKeyword()) {
<div class="manual-chip-row">
<app-topic-chip
[label]="'Neues Keyword wird hinzugefügt...'">
</app-topic-chip>
</div>
} @else {
<p class="empty-state small">Nichts hinzugefügt</p>
}
<div class="table-col coarse-col">
<ng-container
*ngTemplateOutlet="
keywordChipStack;
context: {
keywords: coarseKeywords(),
emptyText: 'Nichts extrahiert',
}
"></ng-container>
</div>
<div class="table-col fine-col thick-border">
<ng-container
*ngTemplateOutlet="
keywordChipStack;
context: {
keywords: fineKeywords(),
emptyText: 'Nichts extrahiert',
}
"></ng-container>
</div>
<div class="table-col own-col">
<ng-container
*ngTemplateOutlet="manualChipStack"></ng-container>
</div>
</div>
</div>
</div>
} @else {
<!-- ===== Mobile: tabbed view instead of squashed columns ===== -->
<mat-tab-group
class="mobile-keyword-tabs"
animationDuration="150ms">
<mat-tab>
<ng-template mat-tab-label>
<span>Breit</span>
<span class="tab-count">{{ broadKeywords().length }}</span>
</ng-template>
<div class="mobile-tab-panel">
<ng-container
*ngTemplateOutlet="
keywordChipStack;
context: {
keywords: broadKeywords(),
emptyText: 'Nichts extrahiert',
}
"></ng-container>
</div>
</mat-tab>
<mat-tab>
<ng-template mat-tab-label>
<span>Coarse</span>
<span class="tab-count">{{ coarseKeywords().length }}</span>
</ng-template>
<div class="mobile-tab-panel">
<ng-container
*ngTemplateOutlet="
keywordChipStack;
context: {
keywords: coarseKeywords(),
emptyText: 'Nichts extrahiert',
}
"></ng-container>
</div>
</mat-tab>
<mat-tab>
<ng-template mat-tab-label>
<span>Fine</span>
<span class="tab-count">{{ fineKeywords().length }}</span>
</ng-template>
<div class="mobile-tab-panel">
<ng-container
*ngTemplateOutlet="
keywordChipStack;
context: {
keywords: fineKeywords(),
emptyText: 'Nichts extrahiert',
}
"></ng-container>
</div>
</mat-tab>
<mat-tab>
<ng-template mat-tab-label>
<span>Eigene</span>
<span class="tab-count">{{ manualKeywords().length }}</span>
</ng-template>
<div class="mobile-tab-panel">
<ng-container
*ngTemplateOutlet="manualChipStack"></ng-container>
</div>
</mat-tab>
</mat-tab-group>
}
@if (isExtracting()) {
<div class="progress-container">
@@ -300,14 +348,13 @@
</mat-progress-bar>
<div class="status-message">{{ statusMessage() }}</div>
</div>
} @else if (
!extractedKeywordsExist() && manualKeywords().length === 0
) {
} @else if (!keywordsExist()) {
<p class="empty-state">
Keine Keywords vorhanden. Extrahiere Keywords oder füge eigene
hinzu.
Noch keine Keywords vorhanden. Extrahiere Keywords aus URL/Text
oder füge oben eigene Keywords hinzu.
</p>
}
<!-- Source content display -->
@if (sourceContent().length > 0) {
<mat-divider></mat-divider>
@@ -1,8 +1,21 @@
/* ============================================================
DESIGN TOKENS / LOCAL VARIABLES
============================================================ */
$phone: 599px;
$tablet: 900px;
$touch-target: 44px;
/* ============================================================
BASE LAYOUT — container becomes the responsive anchor
============================================================ */
.content {
container-type: inline-size;
container-name: keyword-tool;
display: flex;
flex-direction: column;
gap: 0.75rem;
padding: 1rem;
gap: clamp(0.5rem, 1.5vw, 0.75rem);
padding: clamp(0.5rem, 2vw, 1rem);
}
.tab-content {
@@ -12,12 +25,14 @@
gap: 0.5rem;
align-items: start;
}
.full-width {
width: 100%;
}
.extract-btn {
white-space: nowrap;
min-height: $touch-target;
}
.actions {
@@ -25,6 +40,9 @@
justify-content: center;
}
/* ============================================================
TOOLBAR
============================================================ */
.keywords-toolbar {
display: flex;
flex-direction: column;
@@ -39,9 +57,9 @@
.toolbar-controls {
display: flex;
align-items: center;
justify-content: space-between;
justify-content: center;
gap: 0.75rem;
flex-wrap: wrap;
flex-wrap: nowrap; /* fixed: was invalid "no-wrap" */
padding: 0.5rem 0.75rem;
background: var(--sg-background-muted, #f4f5f7);
}
@@ -50,13 +68,35 @@
grid-template-columns: 3fr 1.3fr;
border-left: 1px solid var(--sg-divider, rgba(0, 0, 0, 0.08));
}
.toolbar-controls--placeholder {
/* invisible spacer, preserves grid column width/position */
visibility: hidden;
pointer-events: none;
}
.manual-input-controls {
min-width: 0;
}
@container keyword-tool (max-width: #{$tablet}) {
.toolbar-wrapper {
grid-template-columns: 1fr;
border-left: none;
}
.toolbar-controls--placeholder {
display: none; /* no need for a spacer once stacked */
}
}
.toolbar-group {
display: flex;
align-items: center;
gap: 0.6rem;
}
.toolbar-group--select button {
.toolbar-group button {
display: flex;
align-items: center;
gap: 0.35rem;
@@ -64,6 +104,7 @@
line-height: 30px;
border-radius: 20px;
padding: 0 14px;
min-height: $touch-target;
mat-icon {
font-size: 20px;
@@ -76,22 +117,29 @@
width: 1px;
align-self: stretch;
background: var(--sg-divider, rgba(0, 0, 0, 0.12));
display: none;
}
@media (min-width: 640px) {
.toolbar-divider {
display: block;
}
}
mat-button-toggle-group {
border-radius: 20px;
overflow: hidden;
justify-content: space-around;
::ng-deep .mat-button-toggle-label-content {
line-height: $touch-target;
}
::ng-deep mat-button-toggle {
width: 100%;
}
}
/* Tablet / phone: stack the toolbar and go full-width */
@media (max-width: 768px) {
/* Container-query driven toolbar collapse (tablet/phone) */
@container keyword-tool (min-width: #{$phone + 1}) {
.toolbar-divider {
display: block;
}
}
@container keyword-tool (max-width: #{$tablet}) {
.toolbar-controls {
flex-direction: column;
align-items: stretch;
@@ -101,35 +149,38 @@ mat-button-toggle-group {
justify-content: center;
}
.toolbar-group--select button {
.toolbar-group button {
width: 100%;
justify-content: center;
}
.toolbar-group--view {
justify-content: center;
.toolbar-wrapper {
grid-template-columns: 1fr;
border-left: none;
}
.toolbar-wrapper .spacer {
width: 100%;
}
}
/* Phone: icon-only buttons to save space */
@media (max-width: 480px) {
/* Phone: icon-only toolbar buttons to save space */
@container keyword-tool (max-width: #{$phone}) {
.btn-label {
display: none;
}
.toolbar-group--select button {
.toolbar-group button {
width: auto;
padding: 0 10px;
padding: 0;
min-width: $touch-target;
justify-content: center;
}
}
mat-button-toggle-group {
flex-wrap: wrap;
}
.toggle-text {
margin-left: 0.35rem;
}
/* ============================================================
EXTRACTION GRID / CARD
============================================================ */
.extraction-grid {
display: grid;
grid-template-columns: 1fr;
@@ -150,7 +201,9 @@ mat-button-toggle-group {
}
}
/* === Table-like keyword grid === */
/* ============================================================
DESKTOP TABLE-LIKE KEYWORD GRID
============================================================ */
.keyword-table {
display: flex;
flex-direction: column;
@@ -161,7 +214,6 @@ mat-button-toggle-group {
padding-top: 0.5rem;
display: grid;
grid-template-columns: repeat(3, 1fr) 1.3fr;
grid-template-rows: auto;
column-gap: 1rem;
border-bottom: 2px solid var(--sg-divider, rgba(0, 0, 0, 0.12));
padding-bottom: 0.5rem;
@@ -173,91 +225,16 @@ mat-button-toggle-group {
text-align: center;
}
.extracted-header {
grid-column: 1 / span 3;
grid-row: 0;
font-size: 0.95rem;
font-weight: 600;
color: var(--sg-text-primary);
align-self: end;
}
.sub-cell {
font-weight: 500;
color: var(--sg-text-secondary);
font-size: 1rem;
font-size: clamp(0.8rem, 1.2vw, 1rem);
text-transform: uppercase;
letter-spacing: 0.05em;
align-self: end;
grid-row: 2;
text-align: center;
}
.broad-sub {
grid-column: 1;
}
.coarse-sub {
grid-column: 2;
}
.fine-sub {
grid-column: 3;
}
.manual-sub {
grid-column: 4;
}
.keyword-input-row {
margin-left: 0.5rem;
width: 100%;
display: grid;
grid-column: 1 / span 4;
display: flex;
align-items: center;
gap: 0.35rem;
&.compact {
.small-field {
flex: 10;
::ng-deep .mat-mdc-text-field-wrapper {
padding: 0 0.6rem;
}
::ng-deep .mat-mdc-form-field-flex {
min-height: 8px;
align-items: center;
}
::ng-deep .mat-mdc-form-field-infix {
min-height: 8px;
padding: 1rem 0;
}
::ng-deep .mat-mdc-form-field-subscript-wrapper {
display: none;
}
::ng-deep input.mat-mdc-input-element {
font-size: 0.8rem;
}
::ng-deep .mat-mdc-form-field-label,
::ng-deep mat-label {
font-size: 1rem;
}
}
button.mat-mdc-icon-button {
width: 28px;
height: 28px;
padding: 0;
line-height: 28px;
flex: 1;
.mat-icon {
font-size: 26px;
width: 26px;
height: 26px;
line-height: 26px;
}
}
}
}
.table-body {
display: grid;
grid-template-columns: repeat(3, 1fr) 1.3fr;
@@ -265,7 +242,6 @@ mat-button-toggle-group {
row-gap: 0.4rem;
align-items: start;
border-left: 1px solid var(--sg-divider, rgba(0, 0, 0, 0.08));
//background: var(--sg-background-muted, #f4f5f7);
}
.table-col {
@@ -279,9 +255,6 @@ mat-button-toggle-group {
&:last-child {
border-right: none;
}
&:nth-child(3) {
border-right: 5px solid var(--sg-divider, rgba(0, 0, 0, 0.1));
}
::ng-deep app-topic-chip {
width: 100%;
@@ -292,9 +265,58 @@ mat-button-toggle-group {
opacity: 0.4;
}
}
.thick-border {
border-right: 5px solid var(--sg-divider, rgba(0, 0, 0, 0.1));
border-right: 5px solid var(--sg-divider, rgba(0, 0, 0, 0.1)) !important;
}
@container keyword-tool (max-width: #{$tablet}) {
.table-head,
.table-body {
column-gap: 0.5rem;
}
.table-col {
padding: 0.4rem;
}
}
/* ============================================================
MOBILE KEYWORD TABS (structural replacement for stacked table)
============================================================ */
.mobile-keyword-tabs {
margin-top: 0.5rem;
::ng-deep .mat-mdc-tab-labels {
justify-content: stretch;
}
::ng-deep .mat-mdc-tab {
flex: 1;
min-height: $touch-target;
}
}
.tab-count {
margin-left: 0.35rem;
font-size: 0.75rem;
font-weight: 600;
color: var(--sg-text-secondary);
background: var(--sg-background-muted, #eceff1);
border-radius: 10px;
padding: 0 6px;
min-width: 18px;
display: inline-block;
text-align: center;
}
.mobile-tab-panel {
padding: 0.75rem 0.25rem;
}
/* ============================================================
CHIP STACKS
============================================================ */
.keyword-chip-stack {
display: flex;
flex-direction: column;
@@ -307,6 +329,7 @@ mat-button-toggle-group {
display: flex;
align-items: center;
width: 100%;
gap: 0.25rem;
app-topic-chip {
flex: 1 1 auto;
@@ -315,6 +338,8 @@ mat-button-toggle-group {
button[mat-icon-button] {
flex: 0 0 auto;
min-width: $touch-target;
min-height: $touch-target;
}
}
@@ -370,12 +395,9 @@ mat-button-toggle-group {
}
}
::ng-deep .mat-mdc-chip-option.compact-chip {
.mat-mdc-chip-action-label {
padding: 0 4px;
}
.mat-mdc-chip-action {
padding: 0 4px;
@container keyword-tool (max-width: #{$tablet}) {
.compact-chip {
width: 100%;
}
}
@@ -391,57 +413,44 @@ mat-button-toggle-group {
}
}
.select-all-container {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
justify-content: space-between;
margin-top: 0.5rem;
button {
display: flex;
justify-content: center;
font-size: 0.75rem;
padding: 0 12px;
line-height: 30px;
mat-icon {
font-size: 26px;
width: 26px;
height: 26px;
}
}
}
/* ============================================================
SEARCH BUTTON (sticky on mobile — improves conversion/UX)
============================================================ */
.search-container {
display: flex;
justify-content: flex-end;
margin-top: 0.5rem;
}
/* ============================================================
RESPONSIVE BREAKPOINTS
============================================================ */
.search-btn {
min-height: $touch-target;
}
/* Tablet: soften columns, keep 4 columns but tighter */
@media (max-width: 1024px) {
.table-head,
.table-body {
column-gap: 0.5rem;
@media (max-width: $phone) {
.search-container {
position: sticky;
bottom: 0;
z-index: 5;
background: var(--sg-background);
padding: 0.75rem 0.5rem;
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}
.table-col {
padding: 0.4rem;
}
.compact-chip {
.search-btn {
width: 100%;
}
}
/* Small tablet / large phone: stack columns */
@media (max-width: 768px) {
.content {
padding: 0.75rem;
/* ============================================================
TABS (URL / Text) — stretch on smaller containers
============================================================ */
@container keyword-tool (max-width: #{$tablet}) {
.content ::ng-deep .mat-mdc-tab-labels {
justify-content: stretch;
}
.content ::ng-deep .mat-mdc-tab {
flex: 1;
}
.tab-content {
@@ -452,87 +461,13 @@ mat-button-toggle-group {
width: 100%;
justify-content: center;
}
.table-head,
.table-body {
grid-template-columns: 1fr;
}
.table-head {
display: none; /* labels are redundant once stacked; see column titles below */
}
.table-col {
border-right: none;
border-bottom: 1px solid var(--sg-divider, rgba(0, 0, 0, 0.08));
padding: 0.75rem 0.25rem;
&:nth-child(3) {
border-right: none;
border-bottom: 3px solid var(--sg-divider, rgba(0, 0, 0, 0.08));
}
&:last-child {
border-bottom: none;
}
/* Re-introduce a column label since .table-head is hidden */
&::before {
content: attr(data-col-label);
font-weight: 500;
font-size: 0.85rem;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--sg-text-secondary);
margin-bottom: 0.35rem;
display: block;
}
}
.extracted-header {
grid-column: 1;
grid-row: 1;
}
.own-header {
grid-column: 1;
grid-row: 2;
}
.actions {
align-self: center;
justify-content: flex-start;
}
.search-container,
.select-all-container {
justify-content: stretch;
flex-direction: column;
}
.search-btn,
.select-all-container button {
width: 100%;
}
.view-toggle-row {
justify-content: center;
text-align: center;
}
mat-button-toggle-group {
width: 100%;
::ng-deep .mat-button-toggle {
flex: 1;
}
}
}
/* Phone: tighten further, reduce chip/font sizes */
@media (max-width: 480px) {
/* ============================================================
PHONE-SPECIFIC FINE-TUNING
============================================================ */
@container keyword-tool (max-width: #{$phone}) {
.content {
padding: 0.5rem;
gap: 0.5rem;
}
@@ -540,8 +475,7 @@ mat-button-toggle-group {
padding: 0.35rem;
}
.sub-cell,
.toggle-text {
.sub-cell {
font-size: 0.8rem;
}
@@ -559,7 +493,9 @@ mat-button-toggle-group {
}
}
/* Source expansion panel */
/* ============================================================
SOURCE EXPANSION PANEL
============================================================ */
.source-expansion {
margin: 0.75rem 0;
background: var(--sg-background-muted, #f5f5f5);
@@ -610,6 +546,9 @@ mat-button-toggle-group {
}
}
/* ============================================================
PROGRESS BAR
============================================================ */
.progress-container {
margin-top: 1rem;
padding: 0.5rem 0;
@@ -625,10 +564,7 @@ mat-button-toggle-group {
&::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
inset: 0;
pointer-events: none;
background: linear-gradient(
105deg,
@@ -657,3 +593,21 @@ mat-button-toggle-group {
transform: translateX(100%);
}
}
/* ============================================================
ACCESSIBILITY
============================================================ */
@media (prefers-reduced-motion: reduce) {
.compact-chip,
.progress-container mat-progress-bar::after {
animation: none !important;
transition: none !important;
}
}
button:focus-visible,
.mat-button-toggle:focus-visible,
::ng-deep .mat-mdc-tab:focus-visible {
outline: 2px solid var(--sg-primary, #1976d2);
outline-offset: 2px;
}
@@ -1,10 +1,5 @@
import {
Component,
computed,
signal,
Signal,
WritableSignal,
} from '@angular/core';
import { Component, computed, signal, inject } from '@angular/core';
import { BreakpointObserver } from '@angular/cdk/layout';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
@@ -30,6 +25,9 @@ import { TopicAutocompleteComponent } from '../../shared/ui/topic-autocomplete/t
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
import { TopicLegendComponent } from '../../shared/ui/topic-legend/topic-legend.component';
import { Topic } from '../../api/model/topic';
import { NgTemplateOutlet } from '@angular/common';
import { map } from 'rxjs/operators';
import { toSignal } from '@angular/core/rxjs-interop';
import {
MatButtonToggleModule,
MatButtonToggleGroup,
@@ -68,6 +66,7 @@ type KeywordView = 'llm' | 'topic';
MatButtonToggleGroup,
MatTooltipModule,
A11yModule,
NgTemplateOutlet,
],
templateUrl: './keywords-search.component.html',
styleUrl: './keywords-search.component.scss',
@@ -80,7 +79,15 @@ export class KeywordsSearchComponent {
});
private readonly SESSION_KEY = 'keywords-search-source';
// in component class:
private breakpointObserver = inject(BreakpointObserver);
isMobile = toSignal(
this.breakpointObserver
.observe('(max-width: 768px)')
.pipe(map((r) => r.matches)),
{ initialValue: false },
);
// Category signals - the full backend entries are the source of truth;
// the *Keywords() computed signals below just project the label out of them.
private readonly broadKeywordEntries = signal<KeywordEntryWithTopic[]>([]);
@@ -98,11 +105,12 @@ export class KeywordsSearchComponent {
readonly loadingNewKeyword = signal(false);
readonly extractionSource = signal<InputMode | null>(null);
readonly extractedKeywordsExist = computed(
readonly keywordsExist = computed(
() =>
this.broadKeywords().length > 0 ||
this.coarseKeywords().length > 0 ||
this.fineKeywords().length > 0,
this.fineKeywords().length > 0 ||
this.manualKeywords().length > 0,
);
readonly sourceContent = signal<string>('');
@@ -309,12 +317,8 @@ export class KeywordsSearchComponent {
...this.getKeywordLabels(this.manualKeywords()),
].some((k) => this.normalizeKeyword(k) === normalized);
}
// Add manually from Keywords tab
addKeywordFromInput(keyword: string): void {
this.loadingNewKeyword.set(true);
const normalizedKeyword = keyword.trim();
addKeywordFromInput(keyword: Topic): void {
const normalizedKeyword = keyword.display_name?.trim() ?? '';
if (!normalizedKeyword) return;
if (this.keywordExists(normalizedKeyword)) {
@@ -322,35 +326,54 @@ export class KeywordsSearchComponent {
return;
}
this.topicsService.vectorSearchTopics(normalizedKeyword).subscribe({
next: ({ results }) => {
const newEntry: KeywordEntryWithTopic = {
llm_keyword: {
keyword: normalizedKeyword,
relevance_score: 1,
},
topic_mapping: {
keyword: normalizedKeyword,
topic: results?.[0],
},
};
this.loadingNewKeyword.set(true);
const updated = this.uniqueKeywordEntries([
...this.manualKeywordEntries(),
newEntry,
]);
if (keyword.id === null) {
console.log('Adding new keyword without topic:', normalizedKeyword);
this.topicsService.vectorSearchTopics(normalizedKeyword).subscribe({
next: ({ results }) => {
const newEntry: KeywordEntryWithTopic = {
llm_keyword: { keyword: normalizedKeyword, relevance_score: 1 },
topic_mapping: { keyword: normalizedKeyword, topic: results?.[0] },
};
this.manualKeywordEntries.set(updated);
this.selectedKeywords.set([
...this.selectedKeywords(),
normalizedKeyword,
]);
this.loadingNewKeyword.set(false);
// Explicit enrichment trigger for new keywords
this.enrichManualKeywordsWithTopics([normalizedKeyword]);
this.updateQueryParams();
},
});
this.manualKeywordEntries.set(
this.uniqueKeywordEntries([
...this.manualKeywordEntries(),
newEntry,
]),
);
this.selectedKeywords.set([
...this.selectedKeywords(),
normalizedKeyword,
]);
this.loadingNewKeyword.set(false);
this.updateQueryParams(); // now fires after state is actually updated
},
error: (err) => {
console.error('vectorSearchTopics failed', err);
this.loadingNewKeyword.set(false);
this.statusMessage.set(
`Fehler beim Hinzufügen von "${normalizedKeyword}".`,
);
},
});
} else {
console.log('we dont search', keyword);
const newEntry: KeywordEntryWithTopic = {
llm_keyword: { keyword: normalizedKeyword, relevance_score: 1 },
topic_mapping: { keyword: normalizedKeyword, topic: keyword },
};
this.manualKeywordEntries.set(
this.uniqueKeywordEntries([...this.manualKeywordEntries(), newEntry]),
);
this.selectedKeywords.set([
...this.selectedKeywords(),
normalizedKeyword,
]);
this.loadingNewKeyword.set(false);
this.updateQueryParams();
}
}
removeSelectedKeyword(keyword: string): void {
@@ -388,7 +411,7 @@ export class KeywordsSearchComponent {
this.updateQueryParams();
}
selectAllExtracted(): void {
selectAll(): void {
const all = [
...this.getKeywordLabels(this.manualKeywords()),
...this.getKeywordLabels(this.broadKeywords()),
@@ -399,10 +422,8 @@ export class KeywordsSearchComponent {
this.updateQueryParams();
}
deselectAllExtracted(): void {
this.selectedKeywords.set(
this.uniqueKeywords(this.getKeywordLabels(this.manualKeywords())),
);
deselectAll(): void {
this.selectedKeywords.set([]);
this.updateQueryParams();
}
@@ -410,6 +431,7 @@ export class KeywordsSearchComponent {
this.broadKeywordEntries.set([]);
this.coarseKeywordEntries.set([]);
this.fineKeywordEntries.set([]);
this.manualKeywordEntries.set([]);
this.sourceContent.set('');
this.sourceUrl.set(null);
@@ -428,11 +450,12 @@ export class KeywordsSearchComponent {
this.updateQueryParams();
}
areAllExtractedSelected(): boolean {
areAllSelected(): boolean {
const allExtracted = [
...this.getKeywordLabels(this.broadKeywords()),
...this.getKeywordLabels(this.coarseKeywords()),
...this.getKeywordLabels(this.fineKeywords()),
...this.getKeywordLabels(this.manualKeywords()),
];
return allExtracted.every((k) => this.selectedKeywords().includes(k));
}