File: progress.scss

package info (click to toggle)
cockpit 354-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 308,956 kB
  • sloc: javascript: 775,606; python: 40,351; ansic: 35,655; cpp: 11,117; sh: 3,511; makefile: 580; xml: 261
file content (244 lines) | stat: -rw-r--r-- 8,766 bytes parent folder | download | duplicates (4)
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
@use '../../sass-utilities' as *;

@include pf-root($progress) {
  // Component variables
  --#{$progress}--GridGap: var(--pf-t--global--spacer--md);

  // Element variables
  --#{$progress}__bar--Height: var(--pf-t--global--spacer--md);
  --#{$progress}__bar--BackgroundColor: var(--pf-t--global--color--nonstatus--gray--default); // the bar always needs white under it so that the semi-transparent color shows correctly
  --#{$progress}__bar--BorderRadius: var(--pf-t--global--border--radius--medium);
  --#{$progress}__bar--BorderColor: var(--pf-t--global--border--color--high-contrast);
  --#{$progress}__bar--BorderWidth: var(--pf-t--global--border--width--high-contrast--regular);
  --#{$progress}__measure--m-static-width--MinWidth: 4.5ch; // 4.5 because the % character is wider than a 0
  --#{$progress}__status--Gap: var(--pf-t--global--spacer--sm);
  --#{$progress}__status-icon--Color: var(--pf-t--global--icon--color--regular);
  --#{$progress}__indicator--Height: var(--#{$progress}__bar--Height);
  --#{$progress}__indicator--BackgroundColor: var(--pf-t--global--color--brand--default);
  --#{$progress}__indicator--BorderWidth: var(--pf-t--global--border--width--high-contrast--extra-strong);
  --#{$progress}__indicator--BorderColor: transparent;
  --#{$progress}__helper-text--MarginBlockStart: calc(var(--pf-t--global--spacer--sm) - var(--#{$progress}--GridGap));

  // Modifier variables
  --#{$progress}--m-success__indicator--BackgroundColor: var(--pf-t--global--color--status--success--default);
  --#{$progress}--m-warning__indicator--BackgroundColor: var(--pf-t--global--color--status--warning--default);
  --#{$progress}--m-danger__indicator--BackgroundColor: var(--pf-t--global--color--status--danger--default);
  --#{$progress}--m-success__status-icon--Color: var(--pf-t--global--icon--color--status--success--default);
  --#{$progress}--m-warning__status-icon--Color: var(--pf-t--global--icon--color--status--warning--default);
  --#{$progress}--m-danger__status-icon--Color: var(--pf-t--global--icon--color--status--danger--default);
  --#{$progress}--m-inside__indicator--MinWidth: var(--pf-t--global--spacer--xl);
  --#{$progress}--m-inside__measure--Color: var(--pf-t--global--text--color--on-brand--default);
  --#{$progress}--m-success--m-inside__measure--Color: var(--pf-t--global--text--color--status--on-success--default);
  --#{$progress}--m-warning--m-inside__measure--Color: var(--pf-t--global--text--color--status--on-warning--default);
  --#{$progress}--m-danger--m-inside__measure--Color: var(--pf-t--global--text--color--status--on-danger--default);
  --#{$progress}--m-inside__measure--FontSize: var(--pf-t--global--font--size--sm);
  --#{$progress}--m-outside__measure--FontSize: var(--pf-t--global--font--size--sm);
  --#{$progress}--m-sm__bar--Height: var(--pf-t--global--spacer--sm);
  --#{$progress}--m-sm__measure--FontSize: var(--pf-t--global--font--size--body--sm);
  --#{$progress}--m-lg__bar--Height: var(--pf-t--global--spacer--lg);
}

