tungsten 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06c81130859fa7bd4a0673370e233d1b8fd8ad45
4
- data.tar.gz: a9c421d5a3b3fddbd49d266ab96e36e2ea311bea
3
+ metadata.gz: 485aa16cdbb3ff7a8880fab83541fb5aee360533
4
+ data.tar.gz: c2dc7ff628762fe63152282f12931069381149a1
5
5
  SHA512:
6
- metadata.gz: 12014325939bb67a71482ffb2d5f1d6ebf55b1dbdd786a4daaa543aa4f36f42e4c56f85130e9fe592a99e491025bd912ecdb60c7f65e6ee565670e39b2a5b870
7
- data.tar.gz: 477692ad0379c819068b6302d54392f289ca497c9747eef41c1623993054adb5563f640c5caf9d140772a3cbc0653f5813b6f9a0289b0f50e52474b7c0381a5f
6
+ metadata.gz: 12a0b669adc672af3c518ec67d32a796bf830444b62e49c45c5224526475f71b1410ddcda38eb45614754ded8212f796a9aac6f8db0ce8f9539a39fa21ef4370
7
+ data.tar.gz: 9155fc7a0fde8da462885bfe39e997dd0560645015744c628ea4f6e6a04dd938ad39729c4e1b77d90c4e6108c6f06fa742094eba23d03f84fc0d6ed0e3addb6e
@@ -1,20 +1,18 @@
1
- var toggler = require('compose-toggler')
1
+ var toggler = require( 'compose-toggler' )
2
2
  var formUp = require( 'compose-form-up' )
3
3
  var toolbox = require( 'compose-toolbox' )
4
4
  var ajax = require( 'superagent' )
5
5
  var event = toolbox.event
6
6
 
7
- event.scroll.disablePointer() // disable pointer events on scroll for performance (to avoid extra repaints)
7
+ event.scroll.disablePointer() // disable pointer events on scroll for performance (to avoid extra repaints)
8
8
 
9
- require('compose-slider') // Our slider (range input) component
10
- require('./_icons') // Import svg icons (from Esvg)
9
+ require( 'compose-slider' ) // Our slider (range input) component
10
+ require( './_icons' ) // Import svg icons (from Esvg)
11
11
  require( './_form_helpers' )
12
12
 
13
13
  // Public API object
14
- var tungsten = toolbox.merge( {
14
+ window.Tungsten = module.exports = toolbox.merge( {
15
15
  ajax : ajax,
16
16
  form : formUp,
17
17
  toggler : toggler
18
18
  }, toolbox )
19
-
20
- window.tungsten = module.exports = tungsten
@@ -36,6 +36,10 @@
36
36
  button {
37
37
  margin-left: 10px;
38
38
  }
39
+
40
+ a {
41
+ @include inline-link($gray-08, $gray-09);
42
+ }
39
43
  }
40
44
 
41
45
  #{$block-elements} {
@@ -65,7 +69,16 @@
65
69
  font-size: 16px;
66
70
  }
67
71
 
68
- &-footer {
72
+ header, footer {
73
+ display: flex;
74
+ align-items: baseline;
75
+ .card-actions {
76
+ margin-top: 0;
77
+ margin-left: auto;
78
+ }
79
+ }
80
+
81
+ footer {
69
82
  display: flex;
70
83
  align-items: baseline;
71
84
  @include collapse-top;
@@ -77,14 +90,9 @@
77
90
  background-clip: padding-box;
78
91
  border-top: $card-padding solid transparent;
79
92
  margin: auto $card-padding * -1 $card-padding * -1 $card-padding * -1;
80
-
81
- .card-actions {
82
- margin-top: 0;
83
- margin-left: auto;
84
- }
85
93
  }
86
94
  }
87
95
 
