Skip to content

Instantly share code, notes, and snippets.

import { NotificationElement } from "@vaadin/vaadin-notification";
import { render, TemplateResult } from "lit";
import { isTemplateResult } from "lit/directive-helpers";
export const showNotification = (
contents: string | TemplateResult
): NotificationElement => {
if (isTemplateResult(contents)) {
return _showNotification((root: HTMLElement) => {
render(contents, root);
import { showNotification } from '@vaadin/flow-frontend/a-notification';
import '@vaadin/vaadin-button';
import '@vaadin/vaadin-text-field';
import { css, customElement, html, LitElement } from 'lit-element';
@customElement('hello-world-view')
export class HelloWorldView extends LitElement {
name: string = '';
static get styles() {
const findAll = (element,tag) => {
const lightDom = Array.from(element.querySelectorAll(tag));
const shadowDom = Array.from(element.querySelectorAll("*")).filter(e => e.shadowRoot).flatMap(e => findAll(e.shadowRoot, tag));
return [...lightDom, ...shadowDom];
}
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import tm1637
import RPi.GPIO as IO
import threading
import pygame
canScrollElementVertically = (el, direction) => {
if (direction > 0) {
// Down
return ((el.scrollTop + el.offsetHeight) < el.scrollHeight);
} else {
// Up
return (el.scrollTop > 0);
}
};
@Artur-
Artur- / findMissingImports.js
Created September 6, 2018 11:36
Finds missing import statements for custom elements
findMissingImports = (element) => {
if (element.tagName.indexOf('-') != -1 && !customElements.get(element.tagName.toLowerCase())) {
console.error("Element "+element.tagName+" is not upgraded");
}
Array.from(element.children).forEach(e => findMissingImports(e));
if (element.shadowRoot) {
Array.from(element.shadowRoot.children).forEach(e => findMissingImports(e));
}
}
@Artur-
Artur- / DesignAutowireConfiguration.java
Last active February 27, 2017 19:11
Configuration class for allowing @Autowired components in Vaadin Designer files
package com.vaadin.template.orders.app;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;
import com.vaadin.ui.Component;
import com.vaadin.ui.declarative.Design;
import com.vaadin.ui.declarative.Design.DefaultComponentFactory;
@Artur-
Artur- / Vaadin CLA
Last active September 21, 2023 06:05
Vaadin Contribution Agreement
This Vaadin Contribution Agreement (hereinafter "Agreement") is entered by and between Vaadin Ltd, a limited liability company duly incorporated and organized under the laws of Finland having its principal office at Ruukinkatu 2-4, 20540, Turku, Finland (hereinafter "Vaadin"), and any individual or entity that has executed this Agreement as identified in the signature page of this Agreement (hereinafter "You"), and is made as of the date signed on the signature page of this Agreement (hereinafter "Effective Date").
WHEREAS, Vaadin Ltd manages the Vaadin Project;
WHEREAS, You wish to contribute certain intellectual property defined hereunder to Vaadin and for the use of the Project;
NOW, THEREFORE, in consideration of the mutual covenants set forth herein and intending to be legally bound, You accept and hereby agree to the following terms and conditions pursuant to which You are willing to submit Your present and future Contributions to Vaadin:
From cc81debbf5ca6b0979dbb2104b2ac60f6492c86c Mon Sep 17 00:00:00 2001
From: Artur Signell <artur@vaadin.com>
Date: Wed, 29 Jul 2015 18:16:22 +0300
Subject: [PATCH] Use two-step write so Tomcat correctly reports a dead
connection
Change-Id: Ief2a1111926eefcb131d082b453081c705103e86
---
.../org/atmosphere/cpr/AtmosphereResponse.java | 26 ++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
@Push(transport = Transport.LONG_POLLING)
public class PushWithoutThreads extends DelayedUI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = Vaadin7helloworldUI.class)
public static class Servlet extends VaadinServlet {
}
private VerticalLayout layout;