.#{$progress} {
  display: grid;
  grid-template-rows: 1fr auto;
  grid-template-columns: auto auto;
  grid-gap: var(--#{$progress}--GridGap);
  align-items: end;

  // Modifiers
  // size modifiers
  &.pf-m-sm {
    --#{$progress}__bar--Height: var(--#{$progress}--m-sm__bar--Height);

    .#{$progress}__measure {
      font-size: var(--#{$progress}--m-sm__measure--FontSize);
    }
  }

  &.pf-m-lg {
    --#{$progress}__bar--Height: var(--#{$progress}--m-lg__bar--Height);
  }

  // an inside-style progress component shows the measure inside the indicator
  &.pf-m-inside {
    .#{$progress}__indicator {
      display: flex;
      align-items: center;
      justify-content: center;
      min-width: var(--#{$progress}--m-inside__indicator--MinWidth);
    }

    .#{$progress}__measure {
      font-size: var(--#{$progress}--m-inside__measure--FontSize);
      color: var(--#{$progress}--m-inside__measure--Color);
      text-align: center;
    }
  }

  // an outside-style progress component shows the measure and status icon to the right of the bar
  &.pf-m-outside {
    .#{$progress}__description {
      grid-column: 1 / 3;
    }

    .#{$progress}__status {
      grid-row: 2 / 3;
      grid-column: 2 / 3;
      align-self: center;
    }

    .#{$progress}__measure {
      display: inline-block;
      font-size: var(--#{$progress}--m-outside__measure--FontSize);

      &.pf-m-static-width {
        min-width: var(--#{$progress}__measure--m-static-width--MinWidth);
        text-align: start;
      }
    }

    .#{$progress}__bar,
    .#{$progress}__indicator {
      grid-column: 1 / 2;
    }
  }

  // No Description. If a measure or status is needed, use with inside or outside measure modifier.
  &.pf-m-singleline {
    grid-template-rows: 1fr;

    .#{$progress}__description {
      display: none;
    }

    .#{$progress}__bar {
      grid-row: 1 / 2;
      grid-column: 1 / 2;
    }

    .#{$progress}__status {
      grid-row: 1 / 2;
      grid-column: 2 / 3;
    }
  }

  &.pf-m-outside,
  &.pf-m-singleline {
    grid-template-columns: 1fr fit-content(50%);
  }

  // status modifiers
  &.pf-m-success {
    --#{$progress}__indicator--BackgroundColor: var(--#{$progress}--m-success__indicator--BackgroundColor);
    --#{$progress}__status-icon--Color: var(--#{$progress}--m-success__status-icon--Color);
    --#{$progress}--m-inside__measure--Color: var(--#{$progress}--m-success--m-inside__measure--Color);
  }

  &.pf-m-warning {
    --#{$progress}__indicator--BackgroundColor: var(--#{$progress}--m-warning__indicator--BackgroundColor);
    --#{$progress}__status-icon--Color: var(--#{$progress}--m-warning__status-icon--Color);
    --#{$progress}--m-inside__measure--Color: var(--#{$progress}--m-warning--m-inside__measure--Color);
  }

  &.pf-m-danger {
    --#{$progress}__indicator--BackgroundColor: var(--#{$progress}--m-danger__indicator--BackgroundColor);
    --#{$progress}__status-icon--Color: var(--#{$progress}--m-danger__status-icon--Color);
    --#{$progress}--m-inside__measure--Color: var(--#{$progress}--m-danger--m-inside__measure--Color);

    .#{$progress}__bar {
      @media (prefers-reduced-motion: no-preference) {
        @include pf-v6-animate-danger-jiggle;
      }
    }

    .#{$progress}__status-icon {
      @include pf-v6-fade-default(#{$progress});
    }
  }
}

// Elements

// the progress__description is displayed above the progress bar on the left
.#{$progress}__description {
  grid-column: 1 / 2;
  word-break: break-word;

  &.pf-m-truncate {
    @include pf-v6-text-overflow;
  }
}

// the progress__status is displayed in the upper right
.#{$progress}__status {
  display: flex;
  grid-row: 1 / 2;
  grid-column: 2 / 3;
  gap: var(--#{$progress}__status--Gap);
  align-items: flex-start;
  justify-content: flex-end;
  text-align: end;
  word-break: break-word;
}

// the progress__status-icon is an icon displayed always in the upper right
.#{$progress}__status-icon {
  color: var(--#{$progress}__status-icon--Color);
}

.#{$progress}__bar::before,
.#{$progress}__indicator {
  // disable linter as the indicator element should always grow ltr
  // stylelint-disable liberty/use-logical-spec
  inset-block-start: 0;
  inset-inline-start: 0;
  // stylelint-enable
}

// The progress__bar is a white underlay with a semi-transparent color on top, which matches the progress__indicator color
.#{$progress}__bar {
  position: relative;
  grid-row: 2 / 3;
  grid-column: 1 / 3;
  align-self: center;
  height: var(--#{$progress}__bar--Height);
  overflow: hidden;
  background-color: var(--#{$progress}__bar--BackgroundColor);
  border-radius: var(--#{$progress}__bar--BorderRadius);

  &::before {
    position: absolute;
    inset: 0;
    pointer-events: none;
    content: '';
    border: var(--#{$progress}__bar--BorderWidth) solid var(--#{$progress}__bar--BorderColor);
    border-radius: inherit;
  }
}

// the progress__indicator is the part that advances (widens) as progress is made
// It is assumed that the width of the progress__indicator is set inline or via Javascript
.#{$progress}__indicator {
  position: absolute; // position absolute to bring above the semi-transparent bar overlay
  height: var(--#{$progress}__indicator--Height);
  background-color: var(--#{$progress}__indicator--BackgroundColor);

  // for forced colors mode
  &::before {
    position: absolute;
    inset: 0;
    content: "";
    border: var(--#{$progress}__indicator--BorderWidth) solid var(--#{$progress}__indicator--BorderColor);
    border-radius: var(--#{$progress}__bar--BorderRadius);
  }
}

.#{$progress}__helper-text {
  grid-row: 3 / 4;
  grid-column: 1 / 3;
  margin-block-start: var(--#{$progress}__helper-text--MarginBlockStart);
}

.#{$progress}__measure {
  font-variant-numeric: tabular-nums;
}