All Projects → CubaSAN → rupture-sass

CubaSAN / rupture-sass

Licence: MIT license
Better media queries mixins library for SASS

Programming Languages

SCSS
7915 projects

Projects that are alternatives of or similar to rupture-sass

Skeleton Sass
Skeleton Sass is a highly modular version of Skeleton CSS
Stars: ✭ 151 (+221.28%)
Mutual labels:  mixins
Hyperium
Hyperium, Free Minecraft client with HUDs and Popular mods
Stars: ✭ 217 (+361.7%)
Mutual labels:  mixins
NCop
Composite-aspect oriented framework for .NET
Stars: ✭ 30 (-36.17%)
Mutual labels:  mixins
Sassessentials
Repository for my tutorial course: Sass Essential Training on LinkedIn Learning and Lynda.com.
Stars: ✭ 167 (+255.32%)
Mutual labels:  mixins
Styled Components Spacing
Responsive margin and padding components for styled-components 💅.
Stars: ✭ 209 (+344.68%)
Mutual labels:  mixins
media-blender
Easy and predictable SASS/SCSS media queries
Stars: ✭ 26 (-44.68%)
Mutual labels:  mixins
Super module
SuperModule allows defining class methods and method invocations the same way a super class does without using def included(base). This also succeeds ActiveSupport::Concern by offering lighter syntax
Stars: ✭ 133 (+182.98%)
Mutual labels:  mixins
Sledgehammer
Smashes the stupid out of the client & server.
Stars: ✭ 13 (-72.34%)
Mutual labels:  mixins
Pug Bootstrap
Bootstrap framework written completely using mixins in Pug
Stars: ✭ 212 (+351.06%)
Mutual labels:  mixins
Grimoire-legacy
General-purpose Mixin loader framework, which allows to properly implement mixins on 1.7.10/1.12.2 versions of Minecraft. For updated version check out https://github.com/Aizistral-Studios/Grimoire
Stars: ✭ 27 (-42.55%)
Mutual labels:  mixins
Uniflow Polymer
UniFlow for Polymer
Stars: ✭ 168 (+257.45%)
Mutual labels:  mixins
Web Portfolio
Personal portfolio website made with the React
Stars: ✭ 207 (+340.43%)
Mutual labels:  mixins
ignite
A Mixin and Access Widener mod loader for Spigot/Paper
Stars: ✭ 115 (+144.68%)
Mutual labels:  mixins
Elena Lang
ELENA is a general-purpose language with late binding. It is multi-paradigm, combining features of functional and object-oriented programming. Rich set of tools are provided to deal with message dispatching : multi-methods, message qualifying, generic message handlers, run-time interfaces
Stars: ✭ 161 (+242.55%)
Mutual labels:  mixins
styled-media-helper
💅 Helps manage media queries with styled components
Stars: ✭ 76 (+61.7%)
Mutual labels:  media-queries
Mimic
mimic: Define your Deployments, Infrastructure and Configuration as a Go Code 🚀
Stars: ✭ 145 (+208.51%)
Mutual labels:  mixins
Sponge
The SpongeAPI implementation targeting vanilla Minecraft and 3rd party platforms.
Stars: ✭ 241 (+412.77%)
Mutual labels:  mixins
sass-boilerplate
A collection of common use Sass stylesheets, mixins and functions.
Stars: ✭ 60 (+27.66%)
Mutual labels:  mixins
go-traits
A concept package that helps implement mixin behavior using embedded structs and hook interfaces.
Stars: ✭ 21 (-55.32%)
Mutual labels:  mixins
tale-pug
Tale Pug is the popular JavaScript Template Engine Pug, formerly Jade, for PHP!
Stars: ✭ 32 (-31.91%)
Mutual labels:  mixins

Rupture-sass

Simple media queries for SASS (Rupture mixins for SASS)

Write scss code as follows:

.some-class {
  color: red;
  @include above(32em) {
    color: green;
  }
  @include tablet() {
    color: yellow;
  }
}

Which compiles to:

.some-class {
  color: red;
}
@media only screen and (min-width: 32em) {
  .some-class {
    color: green;
  }
}
@media only screen and (min-width: 400px) and (max-width: 1050px) {
  .some-class {
    color: yellow;
  }
}

Installation

npm install rupture-sass

Use

  • Import package via @import directive
    @import 'node_modules/rupture-sass/rupture';
    // ...
  • If using Webpack as a bundler, with node-sass packge
    @import '~rupture-sass/rupture';
    // ...
  • Download package, and directly include file to project

API Documentation

Customization

Default values

$rupture: (
  mobile-cutoff: 400px,
  desktop-cutoff: 1050px,
  hd-cutoff: 1800px,
  enable-em-breakpoints: false, 
  anti-overlap: false,
  density-queries: 'dppx' 'webkit' 'moz' 'dpi',
  retina-density: 1.5,
  use-device-width: false
);

