chore: fix combobox extension demos

This commit is contained in:
Thijs Louisse 2023-05-30 19:13:30 +02:00
parent b66662931f
commit 8293059fea
9 changed files with 272 additions and 264 deletions

View file

@ -46,48 +46,56 @@ export const Github = () => html`
## Whatsapp ## Whatsapp
```js preview-story ```js preview-story
export const Whatsapp = () => html` export const Whatsapp = () => {
<wa-combobox name="combo" label="Filter chats"> const obamaImgUrl = new URL('../src/wa-combobox/assets/obama.jpeg', import.meta.url).href;
<wa-option const trumpImgUrl = new URL('../src/wa-combobox/assets/trump.jpeg', import.meta.url).href;
title="Barack Obama" const bidenImgUrl = new URL('../src/wa-combobox/assets/biden.jpeg', import.meta.url).href;
text="Yup, let's try that for now👍" const bushImgUrl = new URL('../src/wa-combobox/assets/bush.jpeg', import.meta.url).href;
time="15:02" const clintonImgUrl = new URL('../src/wa-combobox/assets/clinton.jpeg', import.meta.url).href;
is-user-text
is-user-text-read return html`
image="https://pbs.twimg.com/profile_images/822547732376207360/5g0FC8XX_400x400.jpg" <wa-combobox name="combo" label="Filter chats">
.choiceValue=${'Barack Obama'} <wa-option
></wa-option> title="Barack Obama"
<wa-option text="Yup, let's try that for now👍"
title="Donald Trump" time="15:02"
text="Take care!" is-user-text
time="14:59" is-user-text-read
is-user-text image="${obamaImgUrl}"
image="https://pbs.twimg.com/profile_images/874276197357596672/kUuht00m_400x400.jpg" .choiceValue=${'Barack Obama'}
.choiceValue=${'Donald Trump'} ></wa-option>
></wa-option> <wa-option
<wa-option title="Donald Trump"
title="Joe Biden" text="Take care!"
text="Hehe😅. You too, man, you too..." time="14:59"
time="yesterday" is-user-text
image="https://pbs.twimg.com/profile_images/1308769664240160770/AfgzWVE7_400x400.jpg" image="${trumpImgUrl}"
.choiceValue=${'Joe Biden'} .choiceValue=${'Donald Trump'}
></wa-option> ></wa-option>
<wa-option <wa-option
title="George W. Bush" title="Joe Biden"
time="friday" text="Hehe😅. You too, man, you too..."
text="You bet I will. Let's catch up soon!" time="yesterday"
image="https://pbs.twimg.com/profile_images/828483922266877954/ljYUWUCu_400x400.jpg" image="${bidenImgUrl}"
.choiceValue=${'George W. Bush'} .choiceValue=${'Joe Biden'}
></wa-option> ></wa-option>
<wa-option <wa-option
title="Bill Clinton" title="George W. Bush"
time="thursday" time="friday"
text="Dude...😂 😂 😂" text="You bet I will. Let's catch up soon!"
image="https://pbs.twimg.com/profile_images/1239440892664086529/iY0Z83Dr_400x400.jpg" image="${bushImgUrl}"
.choiceValue=${'Bill Clinton'} .choiceValue=${'George W. Bush'}
></wa-option> ></wa-option>
</wa-combobox> <wa-option
`; title="Bill Clinton"
time="thursday"
text="Dude...😂 😂 😂"
image="${clintonImgUrl}"
.choiceValue=${'Bill Clinton'}
></wa-option>
</wa-combobox>
`;
};
``` ```
**Whatsapp example shows:** **Whatsapp example shows:**

View file

@ -397,7 +397,10 @@ export class GoogleCombobox extends LionCombobox {
get slots() { get slots() {
return { return {
...super.slots, ...super.slots,
label: () => renderLitAsNode(html` <img alt="Google Search" src="${googleSearchLogoUrl}" />`), label: () =>
renderLitAsNode(
html` <img alt="Google Search" src="${googleSearchLogoUrl}" style="width:auto; " />`,
),
prefix: () => renderLitAsNode(html` <span>${googleSearchIcon}</span> `), prefix: () => renderLitAsNode(html` <span>${googleSearchIcon}</span> `),
suffix: () => suffix: () =>
renderLitAsNode( renderLitAsNode(

View file

@ -7,31 +7,29 @@ import './style/load-roboto.js';
// TODO: insert ink wc here // TODO: insert ink wc here
export class MdOption extends LionOption { export class MdOption extends LionOption {
static get styles() { static styles = [
return [ ...super.styles,
...super.styles, css`
css` :host {
:host { position: relative;
position: relative; padding: 8px;
padding: 8px; }
}
:host([focused]) { :host([focused]) {
background: lightgray; background: lightgray;
} }
:host([active]) { :host([active]) {
color: #1867c0 !important; color: #1867c0 !important;
caret-color: #1867c0 !important; caret-color: #1867c0 !important;
} }
:host ::slotted(.md-highlight) { :host ::slotted(.md-highlight) {
color: rgba(0, 0, 0, 0.38); color: rgba(0, 0, 0, 0.38);
background: #eee; background: #eee;
} }
`, `,
]; ];
}
/** /**
* @override * @override
@ -67,23 +65,27 @@ export class MdOption extends LionOption {
customElements.define('md-option', MdOption); customElements.define('md-option', MdOption);
export class MdCombobox extends MdFieldMixin(LionCombobox) { export class MdCombobox extends MdFieldMixin(LionCombobox) {
static get styles() { static styles = [
return [ ...super.styles,
...super.styles, css`
css` .input-group__container {
.input-group__container { display: flex;
display: flex; border-bottom: none;
border-bottom: none; }
}
* > ::slotted([role='listbox']) { * > ::slotted([role='listbox']) {
box-shadow: 0 4px 6px 0 rgba(32, 33, 36, 0.28); box-shadow: 0 4px 6px 0 rgba(32, 33, 36, 0.28);
padding-top: 8px; padding-top: 8px;
padding-bottom: 8px; padding-bottom: 8px;
top: 2px; top: 2px;
} }
`, `,
]; ];
constructor() {
super();
this.showAllOnEmpty = true;
} }
} }
customElements.define('md-combobox', MdCombobox); customElements.define('md-combobox', MdCombobox);

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View file

@ -15,164 +15,162 @@ class WaOption extends LionOption {
}; };
} }
static get styles() { static styles = [
return [ ...super.styles,
...super.styles, css`
css` :host {
:host { --background-default: white;
--background-default: white; --background-default-active: gray;
--background-default-active: gray; --secondary: #777;
--secondary: #777; --secondary-lighter: #aaa;
--secondary-lighter: #aaa; --chatlist-icon: #aaa;
--chatlist-icon: #aaa; background-color: var(--background-default);
background-color: var(--background-default); cursor: pointer;
cursor: pointer; color: rgb(74, 74, 74);
color: rgb(74, 74, 74); padding: 0;
padding: 0; transition: max-height 0.4s ease, opacity 0.3s ease;
transition: max-height 0.4s ease, opacity 0.3s ease; max-height: 500px;
max-height: 500px; }
}
:host([checked]) { :host([checked]) {
background-color: #eee; background-color: #eee;
} }
:host(:hover) { :host(:hover) {
background-color: #f6f6f6; background-color: #f6f6f6;
} }
.wa-option { .wa-option {
position: relative; position: relative;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
height: 72px; height: 72px;
pointer-events: all; pointer-events: all;
} }
.wa-option__image { .wa-option__image {
display: flex; display: flex;
flex: none; flex: none;
align-items: center; align-items: center;
margin-top: -1px; margin-top: -1px;
padding: 0 15px 0 13px; padding: 0 15px 0 13px;
} }
.wa-option__image-inner { .wa-option__image-inner {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
background-color: var(--avatar-background); background-color: var(--avatar-background);
border-radius: 50%; border-radius: 50%;
height: 49px; height: 49px;
width: 49px; width: 49px;
} }
.wa-option__image-inner img, .wa-option__image-inner img,
.wa-option__image-inner svg { .wa-option__image-inner svg {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.wa-option__image-inner-inner { .wa-option__image-inner-inner {
position: absolute; position: absolute;
top: 0; top: 0;
z-index: 1; z-index: 1;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.wa-option__content { .wa-option__content {
display: flex; display: flex;
flex-basis: auto; flex-basis: auto;
flex-direction: column; flex-direction: column;
flex-grow: 1; flex-grow: 1;
justify-content: center; justify-content: center;
min-width: 0; min-width: 0;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
padding-right: 15px; padding-right: 15px;
} }
.wa-option__content-row1 { .wa-option__content-row1 {
display: flex; display: flex;
align-items: center; align-items: center;
line-height: normal; line-height: normal;
text-align: left; text-align: left;
} }
.wa-option__content-row1-title { .wa-option__content-row1-title {
display: flex; display: flex;
flex-grow: 1; flex-grow: 1;
overflow: hidden; overflow: hidden;
color: var(--primary-strong); color: var(--primary-strong);
font-weight: 400; font-weight: 400;
font-size: 17px; font-size: 17px;
line-height: 21px; line-height: 21px;
} }
.wa-option__content-row1-time { .wa-option__content-row1-time {
line-height: 14px; line-height: 14px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
margin-left: 6px; margin-left: 6px;
margin-top: 3px; margin-top: 3px;
flex: none; flex: none;
max-width: 100%; max-width: 100%;
color: var(--secondary-lighter); color: var(--secondary-lighter);
font-size: 12px; font-size: 12px;
line-height: 20px; line-height: 20px;
} }
.wa-option__content-row2 { .wa-option__content-row2 {
display: flex; display: flex;
align-items: center; align-items: center;
min-height: 20px; min-height: 20px;
color: var(--secondary); color: var(--secondary);
font-size: 13px; font-size: 13px;
line-height: 20px; line-height: 20px;
margin-top: 2px; margin-top: 2px;
/* color: var(--secondary-stronger); */ /* color: var(--secondary-stronger); */
} }
.wa-option__content-row2-text { .wa-option__content-row2-text {
flex-grow: 1; flex-grow: 1;
overflow: hidden; overflow: hidden;
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
line-height: 20px; line-height: 20px;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.wa-option__content-row2-text-inner { .wa-option__content-row2-text-inner {
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
} }
.wa-option__content-row2-text-inner-icon { .wa-option__content-row2-text-inner-icon {
display: none; display: none;
flex: none; flex: none;
color: var(--chatlist-icon); color: var(--chatlist-icon);
vertical-align: top; vertical-align: top;
margin-right: 2px; margin-right: 2px;
} }
:host([is-user-text]) .wa-option__content-row2-text-inner-icon { :host([is-user-text]) .wa-option__content-row2-text-inner-icon {
display: inline-block; display: inline-block;
} }
:host([is-user-text-read]) .wa-option__content-row2-text-inner-icon { :host([is-user-text-read]) .wa-option__content-row2-text-inner-icon {
color: lightblue; color: lightblue;
} }
/* /*
.wa-option__content-row2-menu { .wa-option__content-row2-menu {
} */ } */
`, `,
]; ];
}
render() { render() {
return html`<div class="wa-option"> return html`<div class="wa-option">
@ -285,59 +283,56 @@ class WaOption extends LionOption {
customElements.define('wa-option', WaOption); customElements.define('wa-option', WaOption);
class WaCombobox extends LionCombobox { class WaCombobox extends LionCombobox {
static get styles() { static styles = [
return [ ...super.styles,
...super.styles, css`
css` :host {
:host { font-family: SF Pro Text, SF Pro Icons, system, -apple-system, system-ui, BlinkMacSystemFont,
font-family: SF Pro Text, SF Pro Icons, system, -apple-system, system-ui, Helvetica Neue, Helvetica, Lucida Grande, Kohinoor Devanagari, sans-serif;
BlinkMacSystemFont, Helvetica Neue, Helvetica, Lucida Grande, Kohinoor Devanagari, }
sans-serif;
}
.input-group__container { .input-group__container {
display: flex; display: flex;
border-bottom: none; border-bottom: none;
} }
* > ::slotted([role='listbox']) { * > ::slotted([role='listbox']) {
max-height: none; max-height: none;
} }
* > ::slotted([slot='input']) { * > ::slotted([slot='input']) {
font-size: 14px; font-size: 14px;
} }
.input-group { .input-group {
padding: 15px; padding: 15px;
background: #f6f6f6; background: #f6f6f6;
} }
.input-group__prefix { .input-group__prefix {
margin-right: 20px; margin-right: 20px;
color: #999; color: #999;
display: flex; display: flex;
} }
.input-group__container { .input-group__container {
border-radius: 18px; border-radius: 18px;
background: white; background: white;
padding: 7px; padding: 7px;
padding-left: 16px; padding-left: 16px;
} }
/** Undo Popper */ /** Undo Popper */
#overlay-content-node-wrapper { #overlay-content-node-wrapper {
position: static !important; position: static !important;
width: auto !important; width: auto !important;
transform: none !important; transform: none !important;
/* height: 300px; /* height: 300px;
overflow: scroll; */ overflow: scroll; */
} }
`, `,
]; ];
}
get slots() { get slots() {
return { return {
@ -360,7 +355,7 @@ class WaCombobox extends LionCombobox {
/** @configure OverlayMixin */ /** @configure OverlayMixin */
this.opened = true; this.opened = true;
/** @configure LionCombobox */ /** @configure LionCombobox */
this.showAllOnEmpty = true; this.showAllOnEmpty = false;
/** @configure LionCombobox */ /** @configure LionCombobox */
this.rotateKeyboardNavigation = false; this.rotateKeyboardNavigation = false;
} }