An open API service indexing awesome lists of open source software.

https://github.com/ianes1978/lit-element-webpack-starter

webcomponent starter with and without external CSS (Bootstrap)
https://github.com/ianes1978/lit-element-webpack-starter

bootstrap lit-element starter-kit webcomponents

Last synced: 2 months ago
JSON representation

webcomponent starter with and without external CSS (Bootstrap)

Awesome Lists containing this project

README

          

# lit-element webcomponent starter JS (+Bootstrap)
version Javascript of [lit-element webcomponent starter TS](https://github.com/ianes1978/lit-element-webpack-starter-typescript)

## intro
This is a simple starter of a webcomponent builded with lit-element library and webpack bundler.
![screen](https://github.com/ianes1978/lit-element-webpack-starter/blob/master/images/screenshot.PNG)

## first-component
example of naked webcomponent

## bs-component
A component that load from external css a global style.
**But preserve the shadowdom for scoped style**.
I think can be usefull to create a library of webcomponent that have to ereditate the global style.

## webcomponents-loader.js is a polyfill for webcomponents
webcomponents-loader.js is a polyfill for webcomponents

*in index.html:*
```



// Take care of cases in which the browser runs this
// script before it has finished running
// webcomponents-loader.js (e.g. Firefox script execution order)
window.WebComponents = window.WebComponents || {
waitFor(cb) { addEventListener('WebComponentsReady', cb) }
}

WebComponents.waitFor(async () => {
await import('./main.js');
});

```
## lit-css-global-scope
it is a simple module to import global style, you can replace with a simple script if you want:
```
import { css } from 'lit-element';
const styleRules = Object.values(document.styleSheets).reduce((obj,styleSheet)=>{
return obj = [...obj,...Object.values(styleSheet.cssRules)]
},[])

let externalStyles = styleRules.map(rule=>rule.cssText).join('\n');
externalStyles = externalStyles.replace(/html {/g,":host {");
externalStyles = externalStyles.replace(/@import/g,"/@import");
externalStyles = css([externalStyles]);

export {externalStyles};
```

# Use it
### Project setup
```
git clone https://github.com/ianes1978/lit-element-webpack-starter.git

npm install
```

### Compiles and hot-reloads for development
```
npm start
```

### Compiles and minifies for production
```
npm run build
```