Coder Social home page Coder Social logo

ezavile / postcss-text-transform Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 48 KB

A PostCSS plugin to transform the text

License: MIT License

CSS 22.44% TypeScript 77.56%
postcss postcss-plugin text-transformations text transform uppercase lowercase capitalize

postcss-text-transform's Introduction

[DEPRECATED] - Use @postcss-plugins/text-transform instead

postcss-text-transform

Travis Codecov npm MIT License

A PostCSS plugin to transform the text.

Installation

npm install postcss-text-transform

What is this? For example, you have the following CSS file (I'm using postcss-each and postcss-cssnext):

backgrounds.css

.u {
  @each $color in green, yellow, red {
    @text-transform $color, upperFirst, $colorTransformed {
      &-bg$(colorTransformed) {
        background-color: $color;
      }
    }
  }
}

And the plugin will give you:

.u-bgGreen {
  background-color: green
}

.u-bgYellow {
  background-color: yellow
}

.u-bgRed {
  background-color: red
}

Usage

JavaScript

postcss([
   require('postcss-text-transform')
]);

TypeScript

import * as postcssTextTransform from 'postcss-text-transform';

postcss([ postcssTextTransform() ]);
@text-transform $text, transformation, $textTransformed { ... }

Transformations

  • camelCase - Converts to camel case.
  • capitalize - Converts the first character of string to upper case and the remaining to lower case.
  • lowerCase - Converts string, as space separated words, to lower case.
  • lowerFirst - Converts the first character of string to lower case.
  • upperCase - Converts string, as space separated words, to upper case.
  • upperFirst - Converts the first character of string to upper case.

Testing

This will build scripts, run tests and generate a code coverage report. Anything less than 100% coverage will throw an error.

npm test

See PostCSS docs for examples for your environment.

Contributing

  • โ‡„ Pull requests and โ˜… Stars are always welcome.
  • For bugs and feature requests, please create an issue.
  • Pull requests must be accompanied by passing automated tests (npm test).

MIT License

postcss-text-transform's People

Contributors

ezavile avatar

Stargazers

 avatar  avatar

Watchers

 avatar

postcss-text-transform's Issues

plugin code

Create a rule to transform the text

.componentNameLowerFirst {
  @each $color in green, yellow, red {
    @textTransform $color, upperFirst, $colorTransformed {
      &--bg$(colorTransformed) {
        background-color: $color;
      }
    }
  }
}

result:

.componentNameUpperFirst--bgGreen {
   background-color: green
}

.componentNameUpperFirst--bgYellow {
   background-color: yellow
}

.componentNameUpperFirst--bgRed {
   background-color: red
}

type of transformation:

  • capitalize
  • camelCase
  • lowerFirst
  • lowerCase
  • upperCase
  • upperFirst

Generate typescript declaration file

Be able to use the plugin with TypeScript

import * as postcssTextTransform from 'postcss-text-transform';

postcss([ postcssTextTransform() ]);

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.