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 conditional (non-attribute) selectors to ElementQueries #1784

Merged
merged 17 commits into from
Apr 17, 2024
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { html, LitElement } from 'lit';
import { customElement, property } from 'lit/decorators.js';

@customElement('label-placeholder')
class LabelPlaceholder extends LitElement {
@property({ type: String })
label!: string;

@property({ type: String })
placeholder!: string;

render() {
return html`
<div>
<div id="label">${this.label}</div>
<div id="placeholder">${this.placeholder}</div>
<slot></slot>
</div>
`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ export class TemplateView extends LitElement {
<button class="button button-shadow-special" id="special-button">Special Button (in Shadow DOM)</button>
</div>
<button class="button" id="foo'*+bar'">Button with special id</button>

<label-placeholder></label-placeholder>

<label-placeholder label="one"></label-placeholder>
<label-placeholder placeholder="two"></label-placeholder>
<label-placeholder label="one" placeholder="two"></label-placeholder>

<label-placeholder label="two"></label-placeholder>
<label-placeholder placeholder="one"></label-placeholder>
<label-placeholder label="two" placeholder="one"></label-placeholder>

<label-placeholder label="Special">Something Special</label-placeholder>
<label-placeholder label="Ordinary" placeholder="Special">Something Else</label-placeholder>
<label-placeholder placeholder="Special">Something Ordinary</label-placeholder>
`;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.vaadin.testUI;

import com.vaadin.flow.component.HasLabel;
import com.vaadin.flow.component.HasPlaceholder;
import com.vaadin.flow.component.HasText;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.littemplate.LitTemplate;

@Tag(LabelPlaceholder.TAG)
@JsModule(LabelPlaceholder.JS_MODULE)
public class LabelPlaceholder extends LitTemplate
implements HasLabel, HasPlaceholder, HasText {
public static final String TAG = "label-placeholder";
public static final String JS_MODULE = "./" + TAG + ".ts";

public LabelPlaceholder() {
//
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
package com.vaadin.testUI;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.html.Div;
Expand All @@ -27,7 +28,7 @@ public TemplateView() {
button.getElement().setAttribute("theme", "light-theme");
button.addClassName("button");
button.addClassName("button-" + i);
getElement().appendChild(new Div(button).getElement());
add(new Div(button));
}

NativeButton slottedButton = new NativeButton(
Expand All @@ -37,6 +38,20 @@ public TemplateView() {
slottedButton.getElement().setAttribute("theme", "light-theme");
slottedButton.addClassName("button");
slottedButton.addClassName("button-special-slot");
getElement().appendChild(slottedButton.getElement());
add(slottedButton);

LabelPlaceholder oneLabelPlaceholder = new LabelPlaceholder();
oneLabelPlaceholder.setLabel("one");
oneLabelPlaceholder.setPlaceholder("two");
add(oneLabelPlaceholder);

LabelPlaceholder flowLabelPlaceholder = new LabelPlaceholder();
flowLabelPlaceholder.setLabel("Flow");
flowLabelPlaceholder.setPlaceholder("flow component");
add(flowLabelPlaceholder);
}

private void add(Component component) {
getElement().appendChild(component.getElement());
}
}
Loading