88
96
  table.card {
89
97
  display: table;
90
- }
98
+ }
@@ -21,8 +21,8 @@ label { *, *:before, *:after {
21
21
  @return 0 0 0 $size $color inset, $empty-shadow;
22
22
  }
23
23
 
24
- @function input-focus-shadow($color: $gray-08) {
25
- @return 0 0 0 1px $color inset, $input-weight-shadow
24
+ @function input-focus-shadow($color: $gray-08, $size: 1px) {
25
+ @return 0 0 0 $size $color inset, $input-weight-shadow
26
26
  }
27
27
 
28
28
  $focus-shadow: input-focus-shadow();
@@ -225,11 +225,17 @@ label {
225
225
  flex: 1 0 auto;
226
226
  margin: 18px 0;
227
227
 
228
- &.label-text {
228
+ .label-text {
229
229
  transition-property: box-shadow, color;
230
+ padding-bottom: .2em;
230
231
  }
232
+
231
233
  select, input, textarea {
232
234
  margin: 0px;
233
235
  }
234
236
  }
235
237
 
238
+ form.button_to {
239
+ width: auto;
240
+ display: inline-flex;
241
+ }
@@ -2,6 +2,7 @@
2
2
  $width: 70px;
3
3
  $height: 24px;
4
4
  $tick-width: $width/2 - 2;
5
+ cursor: pointer;
5
6
  flex-direction: row; align-items: center;
6
7
 
7
8
  .label-text {
@@ -2,3 +2,4 @@
2
2
  @import 'label-placeholder';
3
3
  @import 'check-radio';
4
4
  @import 'check-switch';
5
+ @import 'validation';
@@ -1,21 +1,18 @@
1
1
  @mixin label-placeholder {
2
2
  // Scoped variables
3
- $font-size: 16px;
4
- $padding-x: 12px;
5
- $padding-y: 9px;
6
- $distance-y: -23px;
3
+ $padding-x: .8em;
4
+ $padding-y: 2em;
5
+ $distance-y: .6em;
6
+ $font-size: 1em;
7
7
  $distance-x: 0;
8
- $scale: .875;
9
- $height: 50px;
10
- $duration: .2s;
8
+ $scale: .8;
11
9
 
12
10
  // Input labels
13
11
  label.placeholder-label {
14
12
 
15
- padding-top: 0;
16
- line-height: 2em;
17
- background: $white;
13
+ padding: 0;
18
14
  font-size: $font-size;
15
+ background: $white;
19
16
 
20
17
  // Nested text-based inputs
21
18
  > input,
@@ -45,14 +42,18 @@
45
42
  margin: 0;
46
43
  font-size: inherit;
47
44
  background: transparent;
48
- padding: $padding-y $padding-x;
45
+ padding: ($padding-y / 2) $padding-x;
49
46
 
50
47
  // Move labels out of the way on focus and empty
51
- &:focus + .placeholder-label-text,
52
- &:not(.empty) + .placeholder-label-text, {
53
- z-index: 2;
54
- transform: translate3d($distance-x, $distance-y, 0) scale($scale);
55
- color: darken($gray-08, 10);
48
+ &:focus, &:not(.empty) {
49
+ padding-top: $padding-y - ($distance-y / 1.5);
50
+ padding-bottom: ($distance-y / 1.5);
51
+
52
+ + .placeholder-label-text, {
53
+ z-index: 2;
54
+ transform: translate3d($distance-x, -($distance-y), 0) scale($scale);
55
+ color: $gray-08;
56
+ }
56
57
  }
57
58
  }
58
59
 
@@ -67,8 +68,9 @@
67
68
  input {
68
69
  line-height: inherit;
69
70
  }
71
+
70
72
  textarea {
71
- padding-top: $padding-y + 4;
73
+ padding-top: ($padding-y / 2) + 4;
72
74
  }
73
75
  }
74
76
 
@@ -76,9 +78,8 @@
76
78
  .placeholder-label-text {
77
79
  pointer-events: none;
78
80
  font-size: inherit;
79
- line-height: 1.2em;
80
81
  position: absolute;
81
- top: $padding-y + 5px;
82
+ top: ($padding-y / 2);
82
83
  left: $padding-x;
83
84
  padding: 1px 0 0 1px;
84
85
  transform-origin: left top 0;
@@ -89,8 +90,10 @@
89
90
  color: $gray-06;
90
91
  transform: translate3d(0, 0, 0) scale(1);
91
92
  transition-property: color, transform;
92
- background: $white;
93
- box-shadow: -6px 0 $white, 6px 0 $white;
93
+
94
+ .label-text ~ & {
95
+ top: $font-size / 2 + $padding-y;
96
+ }
94
97
  }
95
98
  }
96
99
 
@@ -0,0 +1,72 @@
1
+ // Apply validation styles to inputs & textareas
2
+ label.valid {
3
+ color: $green-01;
4
+
5
+ input, select, textarea {
6
+ //color: currentColor;
7
+ -webkit-text-fill-color: currentColor;
8
+ box-shadow: input-shadow( $green-01 );
9
+
10
+ @include input-active {
11
+ box-shadow: input-focus-shadow( $green-01 )
12
+ }
13
+ }
14
+ }
15
+
16
+ label.invalid {
17
+ color: $red-01;
18
+
19
+ input, select, textarea {
20
+ //color: currentColor;
21
+ -webkit-text-fill-color: currentColor;
22
+ box-shadow: input-shadow( $red-01, 2px );
23
+
24
+ @include input-active {
25
+ box-shadow: input-focus-shadow( $red-01, 2px )
26
+ }
27
+ }
28
+ }
29
+
30
+ // Validation message animation declaration
31
+ @keyframes expand-validation {
32
+ 0% { max-height: 0em; }
33
+ 100% { max-height: 2.5em; }
34
+ }
35
+
36
+ @keyframes scale-fade-in {
37
+ 0% {
38
+ opacity: 0;
39
+ transform: translate(-50%, -6px) scale(.5);
40
+ }
41
+
42
+ 100% {
43
+ opacity: 1;
44
+ transform: translate(-50%, 6px) scale(1);
45
+ }
46
+ }
47
+
48
+ // Inline validation messages
49
+ .validation-message {
50
+ overflow: hidden;
51
+ display: block;
52
+ z-index: 3;
53
+ animation: expand-validation $duration $timing;
54
+ position: relative;
55
+ top: -1px;
56
+
57
+ // Message bubble (also a hack to maintain proper word wrap)
58
+ .validation-message-text {
59
+ margin: 0;
60
+ display: block;
61
+ padding: .8em .8em;
62
+ border-radius: 0 0 $radius $radius;
63
+ color: $white;
64
+ font-size: 12px;
65
+ line-height: 1em;
66
+ background: $gray-08;
67
+
68
+ .invalid & {
69
+ background: $red-01;
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,71 @@
1
+ module Tungsten
2
+ module ButtonHelper
3
+ def button(text = nil, options = nil, &block)
4
+ options = text if block_given? && options.nil?
5
+ options ||= {}
6
+ tag_name = options[:href].present? ? :a : :button
7
+
8
+ options[:class] = button_classes(options)
9
+ options[:data] ||= {}
10
+ options[:data][:toggle] = options.delete(:toggle)
11
+ options[:data][:confirm] = options.delete(:confirm)
12
+ options[:data][:remote] = options[:remote]
13
+ options[:type] = 'submit' if options[:to]
14
+
15
+ button_options = {
16
+ role: 'button',
17
+ id: options.delete(:id),
18
+ data: options.delete(:data),
19
+ class: options.delete(:class),
20
+ disabled: options.delete(:disabled),
21
+ type: options.delete(:type) || 'button'
22
+ }
23
+
24
+ text = capture(&block).html_safe if block_given?
25
+
26
+ button = content_tag tag_name, button_options do
27
+ concat text
28
+ end
29
+
30
+ if options[:to]
31
+ form = button_to 'input', options.delete(:to), options
32
+ form.sub(/<input type="submit".+?>/, button).html_safe
33
+ else
34
+ button
35
+ end
36
+ end
37
+
38
+ def primary_button(text = nil, options = nil, &block)
39
+ options = text if block_given? && options.nil?
40
+ options ||= {}
41
+ options[:class] = "#{options[:class]} primary".strip
42
+ options[:type] = 'submit'
43
+ button(text, options, &block)
44
+ end
45
+
46
+ def destructive_button(text = nil, options = nil, &block)
47
+ options = text if block_given? && options.nil?
48
+ options ||= {}
49
+ options[:class] = "#{options[:class]} destructive".strip
50
+ options[:method] = 'delete'
51
+ button(text, options, &block)
52
+ end
53
+
54
+ def destructive_primary_button(text = nil, options = nil, &block)
55
+ options = text if block_given? && options.nil?
56
+ options ||= {}
57
+ options[:class] = "#{options[:class]} primary destructive".strip
58
+ options[:type] = 'submit'
59
+ options[:method] = 'delete'
60
+ button(text, options, &block)
61
+ end
62
+
63
+ def button_classes(options)
64
+ classes = ['button']
65
+ classes << options[:class]
66
+ classes << options.delete(:size)
67
+ classes.flatten.compact.uniq.join(' ').strip
68
+ end
69
+
70
+ end
71
+ end
@@ -1,76 +1,43 @@
1
1
  module Tungsten
2
2
  module CardHelper
3
- class Section < Tungsten::Helper
3
+ class Card < Tungsten::Helper
4
4
 
5
- def initialize( title=nil )
5
+ def initialize( title = nil, options = {} )
6
+ @options = options
6
7
  @title = title
7
- @children = { cards: [] }
8
-
9
- heading( title ) if title
10
8
  end
11
9
 
12
10
  def display( body )
13
- content_tag( :section, class: 'section' ) {
14
- concat info
15
- concat content_tag(:div, class: 'section-content') { body }
16
- }
17
- end
18
-
19
- def add_card(card)
20
- @children[cards].push card
11
+ content_tag( :section, class: 'card' ) do
12
+ concat header( @title ) if @title
13
+ concat body
14
+ end
21
15
  end
22
16
 
23
- def heading( text = nil, &block )
24
- @children[:heading] = get_tag(:header, :h2, text, { class: 'section-heading' }, &block )
25
- nil
17
+ def header( text = nil, options = {}, &block )
18
+ options[:class] = "card-header #{options[:class]}".strip
19
+
20
+ content_tag( :header, options ) {
21
+ concat content_tag( :h2, text, class: 'card-heading' ) if text
22
+ concat capture(&block).html_safe if block_given?
23
+ }
26
24
  end
27
25
 
28
- def description( text = nil, &block )
29
- @children[:description] = get_tag(:div, :p, text, { class: 'section-description' }, &block )
30
- nil
31
- end
26
+ def footer( text = nil, options = {}, &block )
27
+ options[:class] = "card-footer #{options[:class]}".strip
32
28
 
33
- def card( text = nil, &block )
34
- content_tag(:section, class: 'section-card') {
35
- concat title( text ) if text
29
+ content_tag( :footer, options ) {
30
+ concat content_tag( :p, text ) unless text.nil?
36
31
  concat capture(&block).html_safe
37
32
  }
38
33
  end
39
34
 
40
- def title( text, options={} )
41
- content_tag(:header, class: "card-title #{options[:class]}") {
42
- content_tag(:h2) { text }
43
- }
44
- end
45
-
46
- def content(options={}, &block )
47
- content_tag(:section, class: "card-section #{options[:class]}", &block)
48
- end
35
+ def actions( options={}, &block )
36
+ options[:class] = "card-actions #{options[:class]}".strip
49
37
 
50
- def footer( options={}, &block )
51
- content_tag(:footer, class: "card-footer #{options[:class]}", &block)
38
+ content_tag( :nav, options, &block )
52
39
  end
53
40
 
54
- private
55
-
56
- def get_tag( tag, wrapper, text, options, &block )
57
- text = if block_given?
58
- capture(&block).html_safe
59
- else
60
- content_tag(wrapper){ text }
61
- end
62
-
63
- content_tag(tag, options ) { text }
64
- end
65
-
66
- def info
67
- if @children[:heading]
68
- content_tag(:div, class: 'section-info') {
69
- concat @children[:heading]
70
- concat @children[:description]
71
- }
72
- end
73
- end
74
41
  end
75
42
  end
76
43
  end