jekyll-stretcher 0.1.1
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/lib/jekyll-stretcher.rb +116 -0
- data/lib/jekyll-stretcher/version.rb +3 -0
- metadata +65 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f0cb33a2fad76660287b7ba0a5c56933ca74a7b4e6b2c370c4d895a881ec8a59
|
4
|
+
data.tar.gz: e3375c42cf7d56156ec9ad0b153a76e48cfdd0a2160c9719a4ea19f524f2b5a8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 12196a9b6358a9124bc65672e0c21cb5fe76498a600b4ac57693cd072417d49c2b0a3728a95ca2a556b158b68deaa0cf01254a06ec4b177f929a605647848b84
|
7
|
+
data.tar.gz: 663d3d8bc95592f0bb52dd21fccfb6e35f05f9eb221e1776fe5cdbd114144919ddaa2747779ba4de5371adb8641214697bb5f2a0eac43aa47ddec75c12b21300
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Converters
|
3
|
+
module StretcherExtensions
|
4
|
+
class StretcherImporter < SassC::Importer
|
5
|
+
def sretcher_mixin()
|
6
|
+
<<-GOOSE
|
7
|
+
// START INJECTED STRETCHER
|
8
|
+
$stretcher-min: 375px !default;
|
9
|
+
$stretcher-max: 1440px !default;
|
10
|
+
|
11
|
+
@mixin jekyll-stretcher-double-scale($properties, $min-value, $max-value) {
|
12
|
+
@each $property in $properties {
|
13
|
+
\#{$property}: $min-value;
|
14
|
+
}
|
15
|
+
|
16
|
+
@media (min-width: $stretcher-min) {
|
17
|
+
@each $property in $properties {
|
18
|
+
\#{$property}: calc(\#{$min-value} + \#{strip-unit($max-value - $min-value)} * (100vw - \#{$stretcher-min}) / \#{strip-unit($stretcher-max - $stretcher-min)});
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
@media (min-width: $stretcher-max) {
|
23
|
+
@each $property in $properties {
|
24
|
+
\#{$property}: $max-value;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
@function strip-unit($number) {
|
30
|
+
@if type-of($number) == \"number\" and not unitless($number) {
|
31
|
+
@return $number / ($number * 0 + 1);
|
32
|
+
}
|
33
|
+
|
34
|
+
@return $number;
|
35
|
+
}
|
36
|
+
// END INJECTED STRETCHER
|
37
|
+
GOOSE
|
38
|
+
end
|
39
|
+
|
40
|
+
def stretcher_rewrite(file)
|
41
|
+
matched = false
|
42
|
+
lines = file.lines.map(&:chomp)
|
43
|
+
|
44
|
+
lines.each_with_index do |l, i|
|
45
|
+
next unless l =~ /->/
|
46
|
+
values = l.match(/^(\s*)([a-z-]+):\s*(\d+|\.\d+|\d+\.\d+)(cm|mm|in|px|pt|pc|em|ex|ch|rem|%|vw|vh|vmin|vmax)\s*->\s*(\d+|\.\d+|\d+\.\d+)(cm|mm|in|px|pt|pc|em|ex|ch|rem|%|vw|vh|vmin|vmax)\s*;/)
|
47
|
+
next unless values
|
48
|
+
indentation, declaration, minVal, minUnit, maxVal, maxUnit = values.captures
|
49
|
+
|
50
|
+
warning = ""
|
51
|
+
if minUnit != maxUnit
|
52
|
+
warning += "#{indentation}@error \"Stretcher mixin units don't match; '#{minVal}#{minUnit} -> #{maxVal}#{maxUnit}': #{minUnit} !== #{maxUnit}\";\n"
|
53
|
+
end
|
54
|
+
if minUnit =~ /%|vw|vh|vmin|vmax/
|
55
|
+
warning += "#{indentation}@warn \"Relative units may not work with the scaling mixin (#{minUnit})\";\n";
|
56
|
+
end
|
57
|
+
|
58
|
+
lines[i] = "#{warning}#{indentation}@include jekyll-stretcher-double-scale(#{declaration}, #{minVal}#{minUnit}, #{maxVal}#{maxUnit});";
|
59
|
+
matched = true
|
60
|
+
end
|
61
|
+
lines.unshift(sretcher_mixin) if matched
|
62
|
+
lines.join("\n")
|
63
|
+
end
|
64
|
+
|
65
|
+
def imports(path, parent_path)
|
66
|
+
root = Pathname.new parent_path
|
67
|
+
file = Pathname.new path
|
68
|
+
|
69
|
+
if file.extname.empty?
|
70
|
+
file = Pathname.new path + ".scss"
|
71
|
+
end
|
72
|
+
|
73
|
+
if root.absolute?
|
74
|
+
relative = root.dirname.join(file)
|
75
|
+
else
|
76
|
+
options[:load_paths].each do |p|
|
77
|
+
p = Pathname.new p
|
78
|
+
relative = p.join(file)
|
79
|
+
break if relative.exist?
|
80
|
+
relative = nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
if relative.empty?
|
85
|
+
Import.new(path)
|
86
|
+
return
|
87
|
+
end
|
88
|
+
|
89
|
+
stretched_source = stretcher_rewrite relative.read
|
90
|
+
|
91
|
+
Import.new(path, source: stretched_source)
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
def sass_configs
|
98
|
+
sass_build_configuration_options(
|
99
|
+
:style => sass_style,
|
100
|
+
:syntax => syntax,
|
101
|
+
:filename => filename,
|
102
|
+
:output_path => output_path,
|
103
|
+
:source_map_file => source_map_file,
|
104
|
+
:load_paths => sass_load_paths,
|
105
|
+
:importer => StretcherImporter,
|
106
|
+
:omit_source_map_url => !sourcemap_required?,
|
107
|
+
:source_map_contents => true,
|
108
|
+
:line_comments_option => line_comments_option
|
109
|
+
)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
class Scss < Converter
|
113
|
+
prepend StretcherExtensions
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-stretcher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Liam Bigelow
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.7'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.7'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
description:
|
34
|
+
email:
|
35
|
+
- liam@cloudcannon.com
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- lib/jekyll-stretcher.rb
|
41
|
+
- lib/jekyll-stretcher/version.rb
|
42
|
+
homepage: https://github.com/cloudcannon/stretcher
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubygems_version: 3.0.3
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
64
|
+
summary: A Jekyll plugin to handle stretcher SCSS syntax
|
65
|
+
test_files: []
|