└── tutorials └── frontend ├── lit-element ├── teaser.adoc ├── article.properties ├── 05-pwa-and-offline │ ├── images │ │ ├── sw-offline.gif │ │ └── persisted-state.gif │ └── content.adoc ├── 01-starting-a-lit-element-project │ ├── images │ │ ├── todo-app.gif │ │ ├── starter-app.png │ │ └── first-component.png │ └── content.adoc ├── 04-navigation-and-code-splitting │ ├── images │ │ ├── stats-view.gif │ │ ├── lazy-load-bundle.gif │ │ └── webpack-output.png │ └── content.adoc ├── 03-state-management-with-redux │ ├── images │ │ ├── redux-dev-tools.png │ │ └── redux-finished-app.gif │ └── content.adoc └── 02-lit-element-templating-properties-and-events │ ├── images │ ├── styled.png │ ├── filters.gif │ ├── add-tasks.gif │ └── task-input.png │ └── content.adoc └── topic.properties /tutorials/frontend/lit-element/teaser.adoc: -------------------------------------------------------------------------------- 1 | // A teaser for the whole article 2 | -------------------------------------------------------------------------------- /tutorials/frontend/topic.properties: -------------------------------------------------------------------------------- 1 | # meta data per topic, likely some description 2 | -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/article.properties: -------------------------------------------------------------------------------- 1 | # Article properties, likely a title and a description 2 | -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/05-pwa-and-offline/images/sw-offline.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/05-pwa-and-offline/images/sw-offline.gif -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/05-pwa-and-offline/images/persisted-state.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/05-pwa-and-offline/images/persisted-state.gif -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/01-starting-a-lit-element-project/images/todo-app.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/01-starting-a-lit-element-project/images/todo-app.gif -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/04-navigation-and-code-splitting/images/stats-view.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/04-navigation-and-code-splitting/images/stats-view.gif -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/01-starting-a-lit-element-project/images/starter-app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/01-starting-a-lit-element-project/images/starter-app.png -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/03-state-management-with-redux/images/redux-dev-tools.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/03-state-management-with-redux/images/redux-dev-tools.png -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/01-starting-a-lit-element-project/images/first-component.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/01-starting-a-lit-element-project/images/first-component.png -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/03-state-management-with-redux/images/redux-finished-app.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/03-state-management-with-redux/images/redux-finished-app.gif -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/04-navigation-and-code-splitting/images/lazy-load-bundle.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/04-navigation-and-code-splitting/images/lazy-load-bundle.gif -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/04-navigation-and-code-splitting/images/webpack-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/04-navigation-and-code-splitting/images/webpack-output.png -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/02-lit-element-templating-properties-and-events/images/styled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/02-lit-element-templating-properties-and-events/images/styled.png -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/02-lit-element-templating-properties-and-events/images/filters.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/02-lit-element-templating-properties-and-events/images/filters.gif -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/02-lit-element-templating-properties-and-events/images/add-tasks.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/02-lit-element-templating-properties-and-events/images/add-tasks.gif -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/02-lit-element-templating-properties-and-events/images/task-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peholmst/learning-content/HEAD/tutorials/frontend/lit-element/02-lit-element-templating-properties-and-events/images/task-input.png -------------------------------------------------------------------------------- /tutorials/frontend/lit-element/01-starting-a-lit-element-project/content.adoc: -------------------------------------------------------------------------------- 1 | = Creating a LitElement project 2 | 3 | :title: Creating a LitElement project 4 | :authors: marcus 5 | :type: text, video 6 | :topic: frontend 7 | :tags: LitElement, templating 8 | :description: Learn how to set up a new project with LitElement 9 | :repo: https://github.com/vaadin-learning-center/lit-element-tutorial-01-starting-a-lit-element-project 10 | :linkattrs: 11 | :imagesdir: ./images 12 | 13 | 14 | In this series of tutorials, you learn how to build an application using Web Components and LitElement. The topics we cover are: 15 | 16 | . Starting a LitElement project 17 | . lit-html templating and events 18 | . State management with Redux 19 | . Navigation and code splitting 20 | . PWA and offline 21 | 22 | .The app we are building 23 | image::todo-app.gif[Todo tutorial app using LitElement, lit-html, and redux.] 24 | 25 | 26 | == Download the LitElement starter 27 | We are using https://webpack.js.org/[Webpack^] to serve the application during development and for building the application for production. This tutorial does not cover Webpack configuration. Instead, we start with a pre-configured project skeleton. 28 | 29 | 30 | https://github.com/vaadin-learning-center/lit-element-tutorial-00-starter/archive/master.zip[Download LitElement starter, role="cta"] 31 | 32 | Once you have downloaded the starter, unzip it and run: 33 | 34 | [source,terminal] 35 | $ npm install 36 | 37 | Then start the development server and navigate to http://localhost:8080. 38 | 39 | [source,terminal] 40 | $ npm run dev 41 | 42 | image::starter-app.png[Empty starter app running on localhost] 43 | 44 | If everything went well, you should see the empty application. You are now ready to get started! 45 | 46 | == Creating the first component 47 | 48 | Start by installing LitElement. 49 | 50 | [source,terminal] 51 | $ npm install --save @polymer/lit-element 52 | 53 | Create a new folder `*views*` in the `*src*` folder, and create a file `*todo-view.js*` in it. We always name our files the same as their HTML tag names to make it easier to navigate the source. 54 | 55 | .`*views/todo-view.js*` 56 | [source,javascript] 57 | ---- 58 | import { LitElement, html } from '@polymer/lit-element'; //<1> 59 | 60 | class TodoView extends LitElement { //<2> 61 | render() { 62 | return html` //<3> 63 |
todo-view
64 | `; 65 | } 66 | } 67 | 68 | customElements.define('todo-view', TodoView); //<4> 69 | ---- 70 | <1> Import the `LitElement` base class and `html` template function 71 | <2> Create a class for the component, extending `LitElement` 72 | <3> Define a template in the `render()` function using the `html` template function. 73 | <4> Associate the component implementation with a HTML tag using the CustomElements registry. 74 | 75 | NOTE: Tag names need to have a dash (-) to avoid naming collisions with native HTML elements. 76 | 77 | Once we have a component definition, we need to import it to the browser is aware of it. The Webpack configuration takes care of including the JavaScript in our app. 78 | 79 | .`*index.js*` 80 | [source,javascript] 81 | ---- 82 | import './styles.css'; 83 | import './views/todo-view.js'; 84 | ---- 85 | 86 | Now we can use the component like any other HTML tag. Let's add it to the `