aboutsummaryrefslogtreecommitdiff
path: root/resources/assets/stylesheets/mixins/studip.scss
blob: 1bbd7d55eea813a53139a16263a6f3afc83d2347 (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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/**
 * studip-mixins.less
 *
 * This file contains all mixins created specifically for Stud.IP
 * while mixins.less should contain a copy of the mixins from
 * twitter's bootstrap.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * @author      Jan-Hendrik Willms <tleilax+studip@gmail.com>
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
 * @category    Stud.IP
 * @since       4.4
 */

// Clearfix
// --------
// For clearing floats like a boss h5bp.com/q
@mixin clearfix {
    &::before,
    &::after {
        display: table;
        content: '';
        // Fixes Opera/contenteditable bug:
        // http://nicolasgallagher.com/micro-clearfix-hack/#comment-36952
        line-height: 0;
    }
    &::after {
        clear: both;
    }
}

// CSS image replacement
// -------------------------
// Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757
@mixin hide-text {
    font: 0/0 a;
    color: transparent;
    text-shadow: none;
    background-color: transparent;
    border: 0;
}

@function icon-path($icon, $role: clickable) {
    $icon: unquote($icon);
    $role: unquote($role);

    $color: 'blue';
    @if $role == info {
        $color: 'black';
    } @else if $role == accept or $role == status-green {
        $color: 'green';
    } @else if $role == inactive {
        $color: 'grey';
    } @else if $role == new or $role == attention or $role == status-red {
        $color: 'red';
    } @else if $role == info_alt or $role == info-alt {
        $color: 'white';
    } @else if $role == status-yellow {
        $color: 'yellow';
    }

    @return "#{$icon-path}/#{$color}/#{$icon}.svg";
}

@mixin background-icon($icon, $role: clickable, $size: 16) {
    $svg: icon-path($icon, $role);

    background-image: url("#{$svg}");

    @if $size {
        @if unitless($size) {
            $size: $size * 1px;
        }
        background-size: $size;
    }
}

@mixin retina-background-image($image0, $image1, $width: 100%, $height: $width) {
    background-image: url("#{$image-path}/#{$image0}");
    @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)
    {
        background-image: url("#{$image-path}/#{$image1}");
        background-size: $width;
    }
}

@mixin icon($position, $icon, $role, $size: 16px, $padding: 0) {
    $position: unquote($position);

    @if unitless($size) {
        @warn "Assuming icon size to be in pixels";
        $size: $size * 1px;
    }

    @if $position == before or $position == after {
        &::#{$position} {
            @include background-icon($icon, $role, $size);
            background-repeat: no-repeat;
            content: ' ';
            display: inline-block;
            height: $size;
            vertical-align: text-top;
            width: $size;

            @if position == before {
                margin-right: $padding;
            } @else {
                margin-left: $padding;
            }
        }
    }
}

// Mixin that replaces the navigation icon tags with css images
@mixin navigation-icon($default-icon-name, $toggled-icon-name) {
    img { display: none; }

    display: inline-block;

    @include background-icon($default-icon-name, clickable);
    @include hide-text();
    @include square(16px);

    &.toggled {
        @include background-icon($toggled-icon-name, clickable);
    }
}

@mixin empty-placeholder-image($icon, $background-color: $dark-gray-color-5) {
    &::before,
    &::after {
        position: absolute;
        top: 50%;
        left: 50%;

        content: '';
        display: block;
        background-image: url(icon-path($icon));
        background-position: center;
        background-repeat: no-repeat;
        background-size: contain;
    }
    &::before {
        height: 280px;
        width: 280px;
        opacity: 0.3;
        transform: translate(-50%, -50%);
    }
    &::after {
        height: 180px;
        width: 180px;
        opacity: 0.6;
        transform: translate(20px, -50px);

    }

    padding-top: 100px;
    background-image: url(icon-path($icon));
    background-repeat: no-repeat;
    background-size: 140px;
    background-position: calc(50% - 100px) calc(50% + 40px);

    @if ($background-color) {
        background-color: mix($background-color, rgba(255, 255, 255, 0), 70%);
    }

    text-align: center;
    height: 40vh;
    color: $content-color;
    font-size: 1.6em;
    position: relative;

}

// Scrollboxes
// From http://lea.verou.me/2012/04/background-attachment-local/
//  and http://dabblet.com/gist/6134408
%scrollbox-vertical {
    overflow: auto;

    background:
        /* Shadow covers */
        linear-gradient(white 30%, rgba(255,255,255,0)),
        linear-gradient(rgba(255,255,255,0), white 70%) 0 100%,

        /* Shadows */
        radial-gradient(farthest-side at 50% 0, rgba(0,0,0,.2), rgba(0,0,0,0)),
        radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,.2), rgba(0,0,0,0)) 0 100%;
    background-repeat: no-repeat;
    background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;

    /* Opera doesn't support this in the shorthand */
    background-attachment: local, local, scroll, scroll;
}

@mixin scrollbox-horizontal {
    overflow: auto;

    background:
        /* Shadow covers */
        linear-gradient(90deg, white 30%, rgba(255,255,255,0)),
        linear-gradient(90deg, rgba(255,255,255,0), white 70%) 100% 0,

        /* Shadows */
        radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.2), rgba(0,0,0,0)),
        radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)) 100% 0;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;

    /* Opera doesn't support this in the shorthand */
    background-attachment: local, local, scroll, scroll;
}

// Define action icons for widgets
@mixin widget-action($action, $icon: $action, $role: clickable) {
    .widget-action[data-action="#{$action}"] {
        @include hide-text();

        width: 16px;
        height: 16px;

        @include background-icon($icon, $role, 16px);

        background-repeat: no-repeat;
        cursor: pointer;
        display: block;
        // vertical-align: middle;

        @content;
    }
}

@mixin scrollbox-horizontal() {
    overflow: auto;

    background:
        /* Shadow covers */
        linear-gradient(90deg, white 30%, rgba(255,255,255,0)),
        linear-gradient(90deg, rgba(255,255,255,0), white 70%) 100% 0,

            /* Shadows */
        radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.2), rgba(0,0,0,0)),
        radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)) 100% 0;
    background:
        /* Shadow covers */
        linear-gradient(90deg, white 30%, rgba(255,255,255,0)),
        linear-gradient(90deg, rgba(255,255,255,0), white 70%) 100% 0,

            /* Shadows */
        radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.2), rgba(0,0,0,0)),
        radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)) 100% 0;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;

    /* Opera doesn't support this in the shorthand */
    background-attachment: local, local, scroll, scroll;
}