npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

knowledgeworker-embedded-asset-api-ui

v2.0.0

Published

A javascript library to support native Knowledgeworker Create UI elements in rich content packages.

Downloads

9

Readme

Knowledgeworker Create Embedded Asset API - UI

A Javascript library to support native Knowledgeworker Create UI elements in rich content packages.

Usage

This library is integrated into knowledgeworker-embedded-asset-api by default and provides CSS variables, CSS classes and Javascript access for all important design params.
For development and review purposes, there is a fallback to default colors, fonts, etc. if you start your asset outside Knowledgeworker Create.

CSS Variables

If you use the knowledgeworker-embedded-asset-api, CSS variables are automatically added to your asset. They also stay up to date if the environment in Knowledgeworker Create changes, e.g. the background color changes. See the list of available variables below, use them in your CSS as usual, e.g. color: var(--kw-text-color);.

--kw-text-color
--kw-headline-color
--kw-action-color
--kw-action-text-color
--kw-action-hover-color
--kw-action-disabled-color
--kw-background-color
--kw-feedback-positive-color
--kw-feedback-partial-positive-color
--kw-feedback-negative-color
--kw-feedback-solution-color
--kw-text-font-size
--kw-text-font-family
--kw-headline-font-family
--kw-headline-font-weight
--kw-button-border-radius

CSS Classes

If you use the knowledgeworker-embedded-asset-api, CSS classes are automatically added to your asset. They also stay up to date if the environment in Knowledgeworker Create changes, e.g. the background color changes. See the list of available classes below, use them as normal in your HTML.

kw-paragraph - <p class="kw-paragraph">...</p>
kw-link - <a class="kw-link">...</a>
kw-headline2 - <h2 class="kw-headline2">...</h2>
kw-headline3 - <h3 class="kw-headline3">...</h3>
kw-headline4 - <h4 class="kw-headline4">...</h4>
kw-headline5 - <h5 class="kw-headline5">...</h5>
kw-headline6 - <h6 class="kw-headline6">...</h6>
kw-button-primary - <button class="kw-button-primary">...</button>
kw-button-secondary - <button class="kw-button-secondary">...</button>

Interactive Elements additionally support the disabled attribute to show they are currently not available.

kw-link - <a class="kw-link" disabled>...</a>
kw-button-primary - <button class="kw-button-primary" disabled>...</button>
kw-button-secondary - <button class="kw-button-secondary" disabled>...</button>

Javascript Access

If you use the knowledgeworker-embedded-asset-api you can listen to the onInitialize and on onDesignChanged events to get an object with all available design params. Initial design is provided via onInitialize; onDesignChanged is used in case the design changes later on.

Types:

export interface FontFaces {
    name: string;
    sources: {
        src: string;
        format: FontType;
    }[];
    fontWeight: string | number;
    fontStyle: string;
}

export interface Design {
    textColor: string;
    headlineColor: string;
    actionColor: string;
    actionTextColor: string;
    actionHoverColor: string;
    actionDisabledColor: string;
    backgroundColor: string;
    feedbackPositiveColor: string;
    feedbackPartialPositiveColor: string;
    feedbackNegativeColor: string;
    feedbackSolutionColor: string;
    textFontSize: string;
    textFontFamily: string;
    headlineFontFamily: string;
    headlineFontWeight: string;
    buttonBorderRadius: string;
    fontFaces: FontFaces[];
}

Example:

import { onInitialize, onDesignChanged } from 'knowledgeworker-embedded-asset-api';

onInitialize((configuration) => {
    // may use `configuration.design.textColor`
});

onDesignChanged((design) => {
    // may use `design.textColor`
});

Versioning

We use the SemVer versioning system. For the available versions, please see the tags on this repository.

Authors

Licence

This project is licensed under MIT licence. Please see LICENSE file for more information.