Context-Full Web Component Library

Overview

CWCO

CWCO Banner

npm license node version Build Build

Contextfull Web Component Library created to improve native Web Component APIs user experience with:

  • No Build Required!
  • Works with other library and frameworks
  • Reactive Template
  • Powerful built-in Directives(including ability to create your own)
  • Built-in Context Data Handling
  • Event and Data Binding in HTML and CSS
  • Build view directly in HTML file
  • Built-in Context
  • Simple API
  • Fast rendering
  • Lightweight package

Learn by Examples

Learn More From The Documentation or visit Examples Playground Page for an extensive list of examples of everything this library can do.

Watch Live Video Introduction

Get Started

Learn about how create a project or starting to explore CWCO as soon as possible.

Install

This module can be used directly in the browser as well in Node environment. You can even use it along with other web libraries and frameworks like React and Angular.

Browser

<!-- use the latest version -->
<script src="https://unpkg.com/cwco/dist/cwco.min.js"></script>

<!-- use a specific version -->
<script src="https://unpkg.com/[email protected]/dist/cwco.min.js"></script>

<!-- link your app script after -->
<script src="app.js"></script>

NodeJs

npm install cwco

You can then import the constructors class according to what you are building.

const { WebComponent, ContextProviderComponent, Directive } = require('cwco');

Code Editors & IDEs

CWCO is just HTML and if you want syntax highlighting for VSCode you can use the inline-html

VSCode

For syntax highlighting of HTML and CSS in javascript use inline-html or lit-html plugins.

You can import html from cwco which is just a help for VSCode which does nothing special to the HTML string you use it with.

import {html, WebComponent} from "./cwco";

class MyButton extends WebComponent {
  get template() {
    return html`<button><slot></slot></button>`
  }
  
  get stylesheet() {
    return html`<style>button {color: #222}</style>`
  }
}

Jet Brain IDEs

These IDEs have built-in HTML-in-Javascript syntax highlighting which can be useful when developing CWCO web components.

Documentation

Want to Help?

Learn How

