quilt_ui 0.0.4 → 0.0.5
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 +4 -4
- data/assets/stylesheets/quilt/components/badge.scss +20 -21
- data/assets/stylesheets/quilt/foundation.scss +5 -2
- data/assets/stylesheets/quilt/foundation/border-radius.scss +11 -0
- data/assets/stylesheets/quilt/foundation/borders.scss +20 -0
- data/assets/stylesheets/quilt/foundation/colors.scss +86 -92
- data/assets/stylesheets/quilt/foundation/shadows.scss +11 -0
- data/assets/stylesheets/quilt/foundation/spacing.scss +2 -2
- data/assets/stylesheets/quilt/foundation/typography.scss +35 -168
- data/helpers/components/component.rb +55 -46
- data/lib/quilt/version.rb +1 -1
- metadata +5 -3
- data/assets/stylesheets/quilt/foundation/defaults.scss +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30ae1623281e5eb33ad4c165b52d1badc0654c23
|
4
|
+
data.tar.gz: beb2c1a1f9ec6d11e32d4352b40e068313011ce4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ef19e4b0c7738c1ae9be759e045642ddae26dae43da59e9995e7621d5d312417f59c32799e6474fe77c8ee1ffd90ce69c6addac8211899839e550eea4a1c772
|
7
|
+
data.tar.gz: 0536a8d90b5dab2a6523a1516fd2720322abe2269d3f742c6ba5d83c412616fc7c188b3486871855fe328675884841f697b2459c5c3f5df97505115271261e0e
|
@@ -1,8 +1,9 @@
|
|
1
1
|
.badge {
|
2
|
-
@include meta
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
@include text-style-meta;
|
3
|
+
@include text-emphasis-subdued;
|
4
|
+
border-radius: border-radius();
|
5
|
+
background-color: color(sky, dark);
|
6
|
+
padding: spacing(extra-tight) spacing(tight);
|
6
7
|
vertical-align: middle;
|
7
8
|
white-space: nowrap;
|
8
9
|
display: inline-block;
|
@@ -12,36 +13,34 @@
|
|
12
13
|
}
|
13
14
|
}
|
14
15
|
|
15
|
-
.badge--success {
|
16
|
-
background-color: color(
|
16
|
+
.badge--status-success {
|
17
|
+
background-color: color(green, light);
|
17
18
|
}
|
18
19
|
|
19
|
-
.badge--info {
|
20
|
-
background-color: color(
|
20
|
+
.badge--status-info {
|
21
|
+
background-color: color(blue, lighter);
|
21
22
|
}
|
22
23
|
|
23
|
-
.badge--subdued {
|
24
|
-
background-color: color(
|
24
|
+
.badge--status-subdued {
|
25
|
+
background-color: color(sky);
|
25
26
|
}
|
26
27
|
|
27
|
-
.badge--attention {
|
28
|
-
background-color: color(
|
28
|
+
.badge--status-attention {
|
29
|
+
background-color: color(yellow, light);
|
29
30
|
}
|
30
31
|
|
31
|
-
.badge--warning {
|
32
|
-
background-color: color(
|
32
|
+
.badge--status-warning {
|
33
|
+
background-color: color(orange, light);
|
33
34
|
}
|
34
35
|
|
35
|
-
.badge--critical {
|
36
|
-
background-color: color(
|
36
|
+
.badge--status-critical {
|
37
|
+
background-color: color(red, light);
|
37
38
|
}
|
38
39
|
|
39
|
-
.badge--complete {
|
40
|
-
background-color: color(
|
40
|
+
.badge--status-complete {
|
41
|
+
background-color: color(sky);
|
41
42
|
}
|
42
43
|
|
43
44
|
.badge--inline {
|
44
|
-
|
45
|
-
line-height: type-line-height(label);
|
46
|
-
margin-left: spacing(tiny);
|
45
|
+
margin-left: spacing(extra-tight);
|
47
46
|
}
|
@@ -1,5 +1,8 @@
|
|
1
1
|
@import 'foundation/utilities';
|
2
|
-
@import 'foundation/spacing';
|
3
2
|
@import 'foundation/colors';
|
3
|
+
|
4
|
+
@import 'foundation/borders';
|
5
|
+
@import 'foundation/border-radius';
|
6
|
+
@import 'foundation/shadows';
|
7
|
+
@import 'foundation/spacing';
|
4
8
|
@import 'foundation/typography';
|
5
|
-
@import 'foundation/defaults';
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$borders-data: (
|
2
|
+
base: 1px solid color(sky),
|
3
|
+
dark: 1px solid color(sky, dark)
|
4
|
+
);
|
5
|
+
|
6
|
+
//*
|
7
|
+
// Returns the specified border.
|
8
|
+
//
|
9
|
+
// @param {String} $variant - The key for a given variant.
|
10
|
+
// @return {List} The border value.
|
11
|
+
|
12
|
+
@function border($variant: base) {
|
13
|
+
$fetched-value: map-get($borders-data, $variant);
|
14
|
+
|
15
|
+
@if $fetched-value {
|
16
|
+
@return $fetched-value;
|
17
|
+
} @else {
|
18
|
+
@error "Border variant `#{$variant}` not found. Available variants: #{available-names($borders-data)}";
|
19
|
+
}
|
20
|
+
}
|
@@ -1,122 +1,116 @@
|
|
1
|
-
// scss-lint:disable ColorVariable, ColorKeyword
|
2
1
|
$color-palette-data: (
|
3
|
-
white:
|
4
|
-
|
5
|
-
|
6
|
-
slate-lightest: #95a7b7,
|
7
|
-
slate-lighter: #798c9c,
|
8
|
-
slate-light: #454e57,
|
9
|
-
slate: #31373d,
|
10
|
-
slate-dark: #272c30,
|
11
|
-
slate-darker: #212529,
|
12
|
-
|
13
|
-
sky-lighter: #fafbfc,
|
14
|
-
sky-light: #f5f6f7,
|
15
|
-
sky: #ebeef0,
|
16
|
-
sky-dark: #d3dbe2,
|
17
|
-
sky-darker: #c3cfd8,
|
18
|
-
|
19
|
-
blue-lightest: #eff9fd,
|
20
|
-
blue-lighter: #cae9f7,
|
21
|
-
blue-light: #4fb0e8,
|
22
|
-
blue: #479ccf,
|
23
|
-
blue-dark: #4293c2,
|
24
|
-
blue-darker: #3e89b5,
|
2
|
+
white: (
|
3
|
+
base: #fff
|
4
|
+
),
|
25
5
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
green: #96bf48,
|
30
|
-
green-dark: #7ba232,
|
31
|
-
green-darker: #4d6110,
|
6
|
+
black: (
|
7
|
+
base: #000
|
8
|
+
),
|
32
9
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
10
|
+
slate: (
|
11
|
+
lightest: #95a7b7,
|
12
|
+
lighter: #798c9c,
|
13
|
+
light: #454e57,
|
14
|
+
base: #31373d,
|
15
|
+
dark: #272c30,
|
16
|
+
darker: #212529
|
17
|
+
),
|
39
18
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
19
|
+
sky: (
|
20
|
+
lighter: #fafbfc,
|
21
|
+
light: #f5f6f7,
|
22
|
+
base: #ebeef0,
|
23
|
+
dark: #d3dbe2,
|
24
|
+
darker: #c3cfd8
|
25
|
+
),
|
46
26
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
27
|
+
blue: (
|
28
|
+
lightest: #eff9fd,
|
29
|
+
lighter: #cae9f7,
|
30
|
+
light: #4fb0e8,
|
31
|
+
base: #479ccf,
|
32
|
+
dark: #4293c2,
|
33
|
+
darker: #3e89b5
|
34
|
+
),
|
53
35
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
36
|
+
green: (
|
37
|
+
lightest: #f8ffec,
|
38
|
+
lighter: #e5fabc,
|
39
|
+
light: #b2d86a,
|
40
|
+
base: #96bf48,
|
41
|
+
dark: #7ba232,
|
42
|
+
darker: #4d6110
|
43
|
+
),
|
60
44
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
45
|
+
yellow: (
|
46
|
+
lightest: #fffbe9,
|
47
|
+
lighter: #fff7b2,
|
48
|
+
light: #ffe477,
|
49
|
+
base: #ffd117,
|
50
|
+
dark: #d4a002,
|
51
|
+
darker: #6f4f0c
|
52
|
+
),
|
67
53
|
|
68
|
-
|
54
|
+
orange: (
|
55
|
+
lightest: #fff9ec,
|
56
|
+
lighter: #ffebcc,
|
57
|
+
light: #fec97d,
|
58
|
+
base: #ff9517,
|
59
|
+
dark: #e06b0c,
|
60
|
+
darker: #7f3a07
|
61
|
+
),
|
69
62
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
63
|
+
red: (
|
64
|
+
lightest: #fef6f5,
|
65
|
+
lighter: #ffd9d6,
|
66
|
+
light: #ff9797,
|
67
|
+
base: #ff5d5d,
|
68
|
+
dark: #d83e3e,
|
69
|
+
darker: #852929
|
70
|
+
),
|
74
71
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
success: green-dark
|
72
|
+
purple: (
|
73
|
+
lightest: #faf1fe,
|
74
|
+
lighter: #eccdff,
|
75
|
+
light: #d098ff,
|
76
|
+
base: #b762ff,
|
77
|
+
dark: #763eaf,
|
78
|
+
darker: #4a1f72
|
83
79
|
),
|
84
80
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
error: red-light,
|
93
|
-
critical: red-light
|
81
|
+
teal: (
|
82
|
+
lightest: #eafdf7,
|
83
|
+
lighter: #c3f9e4,
|
84
|
+
light: #78ecbc,
|
85
|
+
base: #29bc94,
|
86
|
+
dark: #15966d,
|
87
|
+
darker: #186148
|
94
88
|
),
|
95
89
|
|
96
|
-
|
97
|
-
|
90
|
+
shade: (
|
91
|
+
base: rgba(#000, 0.1)
|
98
92
|
),
|
99
93
|
|
100
|
-
|
101
|
-
|
94
|
+
ink: (
|
95
|
+
lighter: rgba(#000, 0.38),
|
96
|
+
light: rgba(#000, 0.56),
|
97
|
+
base: rgba(#000, 0.9)
|
102
98
|
)
|
103
99
|
);
|
104
|
-
// scss-lint:enable ColorVariable, ColorKeyword
|
105
100
|
|
106
101
|
//*
|
107
102
|
// Returns the color value for a given color name and group.
|
108
103
|
//
|
109
|
-
// @param {String} $
|
110
|
-
// @param {String} $
|
104
|
+
// @param {String} $hue - The color's hue.
|
105
|
+
// @param {String} $value - The darkness/ lightness of the color. Defaults to base.
|
111
106
|
// @return {Color} The color value.
|
112
107
|
|
113
|
-
@function color($
|
114
|
-
$color
|
115
|
-
$fetched-color: map-get($color-palette-data, $color-palette-key);
|
108
|
+
@function color($hue, $value: base) {
|
109
|
+
$fetched-color: map-get(map-get($color-palette-data, $hue), $value);
|
116
110
|
|
117
111
|
@if type-of($fetched-color) == color {
|
118
112
|
@return $fetched-color;
|
119
113
|
} @else {
|
120
|
-
@error "Color `#{$
|
114
|
+
@error "Color `#{$hue} - #{$value}` not found. Available colors: #{available-names($color-palette-data)}";
|
121
115
|
}
|
122
116
|
}
|
@@ -1,181 +1,48 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
x-large: rem(32px)
|
7
|
-
);
|
8
|
-
|
9
|
-
$type-size-keys-data: (
|
10
|
-
meta: small,
|
11
|
-
body: medium,
|
12
|
-
section-title: medium,
|
13
|
-
page-title: large,
|
14
|
-
display-title: x-large,
|
15
|
-
label: x-small
|
16
|
-
);
|
17
|
-
|
18
|
-
//*
|
19
|
-
// Returns the font size value for a given typography style.
|
20
|
-
//
|
21
|
-
// @param {String} $style - The key for the style.
|
22
|
-
// @return {Number} The font size value.
|
23
|
-
|
24
|
-
@function type-size($style) {
|
25
|
-
$size-key: map-get($type-size-keys-data, $style);
|
26
|
-
$fetched-value: map-get($type-sizes-data, $size-key);
|
27
|
-
|
28
|
-
@if type-of($fetched-value) == number {
|
29
|
-
@return $fetched-value;
|
30
|
-
} @else {
|
31
|
-
@error "Type style `#{$style}` not found. Available styles: #{available-names($type-size-keys-data)}";
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
$type-line-heights-data: (
|
38
|
-
x-small: rem(14px),
|
39
|
-
small: rem(20px),
|
40
|
-
medium: rem(24px),
|
41
|
-
large: rem(48px)
|
42
|
-
);
|
43
|
-
|
44
|
-
$type-line-height-keys-data: (
|
45
|
-
meta: small,
|
46
|
-
body: medium,
|
47
|
-
section-title: small,
|
48
|
-
page-title: small,
|
49
|
-
display-title: large,
|
50
|
-
label: x-small
|
51
|
-
);
|
52
|
-
|
53
|
-
//*
|
54
|
-
// Returns the line height value for a given typography style.
|
55
|
-
//
|
56
|
-
// @param {String} $style - The key for the style.
|
57
|
-
// @return {Number} The line-height value.
|
58
|
-
|
59
|
-
@function type-line-height($style) {
|
60
|
-
$line-height-key: map-get($type-line-height-keys-data, $style);
|
61
|
-
$fetched-value: map-get($type-line-heights-data, $line-height-key);
|
62
|
-
|
63
|
-
@if type-of($fetched-value) == number {
|
64
|
-
@return $fetched-value;
|
65
|
-
} @else {
|
66
|
-
@error "Type style `#{$style}` not found. Available styles: #{available-names($type-line-height-keys-data)}";
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
$type-weights-data: (
|
73
|
-
bold: 600,
|
74
|
-
medium: 500,
|
75
|
-
regular: 400,
|
76
|
-
light: 300
|
77
|
-
);
|
78
|
-
|
79
|
-
$type-weight-keys-data: (
|
80
|
-
meta: regular,
|
81
|
-
emphasized: bold,
|
82
|
-
body: regular,
|
83
|
-
section-title: medium,
|
84
|
-
page-title: regular,
|
85
|
-
display-title: light
|
86
|
-
);
|
87
|
-
|
88
|
-
//*
|
89
|
-
// Returns the font weight value for a given typography style.
|
90
|
-
//
|
91
|
-
// @param {String} $style - The key for the variant.
|
92
|
-
// @return {Number} The font-weight value.
|
93
|
-
|
94
|
-
@function type-weight($style) {
|
95
|
-
$weight-key: map-get($type-weight-keys-data, $style);
|
96
|
-
$fetched-value: map-get($type-weights-data, $weight-key);
|
97
|
-
|
98
|
-
@if type-of($fetched-value) == number {
|
99
|
-
@return $fetched-value;
|
100
|
-
} @else {
|
101
|
-
@error "Type style `#{$style}` not found. Available styles: #{available-names($type-weight-keys-data)}";
|
102
|
-
}
|
103
|
-
}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
$type-family-data: (
|
108
|
-
sans-serif: ("Helvetica Neue", Helvetica, Arial, sans-serif),
|
109
|
-
monospace: (Monaco, Consolas, "Lucida Console", monospace)
|
110
|
-
);
|
111
|
-
|
112
|
-
$type-family-keys-data: (
|
113
|
-
base: sans-serif,
|
114
|
-
code: monospace
|
115
|
-
);
|
116
|
-
|
117
|
-
//*
|
118
|
-
// Returns the font family for a given typography style.
|
119
|
-
//
|
120
|
-
// @param {String} $style - The key for the variant.
|
121
|
-
// @return {List} The font family list.
|
122
|
-
|
123
|
-
@function type-family($style) {
|
124
|
-
$family-key: map-get($type-family-keys-data, $style);
|
125
|
-
$fetched-value: map-get($type-family-data, $family-key);
|
126
|
-
|
127
|
-
@if $fetched-value != null {
|
128
|
-
@return $fetched-value;
|
129
|
-
} @else {
|
130
|
-
@error "Type family `#{$style}` not found. Available families: #{available-names($type-family-keys-data)}";
|
131
|
-
}
|
132
|
-
}
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
@mixin emphasized-text {
|
137
|
-
font-weight: type-weight(emphasized);
|
138
|
-
}
|
139
|
-
|
140
|
-
@mixin meta-text {
|
141
|
-
font-size: type-size(meta);
|
142
|
-
line-height: type-line-height(meta);
|
143
|
-
font-weight: type-weight(meta);
|
144
|
-
color: color(text, secondary);
|
1
|
+
@mixin text-style-title {
|
2
|
+
color: color(ink);
|
3
|
+
font-size: rem(20px);
|
4
|
+
line-height: rem(24px);
|
5
|
+
font-weight: 400;
|
145
6
|
}
|
146
7
|
|
147
|
-
@mixin
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
8
|
+
@mixin text-style-heading {
|
9
|
+
color: color(ink);
|
10
|
+
font-size: rem(18px);
|
11
|
+
line-height: rem(24px);
|
12
|
+
font-weight: 600;
|
152
13
|
}
|
153
14
|
|
154
|
-
@mixin
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
15
|
+
@mixin text-style-subheading {
|
16
|
+
color: color(ink);
|
17
|
+
font-size: rem(13px);
|
18
|
+
line-height: rem(20px);
|
19
|
+
font-weight: 700;
|
20
|
+
text-transform: uppercase;
|
21
|
+
letter-spacing: 0.04em;
|
22
|
+
-webkit-font-smoothing: antialiased;
|
23
|
+
-moz-osx-font-smoothing: grayscale;
|
159
24
|
}
|
160
25
|
|
161
|
-
@mixin
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
26
|
+
@mixin text-style-body {
|
27
|
+
color: color(ink);
|
28
|
+
font-size: rem(16px);
|
29
|
+
line-height: rem(24px);
|
30
|
+
-webkit-font-smoothing: antialiased;
|
31
|
+
-moz-osx-font-smoothing: grayscale;
|
166
32
|
}
|
167
33
|
|
168
|
-
@mixin
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
34
|
+
@mixin text-style-meta {
|
35
|
+
color: color(ink);
|
36
|
+
font-size: rem(14px);
|
37
|
+
line-height: rem(20px);
|
38
|
+
-webkit-font-smoothing: antialiased;
|
39
|
+
-moz-osx-font-smoothing: grayscale;
|
173
40
|
}
|
174
41
|
|
175
|
-
@mixin
|
176
|
-
|
42
|
+
@mixin text-emphasis-strong {
|
43
|
+
font-weight: 600;
|
177
44
|
}
|
178
45
|
|
179
|
-
@mixin
|
180
|
-
color: color(
|
46
|
+
@mixin text-emphasis-subdued {
|
47
|
+
color: color(ink, light);
|
181
48
|
}
|
@@ -2,6 +2,14 @@ require 'smart_properties'
|
|
2
2
|
|
3
3
|
module Quilt
|
4
4
|
module UIHelper
|
5
|
+
def self.logger_callback
|
6
|
+
nil
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.render_fallback
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
5
13
|
class Component < SimpleDelegator
|
6
14
|
# rubocop:disable Alias
|
7
15
|
alias view_context __getobj__
|
@@ -9,12 +17,33 @@ module Quilt
|
|
9
17
|
|
10
18
|
include SmartProperties
|
11
19
|
|
12
|
-
|
13
|
-
|
20
|
+
property :options, accepts: Hash, default: {}, required: true
|
21
|
+
|
22
|
+
def initialize(view_context, **args)
|
23
|
+
class_properties = self.class.properties.keys
|
24
|
+
valid_args = args.slice(*class_properties)
|
25
|
+
options = args.except(*class_properties)
|
26
|
+
|
27
|
+
super(view_context, options: options, **valid_args)
|
14
28
|
end
|
15
29
|
|
16
|
-
def self.
|
17
|
-
|
30
|
+
def self.new(*args, **attrs, &block)
|
31
|
+
super
|
32
|
+
rescue SmartProperties::AssignmentError => error
|
33
|
+
fallback_error = FallbackError.new(error)
|
34
|
+
|
35
|
+
raise unless Quilt::UIHelper.render_fallback
|
36
|
+
if Quilt::UIHelper.logger_callback.respond_to?(:call)
|
37
|
+
Quilt::UIHelper.logger_callback.call(fallback_error)
|
38
|
+
else
|
39
|
+
Rails.logger.error(fallback_error)
|
40
|
+
end
|
41
|
+
|
42
|
+
fallback(*args, **attrs, &block)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.fallback(*)
|
46
|
+
Fallback.new
|
18
47
|
end
|
19
48
|
|
20
49
|
def self.variants
|
@@ -24,7 +53,7 @@ module Quilt
|
|
24
53
|
|
25
54
|
def self.variant(name, accepts: [true, false], **options)
|
26
55
|
@variants ||= {}
|
27
|
-
@variants[name] = Variant.new(name
|
56
|
+
@variants[name] = Variant.new(name, Set.new(accepts))
|
28
57
|
property name, accepts: accepts, **options
|
29
58
|
end
|
30
59
|
|
@@ -32,44 +61,26 @@ module Quilt
|
|
32
61
|
define_method(:base_css_class) { class_name }
|
33
62
|
end
|
34
63
|
|
35
|
-
property :options, accepts: Hash, default: {}, required: true
|
36
|
-
|
37
|
-
def initialize(view_context, **args)
|
38
|
-
class_properties = self.class.properties.keys
|
39
|
-
valid_args = args.slice(*class_properties)
|
40
|
-
options = args.except(*class_properties)
|
41
|
-
|
42
|
-
super(view_context, options: options, **valid_args)
|
43
|
-
end
|
44
|
-
|
45
64
|
def base_css_class
|
46
65
|
raise NotImplementedError, 'You need to define a base_css_class method for your component'
|
47
66
|
end
|
48
67
|
|
49
|
-
def render
|
50
|
-
raise NotImplementedError, 'You must implement a render method'
|
51
|
-
end
|
52
|
-
|
53
68
|
def variant_classes(*additional_classes)
|
54
|
-
classes =
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
69
|
+
classes = [base_css_class]
|
70
|
+
|
71
|
+
self.class.variants.each do |variant_key, variant|
|
72
|
+
variant_value = self[variant_key]
|
73
|
+
next unless variant_value
|
74
|
+
classes << base_css_class_variant(variant_key, variant_value, variant)
|
60
75
|
end
|
61
76
|
|
62
77
|
[classes, additional_classes].flatten.compact
|
63
78
|
end
|
64
79
|
|
65
80
|
def ui_content_tag(name, *content_or_additional_options, **base_options, &block)
|
66
|
-
additional_options = content_or_additional_options.
|
81
|
+
additional_options = content_or_additional_options.extract_options!
|
67
82
|
|
68
|
-
content =
|
69
|
-
capture(&block)
|
70
|
-
else
|
71
|
-
Array(content_or_additional_options).compact.inject(''.html_safe, :<<)
|
72
|
-
end
|
83
|
+
content = block_given? ? capture(&block) : safe_join(Array(content_or_additional_options))
|
73
84
|
|
74
85
|
options = base_options.merge(additional_options) do |key, base_value, additional_value|
|
75
86
|
case key
|
@@ -83,6 +94,18 @@ module Quilt
|
|
83
94
|
content.blank? ? ''.html_safe : content_tag(name, options) { content }
|
84
95
|
end
|
85
96
|
|
97
|
+
protected
|
98
|
+
|
99
|
+
def base_css_class_variant(variant_key, variant_value, variant)
|
100
|
+
class_name = "#{base_css_class}--#{variant_key}"
|
101
|
+
class_name << "-#{variant_value}" unless variant.boolean?
|
102
|
+
bemerize(class_name)
|
103
|
+
end
|
104
|
+
|
105
|
+
def bemerize(css_class_name)
|
106
|
+
css_class_name.gsub(/(?<!_)_(?!_)/, '-')
|
107
|
+
end
|
108
|
+
|
86
109
|
class Variant < Struct.new(:name, :values)
|
87
110
|
BOOLEAN = Set.new([true, false]).freeze
|
88
111
|
|
@@ -91,27 +114,13 @@ module Quilt
|
|
91
114
|
end
|
92
115
|
end
|
93
116
|
|
94
|
-
class Airbag < SimpleDelegator
|
95
|
-
# rubocop:disable Alias
|
96
|
-
alias component_class __getobj__
|
97
|
-
# rubocop:enable Alias
|
98
|
-
|
99
|
-
def new(*args, **attrs, &block)
|
100
|
-
component_class.new(*args, **attrs, &block)
|
101
|
-
rescue SmartProperties::AssignmentError => error
|
102
|
-
raise if Rails.env.development? || Rails.env.test?
|
103
|
-
Bugsnag.notify(FallbackWarning.new(error))
|
104
|
-
component_class.fallback(*args, **attrs, &block)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
117
|
class Fallback
|
109
118
|
def render(*)
|
110
119
|
''.html_safe
|
111
120
|
end
|
112
121
|
end
|
113
122
|
|
114
|
-
class
|
123
|
+
class FallbackError < RuntimeError; end
|
115
124
|
end
|
116
125
|
end
|
117
126
|
end
|
data/lib/quilt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quilt_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Sauve
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: smart_properties
|
@@ -50,8 +50,10 @@ files:
|
|
50
50
|
- assets/stylesheets/quilt/components.scss
|
51
51
|
- assets/stylesheets/quilt/components/badge.scss
|
52
52
|
- assets/stylesheets/quilt/foundation.scss
|
53
|
+
- assets/stylesheets/quilt/foundation/border-radius.scss
|
54
|
+
- assets/stylesheets/quilt/foundation/borders.scss
|
53
55
|
- assets/stylesheets/quilt/foundation/colors.scss
|
54
|
-
- assets/stylesheets/quilt/foundation/
|
56
|
+
- assets/stylesheets/quilt/foundation/shadows.scss
|
55
57
|
- assets/stylesheets/quilt/foundation/spacing.scss
|
56
58
|
- assets/stylesheets/quilt/foundation/typography.scss
|
57
59
|
- assets/stylesheets/quilt/foundation/utilities.scss
|
@@ -1,22 +0,0 @@
|
|
1
|
-
$defaults-data: (
|
2
|
-
border-radius: 3px,
|
3
|
-
box-shadow: 0 2px 4px color(shadow),
|
4
|
-
border-width: 1px,
|
5
|
-
border: 1px solid color(border)
|
6
|
-
);
|
7
|
-
|
8
|
-
//*
|
9
|
-
// Returns the default value for the passed property
|
10
|
-
//
|
11
|
-
// @param {String} $property - The property to retrieve
|
12
|
-
// @return {Mixed} The default value for that property
|
13
|
-
|
14
|
-
@function default($property) {
|
15
|
-
$fetched-value: map-get($defaults-data, $property);
|
16
|
-
|
17
|
-
@if $fetched-value != null {
|
18
|
-
@return $fetched-value;
|
19
|
-
} @else {
|
20
|
-
@error "Default property `#{$property}` not found. Available properties: #{available-names($defaults-data)}";
|
21
|
-
}
|
22
|
-
}
|