Skip to content

Commit b25295c

Browse files
author
Jicheng Lu
committed
refine option card style
1 parent 1f638b4 commit b25295c

File tree

4 files changed

+66
-30
lines changed

4 files changed

+66
-30
lines changed

src/lib/scss/custom/pages/_chat.scss

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
flex-direction: column;
170170
width: 80%;
171171

172-
.video-group-container {
172+
.video-option-container {
173173
display: flex;
174174
flex-wrap: wrap;
175175
gap: 5px;
@@ -248,26 +248,32 @@
248248
max-width: 100%;
249249
}
250250

251-
.card-element-title {
252-
font-size: 0.8rem;
253-
font-weight: 700;
254-
height: 30%;
255-
}
256-
257-
.card-element-subtitle {
258-
font-size: 0.7rem;
259-
font-weight: 500;
260-
height: 8%;
261-
}
262-
263-
.card-option-group {
264-
margin-top: 5px;
251+
.card-element-body {
252+
display: flex;
253+
flex-direction: column;
254+
justify-content: space-evenly;
255+
gap: 5px;
256+
padding: 10px 15px;
265257

266-
.btn {
267-
display: block;
268-
margin-left: 0px !important;
269-
text-align: left;
270-
border-radius: 10px;
258+
.card-element-title {
259+
font-size: 0.8rem;
260+
font-weight: 700;
261+
}
262+
263+
.card-element-subtitle {
264+
font-size: 0.7rem;
265+
font-weight: 500;
266+
}
267+
268+
.card-option-group {
269+
margin-top: 5px;
270+
271+
.btn {
272+
display: block;
273+
margin-left: 0px !important;
274+
text-align: left;
275+
border-radius: 10px;
276+
}
271277
}
272278
}
273279
}

src/routes/chat/[agentId]/[conversationId]/chat-box.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
isFrame = $page.url.searchParams.get('isFrame') === 'true';
151151
// initial condition
152152
isContentLogClosed = false;
153-
isStateLogClosed = false;
153+
isStateLogClosed = true;
154154
resizeChatWindow();
155155
}
156156

src/routes/chat/[agentId]/[conversationId]/richContent/rc-complex-options.svelte

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
1717
/** @type {any[]} */
1818
let cards = [];
19+
/** @type {any[]} */
20+
let buttons = [];
1921
2022
onMount(() => {
2123
reset();
@@ -25,12 +27,14 @@
2527
2628
/** @param {any[]} options */
2729
function collectOptions(options) {
28-
cards = options?.map(op => {
30+
cards = options?.filter(op => !!op.title || !!op.subtitle)?.map(op => {
2931
// @ts-ignore
30-
const options = op.buttons?.filter(op => !!op.title && !!op.payload)?.map(x => {
32+
const options = op.buttons?.filter(x => !!x.title && !!x.payload)?.map(x => {
3133
return {
3234
title: x.title,
33-
payload: x.payload
35+
payload: x.payload,
36+
is_primary: x.is_primary,
37+
is_secondary: x.is_secondary,
3438
};
3539
}) || [];
3640
@@ -40,6 +44,18 @@
4044
options: options
4145
};
4246
}) || [];
47+
48+
buttons = options?.filter(op => !!!op.title && !!!op.subtitle)?.flatMap(op => {
49+
// @ts-ignore
50+
return op.buttons?.filter(x => !!x.title && !!x.payload)?.map(x => {
51+
return {
52+
title: x.title,
53+
payload: x.payload,
54+
is_primary: x.is_primary,
55+
is_secondary: x.is_secondary,
56+
};
57+
}) || [];;
58+
}) || [];
4359
}
4460
4561
/**
@@ -69,18 +85,18 @@
6985
<div class="complex-option-container">
7086
{#each cards as card, idx (idx)}
7187
<Card class="card-element">
72-
<CardBody>
88+
<CardBody class="card-element-body">
7389
{#if !!card.title}
74-
<div class="card-element-title mb-3">{card.title}</div>
90+
<div class="card-element-title hide-text">{card.title}</div>
7591
{/if}
7692
{#if !!card.subtitle}
77-
<div class="card-element-subtitle mb-3">{card.subtitle}</div>
93+
<div class="card-element-subtitle hide-text">{card.subtitle}</div>
7894
{/if}
7995
{#if card.options?.length > 0}
8096
<div class="card-option-group">
8197
{#each card.options as option, i (i)}
8298
<button
83-
class="btn btn-outline-primary btn-sm m-1"
99+
class={`btn btn-sm m-1 ${option.is_secondary ? 'btn-outline-secondary': 'btn-outline-primary'}`}
84100
disabled={disableOption}
85101
on:click={(e) => handleClickOption(e, option)}
86102
>
@@ -94,3 +110,17 @@
94110
{/each}
95111
</div>
96112
{/if}
113+
114+
{#if buttons.length > 0}
115+
<div class="plain-option-container" style="margin-top: 5px;">
116+
{#each buttons as option, index}
117+
<button
118+
class={`btn btn-sm m-1 ${option.is_secondary ? 'btn-outline-secondary': 'btn-outline-primary'}`}
119+
disabled={disableOption}
120+
on:click={(e) => handleClickOption(e, option)}
121+
>
122+
{option.title}
123+
</button>
124+
{/each}
125+
</div>
126+
{/if}

src/routes/chat/[agentId]/[conversationId]/richContent/rc-plain-options.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
export let options = [];
1515
1616
/** @type {(args0: string, args1: string) => any} */
17-
export let onConfirm;
17+
export let onConfirm = () => {};
1818
1919
/** @type {() => any} */
2020
export let refresh = () => {};
@@ -113,7 +113,7 @@
113113
114114
{#if videoOptions.length > 0}
115115
<div>
116-
<div class="video-group-container">
116+
<div class="video-option-container">
117117
{#each videoOptions as video, index}
118118
<Card class="video-element-card">
119119
<CardBody>

0 commit comments

Comments
 (0)