laxar-uikit

2.1.3 • Public • Published

LaxarJS UiKit Build Status

Bootstrap 3 compatible base styles for LaxarJS widgets, plus a few i18n-UI helpers

This is the home of the default theme for LaxarJS. Based on the SCSS version of Bootstrap 3.3 together with Font Awesome 4.7, it contains only a small number of additional classes.

Also, this repository contains a number of JavaScript library functions, which are too UI-specific to be included into LaxarJS core. They are mostly related to formatting and parsing of values (numbers, decimals, dates) in i18n applications. Learn what's in there for you, by consulting the API docs.

Of course, the additional JavaScript code will only be bundled as part of your application if it actually imports the laxar-uikit module.

What is the default theme?

Several types of artifacts in a LaxarJS application may be themed, namely widgets, controls and layouts. The CSS and HTML of such an artifact lives in a subfolder named after each theme that the artifacts support. However, to allow for reuse of artifacts in different applications, all artifacts should support at least the so-called "default theme". For example, if a widget called my-widget supports the default theme and the cube theme, it will use two folders (my-widget/default.theme and my-widget/cube.theme), and each folder may contain a CSS file and an HTML file for the widget.

Although it has a few extra classes (those starting with the ax- prefix), you may think of the default theme as just Bootstrap 3. When creating custom themes, it is recommended to use a Bootstrap-compatible set of classes, so that any widget can be themed without having to create new HTML markup. Usually, only the folder default.theme will contain the widget HTML, and the other theme folders just specify custom CSS when needed. If your application is using a custom theme (such as the cube.theme), not all widgets need to specify custom CSS for that theme, because LaxarJS will always fall back to the default theme of a widget. Refer to the LaxarJS manual on themes for more information on themes.

Using LaxarJS UiKit in a project

Including LaxarJS UiKit is currently recommended for any LaxarJS application, except if you're aiming to use a non-standard default theme (see below).

Starting with LaxarJS v2, obtain the UiKit either by starting from the Yeoman generator or by using NPM:

npm install --save laxar-uikit

Using the Library

To use the parser and formatter library functions, import them into a widget or control:

import { formatter } from 'laxar-uikit';
 
const format = formatter.create( 'decimal', { decimalPlaces: 1 } );
format( Math.PI ); // --> "3.1"

Or, if using CommonJS modules:

var formatter = require( 'laxar-uikit' ).formatter;
// ...

And, to use i18n:

import { localized } from 'laxar-uikit';
 
const axI18n = // ... obtained by widget injection, depends on the integration technology
const format = localized( axI18n ).formatter.create( 'decimal' );
// assuming the locale is "de"
format( Math.PI ); // --> "3,14"

Using the default.theme

To load the default theme, your loader (webpack) needs to be setup correctly. This is already the case if you project was created using the LaxarJS v2 Yeoman generator.

If creating a project from scratch, first make sure you have the dependencies:

npm install --save-dev laxar-loader sass-loader

Then add a resolve alias and a rule configuration for the default.theme:

// webpack.config.js
resolve: {
   // ...,
   alias: {
      // ...,
      'default.theme': 'laxar-uikit/themes/default.theme'
   }
},
module: {
   rules: [
      // ...,
      {
         test: /[/]default[.]theme[/].*[.]s[ac]ss$/,
         loader: 'sass-loader',
         options: require( 'laxar-uikit/themes/default.theme/sass-options' )
      }
   ]
}

When using webpack and the laxar-loader, the default theme will now be available for use in your application (through the init.js):

// init.js
import { create } from 'laxar';
import artifacts from 'laxar-loader/artifacts?flow=main&theme=default';
 
create( [ /* ... adapters ... */ ], artifacts, { /* ... configuration ... */ } )
   .flow( 'main', document.querySelector( '[data-ax-page]' ) )
   .bootstrap();

Using a custom default theme

In some cases, your application simply does not work with Bootstrap: For example, if you're working with a legacy code base, your options may be limited. Also, you may be producing a mobile-only application an incompatible CSS-framework such as material design.

You can change to a different default theme by creating a module laxar.config.js in your project root, and by setting its default.theme export to the path of your own default theme (which should be a directory named default.theme containing a folder css and a theme.css inside of that).

Of course, now you need to make sure that all default.theme folders of your project's artifacts are compatible with you own default theme!

Building LaxarJS UiKit from source

Instead of using a pre-compiled library within a project, you can also clone this repository:

git clone https://github.com/LaxarJS/laxar-uikit.git
cd laxar-uikit
npm install

To see changes in your application, configure your project to work with the sources (e.g. by using webpack), or rebuild the bundles:

npm run dist

To run the automated karma tests:

npm test

To generate HTML spec runners for opening in your web browser, so that you can e.g. use the browser's developer tools:

npm start

Now you can run the specs by browsing to http://localhost:8080/dist/lib/spec/laxar-uikit.spec.html.

Readme

Keywords

none

Package Sidebar

Install

npm i laxar-uikit

Homepage

laxarjs.org

Weekly Downloads

22

Version

2.1.3

License

MIT

Last publish

Collaborators

  • mkemmann
  • jpommerening
  • x1b
  • alex3683