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

feat: add className property for adding CSS classes to messages #6628

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions packages/message-list/src/vaadin-message-list.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface MessageListItem {
userImg?: string;
userColorIndex?: number;
theme?: string;
className?: string;
}

/**
Expand Down Expand Up @@ -62,6 +63,7 @@ declare class MessageList extends KeyboardDirectionMixin(ThemableMixin(ElementMi
* userAbbr: string,
* userImg: string,
* userColorIndex: number,
* className: string,
* theme: string
* }>
* ```
Expand Down
2 changes: 2 additions & 0 deletions packages/message-list/src/vaadin-message-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class MessageList extends KeyboardDirectionMixin(ElementMixin(ThemableMixin(Poly
* userAbbr: string,
* userImg: string,
* userColorIndex: number,
* className: string,
* theme: string
* }>
* ```
Expand Down Expand Up @@ -160,6 +161,7 @@ class MessageList extends KeyboardDirectionMixin(ElementMixin(ThemableMixin(Poly
.userImg="${item.userImg}"
.userColorIndex="${item.userColorIndex}"
theme="${ifDefined(item.theme)}"
class="${ifDefined(item.className)}"
@focusin="${this._onMessageFocusIn}"
>${item.text}</vaadin-message
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,28 @@ snapshots["vaadin-message-list theme"] =
`;
/* end snapshot vaadin-message-list theme */

snapshots["vaadin-message-list className"] =
`<vaadin-message-list
aria-relevant="additions"
role="log"
>
<vaadin-message
class="pinned"
role="listitem"
tabindex="0"
>
Where to start
<vaadin-avatar
abbr="A"
aria-hidden="true"
name="Admin"
role="button"
slot="avatar"
tabindex="-1"
>
</vaadin-avatar>
</vaadin-message>
</vaadin-message-list>
`;
/* end snapshot vaadin-message-list className */

6 changes: 6 additions & 0 deletions packages/message-list/test/dom/message-list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@ describe('vaadin-message-list', () => {
await nextFrame();
await expect(list).dom.to.equalSnapshot();
});

it('className', async () => {
list.items = [{ text: 'Where to start', userName: 'Admin', className: 'pinned' }];
await nextFrame();
await expect(list).dom.to.equalSnapshot();
});
});
1 change: 1 addition & 0 deletions packages/message-list/test/typings/message-list.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ assertType<string | undefined>(item.userAbbr);
assertType<string | undefined>(item.userImg);
assertType<number | undefined>(item.userColorIndex);
assertType<string | undefined>(item.theme);
assertType<string | undefined>(item.className);

// Mixins
assertType<ElementMixinClass>(list);
Expand Down