-
Notifications
You must be signed in to change notification settings - Fork 0
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
Input element #24
Input element #24
Changes from 21 commits
b42b249
0e21663
5a936c8
2139248
91dab9f
c020c00
e8f8b33
7395774
ba2a70e
f0afdc1
01c3389
f9bc1ca
bb8824d
9f42b6b
6433840
275d4fe
f1b7fde
766c9a9
0890804
e693e02
a3ba66a
a956012
06198dc
28a6f7d
a4230f8
4aaf667
50c18fa
9950619
345677e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
|
||
import { ElementMixin } from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js'; | ||
|
||
/** | ||
* `<vaadin-message-input>` is a Web Component ... | ||
*/ | ||
Peppe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
declare class MessageInputElement extends ThemableMixin(ElementMixin(HTMLElement)) {} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'vaadin-message-input': MessageInputElement; | ||
} | ||
} | ||
|
||
export { MessageInputElement }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
Peppe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js'; | ||
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
import { ElementMixin } from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js'; | ||
import '@vaadin/vaadin-button/src/vaadin-button.js'; | ||
import '@vaadin/vaadin-text-field/src/vaadin-text-area.js'; | ||
/** | ||
* `<vaadin-message-input>` is a Web Component ... | ||
*/ | ||
Peppe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
class MessageInputElement extends ElementMixin(ThemableMixin(PolymerElement)) { | ||
static get template() { | ||
return html` | ||
<style> | ||
:host { | ||
align-items: flex-start; | ||
box-sizing: border-box; | ||
display: flex; | ||
max-height: 50vh; | ||
overflow: hidden; | ||
} | ||
vaadin-text-area { | ||
align-self: stretch; | ||
flex-grow: 1; | ||
padding: 0; | ||
} | ||
vaadin-button { | ||
flex-shrink: 0; | ||
margin: 0; | ||
} | ||
</style> | ||
<vaadin-text-area placeholder="Message"></vaadin-text-area> | ||
Peppe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<vaadin-button theme="primary contained">Send</vaadin-button> | ||
Peppe marked this conversation as resolved.
Show resolved
Hide resolved
pekam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`; | ||
} | ||
|
||
ready() { | ||
super.ready(); | ||
|
||
// Set aria-label to provide an accessible name for the labelless input | ||
const textarea = this.shadowRoot.querySelector('vaadin-text-area').inputElement; | ||
pekam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
textarea.setAttribute('aria-label', 'Message'); | ||
Peppe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
textarea.removeAttribute('aria-labelledby'); | ||
|
||
// Set initial height to one row | ||
textarea.setAttribute('rows', 1); | ||
textarea.style.minHeight = '0'; | ||
} | ||
|
||
static get is() { | ||
return 'vaadin-message-input'; | ||
} | ||
|
||
static get version() { | ||
return '1.0.0-alpha1'; | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: please place these getters after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
customElements.define(MessageInputElement.is, MessageInputElement); | ||
|
||
export { MessageInputElement }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!DOCTYPE html> | ||
Peppe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Message tests</title> | ||
<script> | ||
window.polymerSkipLoadingFontRoboto = true; | ||
</script> | ||
<style> | ||
html { | ||
--vaadin-user-color-1: blue; | ||
--vaadin-user-color-2: green; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="tests" style="padding: 10px"> | ||
<vaadin-message-list></vaadin-message-list> | ||
<vaadin-message-input></vaadin-message-input> | ||
Peppe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
|
||
<script type="module"> | ||
(async () => { | ||
const theme = window.location.search.replace(/.*theme=(\w+).*/, '$1') || 'lumo'; | ||
|
||
await import('../../theme/' + theme + '/vaadin-message-list.js'); | ||
await import('../../theme/' + theme + '/vaadin-message-input.js'); | ||
|
||
window.requestAnimationFrame(() => { | ||
const messageList = document.querySelector('vaadin-message-list'); | ||
messageList.items = [ | ||
{ | ||
text: 'Hello list', | ||
time: 'yesterday', | ||
userName: 'Matt Mambo', | ||
userAbbr: 'MM', | ||
userColorIndex: 1 | ||
}, | ||
{ | ||
text: 'Another message', | ||
time: 'right now', | ||
userName: 'Linsey Listy', | ||
userAbbr: 'LL', | ||
userColorIndex: 2, | ||
userImg: '/test/visual/avatars/avatar.jpg' | ||
} | ||
]; | ||
document.getElementById('tests').dataset.ready = true; | ||
}); | ||
})(); | ||
</script> | ||
</body> | ||
|
||
</html> | ||
Peppe marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; | ||
import '@vaadin/vaadin-lumo-styles/color.js'; | ||
import '@vaadin/vaadin-lumo-styles/sizing.js'; | ||
import '@vaadin/vaadin-lumo-styles/spacing.js'; | ||
import '@vaadin/vaadin-lumo-styles/style.js'; | ||
Comment on lines
+2
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have some convention that should all of these be imported always or only those that you refer to in the same file? Spacing seems to be the only one in use below. |
||
import '@vaadin/vaadin-button/theme/lumo/vaadin-button-styles.js'; | ||
import '@vaadin/vaadin-text-field/theme/lumo/vaadin-text-area-styles.js'; | ||
|
||
registerStyles( | ||
'vaadin-message-input', | ||
css` | ||
:host { | ||
padding: var(--lumo-space-s) var(--lumo-space-m); | ||
} | ||
|
||
vaadin-text-area { | ||
margin: 0 var(--lumo-space-s) 0 0; | ||
} | ||
|
||
:host([dir='rtl']) vaadin-text-area { | ||
margin: 0 0 0 var(--lumo-space-s); | ||
} | ||
`, | ||
{ moduleId: 'lumo-message-input' } | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './vaadin-message-input-styles.js'; | ||
import '../../src/vaadin-message-input.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; | ||
import '@vaadin/vaadin-material-styles/color.js'; | ||
import '@vaadin/vaadin-material-styles/typography.js'; | ||
import '@vaadin/vaadin-button/theme/material/vaadin-button-styles.js'; | ||
import '@vaadin/vaadin-text-field/theme/material/vaadin-text-area-styles.js'; | ||
|
||
registerStyles( | ||
'vaadin-message-input', | ||
css` | ||
:host { | ||
padding: 0.5em 1em; | ||
} | ||
|
||
vaadin-text-area { | ||
margin: 0 0.5em 0 0; | ||
} | ||
|
||
:host([dir='rtl']) vaadin-text-area { | ||
margin: 0 0 0 0.5em; | ||
} | ||
`, | ||
{ moduleId: 'material-message-input' } | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './vaadin-message-input-styles.js'; | ||
import '../../src/vaadin-message-input.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './src/vaadin-message-input.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './theme/lumo/vaadin-message-input.js'; | ||
export * from './src/vaadin-message-input.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use
^2.8.0
if you want the component to be compatible with Vaadin 14.xThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.