Skip to content

Commit

Permalink
Added shadow part for non parsed text, overflow ellipsis for text in …
Browse files Browse the repository at this point in the history
…button (quick reply) (#92)

* Added shadow part for non parsed text, overflow ellipsis for text in button (quick reply)

* Updated tests
  • Loading branch information
petar-basic authored Nov 14, 2024
1 parent 839f336 commit 87ceccb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
9 changes: 9 additions & 0 deletions packages/ui/src/components/quick-reply/quick-reply.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
flex-wrap: wrap;
padding: 0 40px;

rasa-text::part(text) {
width: calc(100%);
max-width: 250px;
text-overflow: ellipsis;
display: inline-block;
white-space: nowrap;
overflow: hidden;
}

&--disabled {
pointer-events: none;
opacity: 0.5;
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/quick-reply/quick-reply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class RasaQuickReply {
{canShowText && this.quickReplyMessage.replies.length && (
<div class={buttonsClassList}>
{this.quickReplyMessage.replies.map((button, key) => (
<rasa-button {...button} key={key} isSelected={button.isSelected}>
<rasa-button {...button} key={key} isSelected={button.isSelected} title={button.text}>
<rasa-text value={button.text} disableParsing={true}></rasa-text>
</rasa-button>
))}
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/text-message/text-message.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('rasa-text-message', () => {
<mock:shadow-root>
<rasa-text>
<mock:shadow-root>
<span class="text">
<span class="text" part="text">
Hello, World!
</span>
</mock:shadow-root>
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('rasa-text-message', () => {
<mock:shadow-root>
<rasa-text>
<mock:shadow-root>
<span class="text">
<span class="text" part="text">
User message
</span>
</mock:shadow-root>
Expand Down
7 changes: 7 additions & 0 deletions packages/ui/src/components/text/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
| `textStreamComplete` | Trigger on stream complete | `CustomEvent<{ value: true; }>` |


## Shadow Parts

| Part | Description |
| -------- | ----------- |
| `"text"` | |


## Dependencies

### Used by
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/text/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class RasaText {
if (this.disableParsing) {
return (
<Host>
<span class="text">{this.value}</span>
<span class="text" part="text">{this.value}</span>
</Host>
);
}
Expand Down

0 comments on commit 87ceccb

Please sign in to comment.