@granite-elements/granite-c3
Advanced tools
Comparing version 3.0.2 to 3.1.0
{ | ||
"extends": ["eslint:recommended", "google"], | ||
"parserOptions": { | ||
"ecmaVersion": 6 | ||
"ecmaVersion": 6, | ||
"sourceType": "module" | ||
}, | ||
@@ -6,0 +7,0 @@ "env": { |
@@ -5,22 +5,4 @@ | ||
import '@granite-elements/granite-js-dependencies-grabber/granite-js-dependencies-grabber.js'; | ||
import { GraniteCssInjector } from '@granite-elements/granite-external-dependencies/granite-css-injector.js' | ||
/* | ||
* We need to get the C3 CSS to inject in in every instance of granite-c3 | ||
*/ | ||
let c3Css = null; | ||
function pathFromUrl(url) { | ||
return url.substring(0, url.lastIndexOf('/') + 1); | ||
} | ||
async function getC3Css() { | ||
let response = await fetch(`${pathFromUrl(import.meta.url)}../../c3/c3.min.css`); | ||
c3Css = await response.text(); | ||
console.log('[granite-c3] getC3Css', c3Css); | ||
document.dispatchEvent(new CustomEvent('c3-css-available')); | ||
} | ||
getC3Css(); | ||
/* global c3 */ | ||
@@ -51,3 +33,3 @@ /** | ||
*/ | ||
class GraniteC3 extends PolymerElement { | ||
class GraniteC3 extends GraniteCssInjector(PolymerElement) { | ||
static get template() { | ||
@@ -76,2 +58,3 @@ return html` | ||
} | ||
/** | ||
@@ -86,2 +69,9 @@ * In order to statically import non ES mudules resources, you need to use `importPath`. | ||
static get cssFiles() { | ||
return [ | ||
{ name: 'c3', path: 'c3/c3.min.css' } | ||
]; | ||
} | ||
static get is() { return 'granite-c3'; } | ||
@@ -304,16 +294,2 @@ static get properties() { | ||
super.connectedCallback(); | ||
if (c3Css) { | ||
if (this.debug) { | ||
console.log('[granite-c3] connectedCallback - CSS already available'); | ||
} | ||
} else { | ||
if (this.debug) { | ||
console.log('[granite-c3] connectedCallback - CSS not yet available'); | ||
} | ||
document.addEventListener('c3-css-available', (evt) => { | ||
console.log('[granite-c3] connectedCallback - received CSS available method'); | ||
this.shadowRoot.querySelector('style').appendChild(document.createTextNode(c3Css)); | ||
}) | ||
} | ||
} | ||
@@ -320,0 +296,0 @@ |
@@ -17,3 +17,3 @@ { | ||
"name": "@granite-elements/granite-c3", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"resolutions": { | ||
@@ -30,2 +30,3 @@ "inherits": "2.0.3", | ||
"dependencies": { | ||
"@granite-elements/granite-external-dependencies": "^1.0.0", | ||
"@granite-elements/granite-js-dependencies-grabber": "^2.0.3", | ||
@@ -32,0 +33,0 @@ "@polymer/lit-element": "^0.5.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
0
27703
5
300