Giter Club home page Giter Club logo

shoelace-style-angular's Introduction

ShoelaceStyleAngular

tests: passing tests with @shoelace-style/shoelace: 2.0.0-beta.63 npm: 1.0.15 license: MIT

Shoelace and Angular

src/app/app.module.ts

import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";

import { ShoelaceStyleAngularModule } from "shoelace-style-angular";

@NgModule({
    imports: [
        BrowserModule,
        // provide angular outputs for shoelace events:
        ShoelaceStyleAngularModule,
    ],
    // required 'cause shoelace based on Web Components:
    schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}

For using shoelace assets, add to config:

{
    "glob": "**/*.*",
    "input": "node_modules/@shoelace-style/shoelace/dist",
    "output": "/assets/shoelace"
}

and to src/main.ts:

import { setBasePath } from "@shoelace-style/shoelace";

setBasePath("/assets/shoelace");

Provide shoelace components and styles to index.html:

<link rel="stylesheet" href="/assets/shoelace/themes/light.css" />
<script type="module" src="/assets/shoelace/shoelace.js"></script>

Example

Pay attention to use two-way bindings for sl-dialog open attribute!

import { Component } from "@angular/core";
import { FormBuilder, Validators } from "@angular/forms";

@Component({
    selector: "app-greeter",
    template: `
        <sl-form [data]="form" (submit)="isDialogOpen = true">
            <sl-input name="username" label="Enter your name"></sl-input>
            <br />
            <sl-button submit [disabled]="form.invalid">Say Hello</sl-button>
        </sl-form>

        <sl-dialog label="Greetings" [(open)]="isDialogOpen">
            Hello,
            {{ form.get("username").value }}!
        </sl-dialog>
    `,
})
export class GreeterComponent {
    form = this.formBuilder.group({
        username: ["World", Validators.required],
    });

    isDialogOpen = false;

    constructor(private formBuilder: FormBuilder) {}
}

Provided Shoelace events

Shoelace event Angular output In template
sl-submit submit sl-form[data]
sl-change change sl-checkbox,
sl-color-picker,
sl-form,
sl-input,
sl-radio,
sl-range,
sl-rating,
sl-select,
sl-switch,
sl-textarea
sl-clear clear sl-tag[clearable]
sl-close close sl-tab[closable]
sl-load load sl-icon,
sl-include
sl-initial-focus,
sl-request-close
initialFocus,
requestClose
sl-dialog,
sl-drawer
sl-show,
sl-hide,
sl-after-show,
sl-after-hide
show,
hide,
afterShow,
afterHide
sl-alert,
sl-color-picker,
sl-details,
sl-dialog,
sl-drawer,
sl-dropdown,
sl-tooltip
sl-start,
sl-finish,
sl-cancel
start,
finish,
cancel
sl-animation
sl-resize resize sl-resize-observer

shoelace-style-angular's People

Contributors

paveldymkov avatar

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.