Comments
  • Is there an vscode extension we can use for syntax highlighing in html templates?

    Is there an vscode extension we can use for syntax highlighing in html templates?

    Screenshot

    Right now it looks like a simple string. it'll be much better if we could get some syntax highlighting and ability to check/format the html and css in template string. Something like what the lit-html vscode extension does

    question feature request 
    opened by Pika-Pool 2
  • The pattern attribute may contain syntax that does not work with data binding syntax

    The pattern attribute may contain syntax that does not work with data binding syntax

    The following will break the component

    <input type="password" id="pwd" name="pwd"
      pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}"
      title="Must contain at least one  number and one uppercase and lowercase letter, and at least 8 or more characters">
    

    This is because it tries to resolve {8,} thinking its a data binding.

    We need a way to handle such cases when we have regex or something similar.

    wontfix 
    opened by ECorreia45 1
  • Properly handle Link tags in stylesheet mixed with style tag

    Properly handle Link tags in stylesheet mixed with style tag

    This will throw an error:

    
    class ExampleComponent extends WebComponent {
      stylesheet = `
            <link rel="stylesheet" href="./example.css">
            <style>:host {display: block;}</style>`;
    }
    
    

    It should allow stylesheet links to be mixed with style tags

    enhancement feature request 
    opened by ECorreia45 1
  • handle function calls in directives

    handle function calls in directives

    The following can be too much for template:

    
    <li repeat="app.todos.filter(todo => app.searchTerm.length >= 3 ? todo.title.toLowerCase().search(app.searchTerm) >= 0 : true)"
    ></li>
    

    This should be able to be formatted to

    <li repeat="getSearchMatchedList(app.todos)"></li>
    

    Right now the directive don't handle function calls as value, like the on* attributes do

    enhancement feature request won't do 
    opened by ECorreia45 1
  • build(deps): bump minimatch from 3.0.4 to 3.1.2

    build(deps): bump minimatch from 3.0.4 to 3.1.2

    Bumps minimatch from 3.0.4 to 3.1.2.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • build(deps): bump minimist from 1.2.5 to 1.2.6

    build(deps): bump minimist from 1.2.5 to 1.2.6

    Bumps minimist from 1.2.5 to 1.2.6.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Release 1.6.0

    Release 1.6.0

    • improve the tracking mechanism to better know when and where to update elements
    • better detect which properties need to be watched for changes;
    • improved rendering of slot tags to be faster and happen during the component mounting and not after
    • added support for stylesheet as object (beta)
    opened by ECorreia45 0
  • Bump minimist from 1.2.5 to 1.2.6

    Bump minimist from 1.2.5 to 1.2.6

    Bumps minimist from 1.2.5 to 1.2.6.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • fix: should update trackers before adding them to the dom

    fix: should update trackers before adding them to the dom

    fixes case where on directive node swap the dom elements are being updated only after being added to the DOM which causes value to be flashed with curly braces before changing into the correct value

    opened by ECorreia45 0
  • Release 1.5.0

    Release 1.5.0

    Improvements

    • improved style data binding anywhere inside the stylesheet body so even properties can be conditionally set;
    • better handling of :host selector and now support for :host-context as well;
    • styles added to the head tag of the document body when mode is none will receive data-bind updates as well.
    • Improved tracking system which delivers faster DOM updates in a much easier to maintain code re-organization

    Bug Fixes

    • a case where default property value inside the class was being ignored when the attribute was not present;
    • JSON string provided via attribute is not parsed to JSON object as it was doing on previous versions
    • slot tags now only trigger updates once instead of twice every time the component was added to the DOM;
    • When a special case of nested repeated tags with inner if attributes were throwing maximum call stack dues to a weird nesting of tracked nodes
    release 
    opened by ECorreia45 0
  • Simplified and improved tracking and context system

    Simplified and improved tracking and context system

    improves the tracking system in a way that it is:

    • easier to maintain;
    • no need for context data to be propagated via dom traversing down;
    • much better structured in small parts
    • remove the need for directives to clean up the DOM nodes attributes
    • no strict relationship is needed between the component and the tracker
    • better file structure and organization
    • faster updates
    enhancement 
    opened by ECorreia45 0
  • Add support for form association

    Add support for form association

    https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals

    Good article breaking it down

    https://javascript.plainenglish.io/web-components-can-now-be-native-form-elements-107c7a93386

    enhancement 
    opened by ECorreia45 0
  • Support for template literal for CSS and Template

    Support for template literal for CSS and Template

    Current

    template = `<button type=“{type}”></button>`
    

    New

    template = html`<button type=“${type}”></button>`
    

    Benefits:

    • syntax highlighting
    • no eval is needed
    enhancement feature request 
    opened by ECorreia45 0
  • Add Deno support

    Add Deno support

    Introduce a file similar to this one https://github.com/beforesemicolon/cwco/blob/master/src/node-window.ts for Deno DOM

    Refer to Node setup guide to understand how it is supposed to work

    help wanted feature request 
    opened by ECorreia45 0
  • Create a VSCode plugin for HTML and CSS highlight for CWCO

    Create a VSCode plugin for HTML and CSS highlight for CWCO

    The plugin does not need to exist inside this repo but anything to make it compatible can be done here.

    Submission of a plugin will make the contributor part of the core development of CWCO.

    Plugin name: cwco Features:

    • support syntax highlight;
    • support the data binding syntax and mapping to the data in the class
    • auto detection of CWCO syntax in .html, .css, .ts, .js, .cjs and .mjs files

    initial request: https://github.com/beforesemicolon/cwco/issues/15

    enhancement help wanted feature request 
    opened by ECorreia45 0
