Skip to content

Commit

Permalink
chore: cleanup tabs and teaser list
Browse files Browse the repository at this point in the history
  • Loading branch information
shibbas committed Nov 18, 2023
1 parent b1f47a4 commit 5f34b92
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 72 deletions.
30 changes: 14 additions & 16 deletions packages/chat-component/src/components/chat-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,13 @@ export class ChatComponent extends LitElement {
${this.isDefaultPromptsEnabled
? html`
<teaser-list-component
.title="${this.interactionModel === 'chat'
.heading="${this.interactionModel === 'chat'
? teaserListTexts.HEADING_CHAT
: teaserListTexts.HEADING_ASK}"
.clickable="${true}"
.actionLabel="${teaserListTexts.TEASER_CTA_LABEL}"
@teaser-click="${this.handleQuestionInputClick}"
.teasers="${teaserListTexts.DEFAULT_PROMPTS}"
.label="${teaserListTexts.TEASER_CTA_LABEL}"
></teaser-list-component>
`
: ''}
Expand Down Expand Up @@ -547,21 +548,18 @@ export class ChatComponent extends LitElement {
] as TabContent[]}"
.selectedTabId="${this.selectedAsideTab}"
>
<div slot="tab-thought-process">
<h3 class="subheadline--small">${globalConfig.THOUGHT_PROCESS_LABEL}</h3>
<div class="tab-component__innerContainer">
${this.chatThoughts
? html` <p class="tab-component__paragraph">${unsafeHTML(this.chatThoughts)}</p> `
: ''}
</div>
<div slot="tab-thought-process" class="tab-component__content">
${this.chatThoughts
? html` <p class="tab-component__paragraph">${unsafeHTML(this.chatThoughts)}</p> `
: ''}
</div>
<div slot="tab-support-context">
<h3 class="subheadline--small">${globalConfig.SUPPORT_CONTEXT_LABEL}</h3>
<ul class="defaults__list always-row">
${this.chatDataPoints?.map(
(dataPoint) => html` <li class="defaults__listItem">${dataPoint}</li> `,
)}
</ul>
<div slot="tab-support-context" class="tab-component__content">
<teaser-list-component
.alwaysRow="${true}"
.teasers="${this.chatDataPoints?.map((d) => {
return { description: d };
})}"
></teaser-list-component>
</div>
<div slot="tab-citations" class="tab-component__content">
<citation-list
Expand Down
37 changes: 24 additions & 13 deletions packages/chat-component/src/components/teaser-list-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ export class TeaserListComponent extends LitElement {
teasers: Teaser[] = [];

@property({ type: String })
title: string = '';
heading: string | undefined = undefined;

@property({ type: String })
label: string = '';
actionLabel: string | undefined = undefined;

@property({ type: Boolean })
alwaysRow = false;

@property({ type: Boolean })
clickable = false;

// Handle the click on a default prompt
handleTeaserClick(teaser: Teaser, event?: Event): void {
Expand All @@ -32,23 +38,28 @@ export class TeaserListComponent extends LitElement {
this.dispatchEvent(teaserClickEvent);
}

renderClickableTeaser(teaser: Teaser) {
return html`
<a
role="button"
href="#"
data-testid="default-question"
@click="${(event: Event) => this.handleTeaserClick(teaser, event)}"
>
${teaser.description}
<span class="teaser-click-label">${this.actionLabel}</span>
</a>
`;
}
override render() {
return html`
<div class="teaser-list-container">
<h1 class="headline">${this.title}</h1>
<ul class="teaser-list">
${this.heading ? html`<h1 class="headline">${this.heading}</h1>` : ''}
<ul class="teaser-list ${this.alwaysRow ? 'always-row' : ''}">
${this.teasers.map(
(teaser) => html`
<li class="teaser-list-item">
<a
role="button"
href="#"
data-testid="default-question"
@click="${(event: Event) => this.handleTeaserClick(teaser, event)}"
>
${teaser.description}
<span>${this.label}</span>
</a>
${this.clickable ? this.renderClickableTeaser(teaser) : teaser.description}
</li>
`,
)}
Expand Down
46 changes: 4 additions & 42 deletions packages/chat-component/src/styles/chat-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ export const chatStyle = css`
padding: 0;
margin: 0;
}
.subheadline--small {
font-size: 12px;
display: inline-block;
}
.chat__container {
min-width: 100%;
transition: width 0.3s ease-in-out;
Expand Down Expand Up @@ -254,48 +250,14 @@ export const chatStyle = css`
display: flex;
justify-content: end;
}
.tab-component__content {
padding: 20px 20px 20px 0px;
}
.tab-component__paragraph {
font-family: monospace;
font-size: large;
border: 1px solid var(--light-gray);
padding: 20px;
border-radius: 25px;
}
.defaults__list {
list-style-type: none;
padding: 0;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
}
.defaults__list.always-row {
text-align: left;
}
.defaults__list:not(.always-row) {
@media (min-width: 1024px) {
flex-direction: row;
}
}
.defaults__listItem {
padding: 10px;
border-radius: 10px;
background: var(--white);
margin: 4px;
color: var(--text-color);
justify-content: space-evenly;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border: 3px solid transparent;
@media (min-width: 768px) {
min-height: 100px;
}
}
.defaults__listItem:hover,
.defaults__listItem:focus {
color: var(--accent-dark);
background: var(--secondary-color);
transition: all 0.3s ease-in-out;
border-color: var(--accent-high);
padding: 20px;
}
`;
7 changes: 6 additions & 1 deletion packages/chat-component/src/styles/teaser-list-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export const styles = css`
display: flex;
flex-direction: column;
justify-content: center;
}
.teaser-list.always-row {
text-align: left;
}
.teaser-list:not(.always-row) {
@media (min-width: 1024px) {
flex-direction: row;
}
Expand All @@ -50,7 +55,7 @@ export const styles = css`
transition: all 0.3s ease-in-out;
border-color: var(--accent-high);
}
.teaser-list-item span {
.teaser-list-item .teaser-click-label {
color: var(--accent-high);
font-weight: bold;
display: block;
Expand Down

0 comments on commit 5f34b92

Please sign in to comment.