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

vinhtan-apps

v1.0.0

Published

Shidoka Web Components for Applications

Downloads

5

Readme

Shidoka Web Components for Applications

shidoka-applications

Contributing to this project

Read the Contributing Guide here.

Using this library in another project

Install the package

npm install @kyndryl-design-system/shidoka-applications @kyndryl-design-system/shidoka-foundation -S

Import the root stylesheet to your app's global styles

The method used (SCSS @use, CSS @import, JS import, or <style> tag) will vary based on your framework/bundler. Some examples:

SCSS

@use '~@kyndryl-design-system/shidoka-foundation/scss/root.scss';

CSS

@import '@kyndryl-design-system/shidoka-foundation/css/root.css';

JS

import '@kyndryl-design-system/shidoka-foundation/css/root.css';

Use CSS tokens/variables

You can make use of tokens/variables included in root.css such as --kd-header-height to pad the body for the fixed position header, --kd-page-gutter for the padding on your main container, or any of the color tokens. These are very bare-bones currently, and will need to be fleshed out later.

Start using components

See Storybook for the full components documentation.

Example: Component with Sub-components

This example imports the Header component AND all of it's subcomponents by targeting the index file.

import '@kyndryl-design-system/shidoka-applications/components/global/header';
<kyn-header>
  <kyn-header-nav>
    <kyn-header-link>Link</kyn-header-link>
  </kyn-header-nav>
</kyn-header>

Example: Single Component

This example imports the HeaderLink component by targeting the component file directly.

import '@kyndryl-design-system/shidoka-applications/components/global/header/headerLink';
<kyn-header-link>Link</kyn-header-link>

React usage

React does not yet support automatic interop with Web Components. This means that React treats all props passed to Web Components as string attributes. It sounds like they are planning to release it eventually, and is now available behind an @experimental flag. Until you've upgraded to a version of React that has support, you will need to use a library like @lit/react to use these components in React.

Some options for React wrapper libraries:

  1. @lit/react
  2. reactify-wc
  3. wc-react

Server-Side Rendering (SSR)

When using with an SSR framework like Next.js, you will encounter errors with code that only runs client-side, like window references for example. This is because web components cannot render on the server. Here is an article that provides some methods to work around this: Using Non-SSR Friendly Components with Next.js and How to entirely disable server-side rendering in next.js v13?. Basically, they need their rendering deferred to only happen on the client-side.

Here is some additional information about why SSR does not work for web components, and some potential polyfills/solutions to enable server rendering: https://lit.dev/docs/ssr/overview/

Handling Failed to execute 'define' on 'CustomElementRegistry'

The Problem

This is a common bundling issue that can appear when you incorporate a component that has already bundled Shidoka components. Typically this would be caused by having a middle layer, for example a Common UI layer that has a cross-platform Header component built using Shidoka components.

Avoiding This

You can get around this in by not declaring Shidoka components as dependencies, and instead declaring them as external or peer dependencies in the middle/common layer.

For example, from the shidoka-applications rollup.js config using the external option: external: [/shidoka-foundation\/components/]. Since shidoka-foundation components are used within shidoka-applications components, this prevents the foundation components from being bundled, meaning it leaves the import statements unaltered (ex: import '@kyndryl-design-system/...'). This way, the application bundler can handle it instead.

This works with bundling from node_modules, but not with CDN hosted files since the deployed application wouldn't know how to resolve aliased node_modules imports like: import '@kyndryl-design-system/...'. In this case you probably need a workaround.

Workaround

If for some reason the above suggestion does not help, there is a library containing a script/polyfill that can be used which allows custom elements to be redefined: https://github.com/caridy/redefine-custom-elements.