Coder Social home page Coder Social logo

vicmans / ng-toggle-button Goto Github PK

View Code? Open in Web Editor NEW
8.0 0.0 6.0 1.9 MB

Angular toggle button switch

Home Page: https://ng-toggle-button.netlify.app/

License: MIT License

JavaScript 7.38% TypeScript 52.62% HTML 36.36% CSS 0.21% SCSS 3.43%
angular button component-library toogleswitch toggle-switch toggle-button

ng-toggle-button's People

Contributors

dependabot[bot] avatar isaac-hughes avatar pflopez avatar snowfrogdev avatar vicmans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng-toggle-button's Issues

Required validator

It would be nice if ng-toggle-button could be compatible with Angular Forms' required validator.

Generic type 'ɵɵComponentDeclaration' error

Hi there, Im seeing an error like #48 when trying to use this component on my app.

Error: node_modules/ng-toggle-button/lib/ng-toggle.component.d.ts:81:18 - error TS2707: Generic type 'ɵɵComponentDeclaration' requires between 7 and 8 type arguments.

81     static ɵcmp: i0.ɵɵComponentDeclaration<NgToggleComponent, "ng-toggle", never, { "value": "value"; "name": "name"; "disabled": "disabled"; "height": "height"; "width": "width"; "margin": "margin"; "fontSize": "fontSize"; "speed": "speed"; "color": "color"; "switchColor": "switchColor"; "labels": "labels"; "fontColor": "fontColor"; "values": "values"; "id": "id"; "ariaLabel": "aria-label"; "ariaLabelledby": "aria-labelledby"; "ariaDescribedby": "aria-describedby"; }, { "change": "change"; "valueChange": "valueChange"; }, never, never, false, never>;

Im using:

"@angular/common": "^14.0.0",
"ng-toggle-button": "^1.4.1",

and node v18.16.0.

I've also tried with "ng-toggle-button": "^1.5.1", but same error.

I've downloaded the repo and run the demo with no errors though. Not sure if Im using the right version of ng-toggle-button for angular 14. Any help appreciated.
Thanks!

Keyboard Navigation

For accessibility purposes the toggle should be tabbable and triggerable with keyboard events.

Great package by the way!

Angular 15

Hi.

After module Import
Error: node_modules/ng-toggle-button/lib/ng-toggle.component.d.ts:75:18 - error TS2707:
ERROR: Generic type 'ɵɵComponentDeclaration' requires between 7 and 8 type arguments.

Focus and blur improvements

It should be possible to focus the toggle using the Tab key on the keyboard. The toggle should handle blur events properly in relation to Angular form control's pristine and touched state. That is to say that if the toggle is focused using the keyboard and then unfocused, it should still be marked as touched even if the toggle value wasn't changed.

Accessibility issue "Form elements must have labels"

Accessibility tools raise an error to do with the input label

ARC Toolkit (Chrome Extension)

Empty label text
Description:
The <label> associated with the form control is empty.
<input type="checkbox" class="ng-toggle-switch-input" name="">

Axe Expert (Chrome Extension)

Issue description
Ensures every form element has a label

<input type="checkbox" class="ng-toggle-switch-input" name="">

To solve this violation, you need to...
Fix at least one (1) of these issues:

  • Form element does not have an implicit (wrapped)
    Related node:
    label
  • Form element does not have an explicit
  • aria-label attribute does not exist or is empty
  • aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty
  • Element has no title attribute
  • Element has no placeholder attribute
  • Element's default semantics were not overridden with role="none" or role="presentation"

Please include a changelog for releases

Hi,
to try and stay up-to-date with my dependencies, I use renovatebot like many.

Unfortunately ng-toggle-button does not provide a changelog file, so even tho I have unit and e2e tests, I need to check your source code changes before upgrading to a newer version, and if the changes seem important, I need to test manually.

A simple changelog would really help me in determining whether or not I should test a new version manually or I can just trust the tests.

Thank you for this project and for considering this suggestion!

Setting initial value does not work.

Try it in your stackblitz, change the config.value to false.
Furtheron it should be possible to programmatically change the toggle button via the value property (not only for the initial state).

Center align text

I am using this component in angular 15.

Is there any property by which we can center align text? Currently, it is either left or right.

image

image

[(ngModel)] doesn't work (Angular v13.0.x)

Found a small problem. ngModel doesn't work on angular v13.
Why is this even needed? why not make value a two way binding?

I tested this with the sample code locally. Can't share a stackblitz link because they don't support v13 yet.

The property and event halves of the two-way binding 'ngModel' are not bound to the same target.
Find more at https://angular.io/guide/two-way-binding#how-two-way-binding-works

35 <ng-toggle [(ngModel)]="config.value">
~~~~~~~

node_modules/ng-toggle-button/lib/ng-toggle.component.d.ts:4:22
4 export declare class NgToggleComponent implements OnInit, ControlValueAccessor {
~~~~~~~~~~~~~~~~~
The property half of the binding is to the 'NgToggleComponent' component.
node_modules/@angular/forms/forms.d.ts:3649:22
3649 export declare class NgModel extends NgControl implements OnChanges, OnDestroy {
~~~~~~~
The event half of the binding is to the 'NgModel' component.
src/app/app.component.ts:28:16
28 templateUrl: './app.component.html',
~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component AppComponent.

ERROR in node_modules/ng-toggle-button/lib/ng-toggle.module.d.ts:1:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

This likely means that the library (ng-toggle-button) which declares NgToggleModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

Angular version:

`
Angular CLI: 9.1.15
Node: 14.17.3
OS: win32 x64

Angular: 9.1.13
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package Version

@angular-devkit/architect 0.901.15
@angular-devkit/build-angular 0.901.15
@angular-devkit/build-optimizer 0.901.15
@angular-devkit/build-webpack 0.901.15
@angular-devkit/core 9.1.15
@angular-devkit/schematics 9.1.15
@angular/cli 9.1.15
@ngtools/webpack 9.1.15
@schematics/angular 9.1.15
@schematics/update 0.901.15
rxjs 6.6.6
typescript 3.8.3
webpack 4.42.0`

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.