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

add generic <ezql-prompt /> web component #20

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions config/tsconfig.cli.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"include": ["../cli/**/*", "../src/**/*"],
"exclude": ["../src/lit-ezql"],
"compilerOptions": {
"rootDir": "..",
"outDir": "../dist",
Expand Down
21 changes: 21 additions & 0 deletions src/lit-ezql/.eleventy.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');

module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addPassthroughCopy('docs-src/docs.css');
eleventyConfig.addPassthroughCopy('docs-src/.nojekyll');
eleventyConfig.addPassthroughCopy(
'node_modules/@webcomponents/webcomponentsjs'
);
eleventyConfig.addPassthroughCopy('node_modules/lit/polyfill-support.js');
return {
dir: {
input: 'docs-src',
output: 'docs',
},
templateExtensionAliases: {
'11ty.cjs': '11ty.js',
'11tydata.cjs': '11tydata.js',
},
};
};
6 changes: 6 additions & 0 deletions src/lit-ezql/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/*
docs/*
docs-src/*
rollup-config.js
custom-elements.json
web-dev-server.config.js
51 changes: 51 additions & 0 deletions src/lit-ezql/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"env": {
"browser": true
},
"rules": {
"no-prototype-builtins": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_"
}
]
},
"overrides": [
{
"files": ["rollup.config.js", "web-test-runner.config.js"],
"env": {
"node": true
}
},
{
"files": [
"*_test.ts",
"**/custom_typings/*.ts",
"packages/labs/ssr/src/test/integration/tests/**",
"packages/labs/ssr/src/lib/util/parse5-utils.ts"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
}
]
}
11 changes: 11 additions & 0 deletions src/lit-ezql/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/node_modules/
/lib/
/test/
custom-elements.json
# top level source
my-element.js
my-element.js.map
my-element.d.ts
my-element.d.ts.map
# only generated for size check
my-element.bundled.js
7 changes: 7 additions & 0 deletions src/lit-ezql/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"singleQuote": true,
"bracketSpacing": false,
"arrowParens": "always"
}
9 changes: 9 additions & 0 deletions src/lit-ezql/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": ["runem.lit-plugin"],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}
28 changes: 28 additions & 0 deletions src/lit-ezql/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2019 Google LLC. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
134 changes: 134 additions & 0 deletions src/lit-ezql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# LitElement TypeScript starter

This project includes a sample component using LitElement with TypeScript.

This template is generated from the `lit-starter-ts` package in [the main Lit
repo](https://github.com/lit/lit). Issues and PRs for this template should be
filed in that repo.

## Setup

Install dependencies:

```bash
npm i
```

## Build

This sample uses the TypeScript compiler to produce JavaScript that runs in modern browsers.

To build the JavaScript version of your component:

```bash
npm run build
```

To watch files and rebuild when the files are modified, run the following command in a separate shell:

```bash
npm run build:watch
```

Both the TypeScript compiler and lit-analyzer are configured to be very strict. You may want to change `tsconfig.json` to make them less strict.

## Testing

This sample uses modern-web.dev's
[@web/test-runner](https://www.npmjs.com/package/@web/test-runner) for testing. See the
[modern-web.dev testing documentation](https://modern-web.dev/docs/test-runner/overview) for
more information.

Tests can be run with the `test` script, which will run your tests against Lit's development mode (with more verbose errors) as well as against Lit's production mode:

```bash
npm test
```

For local testing during development, the `test:dev:watch` command will run your tests in Lit's development mode (with verbose errors) on every change to your source files:

```bash
npm test:watch
```

Alternatively the `test:prod` and `test:prod:watch` commands will run your tests in Lit's production mode.

## Dev Server

This sample uses modern-web.dev's [@web/dev-server](https://www.npmjs.com/package/@web/dev-server) for previewing the project without additional build steps. Web Dev Server handles resolving Node-style "bare" import specifiers, which aren't supported in browsers. It also automatically transpiles JavaScript and adds polyfills to support older browsers. See [modern-web.dev's Web Dev Server documentation](https://modern-web.dev/docs/dev-server/overview/) for more information.

To run the dev server and open the project in a new browser tab:

```bash
npm run serve
```

There is a development HTML file located at `/dev/index.html` that you can view at http://localhost:8000/dev/index.html. Note that this command will serve your code using Lit's development mode (with more verbose errors). To serve your code against Lit's production mode, use `npm run serve:prod`.

## Editing

If you use VS Code, we highly recommend the [lit-plugin extension](https://marketplace.visualstudio.com/items?itemName=runem.lit-plugin), which enables some extremely useful features for lit-html templates:

- Syntax highlighting
- Type-checking
- Code completion
- Hover-over docs
- Jump to definition
- Linting
- Quick Fixes

The project is setup to recommend lit-plugin to VS Code users if they don't already have it installed.

## Linting

Linting of TypeScript files is provided by [ESLint](eslint.org) and [TypeScript ESLint](https://github.com/typescript-eslint/typescript-eslint). In addition, [lit-analyzer](https://www.npmjs.com/package/lit-analyzer) is used to type-check and lint lit-html templates with the same engine and rules as lit-plugin.

The rules are mostly the recommended rules from each project, but some have been turned off to make LitElement usage easier. The recommended rules are pretty strict, so you may want to relax them by editing `.eslintrc.json` and `tsconfig.json`.

To lint the project run:

```bash
npm run lint
```

## Formatting

[Prettier](https://prettier.io/) is used for code formatting. It has been pre-configured according to the Lit's style. You can change this in `.prettierrc.json`.

Prettier has not been configured to run when committing files, but this can be added with Husky and `pretty-quick`. See the [prettier.io](https://prettier.io/) site for instructions.

## Static Site

This project includes a simple website generated with the [eleventy](11ty.dev) static site generator and the templates and pages in `/docs-src`. The site is generated to `/docs` and intended to be checked in so that GitHub pages can serve the site [from `/docs` on the master branch](https://help.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site).

To enable the site go to the GitHub settings and change the GitHub Pages &quot;Source&quot; setting to &quot;master branch /docs folder&quot;.</p>

To build the site, run:

```bash
npm run docs
```

To serve the site locally, run:

```bash
npm run docs:serve
```

To watch the site files, and re-build automatically, run:

```bash
npm run docs:watch
```

The site will usually be served at http://localhost:8000.

## Bundling and minification

This starter project doesn't include any build-time optimizations like bundling or minification. We recommend publishing components as unoptimized JavaScript modules, and performing build-time optimizations at the application level. This gives build tools the best chance to deduplicate code, remove dead code, and so on.

For information on building application projects that include LitElement components, see [Build for production](https://lit.dev/docs/tools/production/) on the Lit site.

## More information

See [Get started](https://lit.dev/docs/getting-started/) on the Lit site for more information.
1 change: 1 addition & 0 deletions src/lit-ezql/dev/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory contains HTML files containing your element for development. By running `npm run build:watch` and `npm run serve` you can edit and see changes without bundling.
22 changes: 22 additions & 0 deletions src/lit-ezql/dev/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8" />
<title>&lt;my-element> Demo</title>
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
<script src="../node_modules/lit/polyfill-support.js"></script>
<script type="module" src="../my-element.js"></script>
<style>
p {
border: solid 1px blue;
padding: 8px;
}
</style>
</head>
<body>
<my-element>
<p>This is child content</p>
</my-element>
</body>
</html>
2 changes: 2 additions & 0 deletions src/lit-ezql/docs-src/.eleventyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore files with a leading underscore; useful for e.g. readmes in source documentation
_*.md
Empty file added src/lit-ezql/docs-src/.nojekyll
Empty file.
7 changes: 7 additions & 0 deletions src/lit-ezql/docs-src/_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This directory contains the sources for the static site contained in the /docs/ directory. The site is based on the [eleventy](11ty.dev) static site generator.

The site is intended to be used with GitHub pages. To enable the site go to the GitHub settings and change the GitHub Pages "Source" setting to "master branch /docs folder".

To view the site locally, run `npm run docs:serve`.

To edit the site, add to or edit the files in this directory then run `npm run docs` to build the site. The built files must be checked in and pushed to GitHub to appear on GitHub pages.
16 changes: 16 additions & 0 deletions src/lit-ezql/docs-src/_data/api.11tydata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/

const fs = require('fs');

module.exports = () => {
const customElements = JSON.parse(
fs.readFileSync('custom-elements.json', 'utf-8')
);
return {
customElements,
};
};
43 changes: 43 additions & 0 deletions src/lit-ezql/docs-src/_includes/example.11ty.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const page = require('./page.11ty.cjs');
const relative = require('./relative-path.cjs');

/**
* This template extends the page template and adds an examples list.
*/
module.exports = function (data) {
return page({
...data,
content: renderExample(data),
});
};

const renderExample = ({name, content, collections, page}) => {
return `
<h1>Example: ${name}</h1>
<section class="examples">
<nav class="collection">
<ul>
${
collections.example === undefined
? ''
: collections.example
.map(
(post) => `
<li class=${post.url === page.url ? 'selected' : ''}>
<a href="${relative(
page.url,
post.url
)}">${post.data.description.replace('<', '&lt;')}</a>
</li>
`
)
.join('')
}
</ul>
</nav>
<div>
${content}
</div>
</section>
`;
};
9 changes: 9 additions & 0 deletions src/lit-ezql/docs-src/_includes/footer.11ty.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = function (data) {
return `
<footer>
<p>
Made with
<a href="https://github.com/lit/lit-element-starter-ts">lit-starter-ts</a>
</p>
</footer>`;
};
7 changes: 7 additions & 0 deletions src/lit-ezql/docs-src/_includes/header.11ty.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function (data) {
return `
<header>
<h1>&lt;my-element></h1>
<h2>A web component just for me.</h2>
</header>`;
};
Loading