🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@ajnauleau/custom-components

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ajnauleau/custom-components

'Simple Custom Web Components for your Project'

latest
Source
npmnpm
Version
1.0.10
Version published
Maintainers
1
Created
Source

Custom Web Components

Make and style custom web components easily!

Installation

$ npm install --save @ajnauleau/custom-components

Style

First start out by adding css styles to your component:

import { Component } from '@ajnauleau/custom-components';


const Custom = Component.styled`
    color: red;
    background: black;
`;

Extend

Extend your component by adding any valid HTML between template literals ``:

class WebComponent extends Custom {

    constructor() {
        super();
    }

    render() {
        let world = 'world';
        return (
            `<div>
                <p>hello ${world}</p>
             <div>
             `
        )
    }
}

Render

Render your new web component and give it a custom name. REMEMBER! Web component names must use a hyphen (-).

customElements.define('custom-component', WebComponent);

Result

Embed and link your javascript, then use your new custom component.

<html>
    <body>
        <custom-component>
        </custom-component>
        <script type="module" src="./index.js"></script>
    </body>
</html>

Summary

Here's the complete javascript file for your reference.

import Component from '@ajnauleau/custom-components';


const Custom = Component.styled`
    color: red;
    background: black;
`;


class WebComponent extends Custom {

    constructor() {
        super();
    }

    render() {
        return (
            `<p>hello</p>`
        )
    }

}


customElements.define('custom-component', WebComponent);

Coming Soon!

Access Props

Attribute to Props, similar to React

Lifecycle

constructor()

render()

componentDidMount()

componentDidUpdate()

componentWillUnmount()

Keywords

styled

FAQs

Package last updated on 03 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts