aboutsummaryrefslogtreecommitdiffstats
path: root/WebContent/VAADIN/themes/valo/components/_formlayout.scss
blob: f0001ffe94b7227bbc03551a9f9de7cfdd561940 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/**
 * Outputs the selectors and properties for the FormLayout component.
 *
 * @param {string} $primary-stylename (v-formlayout) - the primary style name for the selectors
 * @param {bool} $include-additional-styles - should the mixin output all the different style variations of the component
 *
 * @group formlayout
 */
@mixin valo-formlayout ($primary-stylename: v-formlayout, $include-additional-styles: contains($v-included-additional-styles, formlayout)) {

  @include valo-formlayout-spacing;
  @include valo-formlayout-margin;

  .#{$primary-stylename} > table {
    border-spacing: 0;
    position: relative;
  }

  .#{$primary-stylename}.v-has-width > table,
  .#{$primary-stylename}.v-has-width .#{$primary-stylename}-contentcell {
    width: 100%;
  }

  .#{$primary-stylename}-error-indicator {
    width: round($v-unit-size/2);
  }

  .#{$primary-stylename}-captioncell {
    vertical-align: top;
    line-height: $v-unit-size - 1px;

    .v-caption {
      padding-bottom: 0;
    }

    .v-caption-h2,
    .v-caption-h3,
    .v-caption-h4 {
      height: 3em;
    }
  }

  .#{$primary-stylename}-contentcell {
    .v-checkbox,
    .v-radiobutton {
      font-weight: $v-font-weight + 100;
    }

    > .v-label-h2,
    > .v-label-h3,
    > .v-label-h4 {
      position: absolute;
      left: 0;
      margin-top: -0.5em;
      padding-bottom: 0.5em;
      border-bottom: valo-border($color: $v-app-background-color, $strength: 0.5);
    }
  }


  @if $include-additional-styles {
    .#{$primary-stylename}.light {
      @include valo-formlayout-light-style;
    }
  }

}


/**
 * Outputs the styles for form layout margin.
 *
 * @param {list} $margin ($v-layout-margin-top $v-layout-margin-right $v-layout-margin-bottom $v-layout-margin-left) - The margin for the form layout (any valid CSS margin value)
 *
 * @group formlayout
 */
@mixin valo-formlayout-margin ($margin: $v-layout-margin-top $v-layout-margin-right $v-layout-margin-bottom $v-layout-margin-left) {
  $top: 0;
  $right: 0;
  $bottom: 0;
  $left: 0;

  @if length($margin) == 1 {
    $top: $margin;
    $right: $margin;
    $bottom: $margin;
    $left: $margin;
  } @else if length($margin) == 2 {
    $top: nth($margin, 1);
    $right: nth($margin, 2);
    $bottom: nth($margin, 1);
    $left: nth($margin, 2);
  } @else if length($margin) == 3 {
    $top: nth($margin, 1);
    $right: nth($margin, 2);
    $bottom: nth($margin, 3);
    $left: nth($margin, 2);
  } @else if length($margin) == 4 {
    $top: nth($margin, 1);
    $right: nth($margin, 2);
    $bottom: nth($margin, 3);
    $left: nth($margin, 4);
  }

  [class*="margin-top"] > tbody > [class*="firstrow"] > td {
    padding-top: $top;
  }

  [class*="margin-bottom"] > tbody > [class*="lastrow"] > td {
    padding-bottom: $bottom;
  }

  [class*="margin-left"] > tbody > [class*="row"] > [class*="captioncell"] {
    padding-left: $left;
  }

  [class*="margin-right"] > tbody > [class*="row"] > [class*="contentcell"] {
    padding-right: $right;
  }
}


/**
 * Outputs the styles for form layout spacing.
 *
 * @param {size} $vertical ($v-layout-spacing-vertical) - The vertical spacing between the rows in the form layout
 *
 * @group formlayout
 */
@mixin valo-formlayout-spacing ($vertical: $v-layout-spacing-vertical) {
  [class*="spacing"] > tbody > [class*="row"] > td {
    padding-top: $vertical;
  }

  [class*="spacing"] > tbody > [class*="firstrow"] > td {
    padding-top: 0;
  }
}


/**
 * Outputs the styles for a light style form layout. This mixin expects the target to have the normal styles of a form layout applied.
 *
 * @param {size} $row-height ($v-unit-size) - The height of an individual form layout row
 *
 * @group formlayout
 */
@mixin valo-formlayout-light-style ($row-height: $v-unit-size) {
  > table {
    padding: 0;
  }

  > table > tbody > [class*="row"] > td {
    padding-top: 0;
    height: $row-height; // Effectively min-height
    border-bottom: valo-border($color: $v-app-background-color, $strength: 0.3);
  }

  > table > tbody > [class*="lastrow"] > td {
    border-bottom: none;
  }

  > table > tbody > [class*="row"] > [class*="captioncell"] {
    color: valo-font-color($v-background-color, .5);
    text-align: right;
    padding-left: ceil($v-unit-size/3);
    line-height: $row-height;
  }

  > table > tbody > [class*="row"] > [class*="contentcell"] {
    > .v-textfield,
    > .v-textarea,
    > .v-filterselect,
    > .v-datefield,
    > .v-filterselect-input,
    > .v-datefield-textfield {
      width: 100%;
    }

    > .v-textfield,
    > .v-textarea,
    > .v-filterselect input,
    > .v-datefield input,
    > .v-richtextarea {
      @include valo-textfield-style($unit-size: $row-height, $border-radius: 0, $border: null, $bevel: none, $shadow: none, $background-color: null);
      background: transparent;
      border: none;
      color: inherit;

      &:focus {
        box-shadow: none;
      }
    }

    > .v-textfield-prompt,
    > .v-textarea-prompt,
    > .v-filterselect-prompt input,
    > .v-datefield-prompt input {
      @include valo-textfield-prompt-style;
    }

    > .v-textarea,
    > .v-richtextarea {
      height: auto;
    }

    > .v-label-h2,
    > .v-label-h3,
    > .v-label-h4 {
      border-bottom: none;
    }

    > .v-label-h3,
    > .v-label-h4 {
      margin-top: 0;
    }
  }

  .v-richtextarea {
    margin: round($v-unit-size/8) 0;
  }

  .v-filterselect-button,
  .v-datefield-button {
    border: none;

    &:active:after {
      display: none;
    }
  }

  .v-datefield-button {
    right: 0;
    left: auto;
  }

  .v-checkbox {
    margin-left: ceil($v-unit-size/6);
  }
}