layout-tools-for-susy 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +0 -0
- data/README.md +210 -0
- data/lib/layout-tools-for-susy.rb +17 -0
- data/stylesheets/_layout-tools-for-susy.scss +40 -0
- data/stylesheets/config/_constants.scss +7 -0
- data/stylesheets/config/_globals.scss +12 -0
- data/stylesheets/config/_layouts.scss +39 -0
- data/stylesheets/functions/_color-get.scss +21 -0
- data/stylesheets/functions/_color-set.scss +28 -0
- data/stylesheets/functions/_const.scss +12 -0
- data/stylesheets/functions/_layout-build.scss +36 -0
- data/stylesheets/functions/_layout-extend.scss +13 -0
- data/stylesheets/functions/_layout-get.scss +43 -0
- data/stylesheets/functions/_list-implode.scss +18 -0
- data/stylesheets/functions/_list-px-to-em.scss +14 -0
- data/stylesheets/functions/_map-merge-r.scss +24 -0
- data/stylesheets/functions/_map-set.scss +10 -0
- data/stylesheets/functions/_px-to-em.scss +9 -0
- data/stylesheets/functions/_px-to-pc.scss +9 -0
- data/stylesheets/functions/_px-to-rem.scss +8 -0
- data/stylesheets/mixins/_color-set.scss +9 -0
- data/stylesheets/mixins/_const.scss +12 -0
- data/stylesheets/mixins/_layout-extend.scss +13 -0
- data/stylesheets/mixins/_layout-init.scss +17 -0
- data/stylesheets/mixins/_layout-use.scss +94 -0
- data/stylesheets/mixins/_type-base.scss +31 -0
- data/stylesheets/mixins/_type-context.scss +24 -0
- data/stylesheets/placeholders/_clearfix.scss +7 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 22a887b518b4b623e85d8d16b06c8d7a9ac5b2fb
|
4
|
+
data.tar.gz: f99f83a61bf859d7e6788c487172c47d9302cf43
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 30f4c7ba518d7f9eef1c9c73303a6e185fb87b052ad607d3853f3dffb9f25a0d3343189a2deb4694b2b364dbce3e9f4fe6ff4dba17b6a97d4dc83b8b0da04739
|
7
|
+
data.tar.gz: 817f3ff17f10badb66b436ff572855ca865e195c4653c8f1aaca832bd43063fda3588d072cc5f8d896acc0720d7e9cf172a6b80aa65d90eedf685beafe19c375
|
data/CHANGELOG.md
ADDED
File without changes
|
data/README.md
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
# Layout Tools for Susy
|
2
|
+
|
3
|
+
Layout Tools for Susy is a set of handy mixins and functions to structure, organize and access layout settings over multiple breakpoints. Combined with the power of Susy’s grid calculations it allows you to set up responsive grid layouts fast and with ease.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
### NPM
|
7
|
+
```bash
|
8
|
+
$ npm install layout-tools-for-susy --save-dev
|
9
|
+
```
|
10
|
+
This installs layout tools and Susy. Include tools in your stylesheets like this:
|
11
|
+
```scss
|
12
|
+
// file: src/stylesheets/styles.scss
|
13
|
+
@import '../../node_modules/layout-tools-for-susy/node_modules/susy/sass/susy',
|
14
|
+
'../../node_modules/layout-tools-for-susy/stylesheets/layout-tools-for-susy';
|
15
|
+
```
|
16
|
+
|
17
|
+
### Bower
|
18
|
+
```bash
|
19
|
+
$ bower install layout-tools-for-susy --save-dev
|
20
|
+
```
|
21
|
+
This installs layout tools and Susy. Include tools in your stylesheets like this:
|
22
|
+
```scss
|
23
|
+
// file: src/stylesheets/styles.scss
|
24
|
+
@import '../../bower_components/susy/sass/susy',
|
25
|
+
'../../bower_components/layout-tools-for-susy/stylesheets/layout-tools-for-susy';
|
26
|
+
```
|
27
|
+
|
28
|
+
### Gem
|
29
|
+
|
30
|
+
|
31
|
+
## How to use
|
32
|
+
Since Susy2 switched to storing all grid settings in SASS maps, it seems to be quite a good idea to store other basic layout settings the same way. Layout Tools for Susy provides tools to store and access layout settings while making the interaction with SASS maps to a minimum. Let’s see how it’s done.
|
33
|
+
|
34
|
+
### Defining layouts and putting them to use
|
35
|
+
The foundation Layout Tools for Susy build on is a SASS map storing the basic layout settings for your Susy setup and more. Here’s an example:
|
36
|
+
```scss
|
37
|
+
// Layout settings
|
38
|
+
$layouts: (
|
39
|
+
default: (
|
40
|
+
susy: (
|
41
|
+
flow: ltr,
|
42
|
+
math: fluid,
|
43
|
+
output: float,
|
44
|
+
gutter-position: after,
|
45
|
+
container: auto,
|
46
|
+
container-position: center,
|
47
|
+
columns: 4,
|
48
|
+
gutters: .25,
|
49
|
+
column-width: false,
|
50
|
+
global-box-sizing: border-box,
|
51
|
+
last-flow: to,
|
52
|
+
debug: (
|
53
|
+
image: hide,
|
54
|
+
color: rgba(#66f, .25),
|
55
|
+
output: background,
|
56
|
+
toggle: top right,
|
57
|
+
),
|
58
|
+
use-custom: (
|
59
|
+
background-image: true,
|
60
|
+
background-options: false,
|
61
|
+
box-sizing: true,
|
62
|
+
clearfix: false,
|
63
|
+
rem: true,
|
64
|
+
)
|
65
|
+
),
|
66
|
+
base: (
|
67
|
+
base__font-size: 14px,
|
68
|
+
base__line-height: 18px
|
69
|
+
)
|
70
|
+
),
|
71
|
+
M: (
|
72
|
+
susy: (
|
73
|
+
columns: 8
|
74
|
+
),
|
75
|
+
base: (
|
76
|
+
base__font-size: 18px,
|
77
|
+
base__line-height: 24px
|
78
|
+
),
|
79
|
+
breakpoint: (
|
80
|
+
max-width: 1200px,
|
81
|
+
min-width: 801px
|
82
|
+
)
|
83
|
+
),
|
84
|
+
L: (
|
85
|
+
extends: M,
|
86
|
+
susy: (
|
87
|
+
columns: 12
|
88
|
+
),
|
89
|
+
breakpoint: (
|
90
|
+
min-width: 1201px
|
91
|
+
)
|
92
|
+
)
|
93
|
+
);
|
94
|
+
// set up and initialize layout tools
|
95
|
+
@include layout-init($layouts);
|
96
|
+
|
97
|
+
```
|
98
|
+
The root properties of the map $layouts represent the different layout contexts. Layout contexts may be layout variations depending on breakpoints or layout settings specific for e.g. a certain template. There are some important settings that will be defined by default if you don’t set them yourself. The `default` layout will be set up by—you guessed it—default with the properties `susy`—containing Susy’s default settings—and `base`—setting a `base__font-size` and `base__line-height` value. To implement your custom layouts, you have to create your settings map like shown above overriding the defaults and adding additional layout specifications.
|
99
|
+
|
100
|
+
#### Layout contexts
|
101
|
+
The `default` layout context is the most basic. It will be used everywhere where no other layout context is set (by using the `layout-use` mixin). All other layout contexts extend the `default` context and thus override its settings. If you want to extend a specific context, you can define it using the `extends` property within a layout context’s definition map. In the example above the layout context `L` extends `M`. That means the settings and values you will be working with in the layout context `L` are the result from first merging `M` into `default` and then `L` into the first merge’s result. So within the context of `L` the value of `base__font-size` will be 18px. This behaviour allows you create a sophisticated system of layout settings through controlled inheritance of settings and values.
|
102
|
+
|
103
|
+
As said before, after using ```@include layout-init($layouts);``` the `default` layout context is established. Switching to another context is done using the ```layout-use()``` mixin as shown below:
|
104
|
+
```sass
|
105
|
+
.body {
|
106
|
+
|
107
|
+
@include type-base($base__font-size, $base__line-height);
|
108
|
+
|
109
|
+
// Switching to layout context 'M' (and beyond)
|
110
|
+
@include layout-use(M up) {
|
111
|
+
@include type-base($base__font-size, $base__line-height);
|
112
|
+
...
|
113
|
+
}
|
114
|
+
|
115
|
+
// Switching to layout context 'L' (and only 'L')
|
116
|
+
@include layout-use(L) {
|
117
|
+
...
|
118
|
+
}
|
119
|
+
|
120
|
+
}
|
121
|
+
```
|
122
|
+
In this example we set the styles for the base font size and line height. As in our layout definition the font size is a different one for layout context `M`, we switch contexts and set the styles again. As we defined the breakpoint property for this context, including ```layout-use()``` will create a corresponding media query that wraps the new type settings. As we know that context `L` extends `M` and keeps the font size and line height, we added the `up` keyword to the parameter we passed to the mixin. This causes to remove all max- values from the media query so the type settings will be valid from `M`’s min-width to infinity. Adding the `down` keyword works the other way around.
|
123
|
+
|
124
|
+
#### Settings groups
|
125
|
+
Besides `extends` all properties of a layout context represent settings groups. An example is the pre-defined group `base`. Settings groups store key-value-pairs of specific settings. The value of each setting can be anything you want it to be like e.g. valid css values or any kind of SASS value types. You can create as many settings groups as you want and add settings to existing ones. This allows you to separate and organize your settings like in the example below:
|
126
|
+
```scss
|
127
|
+
$layouts: (
|
128
|
+
default: (
|
129
|
+
susy: (
|
130
|
+
...
|
131
|
+
),
|
132
|
+
base: (
|
133
|
+
...
|
134
|
+
),
|
135
|
+
nav: (
|
136
|
+
item__font-size: 14px,
|
137
|
+
item__line-height: 20px,
|
138
|
+
item__border-width: 2px
|
139
|
+
),
|
140
|
+
footer: (
|
141
|
+
...
|
142
|
+
),
|
143
|
+
map-component: (
|
144
|
+
...
|
145
|
+
)
|
146
|
+
)
|
147
|
+
)
|
148
|
+
```
|
149
|
+
To give you even more possibilities to modulize your SASS code base, you can keep e.g. component-specific settings with the corresponding styles in separate files and import them where needed. This is done by using the ```layout-extend()``` mixin like shown below:
|
150
|
+
```scss
|
151
|
+
// separate file _my-component.scss
|
152
|
+
// to be imported in your main style file
|
153
|
+
|
154
|
+
// Component settings
|
155
|
+
$my-component: (
|
156
|
+
default: (
|
157
|
+
my-component: (
|
158
|
+
label__font-size: 12px,
|
159
|
+
label__line-height: 14px,
|
160
|
+
label__border: 1px dotted color-get(rose, dark)
|
161
|
+
)
|
162
|
+
),
|
163
|
+
M: (
|
164
|
+
my-component: (
|
165
|
+
...
|
166
|
+
)
|
167
|
+
)
|
168
|
+
);
|
169
|
+
|
170
|
+
// Add component settings to layouts
|
171
|
+
@include layout-extend($my-component);
|
172
|
+
|
173
|
+
// Use styles
|
174
|
+
.my-component {
|
175
|
+
|
176
|
+
&__label {
|
177
|
+
// Retrieve settings from current layout context
|
178
|
+
$label__font-size: layout-get(my-component, label__font-size);
|
179
|
+
$label__line-height: layout-get(my-component, label__line-height);
|
180
|
+
$label__border: layout-get(my-component, label__border);
|
181
|
+
@include text-context($label__font-size, $label__line-height) {
|
182
|
+
font-family: Helvetica, Arial, sans-serif;
|
183
|
+
padding: px-to-em(20px, $local__font-size) 0;
|
184
|
+
border: $label__border;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
...
|
189
|
+
}
|
190
|
+
|
191
|
+
```
|
192
|
+
|
193
|
+
#### Susy settings
|
194
|
+
The `susy` property represents the Susy settings map. For more information on configuration settings and how to work with Susy, go to: http://susydocs.oddbird.net/en/latest/
|
195
|
+
|
196
|
+
#### Base font size and line height
|
197
|
+
Within a layout context, there will be two global vars available named `$base__font-size` and `$base__line-height`. They are retrieved automatically from the current layout context’s settings. To override them, define the pixel values of your choice for ```base__font-size``` and ```base__line-height``` in your layout contexts’ ```base``` group.
|
198
|
+
|
199
|
+
|
200
|
+
### Layouts and breakpoints
|
201
|
+
|
202
|
+
### Typographic contexts
|
203
|
+
|
204
|
+
### Colors
|
205
|
+
|
206
|
+
### Constants
|
207
|
+
|
208
|
+
### Naming styles
|
209
|
+
|
210
|
+
### Contribute
|
@@ -0,0 +1,17 @@
|
|
1
|
+
base_directory = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
2
|
+
layout_tools_stylesheets_path = File.join(base_directory, 'stylesheets')
|
3
|
+
|
4
|
+
if (defined? Compass)
|
5
|
+
require 'sassy-maps'
|
6
|
+
Compass::Frameworks.register(
|
7
|
+
"layout_tools",
|
8
|
+
:path => base_directory
|
9
|
+
)
|
10
|
+
else
|
11
|
+
ENV["SASS_PATH"] = [ENV["SASS_PATH"], layout_tools_stylesheets_path].compact.join(File::PATH_SEPARATOR)
|
12
|
+
end
|
13
|
+
|
14
|
+
module LayoutTools
|
15
|
+
VERSION = "0.1.0"
|
16
|
+
DATE = "2015-11-30"
|
17
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
// Dependencies
|
2
|
+
@import 'susy';
|
3
|
+
|
4
|
+
// Config
|
5
|
+
@import 'config/constants',
|
6
|
+
'config/layouts',
|
7
|
+
'config/globals';
|
8
|
+
|
9
|
+
// General helpers
|
10
|
+
@import 'functions/map-set',
|
11
|
+
'functions/map-merge-r',
|
12
|
+
'functions/list-implode',
|
13
|
+
'placeholders/clearfix';
|
14
|
+
|
15
|
+
// constants
|
16
|
+
@import 'mixins/const',
|
17
|
+
'functions/const';
|
18
|
+
|
19
|
+
// Unit calculations
|
20
|
+
@import 'functions/px-to-em',
|
21
|
+
'functions/px-to-pc',
|
22
|
+
'functions/px-to-rem',
|
23
|
+
'functions/list-px-to-em';
|
24
|
+
|
25
|
+
// Colors
|
26
|
+
@import 'functions/color-set',
|
27
|
+
'mixins/color-set',
|
28
|
+
'functions/color-get';
|
29
|
+
|
30
|
+
// Typography
|
31
|
+
@import 'mixins/type-base',
|
32
|
+
'mixins/type-context';
|
33
|
+
|
34
|
+
// Layout tools
|
35
|
+
@import 'mixins/layout-init',
|
36
|
+
'mixins/layout-use',
|
37
|
+
'functions/layout-build',
|
38
|
+
'functions/layout-extend',
|
39
|
+
'mixins/layout-extend',
|
40
|
+
'functions/layout-get';
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/**
|
2
|
+
* Layouts map
|
3
|
+
*/
|
4
|
+
$LAYOUTS: (
|
5
|
+
|
6
|
+
default: (
|
7
|
+
susy: (
|
8
|
+
flow: ltr,
|
9
|
+
math: fluid,
|
10
|
+
output: float,
|
11
|
+
gutter-position: after,
|
12
|
+
container: auto,
|
13
|
+
container-position: center,
|
14
|
+
columns: 4,
|
15
|
+
gutters: .25,
|
16
|
+
column-width: false,
|
17
|
+
global-box-sizing: content-box,
|
18
|
+
last-flow: to,
|
19
|
+
debug: (
|
20
|
+
image: hide,
|
21
|
+
color: rgba(#66f, .25),
|
22
|
+
output: background,
|
23
|
+
toggle: top right,
|
24
|
+
),
|
25
|
+
use-custom: (
|
26
|
+
background-image: true,
|
27
|
+
background-options: false,
|
28
|
+
box-sizing: true,
|
29
|
+
clearfix: false,
|
30
|
+
rem: true,
|
31
|
+
)
|
32
|
+
),
|
33
|
+
base: (
|
34
|
+
base__font-size: 16px,
|
35
|
+
base__line-height: 20px
|
36
|
+
)
|
37
|
+
)
|
38
|
+
|
39
|
+
) !global;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/**
|
2
|
+
* Returns a color value for a $tone from a defined $palette.
|
3
|
+
* @param {String} $palette Name of palette.
|
4
|
+
* @param {String} $tone: 'base' Name of tone, default to `base`.
|
5
|
+
* @return {Misc} Color value.
|
6
|
+
*/
|
7
|
+
@function color-get($palette, $tone: 'base') {
|
8
|
+
@if (map-has-key($COLORS, $palette)) {
|
9
|
+
$palette-map: map-get($COLORS, $palette);
|
10
|
+
@if (map-has-key($palette-map, $tone)) {
|
11
|
+
@return map-get($palette-map, $tone);
|
12
|
+
}
|
13
|
+
@else {
|
14
|
+
@error 'Tone `#{$tone}` doesn’t exist in palette `#{$palette}`';
|
15
|
+
}
|
16
|
+
}
|
17
|
+
@else {
|
18
|
+
@error 'Palette `#{$palette}` doesn’t exist';
|
19
|
+
}
|
20
|
+
@return false;
|
21
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/**
|
2
|
+
* Sets one or multiple tone values for a color palette.
|
3
|
+
* @param {String} $palette Name of color palette.
|
4
|
+
* @param {String|Map} $tone Name of tone or–if no $value is given–map of tone-value pairs.
|
5
|
+
* @param {Color value|Boolean} $value: false Color value to be set for $tone.
|
6
|
+
*/
|
7
|
+
@function color-set($palette, $tone, $value: false) {
|
8
|
+
$palette-map: ();
|
9
|
+
$tone-map: ();
|
10
|
+
|
11
|
+
@if ($value) {
|
12
|
+
@if (map-has-key($COLORS, $palette)) {
|
13
|
+
$palette-map: map-get($COLORS, $palette);
|
14
|
+
}
|
15
|
+
$tone-map: ( $tone: $value);
|
16
|
+
}
|
17
|
+
@else {
|
18
|
+
@if (type-of($tone) == map) {
|
19
|
+
$tone-map: $tone;
|
20
|
+
}
|
21
|
+
@else {
|
22
|
+
@error 'Expected $tone to be a valid map. Was `#{type-of($tone)}`.';
|
23
|
+
}
|
24
|
+
}
|
25
|
+
$palette-map: map-merge($palette-map, ( $tone-map ));
|
26
|
+
$COLORS: map-merge($COLORS, ($palette: $palette-map)) !global;
|
27
|
+
@return true;
|
28
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/**
|
2
|
+
* Retrieves value of a constant.
|
3
|
+
* Based on code by Hugo Giraudel, http://www.sitepoint.com/dealing-constants-sass/
|
4
|
+
* @param {String} $name Name of constant.
|
5
|
+
* @return {Misc} Value of constant.
|
6
|
+
*/
|
7
|
+
@function const($name) {
|
8
|
+
@if (map-has-key($CONSTANTS, $name)) {
|
9
|
+
@return map-get($CONSTANTS, $name);
|
10
|
+
}
|
11
|
+
@error 'Unknown constant `#{$name}`.';
|
12
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
/**
|
2
|
+
* Builds layout map by extending the layout defined in $this-layout accordingly to inheritence defined through `extends` setting or a particular layout defined through $with-layout parameter.
|
3
|
+
* @param {String} $this-layout Key of the layout to be extended.
|
4
|
+
* @param {String|Boolean} $with-layout: false Optional layout key to be extended with $this-layout
|
5
|
+
* @return {Map|Boolean} Returns map of extended layout or false, if a layout couldn’t be correctly retrieved from $LAYOUTS.
|
6
|
+
*/
|
7
|
+
|
8
|
+
@function layout-build($this-layout, $with-layout: false) {
|
9
|
+
@if (map-has-key($LAYOUTS, $this-layout)) {
|
10
|
+
$this-layout-map: map-get($LAYOUTS, $this-layout);
|
11
|
+
@if ($this-layout == default) {
|
12
|
+
@return $this-layout-map;
|
13
|
+
}
|
14
|
+
@if ($with-layout == false) {
|
15
|
+
@if (map-has-key($this-layout-map, extends)) {
|
16
|
+
$with-layout: map-get($this-layout-map, extends);
|
17
|
+
}
|
18
|
+
@else {
|
19
|
+
$with-layout: default;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
@if ($with-layout) {
|
23
|
+
@if ($with-layout == default) {
|
24
|
+
@return map-merge-r(map-get($LAYOUTS, $with-layout), $this-layout-map);
|
25
|
+
}
|
26
|
+
@else {
|
27
|
+
$with-layout-map: layout-build($with-layout);
|
28
|
+
@return map-merge-r($with-layout-map, $this-layout-map);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
@else {
|
32
|
+
@return $this-layout-map;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
@return false;
|
36
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/**
|
2
|
+
* Extends layout with map $extension.
|
3
|
+
* @param {Map} $extension Map with additional layout settings.
|
4
|
+
* @param {String} $layout-key: 'default' Key of layout to be retrieved and returned after extension.
|
5
|
+
* @return {Map} Returns extended layout map for $layout-key.
|
6
|
+
*/
|
7
|
+
@function layout-extend($extension, $layout-key: default) {
|
8
|
+
@if (type-of($extension) != map) {
|
9
|
+
@return false;
|
10
|
+
}
|
11
|
+
$LAYOUTS: map-merge-r($LAYOUTS, $extension) !global;
|
12
|
+
@return layout-get(false, false, $layout-key);
|
13
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
/**
|
2
|
+
* Retrieves a particular value from a group or a complete group or whole config from current or specified layout
|
3
|
+
* @param {String|Boolean} $group: false Group of settings to be retrieved. Set to `false` for all groups of a layout.
|
4
|
+
* @param {String|Boolean} $key: false Specifies particular setting to be retrieved. Set to `false` for all settings of a group.
|
5
|
+
* @param {String|Boolean} $of-layout: false Defines layout settings will be retrieved from. Set to `false` to retrieve from current layout.
|
6
|
+
* @return {CSS value|Map|Boolean} Returns a particular setting’s value, a map of settings, a layout map or false if requested resource doesn’t exist.
|
7
|
+
*/
|
8
|
+
|
9
|
+
@function layout-get($group: false, $key: false, $of-layout: false) {
|
10
|
+
|
11
|
+
@if (type-of($of-layout) == string) {
|
12
|
+
@if (map-has-key($LAYOUTS, $of-layout)) {
|
13
|
+
$of-layout: layout-build($of-layout);
|
14
|
+
}
|
15
|
+
@else {
|
16
|
+
$of-layout: false;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
@else {
|
20
|
+
$of-layout: $LAYOUT;
|
21
|
+
}
|
22
|
+
|
23
|
+
@if (type-of($of-layout) == map) {
|
24
|
+
@if ($group == false) {
|
25
|
+
@return $of-layout;
|
26
|
+
}
|
27
|
+
@else {
|
28
|
+
@if (map-has-key($LAYOUT, $group)) {
|
29
|
+
$group: map-get($LAYOUT, $group);
|
30
|
+
@if($key == false) {
|
31
|
+
@return $group;
|
32
|
+
}
|
33
|
+
@else {
|
34
|
+
@if (map-has-key($group, $key)) {
|
35
|
+
@return map-get($group, $key);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
@return false;
|
43
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* Implodes a list separating list items by $separator.
|
3
|
+
* @param {List} $list Sass list of misc items.
|
4
|
+
* @param {String} $separator: '' Separator string.
|
5
|
+
* @param {Boolean} $recursive: false Optionally implode items of type list.
|
6
|
+
* @return {String} Imploded list as string.
|
7
|
+
*/
|
8
|
+
@function list-implode($list, $separator: '') {
|
9
|
+
$result: null;
|
10
|
+
@for $i from 1 through length($list) {
|
11
|
+
$e: nth($list, $i);
|
12
|
+
@if (type-of($e) == list) {
|
13
|
+
$e: list-implode($e, $separator);
|
14
|
+
}
|
15
|
+
$result: if($i != length($list), $result#{$e}#{$separator}, $result#{$e});
|
16
|
+
}
|
17
|
+
@return $result;
|
18
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* Converts all px values in $list to em values based on $context.
|
3
|
+
* @param {List} $list List of values.
|
4
|
+
* @return {List} List of modified values.
|
5
|
+
*/
|
6
|
+
@function list-px-to-em($list, $context) {
|
7
|
+
@for $i from 1 through length($list) {
|
8
|
+
$value: nth($list, $i);
|
9
|
+
@if(type-of($value) == number and unit($value) == px) {
|
10
|
+
$list: set-nth($list, $i, calc-em($value, $context));
|
11
|
+
}
|
12
|
+
}
|
13
|
+
@return $list;
|
14
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/**
|
2
|
+
* Merges to SASS maps recursively
|
3
|
+
* @param {Map} $map1 Map to be merged into.
|
4
|
+
* @param {Map} $map2 Map to be merged into $map1.
|
5
|
+
* @return {Map} Merged map.
|
6
|
+
*/
|
7
|
+
|
8
|
+
@function map-merge-r($map1, $map2) {
|
9
|
+
$map1-keys: map-keys($map1);
|
10
|
+
$map2-keys: map-keys($map2);
|
11
|
+
@each $key in $map1-keys {
|
12
|
+
@if(map-has-key($map1, $key)) {
|
13
|
+
$map1-value: map-get($map1, $key);
|
14
|
+
@if(type-of($map1-value) == map) {
|
15
|
+
$map2-value: map-get($map2, $key);
|
16
|
+
@if(type-of($map2-value) == map) {
|
17
|
+
$map1: map-set($map1, $key, map-merge-r($map1-value, $map2-value));
|
18
|
+
}
|
19
|
+
$map2: map-remove($map2, $key);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
@return map-merge($map1, $map2);
|
24
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* Sets a value in an existing map.
|
3
|
+
* @param {Map} $map Map the value will be set in.
|
4
|
+
* @param {String} $key Key the value will be set for.
|
5
|
+
* @param {Misc} $value Value to be set.
|
6
|
+
*/
|
7
|
+
@function map-set($map, $key, $value) {
|
8
|
+
$new: ($key: $value);
|
9
|
+
@return map-merge($map, $new);
|
10
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Calculates a relative em value from $px relatively to $px-context.
|
3
|
+
* @param {px value} $px Value.
|
4
|
+
* @param {px value} $px-context Context.
|
5
|
+
* @return {em value} Relative em value.
|
6
|
+
*/
|
7
|
+
@function px-to-em($px, $px-context) {
|
8
|
+
@return $px / $px-context * 1em;
|
9
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Calculates the percentage value of $px relatively to $px-context.
|
3
|
+
* @param {px value} $px Part.
|
4
|
+
* @param {px value} $px-context Context.
|
5
|
+
* @return {% value} Percentage value.
|
6
|
+
*/
|
7
|
+
@function px-to-pc($px, $px-context) {
|
8
|
+
@return percentages($px / $px-context);
|
9
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Sets one or multiple tone values for a color palette.
|
3
|
+
* @param {String} $palette Name of color palette.
|
4
|
+
* @param {String|Map} $tone Name of tone or–if no $value is given–map of tone-value pairs.
|
5
|
+
* @param {Color value|Boolean} $value: false Color value to be set for $tone.
|
6
|
+
*/
|
7
|
+
@mixin color-set($palette, $tone, $value: false) {
|
8
|
+
$color: color-set($palette, $tone, $value);
|
9
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/**
|
2
|
+
* Defines a new constant.
|
3
|
+
* Based on code by Hugo Giraudel, http://www.sitepoint.com/dealing-constants-sass/
|
4
|
+
* @param {String} $name Name of new constant.
|
5
|
+
* @param {Misc} $value Value of constant
|
6
|
+
*/
|
7
|
+
@mixin const($name, $value) {
|
8
|
+
@if (map-has-key($CONSTANTS, $name)) {
|
9
|
+
@error 'Constant `#{$name}` is already defined.';
|
10
|
+
}
|
11
|
+
$CONSTANTS: map-merge($CONSTANTS, ( $name: $value )) !global;
|
12
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/**
|
2
|
+
* Extends layout with map $extension.
|
3
|
+
* @param {Map} $extension Map with additional layout settings.
|
4
|
+
* @param {String} $layout-key: 'default' Key of layout to be retrieved and returned after extension.
|
5
|
+
*/
|
6
|
+
@mixin layout-extend($with-layout) {
|
7
|
+
@if (type-of($with-layout) == map) {
|
8
|
+
$LAYOUT: layout-extend($with-layout) !global;
|
9
|
+
}
|
10
|
+
@else {
|
11
|
+
@error 'Expected $with-layout to be of type `map`, was `#{type-of($with-layout)}`.';
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* Sets up layouts from map, initiates default layout, sets globals.
|
3
|
+
* @param {Map} $layouts Map of layout definitions
|
4
|
+
*/
|
5
|
+
@mixin layout-init($user-layouts) {
|
6
|
+
@if(type-of($user-layouts) == map) {
|
7
|
+
$LAYOUT: layout-extend($user-layouts) !global;
|
8
|
+
$base__font-size: layout-get(base, base__font-size) !global;
|
9
|
+
$base__line-height: layout-get(base, base__line-height) !global;
|
10
|
+
$local__font-size: $base__font-size !global;
|
11
|
+
$local__line-height: $base__line-height !global;
|
12
|
+
$susy: layout-get(susy) !global;
|
13
|
+
}
|
14
|
+
@else {
|
15
|
+
@error 'Expected $layouts to be of type `map`, was `#{type-of($layouts)}`.';
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
/**
|
2
|
+
* Implements settings for layout defined by $layout-key locally for @content. Wraps @content in a media query if `breakpoint` settings are present in layout definition.
|
3
|
+
* @param {String} $layout-key: default Layout key of layout which’s settings to be used as context for @content. Can contain modifiers like `up` or `down` to only use min- or max-values of breakpoints.
|
4
|
+
*/
|
5
|
+
|
6
|
+
@mixin layout-use($layout-key: default) {
|
7
|
+
$valid-modes: (only, up, down);
|
8
|
+
$mode: only;
|
9
|
+
@if (type-of($layout-key) == list) {
|
10
|
+
@if (length($layout-key) > 1 AND nth($layout-key, 2) in $valid-modes) {
|
11
|
+
$mode: nth($layout-key, 2);
|
12
|
+
}
|
13
|
+
$layout-key: nth($layout-key, 1);
|
14
|
+
}
|
15
|
+
// temporarily store layout settings of parent context
|
16
|
+
$LAYOUT--parent: $LAYOUT;
|
17
|
+
$susy--parent: $susy;
|
18
|
+
// set new settings globally
|
19
|
+
$LAYOUT: layout-build($layout-key) !global;
|
20
|
+
$susy: layout-get(susy) !global;
|
21
|
+
// set typographic context
|
22
|
+
$base: map-get($LAYOUT, base);
|
23
|
+
$base__font-size--parent: $base__font-size;
|
24
|
+
$base__line-height--parent: $base__line-height;
|
25
|
+
$base__font-size: map-get($base, base__font-size) !global;
|
26
|
+
$base__line-height: map-get($base, base__line-height) !global;
|
27
|
+
// $local__font-size--parent: $local__font-size;
|
28
|
+
// $local__line-height--parent: $local__line-height;
|
29
|
+
// $local__font-size: map-get($base, local__font-size) !global;
|
30
|
+
// $local__line-height: map-get($base, local__line-height) !global;
|
31
|
+
|
32
|
+
// build media query
|
33
|
+
@if ($layout-key == default) {
|
34
|
+
@content;
|
35
|
+
}
|
36
|
+
@else {
|
37
|
+
$breakpoint: map-get($LAYOUT, breakpoint);
|
38
|
+
@if ($breakpoint) {
|
39
|
+
$query: ();
|
40
|
+
|
41
|
+
@if (type-of($breakpoint) != list) {
|
42
|
+
$breakpoint: ( $breakpoint, );
|
43
|
+
}
|
44
|
+
@each $bp in $breakpoint {
|
45
|
+
$sub-query: null;
|
46
|
+
@if (map-has-key($bp, medium)) {
|
47
|
+
$sub-query: (map-get($bp, medium) + unquote(''), );
|
48
|
+
$bp: map-remove($bq, medium);
|
49
|
+
}
|
50
|
+
@else {
|
51
|
+
$sub-query: ('all', );
|
52
|
+
}
|
53
|
+
@if ($mode == up) {
|
54
|
+
$bp: map-remove($bp, max-width);
|
55
|
+
$bp: map-remove($bp, max-device-width);
|
56
|
+
$bp: map-remove($bp, max-height);
|
57
|
+
$bp: map-remove($bp, max-device-height);
|
58
|
+
}
|
59
|
+
@if ($mode == down) {
|
60
|
+
$bp: map-remove($bp, min-width);
|
61
|
+
$bp: map-remove($bp, min-device-width);
|
62
|
+
$bp: map-remove($bp, min-height);
|
63
|
+
$bp: map-remove($bp, min-device-height);
|
64
|
+
}
|
65
|
+
@each $prop, $val in $bp {
|
66
|
+
@if (type-of($val) == 'number') {
|
67
|
+
@if(unit($val) == 'px') {
|
68
|
+
$val: px-to-em($val, const(ROOT_FONT_SIZE));
|
69
|
+
}
|
70
|
+
}
|
71
|
+
$sub-query: append($sub-query, '(' + $prop + ': ' + $val + ')');
|
72
|
+
}
|
73
|
+
$query: append($query, list-implode($sub-query, ' and '));
|
74
|
+
}
|
75
|
+
$query-string: list-implode($query, ', ');
|
76
|
+
|
77
|
+
@media #{$query-string} {
|
78
|
+
@include with-layout($susy) {
|
79
|
+
@content;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
@else {
|
85
|
+
@content;
|
86
|
+
}
|
87
|
+
// restore parent layout settings
|
88
|
+
$LAYOUT: $LAYOUT--parent !global;
|
89
|
+
$susy: $susy--parent !global;
|
90
|
+
$base__font-size: $base__font-size--parent !global;
|
91
|
+
$base__line-height: $base__line-height--parent !global;
|
92
|
+
// $local__font-size: $local__font-size--parent !global;
|
93
|
+
// $local__line-height: $local__line-height--parent !global;
|
94
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
/**
|
2
|
+
* Sets a base value and creates new absolute typographic context based on rem values.
|
3
|
+
* @param {px value} $font-size Font size value.
|
4
|
+
* @param {px value|Boolean} $line-height: 1.25*$font-size Line height value, defaults to 1.25 times font size value-
|
5
|
+
* @param {Booelan} $set-styles: true Pass false to just switch type context without settings styles.
|
6
|
+
*/
|
7
|
+
@mixin type-base($font-size, $line-height: 1.25 * $font-size, $set-styles: true) {
|
8
|
+
// store current type settings temporarily
|
9
|
+
$base__font-size--parent: $base__font-size;
|
10
|
+
$base__line-height--parent: $base__line-height;
|
11
|
+
$local__font-size--parent: if($local__font-size, $local__font-size, $base__font-size);
|
12
|
+
$local__line-height--parent: if($local__line-height, $local__line-height, $base__line-height);
|
13
|
+
// set new type values
|
14
|
+
$base__font-size: $font-size !global;
|
15
|
+
$base__line-height: $line-height !global;
|
16
|
+
$local__font-size: $base__font-size !global;
|
17
|
+
$local__line-height: $base__line-height !global;
|
18
|
+
//set styles
|
19
|
+
@if ($set-styles) {
|
20
|
+
font-size: $base__font-size;
|
21
|
+
font-size: calc-rem($base__font-size);
|
22
|
+
line-height: calc-em($base__line-height, $base__font-size);
|
23
|
+
}
|
24
|
+
// include content
|
25
|
+
@content;
|
26
|
+
// restore parent type context
|
27
|
+
$base__font-size: $base__font-size--parent !global;
|
28
|
+
$base__line-height: $base__line-height--parent !global;
|
29
|
+
$local__font-size: $local__font-size--parent !global;
|
30
|
+
$local__line-height: $local__line-height--parent !global;
|
31
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/**
|
2
|
+
* Changes the local type context without touching type base.
|
3
|
+
* @param {px value} $font-size Font size value.
|
4
|
+
* @param {px value|Boolean} $line-height: 1.25*$font-size Line height value, defaults to 1.25 times font size value.
|
5
|
+
* @param {Boolean} $set-styles: true Pass false to just switch type context without setting styles.
|
6
|
+
*/
|
7
|
+
@mixin type-context($font-size, $line-height: 1.25 * $font-size, $set-styles: true) {
|
8
|
+
// store context
|
9
|
+
$local__font-size--parent: $local__font-size;
|
10
|
+
$local__line-height--parent: $local__line-height;
|
11
|
+
// override context
|
12
|
+
$local__font-size: $font-size !global;
|
13
|
+
$local__line-height: $line-height !global;
|
14
|
+
// set styles
|
15
|
+
@if($set-styles) {
|
16
|
+
font-size: calc-em($font-size, $local__font-size--parent);
|
17
|
+
line-height: calc-em($line-height, $local__font-size);
|
18
|
+
}
|
19
|
+
// include content
|
20
|
+
@content;
|
21
|
+
// restore previous context
|
22
|
+
$local__font-size: $local__font-size--parent !global;
|
23
|
+
$local__line-height: $local__line-height--parent !global;
|
24
|
+
}
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: layout-tools-for-susy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oliver Wehn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sass
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: susy
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.2.7
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.2.7
|
41
|
+
description: Organize and handle layouts over multiple breakpoints
|
42
|
+
email:
|
43
|
+
- hello@oliverwehn.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- CHANGELOG.md
|
49
|
+
- README.md
|
50
|
+
- lib/layout-tools-for-susy.rb
|
51
|
+
- stylesheets/_layout-tools-for-susy.scss
|
52
|
+
- stylesheets/config/_constants.scss
|
53
|
+
- stylesheets/config/_globals.scss
|
54
|
+
- stylesheets/config/_layouts.scss
|
55
|
+
- stylesheets/functions/_color-get.scss
|
56
|
+
- stylesheets/functions/_color-set.scss
|
57
|
+
- stylesheets/functions/_const.scss
|
58
|
+
- stylesheets/functions/_layout-build.scss
|
59
|
+
- stylesheets/functions/_layout-extend.scss
|
60
|
+
- stylesheets/functions/_layout-get.scss
|
61
|
+
- stylesheets/functions/_list-implode.scss
|
62
|
+
- stylesheets/functions/_list-px-to-em.scss
|
63
|
+
- stylesheets/functions/_map-merge-r.scss
|
64
|
+
- stylesheets/functions/_map-set.scss
|
65
|
+
- stylesheets/functions/_px-to-em.scss
|
66
|
+
- stylesheets/functions/_px-to-pc.scss
|
67
|
+
- stylesheets/functions/_px-to-rem.scss
|
68
|
+
- stylesheets/mixins/_color-set.scss
|
69
|
+
- stylesheets/mixins/_const.scss
|
70
|
+
- stylesheets/mixins/_layout-extend.scss
|
71
|
+
- stylesheets/mixins/_layout-init.scss
|
72
|
+
- stylesheets/mixins/_layout-use.scss
|
73
|
+
- stylesheets/mixins/_type-base.scss
|
74
|
+
- stylesheets/mixins/_type-context.scss
|
75
|
+
- stylesheets/placeholders/_clearfix.scss
|
76
|
+
homepage: https://github.com/oliverwehn/layout-tools-for-susy
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
- GPL-2.0
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 1.3.6
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project: layout-tools-for-susy
|
97
|
+
rubygems_version: 2.4.8
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Handy mixins and functions to handle layout settings for multiple breakpoints.
|
101
|
+
test_files: []
|