New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lansforsakringar/core-components

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lansforsakringar/core-components

Länsförsäkrginar Design System Core Components

0.1.1
npm
Version published
Weekly downloads
16
-86.99%
Maintainers
0
Weekly downloads
 
Created
Source

LFDS Core Components

LFDS is Länsförsäkringar's design system core components distributed as composable Web Components.

Using Components

You can import the design system using a script tag. Many CDN's distribute packages published to npm, for example jsDelivr. You should define the exact version you want to use to avoid breaking changes.

<script
  type="module"
  src="https://cdn.jsdelivr.net/npm/@lansforsakringar/core-components@VERSION"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lansforsakringar/core-components@VERSION/index.css">

If you prefer to host them yourself, you can export the package to a directory and serve it from your own server, see CLI.

Bundling

Install

The design system is published on NPM and can be installed as a package.

npm install @lansforsakringar/core-components

When using a bundler like Vite or Webpack, you have two options for importing and registering the components.

Lazy Loading

By importing the bare module, components will load lazily as they are rendered on the page, making sure that no unused code is loaded.

import '@lansforsakringar/core-components'
Manually Registering Components

If you have more specific needs, e.g. your own lazy loading behavior, you can import the individual components and register them as custom elements.

import {
  LfdsButton,
  defineCustomElement,
} from '@lansforsakringar/core-components/lfds-button.js'

defineCustomElement(LfdsButton)

Styles

You'll also need to import the global styles in your application. If you are using build tools like Vite or Webpack, you can import the CSS file directly in your JavaScript.

import "@lansforsakringar/core-components/index.css"

Or in your CSS if you are using a CSS preprocessor like PostCSS.

@import "@lansforsakringar/core-components";

If you are not using a build tool, you can either load the styles from a CDN, see Script/Link Tag, or copy the neccessary files and serve them yourself, see CLI.

Assets

The design system make use of static assets e.g. images, fonts etc. These files are included in the distributed packages and need to be served by the consuming application.

The design systems needs to be configured so that it knowns where you are serving the assets from. This is done by wrapping your application (or parts of) with the <lfds-config> element, setting the assetPath attribute to the public path where assets are served.

<!doctype html>
<html>
  <head>
    <script type="module" src="/my-app.js"></script>
  </head>
  <body>
    <lfds-config assetPath="/lfds-assets">
      <!-- Your application goes here -->
    </lfds-config>
  </body>
</html>

Vite

For convenience, the design system provides a Vite plugin that can be used to serve these assets.

// vite.config.js
import { lfdsVite } from '@lansforsakringar/core-components/plugin'

export default {
  plugins: [lfdsVite({ assetDir: 'lfds-assets' })],
}

On build, the assets will be copied over to the provided assetDir relative to the Vite out directory.

CDN

Just like with the script tag, assets can be served from a CDN. All assets are configured to be served from the /assets path relative to the package.

<lfds-config
  assetPath="https://cdn.jsdelivr.net/npm/@lansforsakringar/core-components@VERSION/assets">
  <!-- Your application goes here -->
</lfds-config>

Selfhosted

If you are not using Vite or want to serve the assets in a different way, you can copy them to your web server and serve them yourself, see CLI.

CLI

This packages comes with a CLI for common tasks like exporting assets.

Export

The export command will take all JS/CSS entry points, including their associated dependencies and assets, and copies them to a directory of your choice.

$ lfds export --out dist/lfds

Assuming that the "dist" folder is publicly accessible on your server, you can reference the files like this in your application:

<!doctype html>
<html>
<head>
  <script type="module" src="/lfds/core-components.esm.js"></script>
  <link rel="stylesheet" href="/lfds/lfds-components.css">
</head>
<body>
  <lfds-config assetPath="/lfds/assets">
    <!-- Your application goes here -->
  </lfds-config>
</body>
</html>

You can also load individual components just like Manually Registering Components.

<script type"module">
  import {
    LfdsButton,
    defineCustomElement,
  } from '/lfds/core-components/lfds-button.js'

  defineCustomElement(LfdsButton)
</script>

FAQs

Package last updated on 04 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts