Git Product home page Git Product logo

designsystem's Introduction

Kirby Design System

npm npm npm Build Status

GitHub forks GitHub stars

About

Kirby Design System is a UX Component library implementing the Kirby Design Philosophy.

Kirby Components are built on top of Angular and can be used in Angular projects.

The Kirby Cookbook, containing samples, status of components etc. can be accessed from https://cookbook.kirby.design.


๐Ÿ’ฅ Kirby v. 1.0.0 has landed! Please see the Migration Guide if you're upgrading from <= 0.8.x


Table of Contents

Installation

Install through npm:

npm i @kirbydesign/designsystem

Include KirbyModule

Import the KirbyModule in your AppModule:

import { KirbyModule } from '@kirbydesign/designsystem';

...

@NgModule({
    imports: [
        ...,
        KirbyModule
    ],
    ...
})
export class AppModule {}

Sass

Include the Kirby global styles in your app:

  • Eg. in src/styles.scss:

    @import '~@kirbydesign/designsystem/scss/global-styles';

    In each .scss file where you need to access the Sass utility functions from Kirby (e.g. colors or fonts) you must import the scss utilities:

    @import '~@kirbydesign/designsystem/scss/utils';

Testing

To unit-test applications using Kirby's Components, we recommend importing one of the following modules:

  • When using jasmine: import { KirbyTestingModule } from '@kirbydesign/designsystem/testing-jasmine';
  • When using jest: import { KirbyTestingModule } from '@kirbydesign/designsystem/testing-jest';

Example:

import { KirbyTestingModule } from '@kirbydesign/designsystem/testing-jasmine';

describe('AppComponent', () => {
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [KirbyTestingModule],
      declarations: [AppComponent]
    }).compileComponents();
  }));

  ...

});

For unit test performance reasons it's highly recommended to utilize these modules, since they provide a template-less implementation of the Kirby Components, but still translude content through <ng-content></ng-content> and provide @Input-decorated properties and @Output-decorated EventEmitters, without having to reflow the DOM, execute component logic etc.

Migration Guide

To upgrade, please perform the following tasks:

  • v0.x.x => v1.0.0

    Simplified namespaces

    Import @kirbydesign/designsystem instead of @kirbydesign/designsystem/list or @kirbydesign/designsystem/modal. This can be done by executing the following commands (Mac/Linux and Windows respectively):

    Mac / Linux
    cd <root folder of your application>
    find . -name "*.ts" ! -name "*.spec.ts" -type f -exec sed -i '' -e "s|from '@kirbydesign/designsystem/.*';$|from '@kirbydesign/designsystem';|g" {} \;
    find . -name "*.spec.ts" -type f -exec sed -i '' -e "s|from '@kirbydesign/designsystem/testing';$|from '@kirbydesign/designsystem/testing-jasmine';|g" {} \;

    Note: If you're using jest you should replace with @kirbydesign/designsystem/testing-jest instead.

    Windows
    cd <root folder of your application>
    Get-ChildItem "*.ts" -Recurse | ForEach {
    (Get-Content $_ | ForEach  { $_ `
      -replace "from '@kirbydesign/designsystem/((?!testing).)*';$", "from '@kirbydesign/designsystem';" `
      -replace "from '@kirbydesign/designsystem/testing';$", "from '@kirbydesign/designsystem/testing-jasmine';" `
    }) | Set-Content $_
    }

    Note: If you're using jest you should replace with @kirbydesign/designsystem/testing-jest instead.

    Change TypeScript configuration

    Due to Kirby not being distributed as a source-distribution package any more, changes to tsconfig.json, tsconfig.app.json as well as tsconfig.spec.json should be reverted:

    In tsconfig.json:

    • Remove the line "./node_modules/@kirbydesign/designsystem/**/*.ts" from the includes-array

    In tsconfig.app.json:

    • Remove the line "./node_modules/@kirbydesign/designsystem/**/*.ts" from the includes-array
    • Remove the line "../node_modules/@kirbydesign/designsystem/testing/**/*.*" from the excludes-array

    In tsconfig.spec.json:

    • Remove the line "../node_modules/@kirbydesign/designsystem/**/*.ts", from the includes-array

    Changed dependencies

    Remove any previously installed dev-dependencies for sass-extract, sass-extract-loader and ng-mocks (unless otherwise used in your application). This can be done by the following command:

    npm uninstall --save-dev sass-extract sass-extract-loader ng-mocks

    Deprecation

    The following legacy components have been removed:

    • ListItemComponent (<kirby-list-item>)
    • ListFlexItemComponent (<kirby-list-flex-item>)
    • ListCellComponent (<kirby-list-cell>)
    • ListCellLineComponent (<kirby-list-cell-line>)

    The following directives have been deprecated and will be removed in future versions:

    • ListItemDirective ([kirbyListItem])
    • ListFlexItemDirective ([kirbyListFlexItem])

    Please see the list documentation on how to use the list component(s) and directives.

Icons

Kirby comes bundled with a default set of icons. Make sure the .svg files used by Kirby are copied to your output folder by adding the following to build > options > assets in angular.json:

{
  ...
  "build": {
    "options": {
      "assets": [
        ...,
        {
          "glob": "**/*.svg",
          "input": "node_modules/@kirbydesign/designsystem/icons/svg",
          "output": "./assets/kirby/icons/svg"
        },
        ...
      ],
    }
  }
}

Folder Structure

The folder structure of the repository is based on Nrwl's NX mono-repository project.

A basic walkthrough is outlined in the structure below:

@kirbydesign/designsystem
โ”œโ”€โ”€ apps                    # Contains source code for applications
|  โ”œโ”€โ”€ cookbook             # - Cookbook application (showcase and examples)
|  โ””โ”€โ”€ cookbook-e2e         # - End-to-end tests for Cookbook application
โ”œโ”€โ”€ config
|  โ””โ”€โ”€ helm
โ”œโ”€โ”€ dist                    # Contains output files when building artifacts (for distribution)
|  โ”œโ”€โ”€ apps
|  โ””โ”€โ”€ libs
โ”œโ”€โ”€ libs                    # Contains source code for libraries
|  โ””โ”€โ”€ designsystem         # - Actual implementation of library (designsystem)
โ”œโ”€โ”€ scripts                 # Scripts for building artifacts
โ””โ”€โ”€ tools                   # Contains various tools
   โ”œโ”€โ”€ generate-mocks       # - CLI utility for generating mocks for `@kirbydesign/designsystem/testing-jasmine`
   |                        #   and `@kirbydesign/designsystem/testing-jest` entry points.
   โ”œโ”€โ”€ sass-to-ts           # - CLI and Webpack plugin for extract global variables from SASS to TS
   โ”œโ”€โ”€ schematics           # - Angular schematics
   โ””โ”€โ”€ tslint-rules         # - Custom lintiong rules

Scripts

Below is an overview of most widely used scripts, available for this project.
Use them in your terminal like: npm run <script>:

Command Description
start Starts the development server, providing a means of running (and developing on the Cookbook)
lint Lints the entire project (both TypeScript and SCSS source code)
lint:cookbook Lints the Cookbook application (both TypeScript and SCSS source code)
lint:designsystem Lints the Designsystem library (both TypeScript and SCSS source code)
dist:cookbook Builds a distribution folder of the Cookbook application
dist:designsystem Builds a distribution folder of the Designsystem library
transpile:tools Transpiles tools, required to produce library distribution (this is done as a post-install hook, but may have value if altering tool implementation)

Developing new features in Kirby

When developing new features in the Kirby Designsystem library, please follow the process described below:

"New feature"-process

TBD

Testing new features

Developing new features should also include that they should be tested.

  1. Make sure that the code is unit tested.

  2. Make sure that examples and showcases are added for the new features (in the cookbook)

    ... this will also act as documentation for users of the Designsystem library.

  3. Test the new features in your own application

    The easiest way to do this is to build a distribution package, and install it in your own project.

    # 1. From the root of this repository, execute (this may take a minute or two):
    ./scripts/publish.js
    
    # Them, from the root of your application, execute:
    <path-to-root-of-designsystem>/dist/kirbydesign-designsystem-<version>.tgz
    
    # ... where <path-to-root-of-designsystem> is replaced with the real path
    #     and <version> is the version of designsystem that was build (in the previous step)
    
    # You do NOT want to commit the changes made to package.json and package-lock.json to your code base!
    

Polyfills

Some features of Kirby requires polyfills to ensure compability across all major browsers (e.g. the ResizeObserverService used by the automagic sizing feature of the Kirby Card component).

To enable the polyfill, you register a polyfill loader that checks whether the polyfill is needed or the feature is already supported by the browser (and can skip requesting the polyfill).
To use the sizing feature of Kirby Card across all major browsers, you must copy additional files from the Kirby package to your output folder.
Add the following to build > options > assets in angular.json:

{
  ...
  "build": {
    "options": {
      "assets": [
        ...,
        {
          "glob": "**/*",
          "input": "./node_modules/@kirbydesign/designsystem/polyfills",
          "output": "./kirby/polyfills"
        },
        ...
      ],
    }
  }
}

Finally, add the following to index.html:

<head>
  ...
  <script src="kirby/polyfills/resize-observer-polyfill-loader.min.js"></script>
</head>

Please note: If you don't want the additional http request for the polyfill loader, you can copy the contents of node_modules/@kirbydesign/designsystem/polyfills/resize-observer-polyfill-loader.js into a script tag in index.html instead

Chart Components

The Kirby chart components use Highcharts. Note that this is a licensed product.

designsystem's People

Contributors

alberttuft avatar anders-bloch avatar askarby avatar azeemchauhan avatar bdujrn avatar hafstad avatar hawkish avatar icarusoft avatar jakobe avatar jonasjensen-brolstark avatar labanos avatar lal-jyskebank-dk avatar langecode avatar lydemann avatar mmmtrifork avatar monstergamedev avatar mortengregersen avatar neigaard avatar nicolainormann avatar petarring avatar peterlindholm avatar pg-jyskebank-dk avatar roa-jyskebank-dk avatar rolchau avatar sanderjespersen avatar silvergull avatar sneigaard avatar sorenfruergaard avatar szutrifork avatar unnamjolner avatar

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.