Code Monkey home page Code Monkey logo

lit.dev's Introduction

lit.dev

New site, new repo.

Packages

This is an npm workspaces monorepo.

  • lit-dev-content: Main content of lit.dev
  • lit-dev-server: Production web server for lit.dev
  • lit-dev-tools: Eleventy plugins and other internal tools

Developing

Install dependencies

npm ci

Develop site content

npm run dev

Serves at http://localhost:5415.

Dev mode is different to production in these ways:

  • Browser auto-reload.
  • CSS is not inlined or minified. CSS changes are reflected immediately.
  • JS is not inlined, bundled, bare-module transformed, or minified. JS changes are reflected immediately after tsc compile.
  • HTML is not minified.

If needed, you can check for dev mode from an Eleventy template using the env.DEV global:

{% if env.DEV %}
  <p>Dev mode</p>
{% else %}
  <p>Prod mode</p>
{% endif %}

Update generated API docs

First run npm run dev as shown above, and then in another terminal:

cd packages/lit-dev-api
npm run build:watch

You can now edit the comments in any .ts file in the lit directory, and after the automatic rebuild, the dev site will refresh.

code packages/lit-dev-api/lit/

The lit directory is a regular cloned git repo, so you can make changes directly here, and push PRs from it as normal. It's configured to track the main branch, but is pinned to a particular commit. To update the current commit, update the sha field in packages/lit-dev-tools-cjs/src/api-docs/configs/lit-2.ts.

Serve production mode

npm run build
npm start

Serves at http://localhost:6415

Watch production mode

npm start # production server

cd packages/lit-dev-content
npm run build:ts:watch     # TypeScript
npm run build:rollup:watch # Rollup
npm run build:eleventy:watch   # Eleventy

Serves at http://localhost:6415

Start production Docker environment locally

docker build -t litdev . --build-arg LITDEV_ENV=local
docker run --rm --name litdev -p 6415:6415 -e LITDEV_ENV=local -e MODE=main litdev
docker run --rm --name litdev-playground -p 6416:6416 -e LITDEV_ENV=local -e MODE=playground litdev

Serves at http://localhost:6415

Updating screenshots tests

Unless you are using Linux, screenshot test goldens need to be created by downloading artifacts from the "Integration Tests" Github Action.

If the integration tests fail, two .zip archives are generated as artifacts, which can be downloaded from the "Artifacts" menu in the top-right of the failing action:

  • screenshot-goldens.zip: New goldens which, if correct, can be extracted into packages/lit-dev-tests/src/playwright and committed as the new goldens:

    unzip screenshot-goldens.zip -d packages/lit-dev-tests/src/playwright
  • screenshot-diffs.zip: Expected, actuals, and diff screenshots. Can be extracted and viewed directly to help understand what failed.

Contributing Tutorials

See the Tutorial Contributing guide at packages/lit-dev-content/samples/tutorials/CONTRIBUTING.md

lit.dev's People

Contributors

38elements avatar andrewjakubowicz avatar aomarks avatar augustjk avatar bicknellr avatar davidmaxwaterman avatar davie-robertson avatar dependabot[bot] avatar e111077 avatar graynorton avatar haprog avatar johnspurlock avatar justinfagnani avatar kevinpschaaf avatar nikolamicic21 avatar niznikr avatar nkabrown avatar nozomuikuta avatar oelhanafey avatar olange avatar ottowinter avatar paglobal avatar peschee avatar peter50216 avatar rictic avatar robintty avatar rodydavis avatar talhaguy avatar taylor-vann avatar thescientist13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lit.dev's Issues

[docs] "Updates?" in shouldUpdate

I've made several checks with method shouldUpdate, and property changes inside this method do not trigger an element update, but the parameter changedProperties itself of shouldUpdate is updated synchronously in the same element update.

So I think the field "Updates?" of this method in this doc is wrong. It should says:

Updates? | No | Property changes inside this method will not trigger an element update.

Don't add links for directories in guides structure

To match our current outline, I'd like to omit link for the directories themselves.