Releases(1.7.8)
  • 1.7.8(Nov 19, 2022)

    What's Changed

    • build(deps): bump minimist from 1.2.5 to 1.2.6 by @dependabot in https://github.com/beforesemicolon/cwco/pull/28
    • build(deps): bump minimatch from 3.0.4 to 3.1.2 by @dependabot in https://github.com/beforesemicolon/cwco/pull/32

    Full Changelog: https://github.com/beforesemicolon/cwco/compare/1.6.0...1.7.8

    Source code(tar.gz)
    Source code(zip)
  • 1.6.0(Apr 10, 2022)

    🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊

    This release tackled a lot of internal code cleanup and refactoring, bug fixes and speed and tracking improvements for an even smoother experience. Some of these are:

    Improvements 👌

    • Improved tracking mechanism to better know when and where to update elements
    • Better detect which properties need to be watched for changes;
    • Improved rendering of slot tags to be faster and happen during the component mounting and not after

    New  🎉

    • Added support for stylesheet as an object (beta) learn more

    What's Changed

    • fix: should update trackers before adding them to the dom by @ECorreia45 in https://github.com/beforesemicolon/cwco/pull/24
    • Bump minimist from 1.2.5 to 1.2.6 by @dependabot in https://github.com/beforesemicolon/cwco/pull/25
    • Css json by @ECorreia45 in https://github.com/beforesemicolon/cwco/pull/26
    • Release 1.6.0 by @ECorreia45 in https://github.com/beforesemicolon/cwco/pull/27

    New Contributors

    • @dependabot made their first contribution in https://github.com/beforesemicolon/cwco/pull/25

    Full Changelog: https://github.com/beforesemicolon/cwco/compare/1.5.0...1.6.0

    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Feb 5, 2022)

    🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊

    This new release improves the internal code organization and introduced a better node tracking system which delivers 25% better node updates even for complex context data setup.

    Improvements 👌

    • improved style data binding anywhere inside the stylesheet body so even properties can be conditionally set;
    • better handling of :host selector and now support for :host-context as well;
    • styles added to the head tag of the document body when mode is none will receive data-bind updates as well.
    • Improved tracking system which delivers faster DOM updates in a much easier to maintain code re-organization

    Fixes 🔨

    • a case where default property value inside the class was being ignored when the attribute was not present;
    • JSON string provided via attribute is not parsed to JSON object as it was doing on previous versions
    • slot tags now only trigger updates once instead of twice every time the component was added to the DOM;
    • When a special case of nested repeated tags with inner if attributes were throwing maximum call stack dues to a weird nesting of tracked nodes

    What's Changed

    • Develop by @ECorreia45 in https://github.com/beforesemicolon/cwco/pull/20
    • Simplified and improved tracking and context system by @ECorreia45 in https://github.com/beforesemicolon/cwco/pull/21
    • Release 1.5.0 by @ECorreia45 in https://github.com/beforesemicolon/cwco/pull/22

    Full Changelog: https://github.com/beforesemicolon/cwco/compare/1.4.0...1.5.0

    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Jan 19, 2022)

    🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊🎉🥳🎊

    Fixes: 🔨

    • Non-data-like objects were being proxied. These are things like DOM elements, class instances, etc. Now, only pure data objects are proxied. Things like Array, TypedArrays, Set, Map, and Object literals properties.
    • Components in none mode that are used many times on the page will have a global style in the header and inside the shadow DOM as well. This is no longer the case. Their style will be included once in the document head tag.
    • Inline event handling has better support and works just like web standards for inline event handling on tags now. This includes proper mapping of the this keyword and complex logic.
    • Stylesheet CSS selector grouping now works properly
    • Stylesheet CSS data binding for context web components restored. It stopped working with a previous update to support link in the stylesheet.
    • SVG tags are now parsed correctly. Previously they were being created with document.createElement instead of document.createElementNS

    Improvements: 👌

    • Internal type and enums are now exposed for usage under the CWCO namespace
    • Now anything can be passed via attributes including class instances, Set, Map, functions, etc.
    • Non-primitive value attribute is no longer kept on the element which would expose complex stringified data objects

    New: 🆕

    • New html utility for VSCode developers

    What's Changed

    • code of conduct by @ECorreia45 in https://github.com/beforesemicolon/cwco/pull/13
    • Support for more data type pass via attr by @ECorreia45 in https://github.com/beforesemicolon/cwco/pull/14
    • Release 1.4.0 by @ECorreia45 in https://github.com/beforesemicolon/cwco/pull/18

    Full Changelog: https://github.com/beforesemicolon/cwco/compare/1.3.0...1.4.0

    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Jan 9, 2022)

    🥳 👊🏽 🎉 🎊 🍾 🥂 🎁

    Fixes 🛠

    • examples-tab offset for firefox
    • Binding attribute will no longer keep the attribute with curly braces in the value

    New 🤩 🤯

    Improvements 🦾

    • More efficient context data propagation
    • Prevent unnecessary updates when directive value did not change

    What's Changed

    • fix current-tab-indicator offset in firefox by @dym-sh in https://github.com/beforesemicolon/cwco/pull/7
    • Release 1.3.0 by @ECorreia45 in https://github.com/beforesemicolon/cwco/pull/11

    New Contributors

    • @dym-sh made their first contribution in https://github.com/beforesemicolon/cwco/pull/7

    Full Changelog: https://github.com/beforesemicolon/cwco/compare/1.2.0...1.3.0

    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Jan 2, 2022)

    This release makes small internal improvements addressing some bugs and introducing small features:

    Improvements

    • Better handle multiple dom element references with ref directive where the list would contain duplicated entries of the same node;
    • Better support link tags in the stylesheet property and concat CSS style in the style tag to a single style tag.
    • Update docs broken links;
    • Several docs text fixes including improved examples and explanation of features;

    What's Changed

    • Release 1.1.1 by @ECorreia45 in https://github.com/beforesemicolon/cwco/pull/1

    New Contributors

    • @ECorreia45 made their first contribution in https://github.com/beforesemicolon/cwco/pull/1
    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(Jan 1, 2022)

