# css-mqpacker-starter

> Mixin starter for css-mqpacker with bootstrap breakpoints. Scss mixin for right order of queries

Latest version **1.0.1** (published 2020-06-07) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install css-mqpacker-starter
pnpm add css-mqpacker-starter
yarn add css-mqpacker-starter
bun add css-mqpacker-starter
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-06-07 |
| First published | 2020-06-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Michael Gitart |
| Maintainers | gitart |
| Keywords | css-mqpacker, scss, sass, starter |

## Links

- npm: https://www.npmjs.com/package/css-mqpacker-starter
- Repository: https://github.com/MichaelGitArt/css-mqpacker-starter
- Homepage: https://github.com/MichaelGitArt/css-mqpacker-starter#readme
- Issues: https://github.com/MichaelGitArt/css-mqpacker-starter/issues
- npm.io page: https://npm.io/package/css-mqpacker-starter

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2020-06-07
- 1.0.0 — 2020-06-03

## README

# css-mqpacker-starter

### Mixin starter with scss for [css-mqpacker](https://www.npmjs.com/package/css-mqpacker)

You must use the package with scss and postcss.
You will find the webpack rule for compiling scss files with css-mqpacker below or use [webpack starter](https://github.com/MichaelGitArt/webpack-starter-gitart).

[Installation](#installation) <br>
[Breakpoints](#Breakpoints) <br>
[Init order](#init-order) <br>
[Mixins](#mixins) <br>
[Source mixin code](#source-mixin-code) <br>
[Possible order error](#possible-order-error) <br>
[Webpack rule for compiling](#webpack-rule-for-compiling) <br>

## Installation

Install the package

```shell script
npm i css-mqpacker-starter
```

Import in main scss file

```scss
@import "~css-mqpacker-starter";
@include initMediaPosition();
```

Now use it :)

```scss
@include sm {
  body {
    font-size: 15px;
  }
}
```

## Breakpoints

The package provide default breakpoints:

| Breakpoint | Pixels |
| ---------- | ------ |
| \$xl       | 1200px |
| \$lg       | 992px  |
| \$md       | 768px  |
| \$sm       | 576px  |
| \$xs       | 420px  |
| \$xxs      | 360px  |

## Mixins

There are media queries mixins for each breakpoint. Desktop First and Mobile First.

```scss
@include xl {
}
@include xl-up {
}
```

| down | up     |
| ---- | ------ |
| xl   | xl-up  |
| lg   | lg-up  |
| md   | md-up  |
| sm   | sm-up  |
| xs   | xs-up  |
| xxs  | xxs-up |

## Init order:

Put the mixin before custom scss code. It will create placeholder styles
for body tag. It's important for css-mqpacker; There can be wrong order media queries without the mixin.

```scss
@include initMediaPosition();
```

Possible error see [below](#possible-order-error)

### Source mixin code:

```scss
@mixin xl {
  @media only screen and (max-width: $xl - 1) {
    @content;
  }
}

@mixin xl-up {
  @media only screen and (min-width: $xl) {
    @content;
  }
}
```

#### Possible order error

In the case:

```scss
.card {
  // styles
  @include sm {
    // styles 2
  }
}

.container {
  max-width: 1200px;
  @include md {
    max-width: 500px;
  }
  @include sm {
    max-width: none;
  }
}
```

Output after css-mqpacker will be:

```scss
.card {
  // styles
}
.container {
  max-width: 1200px;
}

@media only screen and (min-width: $sm) {
  .card {
    // styles 2
  }
  .container {
    max-width: none;
  }
}
@media only screen and (min-width: $md) {
  .container {
    max-width: 500px;
  }
}
```

On screen \$sm and below style `.container{ max-width: none; }` will not be applied.
Use `@include initMediaPosition()` to prevent this error.

### Webpack rule for compiling

Here is example: [Webpack starter](https://github.com/MichaelGitArt/webpack-starter-gitart)

```js
// rules:
[
  {
    test: /\.scss$/,
    use: [
      isDev ? "style-loader" : MiniCssExtractPlugin.loader,
      {
        loader: "css-loader",
        options: { sourceMap: true },
      },
      {
        loader: "postcss-loader",
        options: {
          sourceMap: true,
          config: { path: "postcss.config.js" },
        },
      },
      {
        loader: "sass-loader",
        options: { sourceMap: true },
      },
    ],
  },
];
```

---
_Source: https://npm.io/package/css-mqpacker-starter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