I did this by replacing the index.md in a given directory with a stub that contains only metadata, and rewriting the nav template like this:

      <side-nav>
        {%- set navSections = collections.guide | eleventyNavigation -%}
        {# Uncomment to use prebuilt nav
        {{ navSections | eleventyNavigationToHtml | safe }}
        #}
        <ul>
        {%- for entry in navSections %}
          <li{% if entry.url == page.url %} class="my-active-class"{% endif %}>
            {%- if entry.children | length %}
              <span class="sectionHead">{{ entry.title }}</span>
              {% set navPages = entry.children %}
              <ul>
              {%- for entry in navPages %}
                <li{% if entry.url == page.url %} class="my-active-class"{% endif %}>
                  <a href="{{ entry.url | url }}">{{ entry.title }}</a>
                </li>
              {%- endfor %}
              </ul>  
            {%- else %}
              <a href="{{ entry.url | url }}">{{ entry.title }}</a>
            {%- endif %}
          </li>
        {%- endfor %}
        </ul>
      </side-nav>

Not sure if there's a simpler way to do this.

Minimal usability pass

There are some janky things about the site right now in terms of layout and nav. Do a minimal pass through to make things more reasonable.

Add section on working with other libraries?

Description

An expression in the child position (aka text position) can return a node or iterable of nodes, something that can be used to integrate the output of other libraries into a Lit template. We don't really cover this at the moment.

Acceptance criteria

Section on working with other libraries that describes, at minimum, using child position expressions to inject nodes into the templated DOM.

Redirect lit-html.com to the lit-html docs site

Initiative / goal

We now have the lit-html.com domain!
It doesn't point anywhere :/

Scope

Figure out DNS settings to redirect to the current docs site

Acceptance criteria and must have scope

Typing lit-html.com into a browser redirects to the current docs site

Add release notes to docs site

Description

  • For consistency with lit-html docs.

Acceptance criteria

  • Individual pages per-release (for example, /guide/release-notes/2.4.0.html)
  • Summary page collecting all release notes. (for example, /guides/release-notes.html) release
  • Only document releases going forward; for older releases, we can point to the changelog.

Consider migrating to AppEngine

Deploying via cloud build/cloud run seems pretty broken. At the moment, cloud build is timing out with no useful error message, while the local lerna build works fine.

Even when it works, it's slower and less intuitive than working with App Engine.

Asynchronous operation cancellation or order

Description

When you rely on an asynchrounous task to complete, if an earlier asynchronous task completes after its next iteration, you get the result of the first task instead of the last.

Steps to Reproduce

  1. Use a directive that updates the value in a relatively long time.
  2. Update the rendering, making the directive fire again but this time faster.

The same happen if you render something else afterward, your new value is overridden.

Live Reproduction Link

https://stackblitz.com/edit/lit-html-jdv5ml?file=src%2Findex.js

Actual Results

The result from the last directive call show up but shortly after the result from the first directive call show up.

Expected Results

This code obviously miss some order or cancellation management. I do not expect it to work as is.
Should this library support also a conditional rendering at this point ?
A solution would be a pattern to use to fix this behaviour and maybe extend the documentation on Asynchronous Directives

An other solution would be to use a central model such as redux but this would imply a big change to my application that I would better avoid if possible.

Add docs for platform-support

Previously LitElement's polyfill support was built in. Now it's opt-in via the platform-support module. Docs should be added for this.

There are platform-support modules in:

  • updating-element
  • lit-html
  • lit-element (includes updating-element and lit-html's platform-support modules)

The idea is that platform-support should be loaded right after loading the webcomponents polyfills.

Related libraries—Finish Standalone lit-html section

  • Add intro, explaining that lit-html can be used independently of web components or LitElement to render DOM anywhere in the page.

  • Fill in missing content. In particular, probably restructure a bit to clarify where the context comes from when using lit-html standalone, and how the examples differ from the LitElement based examples.

  • Edit & clean up.

Redirects

  • A way to declare redirects for future document moves
  • Fragment redirects somehow?
  • Redirects from old site to new site

[lit-html] Docs should describe lit-html change detection explictly

Currently the docs say things like, "When you call render, lit-html only updates the parts of the template that have changed since the last render. This makes lit-html updates very fast."

But they don't say explicitly how this happens. In particular, that lit keeps track of the current value at each binding site (aka "hole in the DOM", aka Part). On render, it compares the new value with the current rendered value, and only re-renders if they're different.

The live() directive is designed to apply different change detection logic (against the live DOM value, instead of the value that lit rendered).

[docs] Add language and version to docs URLs

We should be able to preserve docs for each release, and plan for the future with docs in multiple languages. URLs would end up looking like https://polymer.github.io/lit-html/en/1.0/guide or https://polymer.github.io/lit-html/en/latest/guide.

Alert styles missing

When I was demoing the site today, I realized the alert styles were missing.

It looks like they got dropped as part of one of the big clean-ups:

https://github.com/PolymerLabs/lit.dev/pull/37/files#diff-3b9e86ecc61632ab075bd985e7366ae7f4c151634f65e5e0c100a03383661cb4L288

If that link doesn't work right... Starting on L288 of main.css in that PR, you can see the deleted styles. We need to put these back--not sure if they should go in main.css or guide.css, though. (We use them in both the guides and the tutorial typically, if that helps--although I'm not sure whether that will make sense with the new tutorial format.

[docs] Docs feedback mechanism

Another general design request for post-1.0: I'd like to provide a feedback mechanism. We can easily put one at the bottom of the page, but since some of our pages are quite long, having a "was this page helpful" button at the very end isn't perfect.

Old Polymer site had "Edit on GitHub" buttons, which were nice, but much higher friction, since users had to have a GitHub account, be willing to click through and create a PR, instead of just commenting anonymously.

Options include:

  • A sticky footer (see the Sentry docs.
  • Something attached to the header.
  • A small feedback tab on the side that opens an overlay. I'm not saying this well, but I've seen that implemented somewhere, too.

Information to collect:
Was this page helpful to you? [Yes] {No]
[If no] Comment [ ]
Could also offer "Edit on GitHub" or "Open an Issue" as options.

Tweak template intro wording

Comments from #14, to handle after larger reorgs are done:

"Since "tag" is used to refer to HTML tags too, do we want to clarify that html is a "template literal tag" the first time we use it? I know that could be a lot of "tagged template literal tagged with the template literal tag" and such... so maybe not a great idea. Maybe there's a way to work the full phrase "tagged template literal" in there. Also thinking if we should emphasize that this is standard plain JS, considering how many other frameworks use some fork of JS.

And should we have a link to MDN on tagged template literals, or would we lose readers to the hyperlink void that way?"

"We don't mention that html is a function prior to this, we just call it a tag, so this could be a bit too much detail on that aspect. Could we say something around a lit-html template being an expression that returns a value that can be stored in variables, passed to and from functions, etc? I think JSX or React docs go into this a bit, for comparison."

"Rather than the specifics of the browser passing things to a tag function, we could describe the end result which is that the html tag captures the template strings and expression values separately, so that on repeated renders is can update only the expressions that changed.

One specific thing I have in mind there is around "re-render only the parts of template that have changed." - depending on our semantics here, the "template" doesn't change, only the values passed to it do. So we could lean more on saying we only update the expressions that change."

[docs] Add info on automatic XSS-prevention / escaped characters

Description

In this article, it mentions that 'lit-html' includes XSS-prevention. That's what lead me to this library.
https://benfrain.com/html-templating-with-vanilla-javascript-es2015-template-literals/

Naturally, I wanted to verify that before using lit-html so I searched for 'escape' and 'XSS' in the documentation, but I wasn't able to find any mention of that functionality anywhere.

By trial and error, I found out that lit-html automatically removes <script></script> tags when using the html tagged template literal.

I also could not find info about the unsafeHTML directive in the docs although it is included in the source code.

Introduction-- Why Lit?-- Write Content

Decide if this content goes here or on the main landing page.
Conclusion: probably OK to go here.
Even if it covers similar ground, it'll be in a different form.
Write content.

Choose canonical path for docs

By default eleventy adds a slash after filenames, but allows users to access the path without the slash. This results in relative URLs failing in some cases.

We need to pick a scheme and possibly add a redirect handler to rewrite the non-canonical form.

I prefer not adding the slash, because it's easier to write hrefs correctly when they match the file system. (When adding the slash, a sibling link from guides/foo to guides/bar needs to be written as ../bar/ instead of just bar.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.