0.1.0 • Published 5 years ago

@aybolit/bootstrap v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Aybolit Bootstrap

Aybolit Bootstrap is a set of the web components inspired by Bootstrap framework.

Overview

Bootstrap 4 is used as a base, but Aybolit does not preserve the original CSS, cuts some corners and makes adjustments here and there. The main idea behind these changes is flexible theming support, with reasonable bundle size.

The upcoming Bootstrap 5, expected to land this year, will likely introduce a lot of changes to be adapted by Aybolit. The first-class Web Components support for Bootstrap was requested, and is considered by maintainers as possible for v6.

Installation

Aybolit Bootstrap is available as npm package:

# with npm
npm i @aybolit/bootstrap --save

# with yarn
yarn add @aybolit/bootstrap

Import either all or individual components:

// all components
import '@aybolit/bootstrap';

// button only
import { AbsButton } from '@aybolit/bootstrap';

You can also use get Aybolit Bootstrap from the CDN:

<script src="https://unpkg.com/@aybolit/bootstrap@latest?module" type="module"></script>

Components

Examples

<!-- Button -->
<abs-button>Button</abs-button>
<abs-button theme="primary">Primary theme</abs-button>
<abs-button size="small">Small size</abs-button>
<abs-button link="https://example.com">Link</abs-button>

<!-- Checkbox -->
<abs-checkbox>Unchecked</abs-checkbox>
<abs-checkbox checked>Checked</abs-checkbox>
<abs-checkbox indeterminate>Indeterminate</abs-checkbox>

<!-- Progress -->
<abs-progress value="50" max="100"></abs-progress>

<!-- Range -->
<abs-range min="0" max="10" value="5"></abs-range>

<!-- Switch -->
<abs-switch>Unchecked</abs-switch>
<abs-switch checked>Checked</abs-switch>

Theme Variants

All the components can be themed using theme attribute with one of the following values:

  • primary
  • info
  • success
  • warning
  • danger

The colors for each theme variant can be adjusted using custom CSS properties listed below.

Custom CSS Properties

The following custom CSS properties are available for styling.

General Theme

Changing these properties affect all the components at the level of cascade where they are specified. Keep in mind that lightness level is used as base for automatic contrast adjustment, so changing it might affect e.g. buttons text color.

PropertyDescription Fallback
--abs-primary-hPrimary color hue211
--abs-primary-sPrimary color saturation100
--abs-primary-lPrimary color lightness48
--abs-info-hInfo color hue188
--abs-info-sInfo color saturation78
--abs-info-lInfo color lightness41
--abs-success-hSuccess color hue134
--abs-success-sSuccess color saturation61
--abs-success-lSuccess color lightness41
--abs-warning-hWarning color hue45
--abs-warning-sWarning color saturation100
--abs-warning-lWarning color lightness60
--abs-danger-hDanger color hue354
--abs-danger-sDanger color saturation70
--abs-danger-lDanger color lightness48

Individual Components

These properties expose certain colors not covered by general theme settings.

ComponentPropertyDescription Fallback
Button--abs-button-bg-colorUn-themed button background#fff
Button--abs-button-border-colorUn-themed button border colortransparent
Button--abs-button-colorUn-themed button color#212529
Checkbox--abs-checkbox-border-colorUnchecked state border color#adb5bd
Checkbox--abs-checkbox-disabled-bgDisabled unchecked state background#e9ecef
Checkbox--abs-checkbox-disabled-textDisabled state text color#6c757d
Progress--abs-progress-bar-colorProgress bar color#e9ecef
Range--abs-range-track-bgTrack background#dee2e6
Range--abs-range-disabled-bgDisabled state thumb background#adb5bd
Switch--abs-switch-disabled-bgDisabled off state background #e9ecef
Switch--abs-switch-disabled-textDisabled off state text color #6c757d
Switch--abs-switch-off-thumb-bgOff state thumb background #adb5bd
Switch--abs-switch-off-track-bgOff state track background #fff
Switch--abs-switch-off-track-borderOff state track border color #adb5bd
Switch--abs-switch-on-thumb-bgOn state thumb background #fff