-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use component extensions for theming (#50)
- Loading branch information
Showing
28 changed files
with
271 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { AvatarElement } from '@vaadin/vaadin-avatar/src/vaadin-avatar.js'; | ||
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; | ||
|
||
registerStyles( | ||
'vaadin-message-avatar', | ||
css` | ||
:host { | ||
--vaadin-avatar-outline-width: 0px; /* stylelint-disable-line length-zero-no-unit */ | ||
flex-shrink: 0; | ||
} | ||
`, | ||
{ moduleId: 'vaadin-message-avatar-styles' } | ||
); | ||
|
||
/** | ||
* The avatar element for message. | ||
* | ||
* ### Styling | ||
* | ||
* See [`<vaadin-avatar>` documentation](https://github.com/vaadin/vaadin-avatar/blob/master/src/vaadin-avatar.js) | ||
* for `<vaadin-message-avatar>` parts and available slots | ||
* | ||
* See [ThemableMixin – how to apply styles for shadow parts](https://github.com/vaadin/vaadin-themable-mixin#readme) | ||
* | ||
* @extends AvatarElement | ||
*/ | ||
class MessageAvatarElement extends AvatarElement { | ||
static get is() { | ||
return 'vaadin-message-avatar'; | ||
} | ||
|
||
static get version() { | ||
return '2.0.0-alpha1'; | ||
} | ||
} | ||
|
||
customElements.define(MessageAvatarElement.is, MessageAvatarElement); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { ButtonElement } from '@vaadin/vaadin-button/src/vaadin-button.js'; | ||
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; | ||
|
||
registerStyles( | ||
'vaadin-message-input-button', | ||
css` | ||
:host { | ||
flex-shrink: 0; | ||
margin: 0; | ||
} | ||
`, | ||
{ moduleId: 'vaadin-message-input-button-styles' } | ||
); | ||
|
||
/** | ||
* The button element for a message input. | ||
* | ||
* ### Styling | ||
* | ||
* See [`<vaadin-button>` documentation](https://github.com/vaadin/vaadin-button/blob/master/src/vaadin-button.js) | ||
* for `<vaadin-message-input-button>` parts and available slots | ||
* | ||
* See [ThemableMixin – how to apply styles for shadow parts](https://github.com/vaadin/vaadin-themable-mixin#readme) | ||
* | ||
* @extends ButtonElement | ||
*/ | ||
class MessageInputButtonElement extends ButtonElement { | ||
static get is() { | ||
return 'vaadin-message-input-button'; | ||
} | ||
|
||
static get version() { | ||
return '2.0.0-alpha1'; | ||
} | ||
} | ||
|
||
customElements.define(MessageInputButtonElement.is, MessageInputButtonElement); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { TextAreaElement } from '@vaadin/vaadin-text-field/src/vaadin-text-area.js'; | ||
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; | ||
|
||
registerStyles( | ||
'vaadin-message-input-text-area', | ||
css` | ||
:host { | ||
align-self: stretch; | ||
flex-grow: 1; | ||
padding: 0; | ||
} | ||
`, | ||
{ moduleId: 'vaadin-message-input-text-area-styles' } | ||
); | ||
|
||
/** | ||
* The text area element for a message input. | ||
* | ||
* ### Styling | ||
* | ||
* See [`<vaadin-text-area>` documentation](https://github.com/vaadin/vaadin-text-field/blob/master/src/vaadin-text-area.js) | ||
* for `<vaadin-message-input-text-area>` parts and available slots | ||
* | ||
* See [ThemableMixin – how to apply styles for shadow parts](https://github.com/vaadin/vaadin-themable-mixin#readme) | ||
* | ||
* @extends TextAreaElement | ||
*/ | ||
class MessageInputTextAreaElement extends TextAreaElement { | ||
static get is() { | ||
return 'vaadin-message-input-text-area'; | ||
} | ||
|
||
static get version() { | ||
return '2.0.0-alpha1'; | ||
} | ||
|
||
ready() { | ||
super.ready(); | ||
|
||
const textarea = this.inputElement; | ||
textarea.removeAttribute('aria-labelledby'); | ||
|
||
// Set initial height to one row | ||
textarea.setAttribute('rows', 1); | ||
textarea.style.minHeight = '0'; | ||
|
||
// Add enter handling for text area. | ||
textarea.addEventListener('keydown', (e) => { | ||
if (e.key === 'Enter' && !e.shiftKey) { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
this.dispatchEvent(new CustomEvent('enter')); | ||
} | ||
}); | ||
} | ||
|
||
_setAriaLabel(message) { | ||
// Set aria-label to provide an accessible name for the labelless input | ||
this.inputElement.setAttribute('aria-label', message); | ||
} | ||
} | ||
|
||
customElements.define(MessageInputTextAreaElement.is, MessageInputTextAreaElement); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+36 Bytes
(100%)
test/visual/screens/vaadin-message/material-message-list-ltr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; | ||
import '@vaadin/vaadin-avatar/theme/lumo/vaadin-avatar-styles.js'; | ||
|
||
registerStyles( | ||
'vaadin-message-avatar', | ||
css` | ||
:host { | ||
margin-right: calc(var(--lumo-space-m) - var(--vaadin-avatar-outline-width)); | ||
margin-top: calc(var(--lumo-space-s) - var(--vaadin-avatar-outline-width)); | ||
} | ||
:host([dir='rtl']) { | ||
margin-left: calc(var(--lumo-space-m) - var(--vaadin-avatar-outline-width)); | ||
margin-right: calc(var(--vaadin-avatar-outline-width) * -1); | ||
} | ||
`, | ||
{ moduleId: 'lumo-message-avatar' } | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './vaadin-message-avatar-styles.js'; | ||
import '../../src/vaadin-message-avatar.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; | ||
import '@vaadin/vaadin-button/theme/lumo/vaadin-button-styles.js'; | ||
|
||
registerStyles('vaadin-message-input-button', css``, { moduleId: 'lumo-message-input-button' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './vaadin-message-input-button-styles.js'; | ||
import '../../src/vaadin-message-input-button.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; | ||
import '@vaadin/vaadin-text-field/theme/lumo/vaadin-text-area-styles.js'; | ||
import '@vaadin/vaadin-text-field/theme/lumo/vaadin-text-field-styles.js'; | ||
|
||
registerStyles( | ||
'vaadin-message-input-text-area', | ||
css` | ||
:host { | ||
margin: 0 var(--lumo-space-s) 0 0; | ||
} | ||
:host([dir='rtl']) { | ||
margin: 0 0 0 var(--lumo-space-s); | ||
} | ||
`, | ||
{ moduleId: 'lumo-message-input-text-area' } | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './vaadin-message-input-text-area-styles.js'; | ||
import '../../src/vaadin-message-input-text-area.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
import './vaadin-message-input-styles.js'; | ||
import './vaadin-message-input-text-area.js'; | ||
import './vaadin-message-input-button.js'; | ||
import '../../src/vaadin-message-input.js'; |
Oops, something went wrong.