Coder Social home page Coder Social logo

geekyeggo / sdpi-components Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 2.0 5.77 MB

Web components for your Stream Deck plugin; take the hassle out of the property inspector.

Home Page: https://sdpi-components.dev

License: MIT License

TypeScript 93.45% HTML 4.88% JavaScript 1.67%
property-inspector streamdeck streamdeck-tools sdpi streamdeck-plugins

sdpi-components's People

Contributors

geekyeggo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jamesmighty hrko

sdpi-components's Issues

Select doesn't properly support onchange event.

I was perusing this as a potential overhaul for my PI, but I currently use the onchange="funcXYZ(this.value)" to react to changes when a new selection is made.

I can't seem to get it to work?

[Discussion] Expand Data Source

To set the stage: I'm currently working on a StreamDeck plugin for Firebot, a Twitch chatbot. Firebot has something called preset effect lists, that can be controlled via API. Effect lists can have variables that you can pass on execution. I'd love to essentially have a group of sdpi-textfields that are controlled by a data source (array of label strings) that output into an object as it would greatly simplify my end of things with the plugin.

@GeekyEggo Would you be okay with having a component like this? If so, I'll have a look at implementing and contributing it.

Add support for localizations

Background

The Stream Deck SDK provides support for localization in the form of multiple manifest files suffixed with locale codes, e.g. manifest.de.json; official, Stream Deck offers support for the following languages:

  • Chinese: zh_CN
  • German: de
  • English: en
  • French: fr
  • Japanese: ja
  • Korean: ko
  • Spanish: es

Proposal

For content rendered as part of sdpi-components, it should be possible to offer a means of displaying translated content. This should be achievable in a centralized way that reduces duplication of both resources, and changes as part of sdpi-components.

Design

A new top-level object-instance will be added to the SDPIComponents namespace on the window, named i18n. This new object will enable interaction with translations, including specifying available resources. It will be up to the consumer to provide resources, and interact with this object to specify the available languages and their resources. An example of this interaction is:

SDPIComponents.i18n.locales = {
    en: {
        greeting: 'Hello'
    },
    es: {
        greeting: 'Hola'
    },
    fr: {
        greeting: 'Salut'
    }
};

When discovering a localization, the following hierarchy is used:

  • Key present in language pack matching info.language.
  • Key present in default language pack (en).
  • No resources, fallback to raw value, e.g. __MSG_hello__.

Example

Given the following translations, and property inspector HTML.

SDPIComponents.i18n.locales = {
    en: {
        fav_color: "Favourite Color",
        please_choose_color: "Please choose a color",
        red: "Red",
        green: "Green",
        blue: "Blue",
    },
    ...
};
<sdpi-item label="__fav_color__">
    <sdpi-select setting="color" placeholder="__MSG_please_choose_color__">
        <optgroup label="__MSG_primary_colors__">
            <option value="#ff0000">__MSG_red__</option>
            <option value="#00ff00">__MSG_green__</option>
            <option value="#0000ff">__MSG_blue__</option>
        </optgroup>
    </sdpi-select>
</sdpi-item>

When the language is en, the element will render as follows:

<sdpi-item label="Favourite Color">
    <sdpi-select setting="color" placeholder="Please choose a color">
        <optgroup label="Primary Colors">
            <option value="#ff0000">Red</option>
            <option value="#00ff00">Green</option>
            <option value="#0000ff">Blue</option>
        </optgroup>
    </sdpi-select>
</sdpi-item>

Changes

To accommodate translations, the following initial changes will need to be made.

  • Add a new sdpi-i18n element that provides a way of rendering content from a resource.
  • Update labels for:
    • sdpi-item
    • sdpi-checkbox
    • sdpi-checkbox-list 1
  • Update option, and option group, labels for:
    • sdpi-radio 1
    • sdpi-select 1
  • Update dynamic data sources to be localized.
  • Update loading text to be localized.
  • Update placeholder for:
    • sdpi-select
    • sdpi-textfield

1 Translations will be applied to dynamic data sources.

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.