Skip to content

Commit

Permalink
use LitElement and Redux
Browse files Browse the repository at this point in the history
  • Loading branch information
kherrick committed Sep 24, 2019
1 parent 9beda1c commit 080ce32
Show file tree
Hide file tree
Showing 154 changed files with 6,076 additions and 14,587 deletions.
24 changes: 12 additions & 12 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

{
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-object-rest-spread"
],
"presets": [
["babel-preset-env", {
"modules": false,
"targets": {
"browsers": "ie >= 11"
[
"@babel/preset-env",
{
"targets": {
"esmodules": true
}
}
}]
],
"env": {
"test": {
"presets": [["babel-preset-env"]]
}
}
]
]
}
23 changes: 22 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[**]

[*]

# Change these settings to your own preference
indent_style = space
indent_size = 2

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.json]
indent_size = 2

[*.{html,js,md}]
block_comment_start = /**
block_comment = *
block_comment_end = */
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/dist

/dev/index.html
/index.html
23 changes: 6 additions & 17 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
{
"extends": "eslint:recommended",
"env": {
"es6": true,
"browser": true
},
"globals": {
"__dirname": true,
"process": true
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"extends": ["plugin:prettier/recommended"],
"rules": {
"eol-last": [
"error",
"always"
],
"no-multiple-empty-lines": [
"prettier/prettier": [
"error",
{
"max": 1,
"maxBOF": 1,
"maxEOF": 1
"singleQuote": true,
"semi": false,
"printWidth": 120
}
]
}
Expand Down
21 changes: 16 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
/bundle/
/dist/
/node_modules
/src/index.html
/tests/jest/coverage
## editors
/.vscode

## system files
.DS_Store

## npm
/node_modules/
/npm-debug.log

## temp folders
/.tmp/

## built files
/dist
/service-worker.js
Empty file added .nojekyll
Empty file.
114 changes: 50 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,85 +1,71 @@
x-weather
======
# \<x-weather>

## About

* A collection of [web components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) implementing portions of the [OpenWeatherMap API](https://openweathermap.org/api).
A collection of [web components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) implementing portions of the [OpenWeatherMap API](https://openweathermap.org/api).

<a href="https://kherrick.github.io/x-weather/">
<img src="https://raw.githubusercontent.com/kherrick/x-weather/master/assets/x-weather-screenshot.png" width="75%" />
</a>
<a href="https://kherrick.github.io/x-weather/">
<img src="https://raw.githubusercontent.com/kherrick/x-weather/master/assets/x-weather-screenshot.png" width="75%" />
</a>

## Installation

### Add Internet Explorer 11 compatible polyfills

```html
<div id="ce-es5-shim">
<script>
if (!window.customElements) {
var ceShimContainer = document.querySelector('#ce-es5-shim')
// This prevents custom-elements-es5-adapter.js from parsing or running.
ceShimContainer.parentElement.removeChild(ceShimContainer)
}
</script>
## Usage

<!-- Required, due to a conflict between the polyfills, transpilation, and IE... -->
<script
charset="utf-8"
src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"
></script>
</div>
### Static Import Example:

<!-- Web component polyfill (only loads what it needs) -->
<script
charset="utf-8"
src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs/webcomponents-lite.js"
></script>
Install:
```bash
npm i x-weather
```

### Load and register the web component in the CustomElementRegistry
Render:

```html
<script src="https://cdn.jsdelivr.net/npm/x-weather@latest/lib/build-ie11-iife/iife/main.js"></script>
```
<script type="module">
import * as XWeather from './node_modules/x-weather/dist/esm/module.js'
## Usage
XWeather.defineCustomElements()
</script>
<x-weather
appid="NOT_A_REAL_APP_ID"
location="Detroit, Michigan"
>
<x-current primaryscale="f"></x-current>
<x-forecast days="14" primaryscale="f"></x-forecast>
</x-weather>
```

* After installation and [signing up for an API key](https://home.openweathermap.org/users/sign_up), use the custom element:
### Dynamic Import Example:

Render:
```html
<script>
import('https://unpkg.com/x-weather/dist/esm/defineCustomElements.js')
.then(({
defineCustomElements
}) => {
defineCustomElements()
})
</script>
<x-weather
appid="NOT_A_REAL_API_KEY"
host="api.openweathermap.org"
location="Phoenix, Arizona"
appid="NOT_A_REAL_APP_ID"
location="Detroit, Michigan"
>
<style>
x-current {
float: left;
width: 12rem;
}
x-forecast {
--x-forecast-item-float: left;
--x-forecast-item-width: 12rem;
}
</style>
<x-current scale="F"></x-current>
<x-forecast days="2" scale="F"></x-forecast>
<x-current primaryscale="f"></x-current>
<x-forecast days="14" primaryscale="f"></x-forecast>
</x-weather>
```

## Additional information
## Development
```bash
npm run start
```

## Lint
```bash
npm run lint
```

* Other builds and examples (including basic service workers) can be found inside the [lib folder](https://github.com/kherrick/x-weather/tree/master/lib)
* The package can be installed and imported by npm:
- `npm i x-weather`
- `import 'x-weather/lib/build-no-polyfills-esm/esm/main'`
* Building basics:
- Site
* `NODE_ENV=production npm run build`
- Module
* `NODE_ENV=production npm run bundle-modules`
- Template
* `npm run build-templates API-KEY SERVICE-WORKER-URL`
## Build
```bash
npm run build
```
34 changes: 0 additions & 34 deletions bin/build_templates

This file was deleted.

19 changes: 0 additions & 19 deletions bin/npm_check

This file was deleted.

41 changes: 0 additions & 41 deletions config/rollup.config.custom.elements.shady.dom-esm.js

This file was deleted.

43 changes: 0 additions & 43 deletions config/rollup.config.custom.elements.shady.dom-systemjs.js

This file was deleted.

Loading

0 comments on commit 080ce32

Please sign in to comment.