Spaces:
Running
Running
File size: 5,255 Bytes
1b9d27c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | # Flask
[](https://travis-ci.org/jaradlight/flask)
Helper files for fonts and colours in Sass projects.
## Installation
Install from your preferred package manager:
- **NPM**: `npm install flask`
- **Bower**: `bower install flask`
Import to your stylesheets:
``` scss
// Installed with NPM
@import '../node_modules/flask/sass/flask';
// Installed with Bower
@import '../bower_components/flask/sass/flask';
```
### Importing specific features
If you would like to use one or more features without importing everything, simply import the Flask core followed by the features you need.
``` scss
// Import Flask Core.
@import '../node_modules/flask/sass/flask/core/core';
// Import Flask Palette feature.
@import '../node_modules/flask/sass/flask/palette/palette';
```
## Palette
### Usage
``` scss
.teal-base {
color: palette(teal);
// color: #2ed399;
}
.teal-light {
color: palette(teal, light);
// color: #43d7a3;
}
.teal-alias {
color: palette(brand-primary);
// color: #2ed399;
}
.teal-alias-with-variant {
color: palette(brand-primary, light);
// color: #43d7a3;
}
.teal-aliased-variant {
color: palette(highlight);
// color: #43d7a3;
}
```
### Setup
[Example](https://github.com/jaradlight/flask/blob/master/test/setup/_palette.scss)
Begin by defining base colours. You can simply define these inside the palette map instead, but separate base variables make it easier to programmatically define variants.
``` scss
$flask-color-teal-base: #2ed399;
```
#### $palettes
Next create the palette map. This variable will contain all colours and their variants. A colour group is defined by a nested map within the main palette map. The colour group key and any variant keys can be anything you like. However, every colour group needs one colour with the `base` key. Variants are optional.
``` scss
$palettes: (
teal: ( // Colour group key
base: $flask-color-teal-base, // Base colour
dark: darken($flask-color-teal-base, 10), // Dark Variant
light: lighten($flask-color-teal-base, 10) // Light Variant
)
);
```
#### $palette-aliases
Optionally, a `$palette-aliases` map can assign aliases to colour groups. Aliases can be used in place of colour group keys as the first argument to `palette()`. Additionally, aliases for specific colours may be defined by assigning a map of palette function arguments to the alias key.
``` scss
$palette-aliases: (
brand-primary: teal,
highlight: (teal, light)
);
```
## Fonts
### Usage
``` scss
.font-family-function {
font-family: font-family(open-sans);
// font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.font-family-mixin {
@include font-family(open-sans);
// font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.font-name {
font-family: font-name(open-sans);
// font-family: "Open Sans";
}
.font-name-aliased {
font-family: font-name(primary-sans-serif);
// font-family: "Open Sans";
}
.font-name-aliased-with-variant {
font-family: font-name(primary-sans-serif, special);
// font-family: "Open Sans Special";
}
.font-name-aliased-variant {
content: font-name(heading);
// content: "Open Sans Special";
}
.font-type {
content: font-type(open-sans);
// content: sans-serif
}
.font-fallback {
content: font-fallback(open-sans);
// content: "Helvetica Neue", Helvetica, Arial, sans-serif
}
```
### Setup
[Example](https://github.com/jaradlight/flask/blob/master/test/setup/_font.scss)
#### $fonts
The fonts map contains all font names, variants, and fallbacks (if applicable).
Each font should have its own group. For example, if you are using 'Merriweather', you may define a font group under the key `merriweather`.
For each font group, required keys are:
* `font-type` The font family's type. ie: serif, sans-serif, glyph, etc
* `regular` The name of the basic version of the font.
Optional keys:
* `fallback` A map of fallback fonts for this font family. If set, will override the fallback used from `$font-fallbacks` which is based on `font-type`.
``` scss
$fonts: (
merriweather: (
font-type: serif,
regular: 'Merriweather',
fallback: (
'Georgia',
serif
)
)
);
```
#### $font-fallbacks
`$font-fallbacks` map variable:
``` scss
$font-fallbacks: (
serif: (
'Georgia',
serif
),
sans-serif: (
'Helvetica Neue',
Helvetica,
Arial,
sans-serif
)
);
```
#### $font-aliases
Optionally, a `$font-aliases` map can assign aliases to fonts. Aliases can be used in place of font group keys in `font` functions. Additionally, aliases for specific font variants may be defined by assigning a map of font-name function arguments to the alias key.
``` scss
$font-aliases: (
primary-serif: merriweather,
primary-sans-serif: open-sans,
heading: (open-sans, special)
);
```
#### Additional Functions
``` scss
.font-name {
content: font-name(open-sans);
// content: "Open Sans"
}
.font-type {
content: font-type(merriweather);
// content: serif
}
.font-fallback {
content: font-fallback(merriweather);
// content: "Georgia", serif
}
```
|