# @axioms/axioms-ui

> Axioms Stencil Component Collection

Latest version **0.0.3** (published 2020-10-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @axioms/axioms-ui
pnpm add @axioms/axioms-ui
yarn add @axioms/axioms-ui
bun add @axioms/axioms-ui
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2020-10-07 |
| First published | 2020-10-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | abhishektiwari |

## Links

- npm: https://www.npmjs.com/package/@axioms/axioms-ui
- Repository: https://github.com/axioms-io/axioms-ui
- Homepage: https://github.com/axioms-io/axioms-ui#readme
- Issues: https://github.com/axioms-io/axioms-ui/issues
- npm.io page: https://npm.io/package/@axioms/axioms-ui

## Dependencies (3)

- [latest](https://npm.io/package/latest.md) ^0.2.0
- [@stencil/core](https://npm.io/package/@stencil/core.md) ^2.0.1
- [google-libphonenumber](https://npm.io/package/google-libphonenumber.md) ^3.2.13

## Recent versions

- 0.0.3 (latest) — 2020-10-07
- 0.0.2 — 2020-10-04
- 0.0.1 — 2020-10-03

## README

# Axioms UI ![NPM](https://img.shields.io/npm/v/@axioms/axioms-ui?style=flat-square)
Ready to use Axioms custom elements to quickly add authentication in your static web sites and single page apps.


# Install

## As Script Tag
Add following script tags in HTML header,

```html
<script type="module" src="https://cdn.jsdelivr.net/npm/@axioms/axioms-ui@0.0.3/dist/axioms-ui/axioms-ui.esm.js"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/@axioms/axioms-ui@0.0.3/dist/axioms-ui/axioms-ui.js"></script>
```

## As NPM Package
Install NPM package,

```bash
npm i @axioms/axioms-ui
```

# Use
An example of how to use the web component with html,

```html
<passwordless-code channel="sms" tenant-domain="axioms.example.com" client-id="SWmAwjdKxGK3cDTBnCoBiFbDpbQKX6nW_JQUv5xgXma1Ta8WXFm88NvPr4tNQTvI" start-button-label="Get started now"  />
```

Additionally you can hide or show content based on authentication.

```html
<div style="display: none;" id="auth-content ">
    <p id="logged-in ">You are logged in.</p>
    <p id="logged-in-status "></p>
    <button class='btn' onclick="logout()">Logout now</button>
</div>
<script>
    var hasAuth = false;
    var idTokenPayload;

    document.addEventListener("DOMContentLoaded", checkAuth);

    async function checkAuth() {
        await customElements.whenDefined('passwordless-code');

        const passwordLinkElement = document.querySelector('passwordless-code');
        const authContentElement = document.getElementById("auth-content ");

        if (passwordLinkElement) {
            hasAuth = await passwordLinkElement.isAuthenticated();
            idTokenPayload = await passwordLinkElement.getIdTokenPayload();
            if (hasAuth) {
                authContentElement.style.display = "block ";
                var expires_at = new Date(idTokenPayload.exp * 1000).toLocaleString("en-US")
                var paragraph = document.getElementById("logged-in-status ");
                var status = document.createTextNode(
                    `Your username is ${idTokenPayload.preferred_username} and you session expires at ${expires_at}.`);
                paragraph.appendChild(status)
            } else {
                authContentElement.style.display = "none ";
            }
        }
    }
    const passwordLinkElement = document.querySelector('passwordless-code');
    passwordLinkElement.addEventListener('authCompleted', event => updateContent(event));

    function updateContent(event) {
        location.reload()
    }

    async function logout() {
        const passwordLinkElement = document.querySelector('passwordless-code');
        idTokenPayload = await passwordLinkElement.logout();
    }
</script>
```

# Styling
Set value for css variables to style web components according to your requirements.

```html
<style>
    @import url('https://fonts.googleapis.com/css2?family=Sen&display=swap');
    :root {
        --app-primary-color: #ff5136;
        --app-secondary-color: #6c757d;
        --app-text-color: #000;
        --app-font-family: 'Sen', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
    }
</style>
```

# Component Documentation
List of available props, events, and methods for each component.

- [Passwordless using Link](https://github.com/axioms-io/axioms-ui/tree/master/src/components/passwordless-link)
- [Passwordless using Code](https://github.com/axioms-io/axioms-ui/tree/master/src/components/passwordless-code)

---
_Source: https://npm.io/package/@axioms/axioms-ui · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