Owner
Before Semicolon
Blog & Youtube Channel | Web, UI, Software Development & Developer's Career Tips
Before Semicolon
This is a full-stack exercise tracker web application built using the MERN (MongoDB, ExpressJS, ReactJS, NodeJS) stack. You can easily track your exercises with this Full-Stack Web Application.

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

WMouton 2 Dec 25, 2021
A lightweight vanilla JavaScript context menu library with FontAwesome support.

Contextify A lightweight vanilla JavaScript context menu library with FontAwesome support. This library was written for use in a personal project of m

Jacob Hampton 2 Jun 1, 2022
Todo-App with React-Context

View on Heroku : [https://todo-app-context.herokuapp.com/] Getting Started with Create React App This project was bootstrapped with Create React App.

Rahmi Köse 0 Jan 2, 2022
Finance-Tracker - A basic finance-tracker application built using Next.js, React Hooks and Context API

Next.js + Tailwind CSS Example This example shows how to use Tailwind CSS (v3.0) with Next.js. It follows the steps outlined in the official Tailwind

Osemwengie Benjamin 1 Jan 2, 2022
🚀🚀 A Shopify embedded app starter template, with updated dependencies, session storage, app context and examples for basic functionalities.

Shopify Node App Starter This is a starter template for embedded shopify apps based on the shopify cli node app. Contributions to create the perfect s

Carsten Lebek 143 Jan 8, 2023
Context-aware smart contracts for blockchain IoT systems

Context-aware smart contracts for blockchain IoT systems It contains 2 directories: contracts: contains the ContextAwareSmartContract.sol contract wit

ibelab 6 Jun 17, 2022
Context-carrying logger with conditional methods.

logger Provides a simple logging interface as well as a LogContext class which carries a context around. Installation npm install @rocicorp/logger Us

Rocicorp 9 May 20, 2022
mock APIs, intelligently, with context, and perform other stuff as well

@sasta-sa/project mock APIs, intelligently, with context, and perform other stuff as well ?? Setting up Clone the project git clone https://github.com

null 5 Jan 27, 2022
A free JavaScript plugin to create custom right click context menus.

CtxMenu (Javascript) A modern, light weight, object oriented solution for adding right click context menus for your website. demo Installation Downloa

Nils Söderman 18 Oct 13, 2022
Simple and lightweight vertical 3-dot context menu

3-dot Context Menu Thanks for taking a look at our 3-dot context menu for web development. The 3-dot context menu allows a simple and lightweight impl

Boardies IT Solutions 3 Nov 6, 2022
A demo of using the new require.context syntax in Expo with Metro bundler

Metro Context Modules Demo This is a demo of using the experimental 'Context Module' (require.context) feature in Metro bundler. Setup metro.config.js

Evan Bacon 17 Nov 19, 2022
A Node.js AI chatbot with unlimited context and chat history.

Memory Bot Memory Bot is an AI chatbot built with Node.js to demonstrate unlimited context and chat history for more cost-efficient context-aware conv

Gordon Mickel 6 May 10, 2023
This simple project, show how work with async Fetch, function component and class component

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

DaliyaAsel 2 Feb 17, 2022
dynamic-component-app is an angular application for dynamic component template creation

MyApp This project was generated with Angular CLI version 14.1.0. Development server Run ng serve for a dev server. Navigate to http://localhost:4200/

Aniket Muruskar 7 Aug 26, 2022
A component to quickly choose fonts from Google Web Fonts, custom fonts you (the web developer) provide, as well as system fonts.

Fontpicker jQuery Plugin A component to quickly choose fonts from Google Web Fonts, custom fonts you (the web developer) provide, as well as system fo

Arjan Haverkamp 24 Dec 3, 2022
Futurice web component library.

Ice Core Ice Core provides the core Ice web component library. Each web component comes with its own functional styling which can be customised as nee

Futurice 2 Mar 31, 2022
🗂 Universal Media Library as a web component.

Kondonizer Kondonizer is a custom element (a native HTML tag) that can be integrated in any frontend code. It displays a media library based on a Medi

EcoHead 6 Jul 19, 2022
Tool Cool Color Picker is a color picker library written in typescript and using web component technologies.

Tool Cool Color Picker Tool Cool Color Picker is a color picker library written in typescript and using web component technologies. Check out the demo

Tool Cool 13 Oct 23, 2022
Full Stack project- Web application to create a biking session

Bicycool Full Stack project: Web application to create a biking session To install and run the project: Run in the terminal of a server folder: -npm i

Hadassah Engel 12 Mar 10, 2022