add media cache http://kizu.ru/en/issues/new-stylus-features/#result
Этот коммит содержится в:
родитель
350718cfa1
Коммит
700b504895
@ -301,4 +301,37 @@ _h24 = 'h2,h3,h4'
|
||||
_h36 = 'h3,h4,h5,h6'
|
||||
_h35 = 'h3,h4,h5'
|
||||
|
||||
imp = !important
|
||||
imp = !important
|
||||
|
||||
//From kizu.ru
|
||||
// Define the cache and the aliases
|
||||
$media_cache = {}
|
||||
$media_aliases = {
|
||||
palm: '(max-width: 480px)'
|
||||
lap: '(min-width: 481px) and (max-width: 1023px)'
|
||||
lap-and-up: '(min-width: 481px)'
|
||||
portable: '(max-width: 1023px)'
|
||||
desk: '(min-width: 1024px)'
|
||||
desk-wide: '(min-width: 1200px)'
|
||||
}
|
||||
|
||||
// Mixin for caching the blocks with the given conditions
|
||||
media($condition)
|
||||
helper($condition)
|
||||
unless $media_cache[$condition]
|
||||
$media_cache[$condition] = ()
|
||||
push($media_cache[$condition], block)
|
||||
|
||||
+helper($condition)
|
||||
{selector() + ''}
|
||||
{block}
|
||||
|
||||
// Function we would use to call all the cached styles
|
||||
apply_media_cache()
|
||||
for $media, $blocks in $media_cache
|
||||
$media = unquote($media_aliases[$media] || $media)
|
||||
$media = '(%s)' % $media unless match('\(', $media)
|
||||
$media = 'only screen and %s' % $media
|
||||
@media $media
|
||||
for $block in $blocks
|
||||
{$block}
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user