less-plugin-dls
Less plugin for Baidu DLS.
Last updated 12 days ago by ecomfe-core .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install less-plugin-dls 
SYNC missed versions from official npm registry.

less-plugin-dls

Less plugin for Baidu DLS.

???? less-plugin-dls is a work in progress. ????

Installation

npm i --save-dev less-plugin-dls

Usage

Autoinject with Less plugin

import less from 'less'
import dls from 'less-plugin-dls'

less
  .render('a { color: @dls-link-font-color-normal; }', {
    plugins: [dls()]
  })
  .then(result => {
    // handle result
  })

Import from stylesheets

With less-loader:

@import "~less-plugin-dls/tokens/index.less";

a { color: @dls-link-font-color-normal; }

Use CLI argument

lessc style.less --dls

Custom functions

dls-contextual(@color, @type)

To generate contextual colors according to the given brand color.

Params:

  • @color: Color - the brand color.
  • @type: info | success | warning | error - the color context.

Return value:

Color - the generated contextual color.

@color: dls-contextual(#3d88f2, success); // → #39bf45

dls-shade(@color, @level)

To generate a specific shade level of the given base color.

Params:

  • @color: Color - the base color.
  • @level: Number - the shade level.

Return value:

Color - the generated shaded color.

@color: dls-shade(#3d88f2, 3); // → #b3cfff

dls-sum(...@dimensions)

To get the sum of the given dimensions or calc expressions.

Params:

  • @dimensions: List<Dimension | Calc> - A list of length values.

Return value:

Dimension | Calc - the total value of the given list.

@width: dls-sum(1px, 30%); // → calc(1px + 30%)
@height: dls-sum(1px, 10px, 100px); // → 111px
@top: dls-sum(calc(1px + 5em), -1px); // → 5em
@left: dls-sum(calc(1px + 5em), -1px, calc(-5em)); // → 0

dls-even(@dimension)

To calculate the closest even integer value for a given dimension.

Params:

  • @dimension: Dimension - The given length value.

Return value:

Dimension - the closest even value.

@width: dls-even(1px); // → 2px
@height: dls-even(2); // → 2
@top: dls-even(19.6px); // → 20px
@left: dls-even(2.8em); // → 2em

dls-line-height(@line-height, @font-size): Dimension

To calculate the absolute line-height from the given line-height and font-size value.

Will return @line-height directly if it is an absolute length (eg. 15px, 2em). Will return the product of @line-height and @font-size for relative lengths (eg. 1.5, 200%).

Params:

  • @line-height: Dimension - the line-height value.
  • @font-size: Dimension - the font-size value.

Return value:

The absolute length of the line-height.

@h1: dls-line-height(1.5, 16px); // → 24px
@h2: dls-line-height(120%, 15px); // → 18px
@h3: dls-line-height(2em, 1.2em); // → 2em

Options

reduceCalc: boolean

Indicates whether to reduce calc expression to the simplest form or not.

Default value: true.

Tooling

CLI checker

npx dls check -c -o result.log

Commands

check

To check which variables are not used inside a directory. The current strategy is plain text search so that doesn't cover the case of Less's variable name interpolation.

Options
  • --dir / -d

    The target directory to check.

    Default: ..

  • --exclude / -x

    Comma-separated glob expression, indicates which files should be ignored.

    Default: node_modules,test.

    npx dls check -x node_modules,test,dist # or --exclude=node_modules,test,dist
    
  • --components / -c

    Comma-separated component names to specify which component-level variables will be checked. --components=all will check all component-level variables.

    Variables can be ignored if you put a .dlsignore file under the project root directory, with each variable (should be prefixed by @) on a single line. Lines led by # will be treated as comments.

    npx dls check -c button,select # or --components=button,select
    npx dls check -c all # or --components=all
    
  • --output / -o

    The output file for the check result.

    npx dls check -o result.log # or --output=result.log
    

Editor Extensions

License

MIT

Current Tags

  • 1.0.0-alpha.11                                ...           latest (12 days ago)

84 Versions

  • 1.0.0-alpha.11                                ...           12 days ago
  • 1.0.0-alpha.10                                ...           17 days ago
  • 1.0.0-alpha.9                                ...           17 days ago
  • 1.0.0-alpha.8                                ...           18 days ago
  • 1.0.0-alpha.7                                ...           19 days ago
  • 1.0.0-alpha.6                                ...           23 days ago
  • 1.0.0-alpha.5                                ...           24 days ago
  • 1.0.0-alpha.4                                ...           25 days ago
  • 1.0.0-alpha.3                                ...           a month ago
  • 1.0.0-alpha.2                                ...           a month ago
  • 1.0.0-alpha.1                                ...           a month ago
  • 1.0.0-alpha.0                                ...           a month ago
  • 0.33.4                                ...           3 months ago
  • 0.33.3                                ...           4 months ago
  • 0.33.2                                ...           4 months ago
  • 0.33.1                                ...           5 months ago
  • 0.33.0                                ...           5 months ago
  • 0.32.0                                ...           5 months ago
  • 0.31.0                                ...           5 months ago
  • 0.30.0                                ...           5 months ago
  • 0.29.0                                ...           5 months ago
  • 0.28.0                                ...           6 months ago
  • 0.27.0                                ...           6 months ago
  • 0.26.8                                ...           6 months ago
  • 0.26.7                                ...           6 months ago
  • 0.26.6                                ...           6 months ago
  • 0.26.5                                ...           6 months ago
  • 0.26.4                                ...           6 months ago
  • 0.26.3                                ...           7 months ago
  • 0.26.2                                ...           7 months ago
  • 0.26.1                                ...           7 months ago
  • 0.26.0                                ...           7 months ago
  • 0.25.0                                ...           8 months ago
  • 0.24.2                                ...           8 months ago
  • 0.24.1                                ...           8 months ago
  • 0.24.0                                ...           8 months ago
  • 0.23.3                                ...           9 months ago
  • 0.23.2                                ...           9 months ago
  • 0.23.1                                ...           9 months ago
  • 0.23.0                                ...           9 months ago
  • 0.22.0                                ...           9 months ago
  • 0.21.1                                ...           9 months ago
  • 0.21.0                                ...           9 months ago
  • 0.20.3                                ...           9 months ago
  • 0.20.2                                ...           9 months ago
  • 0.20.1                                ...           9 months ago
  • 0.20.0                                ...           9 months ago
  • 0.19.0                                ...           10 months ago
  • 0.18.0                                ...           10 months ago
  • 0.17.1                                ...           10 months ago
  • 0.17.0                                ...           10 months ago
  • 0.16.3                                ...           10 months ago
  • 0.16.2                                ...           10 months ago
  • 0.16.1                                ...           10 months ago
  • 0.16.0                                ...           10 months ago
  • 0.15.2                                ...           10 months ago
  • 0.15.1                                ...           10 months ago
  • 0.15.0                                ...           10 months ago
  • 0.14.2                                ...           10 months ago
  • 0.14.1                                ...           10 months ago
  • 0.14.0                                ...           10 months ago
  • 0.13.0                                ...           10 months ago
  • 0.12.0                                ...           a year ago
  • 0.11.0                                ...           a year ago
  • 0.10.0                                ...           a year ago
  • 0.9.3                                ...           a year ago
  • 0.9.2                                ...           a year ago
  • 0.9.1                                ...           a year ago
  • 0.9.0                                ...           a year ago
  • 0.8.0                                ...           a year ago
  • 0.7.0                                ...           a year ago
  • 0.6.0                                ...           a year ago
  • 0.5.3                                ...           a year ago
  • 0.5.2                                ...           a year ago
  • 0.5.1                                ...           a year ago
  • 0.5.0                                ...           a year ago
  • 0.4.0                                ...           a year ago
  • 0.3.0                                ...           a year ago
  • 0.2.0                                ...           a year ago
  • 0.1.4                                ...           a year ago
  • 0.1.3                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 12
This Month 12
Last Day 0
Last Week 20
Last Month 233
Dependencies (4)
Dependents (2)

Copyright 2014 - 2017 © taobao.org |