In order to override any value use $rupture: map-merge($rupture, (key: value, ..., keyN: valueN)

$rupture: map-merge($rupture, (
  mobile-cutoff: 768px,
  desktop-cutoff: 1366px
));

mobile-cutoff (value)

Upper bound where mobile() mixin has an effect and lower bound of the tablet() mixin.

desktop-cutoff (value)

Lower bound where desktop() mixin has an effect and upper bound of the tablet() mixins.

hd-cutoff (value)

Lower bound where hd() mixin starts to have an affect

enable-em-breakpoints (boolean)

Convert pixel values into EM's values:

$rupture: map-merge($rupture, (
  enable-em-breakpoints: true
));
@include below(768px) {/*...*/};
// Compiles to:
// @media only screen and (max-width: 48em) {...}

anti-overlap (boolean | value | list)

Fixes overlaped boundaries of two or more media queries, for example we might have

@media only screen and (max-width: 48em) {/*...*/}
@media only screen and (min-width: 48em) {/*...*/}

in this case, when screen size is exactly 48em's or 768px two media queries will be applied in one time. In order to prevent this, override the anti-overlap value

$rupture: map-merge($rupture, (
  anti-overlap: true
));
// Resolves to:
// @media only screen and (max-width: 48em) {/*...*/}
// @media only screen and (min-width: 48.0625em) {/*...*/}

By default adjustement happens with +1px value or +0.0625em if enable-em-breakpoints is true but also specific values, like 1px or 0.5rem might be assigned

anti-overlap: false // default value
anti-overlap: true // enables 1px (or em equivalent) overlap correction globally
anti-overlap: 0px // same as anti-overlap = false
anti-overlap: 1px // same as anti-overlap = true
anti-overlap: -1px // negative offsets decrease the `max-width` arguments
anti-overlap: 0.001em // positive offsets increase the `min-width` arguments
anti-overlap: 1px 0.0625em 0.0625rem // explicit relative values will be used if they are provided instead of calculating them from the font size

density-queries (list)

Set of vendor prefixes for generating vendor specific density media queries. Valid values are 'webkit', 'moz', 'o', 'ratio', 'dpi', and 'dppx' Used in density() and retina() mixins as well as when $density or $retina specified as parameter

$rupture: map-merge($rupture, (
  density-queries: 'dppx' 'webkit' 'moz' 'dpi',
));
div {
  @include density(2) {/*...*/}
}

Compiles to:

@media only screen and (min-resolution: 2dppx), /* dppx */
only screen and (-webkit_min-device-pixel-ratio: 2), /* webkit */
only screen and (min--moz-device-pixel-ratio: 2), /* moz */
only screen and (min-resolution: 192dpi) { /* dpi */
    div {/*...*/}
}

retina-density (value)

Density value for retina density mixins, by default 1.5

use-device-width (boolean)

Toggles min-width and max-width media queries to min-device-width and max-device-width

rasterise-media-queries (boolean)

Supresses all adjustements like density or retina from all media queries. Mostly used to generate fallback styles for legasy browsers

scale (list)

A list of breakpoint bounds for referencing breakpoint span as an index. The idea is taken from breakpoint-slicer.

$rupture: map-merge($rupture, (
  scale: 0 400px 600px 800px 1050px 1800px
));

In this case, 0 to 400px will have index 1, 400px to 600px index 2, an so on... Then you can reference index in mixins, like:

@include at(2) {/*...*/}
// Compiles to:
// @media only screen and (min-width: 400px) and (max-width: 600px) {}

scale-names (list)

A list of string reppresentation for indexes in scale property

$rupture: map-merge($rupture, (
  scale: 0 400px 600px 800px 1050px 1800px,
  scale-names: 'xs' 's' 'm' 'l' 'xl' 'hd'
));
scale:                 0        400px       600px       800px       1050px      1800px
//                     └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────
//                          1           2           3           4           5           6
scale-names:               'xs'        's'         'm'         'l'         'xl'        'hd'
@include at(s) {/*...*/}
// Compiles to:
// @media only screen and (min-width: 400px) and (max-width: 600px) {}

Mixins

above(value)

Media query kicks in above the specified value, index or scale name

from-width(value)

Alias to above()

from(value)

Alias to above() using breakpoint-slicer syntax

below(value)

Media query kicks in below the specified value, index or scale name

to-width(value)

Alias to below()

to(value)

Alias to below() using breakpoint-slicer syntax

between(minVal, maxVal)

Media query takes an affect between minVal and maxVal value, index or scale name

at(value)

Used for specifying media query only at exact index or scale-name

@include at(s) {/*...*/}
// Compiles to:
// @media only screen and (min-width: 400px) and (max-width: 600px) {}

Has no reason with px, em or rem values

mobile()

Media query for screens width like mobile, by default from 0 till 400px, upper bound could be changed with mobile-cutoff

tablet()

Media query for screens width like tablet, by default from 400px till 1050px, lower bound could be changed with mobile-cutoff and upper bound with desktop-cutoff

desktop()

Media query for desktop like screens, by default from 1050px and above, lower bound could be changed with desktop-cutoff

hd()

Media query for large screens, by default from 1800px and above, lower bound could be changed with hd-cutoff

density(number)

Media query for specific device pixel density, possible values 1.5, 2

div {
  @include density(2) {/*...*/}
}

Compiles to:

@media only screen and (min-resolution: 2dppx), /* dppx */
only screen and (-webkit_min-device-pixel-ratio: 2), /* webkit */
only screen and (min--moz-device-pixel-ratio: 2), /* moz */
only screen and (min-resolution: 192dpi) { /* dpi */
    div {/*...*/}
}

retina()

Add density media queries with retina-density, default retina density is 1.5 but migth be changed with retina-density

landscape()

Add a media query for screen when the viewport is wider than it is tall or in landscape mode

portrait()

Add a media query for screen when the viewport is taller than it is wide or in portrait mode

hover()

Add media queries for devices with hover over element's ability

touch()

Add media queries for devices with touch only ability

Mixins Arguments

Almost all mixins receive parameters to make media query more specific. Following parameters are: $scale-point, $anti-overlap, $density, $orientation, $use-device-width, $fallback-class and can be added to mixin separately.

div {
  @include above(32em, $orientation: portrait, $fallback-class: '.tablet-portrait') {
    color: red;
  }
}

Compiles to:

@media only screen and (min-width: 32em) and (orientation: portrait) {
  div {
    color: red;
  }
}

.tablet-portrait div {
  color: red;
}

Miscellaneous

Inspired by Rupture mixins lib for Stylus

Thanks

elgandoz Honza

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].