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

@simonsoft/cds-components

v1.1.4-0

Published

<!-- SPDX-FileCopyrightText: © 2022 Simonsoft AB

Downloads

8

Readme

cds-components

The Content Delivery System components are a collection of reusable components available for use in Simonsoft customer applications.

Installation

npm install @simonsoft/cds-components

1. Language Picker

Language Picker is a component that retrieves and displays the available languages for a particular version of a docno and allows the user to choose the desired language. The languages are retrieved from the Algolia index.

1.1. Usage

Here's a simple example of how to use the component in an HTML file without the need to add any other dependencies.

example.html

<!--
SPDX-FileCopyrightText: © 2022 Simonsoft AB

SPDX-License-Identifier: LicenseRef-LICENSE
-->

<!DOCTYPE html>
<html lang="en">
  <head>
    ...

    <!--
      1. Add the component script to your HTML page.
    -->
    <script type="module" src="./node_modules/@simonsoft/cds-components/dist/language-picker.js"></script>

    <!--
      2. Add the component stylesheet to your HTML page.
    -->
    <link rel="stylesheet" href="./node_modules/@simonsoft/cds-components/dist/language-picker.css" />

    <!--
      3. Add the required bootstrap stylesheet from our library or another CDS to your HTML page.
    -->
    <link rel="stylesheet" href="./node_modules/@simonsoft/cds-components/dist/bootstrap.css" />

  </head>

  <body>

    <!--
      4. Add the language-picker component in your HTML page wherever suits you best. Typically in the navigation bar.
    -->
    <language-picker
      size="sm"
      variant="primary"
      menuVariant="primary"
      default="en-US"
      lazy="true"
      redirect="true"
      version="latest"
      docno="CMS_DOCNO"
      algoliaAppId="**********"
      algoliaApiKey="********************************"
      algoliaIndexName="cdn_public_v1"
      urlprefix="https://cloudid.simonsoftcdn.com"
      onSelect="onSelect(language, format, urldocument, url)"
    />

    <!--
      5. Optionally intercept and customize the component actions.
    -->
    <script>
      // There are two ways of intercepting the onSelect events:
      // Method 1 (Callback Function):
      function onSelect(language, format, urldocument, url) {
        console.log('The selection has changed (callback): ', 'language: ' + language, 'format: ' + format, 'urldocument: ' + urldocument, 'url: ' + url);
      }
      // Method 2 (Event Listener):
      document.addEventListener('onLanguagePickerSelect', function (e) {
        console.log('The selection has changed (event listener): ', 'language: ' + e.detail.language, 'format: ' + e.detail.format, 'urldocument: ' + e.detail.urldocument, 'url: ' + e.detail.url);
        // Override the default behavior of the selection which is to navigate to the url/urldocument if needed.
        e.preventDefault();
      }, false);
    </script>
  </body>
</html>

1.2. Advanced Usage

In a Node.js module, instead of using the script bundle, you can import the component in your JS file.

example.js

// Required
import '@simonsoft/cds-components/lib/components/language-picker';

// Optional (Includes the required Bootstrap styles if not already loaded elsewhere)
import '@simonsoft/cds-components/lib/bootstrap'