Giter Site home page Giter Site logo

spinner-button's Introduction

Spinner button web component

Spinner demo

Codepen

Installation

$ npm install @ayunoshev/spinner-button

Usage

To stylize, pass some or all of the custom properties from the first example. To activate spinner programmatically, use method activate(), to stop spinning - disactivate(). See Codepen

With ES modules

<!doctype html>
<html>
<head>
  <title>Example</title>
  <script type="module">
      import {registerSpinnerButtonComponent} from "./node_modules/@ayunoshev/spinner-button/dist/index.js";

      registerSpinnerButtonComponent();
      registerSpinnerButtonComponent('spinner-button');
  </script>
  <style>
    .my-style {
      --spinner-button-background-color: black;
      --spinner-button-background-color--disabled: black;
      --spinner-button-border-color: #FF1569;
      --spinner-button-text-color: #FF1569;
      --spinner-button-text-color--disabled: #1F1F1F;
      --spinner-button-inner-spinner-color: #FF1569;
      --spinner-button-outer-spinner-color: #FF1569;
    }
  </style>
</head>
<body
    style="background-color:black;
           display: grid;
           grid-template-columns: repeat(3, max-content);
           grid-gap: 20px">

<app-spinner-button id="btn">Call api</app-spinner-button>
<spinner-button class="my-style">Submit</spinner-button>

<script>
    document.getElementById('btn').addEventListener('click', () => {
        console.log('doing something async...')
    });
</script>

</body>
</html>

With Angular

In main.ts:

import {registerSpinnerButtonComponent} from '@ayunoshev/spinner-button';

registerSpinnerButtonComponent();

And then in the module in which you're going to use the component:

import {CUSTOM_ELEMENTS_SCHEMA, NgModule} from '@angular/core';
@NgModule({
  schemas: [
    CUSTOM_ELEMENTS_SCHEMA,
  ]
})
export class SomeModule {
}

Inside some component template of that module:

<app-spinner-button [attr.disabled]="!form.valid">Submit
</app-spinner-button>

spinner-button's People

Contributors

alexey-yunoshev avatar

Watchers

 avatar  avatar  avatar

spinner-button's Issues

Refactor

Files ending in .js, or extensionless files, when the nearest parent package.json file contains a top-level field "type" with a value of

Export element classes

import {SomeElement} from 'some-element';

customElements.define('my-some-element', class extends SomeElement{});

add https://github.com/webcomponents/custom-elements-json

export class MyElement extends LitElement {
// ...
}

customElements.define('my-element', MyElement);

declare global {
interface HTMLElementTagNameMap {
"my-element": MyElement,
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.