summaryrefslogtreecommitdiffstats
path: root/WebContent/VAADIN/themes/valo/components/_csslayout.scss
blob: 3525bcad5ad8c0f9a72e13eb19b9bdb3abdbc439 (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
/**
 * The amount of spacing between different widgets in a component group.
 * If null, a computed value is used ($v-border size * -1, or 1px if $v-border size is 0)
 * 
 * @group csslayout
 */
$v-component-group-spacing: null !default;


/**
 * Outputs the additional styles for the CssLayout component. Does not produce any other output.
 * 
 * @param {string} $primary-stylename (v-csslayout) - 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 csslayout
 */
@mixin valo-csslayout ($primary-stylename: v-csslayout, $include-additional-styles: contains($v-included-additional-styles, csslayout)){
  @if $include-additional-styles {
    .#{$primary-stylename}-well {
      @include valo-panel-well-style;
      @include valo-panel-adjust-content-margins;
    }

    .#{$primary-stylename}-card {
      @include valo-panel-style;
      @include valo-panel-adjust-content-margins;
    }

    .#{$primary-stylename}-v-component-group {
      @include valo-component-group;
    }
  }
}


/**
 * Outputs the styles for a horizontal component group. The target component is 
 * expected to be a CssLayout, which is a single DIV element with child components 
 * directly inside.
 * 
 * @group csslayout
 * 
 * @example scss
 * .my-csslayout {
 *   @include valo-component-group;
 * }
 */
@mixin valo-component-group {
  white-space: nowrap;
  position: relative;

  @if $v-border-radius > 0 {
    .v-widget ~ .v-widget:not(:last-child) {
      border-radius: 0;
    }

    .v-widget:last-child {
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
    }

    .v-widget:first-child,
    .v-caption:first-child + .v-widget {
      border-top-right-radius: 0;
      border-bottom-right-radius: 0;
    }

    .v-widget ~ .v-widget.first.first {
      border-radius: $v-border-radius 0 0 $v-border-radius;
    }

    .v-widget ~ .v-widget.last.last {
      border-radius: 0 $v-border-radius $v-border-radius 0;
    }
  }

  // Assume most components have borders.
  // This is just a best-guess, will need fine-tuning if border-widths vary from widget-to-widget
  .v-widget {
    vertical-align: middle;

    $v-border-width: first-number($v-border);

    @if $v-border-width > 0 {
      margin-left: $v-component-group-spacing or -$v-border-width;
    } @else {
      margin-left: $v-component-group-spacing or 1px;
    }

    &:first-child {
      margin-left: 0;
    }

    // Focused component should be on top
    &:focus,
    &[class*="focus"],
    [class*="focus"] {
      position: relative;
      z-index: 5;
    }
  }
}