Skip to content

Commit bbf018c

Browse files
committed
ability to render a simplified typography styleguide for the dummy test app
1 parent 7666dd3 commit bbf018c

File tree

6 files changed

+71
-37
lines changed

6 files changed

+71
-37
lines changed

app/assets/stylesheets/smurfville/typography.css.sass.erb

Whitespace-only changes.

app/controllers/smurfville/styleguide_controller.rb

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def helper
1616
def typography
1717
# @parser = Smurfville::TypographyParser.new
1818
# @parser.parse
19+
@typographies = ["%f-gigantic-headline", "%f-big-headline", "%f-default-headline", "%f-small-headline", "%f-big-fliesstext", "%f-default-fliesstext", "%f-small-fliesstext"]
1920
end
2021
end
2122
end

app/helpers/smurfville/styleguide_helper.rb

+8
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,13 @@ def foreground_color(background_color)
1111
"black"
1212
end
1313
end
14+
15+
def typography_class(typography)
16+
typography.gsub("%f-", "")
17+
end
18+
19+
def typography_humanized(typography)
20+
typography.gsub("%f-", "").gsub("-", " ")
21+
end
1422
end
1523
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<% typographies.each do |typography| %>
2+
<%= ".#{typography_class(typography)}" %>
3+
<%= "@extend #{typography}" %>
4+
<% end %>
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
:sass
2-
@import "typography"
3-
.typo1
4-
+default-text()
1+
// ---- CSS ----
2+
:css
3+
#{Sass::Engine.new(File.read("#{Rails.root}/app/assets/stylesheets/_typography.sass") + render("typography_classes", typographies: @typographies)).render}
54

6-
.typo1= "typo1"
5+
// ---- HTML ----
6+
7+
.typography-list
8+
- @typographies.each do |typography|
9+
.typographylist--item{class: typography_class(typography)}= "#{typography_humanized(typography)}: The quick brown fox ..."
10+
%hr
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,54 @@
1-
$default-font-family: "Helvetica", "Arial", sans-serif
2-
3-
// these could become important if we should decide to use compass vertical rhythm
4-
$relative-font-sizing : false
5-
$base-line-height : 20px
6-
7-
$small-font-size : 11px
8-
$base-font-size : 13px
9-
$big-font-size : 15px
10-
11-
$input-field-font-size: $big-font-size
12-
13-
$header-font-small : 17px
14-
$header-font-default : 18px
15-
$header-font-big : 25px
16-
$header-font-gigantic : 36px
17-
18-
// styleguide_typography:
19-
// mixin: "headline-text"
20-
// params:
21-
// "$font-size": ["$header-font-small", "$header-font-default", "$header-font-big", "$header-font-gigantic"]
22-
// "$font-color": ["$text-color", "$light-text-color"]
23-
=headline-text($font-size: $header-font-default, $font-color: $text-color)
24-
font-family: $default-font-family
1+
// --- this doesn't really belong here ---
2+
3+
$text-color: black
4+
5+
// ---------------------------------------
6+
7+
8+
// variables
9+
$headline-font-family: "Helvetica", "Arial", sans-serif
10+
$fliesstext-font-family: "Georgia", serif
11+
12+
$small-fliesstext-font-size: 11px
13+
$default-fliesstext-font-size: 13px
14+
$big-fliesstext-font-size: 15px
15+
16+
$small-headline-font-size: 17px
17+
$default-headline-font-size: 18px
18+
$big-headline-font-size: 25px
19+
$gigantic-headline-font-size: 36px
20+
21+
22+
// mixins
23+
=headline-text($font-size: $default-headline-font-size, $line-height-factor: 1.2, $font-color: $text-color)
24+
font-family: $headline-font-family
2525
font-weight: bold
2626
color: $font-color
2727
font-size: $font-size
28+
line-height: $font-size * $line-height-factor
2829

29-
// styleguide_typography:
30-
// mixin: default-text
31-
// params:
32-
// "$font-size": ["$small-font-size", "$base-font-size", "$big-font-size"]
33-
// "$font-color": ["$text-color", "$light-text-color"]
34-
=default-text($font-size: $base-font-size, $font-color: $text-color)
35-
font-family: $default-font-family
30+
=fliesstext($font-size: $default-fliesstext-font-size, $line-height-factor: 1.4, $font-color: $text-color)
31+
font-family: $fliesstext-font-family
3632
color: $font-color
37-
font-size: $font-size
33+
font-size: $font-size
34+
line-height: $font-size * $line-height-factor
35+
36+
37+
38+
// placeholder selectors
39+
%f-gigantic-headline
40+
+headline-text($gigantic-headline-font-size)
41+
%f-big-headline
42+
+headline-text($big-headline-font-size)
43+
%f-default-headline
44+
+headline-text($default-headline-font-size)
45+
%f-small-headline
46+
+headline-text($small-headline-font-size)
47+
48+
%f-big-fliesstext
49+
+fliesstext($big-fliesstext-font-size)
50+
%f-default-fliesstext
51+
+fliesstext($default-fliesstext-font-size)
52+
%f-small-fliesstext
53+
+fliesstext($small-fliesstext-font-size)
54+

0 commit comments

Comments
 (0)