Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/rfs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn Cuppens <martijn.cuppens@gmail.com>2017-09-03 16:05:38 +0300
committerMartijn Cuppens <martijn.cuppens@gmail.com>2017-09-03 16:05:38 +0300
commit68305e45c8c4bd6a1a1fbc4870e76e00e3aa3ee2 (patch)
tree7cc6392cd51ae02ba4b612d8f810d302e0aa4705
parent7d1690cde550dd58bae23d29135801d3dd3b53ab (diff)
#3: Version 4.0.0
-rw-r--r--README.md24
-rw-r--r--package.json2
-rw-r--r--scss/_rfs.scss24
3 files changed, 31 insertions, 19 deletions
diff --git a/README.md b/README.md
index ac42d35..b687dda 100644
--- a/README.md
+++ b/README.md
@@ -37,19 +37,19 @@ manage and update RFS as a dependency.
This input (SCSS):
```scss
.title {
- @include rfs(60);
+ @include rfs(62);
}
```
Will generate this (CSS):
```css
.title {
- font-size: 3.75rem;
+ font-size: 62px;
}
@media (max-width: 1200px) {
.title {
- font-size: calc(1.35rem + 3.2vw);
+ font-size: calc(23.6px + 3.2vw);
}
}
```
@@ -63,23 +63,23 @@ Will generate this (CSS):
## Configuration
![RFS visualisation](http://i.imgur.com/KpcsXUk.png)
-There are configuration variables which influence the calculation of the font size. All variables must be set unitless in the configuration:
+There are configuration variables which influence the calculation of the font size. If no unit is used, `px`-units will be assumed as unit. In the graph above, `$rfs-minimum-font-size` is set to `12`, `$rfs-breakpoint` is set to `1200`, and `$rfs-factor` is set to `5`.
-**$rfs-minimum-font-size:** (in `px`)
+**$rfs-minimum-font-size:** (in `px` or `rem`)
Font sizes which are calculated by RFS will never be lower than this size.
However, you can still pass a smaller font size to RFS, but then RFS won't dynamically scale this font size. For example (see graph above): `rfs(17)` will trigger dynamic rescaling, with `rfs(10)` it will just stay `10px` all the time.
-*Default value: `12`*
+*Default value: `14px`*
**$rfs-minimum-font-size-unit:** (string)
-The font size will be rendered in this unit. Possible units are `px` and `rem`. This setting doesn't influence `$rfs-minimum-font-size`, which will always be configured in `px`.
-*Default value: `rem`*
+The font size will be rendered in this unit. Possible units are `px` and `rem`.
+*Default value: `px`*
-**$rfs-breakpoint:** (in `px`)
-This is the point where dynamic rescaling begins. Above this breakpoint, the font size will be equal to the font size you passed to the mixin.
-*Default value: `1200`*
+**$rfs-breakpoint:** (in `px`, `em` or `rem`)
+This is the point where dynamic rescaling begins. Above this breakpoint, the font size will be equal to the font size you passed to the mixin.
+*Default value: `1200px`*
**$rfs-breakpoint-unit:** (string)
-The width of `$rfs-breakpoint` will be rendered in this unit. Possible units are `px`, `em` and `rem`. This setting doesn't influence `$rfs-breakpoint`, which will always be configured in `px`.
+The width of `$rfs-breakpoint` will be rendered in this unit. Possible units are `px`, `em` and `rem`.
*Default value: `px`*
**$rfs-factor:** (number)
diff --git a/package.json b/package.json
index c29aa6f..dfe233a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "rfs",
- "version": "3.0.2",
+ "version": "4.0.0",
"description": "A scss-mixin for responsive font-sizes.",
"main": "scss/rfs.scss",
"scripts": {
diff --git a/scss/_rfs.scss b/scss/_rfs.scss
index eebcdf8..5cf16da 100644
--- a/scss/_rfs.scss
+++ b/scss/_rfs.scss
@@ -4,11 +4,18 @@
//
// See https://github.com/MartijnCuppens/rfs.
+// Disable RFS by setting $enable-responsive-font-sizes to false.
+$enable-responsive-font-sizes: true !default;
+@if $enable-responsive-font-sizes == false {
+ // If $rfs-factor is set to 1, fluid font-resizing is disabled.
+ $rfs-factor: 1;
+}
+
// Configuration.
// Minimum fontsize.
-$rfs-minimum-font-size: 12px !default;
-$rfs-minimum-font-size-unit: rem !default;
+$rfs-minimum-font-size: 14px !default;
+$rfs-minimum-font-size-unit: px !default;
// Breakpoint at where font-size starts decreasing if screen width is smaller.
$rfs-breakpoint: 1200px !default;
@@ -23,16 +30,19 @@ $rfs-rem-value: 16 !default;
// Remove px-unit from $rfs-minimum-font-size for calculations.
@if (unit($rfs-minimum-font-size) == "px") {
$rfs-minimum-font-size: $rfs-minimum-font-size / ($rfs-minimum-font-size * 0 + 1);
+} @else if (unit($rfs-minimum-font-size) == "rem") {
+ $rfs-minimum-font-size: $rfs-minimum-font-size / ($rfs-minimum-font-size * 0 + (1 / $rfs-rem-value));
}
-// Remove px-unit from $rfs-breakpoint for calculations.
+// Remove unit from $rfs-breakpoint for calculations.
@if (unit($rfs-breakpoint) == "px") {
$rfs-breakpoint: $rfs-breakpoint / ($rfs-breakpoint * 0 + 1);
+} @else if (unit($rfs-breakpoint) == "rem" or unit($rfs-breakpoint) == "em") {
+ $rfs-breakpoint: $rfs-breakpoint / ($rfs-breakpoint * 0 + (1 / $rfs-rem-value));
}
// Responsive font-size mixin.
@mixin rfs($fs, $important: false) {
-
$rfs-suffix: "";
// Add !important suffix if needed.
@@ -41,15 +51,18 @@ $rfs-rem-value: 16 !default;
}
// If $fs is not a number (like inherit) or $fs has a unit (like 1.5em) or $ is 0, just print the value.
- @if type-of($fs) != "number" or (not unitless($fs) and unit($fs) != "px") or $fs == 0 {
+ @if type-of($fs) != "number" or (not unitless($fs) and unit($fs) != "px" and unit($fs) != "rem") or $fs == 0 {
font-size: #{$fs}#{$rfs-suffix};
} @else {
// Remove px-unit from $fs for calculations.
@if (unit($fs) == "px") {
$fs: $fs / ($fs * 0 + 1);
+ } @else if (unit($fs) == "rem") {
+ $fs: $fs / ($fs * 0 + (1 / $rfs-rem-value));
}
+
// Default font-size.
@if $rfs-minimum-font-size-unit == rem {
font-size: #{$fs / $rfs-rem-value}rem#{$rfs-suffix};
@@ -74,7 +87,6 @@ $rfs-rem-value: 16 !default;
// Calculate minimum font-size for given font-size.
$fs-min: $rfs-minimum-font-size + ($fs - $rfs-minimum-font-size) / $rfs-factor;
-
// Calculate difference between given font-size and minimum font-size for given font-size.
$fs-diff: $fs - $fs-min;