@dpa-id-components/dpa-shared-components
TypeScript icon, indicating that this package has built-in type declarations

9.9.8 • Public • Published

DPA shared components library

Collection of vue 3 components for usage across dpa projects.

Pre-requirements

This project requires a node version of 16.x or higher. For Node environments such as nuxt.js Node v20 or higher is required to prevent errors from the missing crypto library, which is needed for uuid.

You need to add and integrate the Inter font that can be found in src/assets/fonts to your project manually. An example how the CSS could look can be found in src/tailwind/fonts.css

Notes

This project uses Typescript version >= 5.0. This upgrade included changes to the module resolution, which are not yet reflected fully in the tsconfig. If your project uses TS 5.0 or higher itself you most likely need to set

"resolvePackageJsonExports": false

to prevent transpiler errors. For more information see the migration guide of ts.

Usage

To use a component just import it from @dpa-id-components/dpa-shared-components like

import { UiBadge } from "@dpa-id-components/dpa-shared-components";

Tailwind

To have the styling working correctly you have to extend the tailwind config in your project.

Please ensure that the version of Tailwind in your host application meets the version specified under peerDependencies in package.json.

import sharedComponentsConfig from '@dpa-id-components/dpa-shared-components/tailwindConfig'
import { Config } from 'tailwindcss'

export default {
  presets: [sharedComponentsConfig],
  content: [
    // ... your content globs ...
    './node_modules/@dpa-id-components/dpa-shared-components/**/*.{js,mjs,cjs}'
  ]
}
satisfies
Config

The tailwind config is located at ./src/tailwind/tailwind.config.ts. Please be aware that used plugins must be listed in the dependencies or the projects using the components have to install it.

Add a component

To add a new component please add at least the following files:

  • Readme.md
  • Component.spec.ts
  • Component.stories.js
  • Component.vue

The readme should contain a minimal explanation of the usage and a definition of the api of the component (props, events, slots...). Also don't forget to add an import/export in ./src/components/index.ts to make your component available.

Tests

Tests are based on vitest and Vue Test Utils 2 running in a jsdom environment. To run the tests run

npm run test

The tests automatically are run as a watch task.

Storybook

This project runs on a 6.5 version of Storybook with a vite integration. If you want to change the vite config for storybook, please be aware that storybook overwrites the plugin section of the config in ./.storybook/main.ts, since storybook can't handle the vue plugin.

To start storybook locally run

npm run storybook

A deployed version of the storybook can be found here.

Link the project locally

For a better developer experience and testing in your actual it's recommended to link the package locally. For that run

npm link

in the root of your cloned shared components and

npm link "@dpa-id-components/dpa-shared-components"

in your target project.

Don't forget to run

npm run build

before linking or otherwise you wouldn't have a dist folder.

If linking doesn't seem to work, you can try to clear your vite-cache by deleting the node_modules/.vite folder

SVG icons

To add SVG icons, just copy the .svg file to ./src/assets/icons. Preferably you add the filename also to the ìconNames.ts so it's available in Storybook as option and in the overview. SVGs get loaded by vite-svg-loader, which optimizes the SVGs with svgo. Config can be added in vite.config.ts and ./.storybook/main.ts ( duplicated since Storybook can't handle the vite config plugins). Custom optimizations right now are:

  • removing dimensions (width/height attributes)
  • removing fills (to enable styling)

Releasing

To publish a new release just go to the Actions tab and click "Publish new version". You are prompted with the option to choose which version to bump. Behind the scenes it just does one of those commands below. They will still work on their own but the #shared-components Slack channel won't be notified.

npm run release:patch
npm run release:minor
npm run release:major

Readme

Keywords

none

Package Sidebar

Install

npm i @dpa-id-components/dpa-shared-components

Weekly Downloads

328

Version

9.9.8

License

ISC

Unpacked Size

2.1 MB

Total Files

312

Last publish

Collaborators

  • goersch.juliane
  • martinherweg
  • borchert.manja
  • roessel.nico
  • karlbanke
  • hajo.cirksena.dpa
  • schubert.florian
  • michelle3105
  • arifpehlivan
  • dpa-connect-deployment
  • antje.sommer
  • mlnmln
  • andrewbeng89
  • mridul_dpa