summaryrefslogtreecommitdiffstats
path: root/browser/components/newtab/content-src/styles/_feature-callout.scss
blob: aa0ba0ed1e9f45525ad8b15d7b6d8ee1fecc8840 (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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

@import 'feature-callout-theme';

$max-z-index: 2147483647;

.onboardingContainer.featureCallout {
  // See _feature-callout-theme.scss for the theme mixins and
  // FeatureCallout.sys.mjs for the color values
  @include light-theme;

  position: absolute;
  transition: opacity 0.5s ease;
  z-index: $max-z-index - 2;
  outline: none;
  color: var(--fc-color);

  @media (prefers-color-scheme: dark) {
    @include dark-theme;
  }

  @media (prefers-contrast) {
    @include hcm-theme;
  }

  // Account for feature callouts that may be rendered in the chrome but
  // displayed on top of content. Each context has its own color scheme, so they
  // may not match. In that case, we use the special media query below.
  &.simulateContent {
    @media (-moz-content-prefers-color-scheme: light) {
      @include light-theme;
    }

    @media (-moz-content-prefers-color-scheme: dark) {
      @include dark-theme;
    }

    @media (prefers-contrast) {
      @include hcm-theme;
    }
  }

  &.hidden {
    opacity: 0;
    pointer-events: none;
  }

  &,
  & .outer-wrapper {
    // auto height to allow for arrow positioning based on height
    height: auto;
  }

  .screen {
    // override transform in about:welcome
    &:dir(rtl) {
      transform: none;
    }

    &[pos='callout'] {
      height: fit-content;
      min-height: unset;
      overflow: visible;

      .logo-container {
        display: flex;
        justify-content: center;

        .brand-logo {
          margin: 30px 45px 0;

          // This may not work for all future messages, so we may want to make
          // flipping the logo image in RTL mode configurable
          &:dir(rtl) {
            transform: rotateY(180deg);
          }
        }
      }

      .welcome-text {
        align-items: baseline;
        text-align: start;
        margin-inline: 30px;
        padding: 20px 0 0;

        h1,
        h2 {
          font-size: 0.8em;
          margin: 0;
          color: inherit;
        }

        h1 {
          font-weight: bold;
        }

        h2 {
          margin-block: 10px;
        }
      }

      // Secondary section is not included in callouts
      .section-secondary {
        display: none;
      }

      .section-main {
        height: fit-content;
        width: fit-content;

        .main-content {
          position: relative;
          overflow: hidden;
          border: 1px solid var(--fc-border);
          box-shadow: 0 2px 6px rgba(0, 0, 0, 15%);
          border-radius: 4px;
          padding-top: 0;
          // Subtract 4px, the block margin of buttons
          padding-bottom: 30px - 4px;
          width: 25em;
          background-color: var(--fc-background);

          .steps {
            height: auto;
            position: absolute;
            // 30px is the margin of the CTAs from the bottom. The CTAs are 32px
            // tall, and the steps are 8px tall. So we need to offset the steps
            // by half the difference in order to center them. = 36px
            bottom: 30px + math.div(32px, 2) - math.div(8px, 2);
            margin: 0 30px;
            padding-block: 0;

            .indicator {
              // using border will show up in Windows High Contrast Mode to improve accessibility.
              border: 4px solid var(--fc-step-color);

              &.current {
                border-color: var(--fc-accent-color);
              }
            }

            & .indicator.current,
            &.progress-bar .indicator.complete {
              border-color: var(--fc-accent-color);
            }
          }
        }

        .dismiss-button {
          font-size: 1em;
          top: 0;
          margin-block: 15px 0;
          margin-inline: 0 15px;
          z-index: $max-z-index;
          background-color: var(--fc-background);
        }
      }

      .action-buttons {
        .primary,
        .secondary-cta .secondary {
          padding: 4px 16px;
          font-size: 0.8em;
          height: 2em;
          background-color: var(--fc-button-background);
        }

        .primary {
          font-weight: bold;
          float: inline-end;
          margin-inline: 10px 30px;
          padding: 4px 16px;
          font-size: 0.8em;
          line-height: 16px;
          min-height: 32px;
        }

        .secondary-cta {
          float: inline-end;
        }
      }

      .action-buttons .primary,
      .action-buttons .secondary-cta .secondary,
      .dismiss-button {
        border-radius: 4px;
        border: 1px solid var(--fc-button-border);
        cursor: pointer;
        color: var(--fc-button-color);

        &:hover {
          background-color: var(--fc-button-background-hover);
          color: var(--fc-button-color-hover);
          border: 1px solid var(--fc-button-border-hover);

          &:active {
            background-color: var(--fc-button-background-active);
            color: var(--fc-button-color-active);
            border: 1px solid var(--fc-button-border-active);
          }
        }

        &:focus-visible {
          box-shadow: none;
          outline: 2px solid var(--fc-accent-color);
          outline-offset: 2px;
        }
      }
    }
  }

  $arrow-size: 24px;
  $arrow-inset-size: math.div($arrow-size, 2);
  // the arrow already overlaps the callout by 12px (see above), but to account
  // for different pixel scaling factors, we can overlap by 1px more, since the
  // border is drawn underneath the callout (on ::after). this is either added
  // to or subtracted from absolute coordinates, depending on the direction.
  $arrow-overlap-inset: -$arrow-inset-size + 1px;

  // applied to all callout arrow foreground and background
  &.callout-arrow::before,
  &.callout-arrow::after {
    content: '';
    position: absolute;
    width: $arrow-size;
    height: $arrow-size;
    transform: rotate(45deg);
    // keep the border crisp under transformation
    transform-style: preserve-3d;
  }

  // color for all arrow foreground
  &.callout-arrow::before {
    z-index: $max-z-index;
    background-color: var(--fc-background);
  }

  // styles for all arrow backgrounds
  &.callout-arrow::after {
    background: transparent;
    outline: 1px solid var(--fc-border);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 15%);
    z-index: -1;
  }

  // up arrow positioning
  &.arrow-top::before,
  &.arrow-top::after {
    top: $arrow-overlap-inset;
    inset-inline-start: calc(50% - $arrow-inset-size);
  }

  // down arrow positioning
  &.arrow-bottom::before,
  &.arrow-bottom::after {
    bottom: $arrow-overlap-inset;
    inset-inline-start: calc(50% - $arrow-inset-size);
  }

  // end arrow positioning
  &.arrow-inline-end::before,
  &.arrow-inline-end::after {
    top: calc(50% - $arrow-inset-size);
    inset-inline-end: $arrow-overlap-inset;
  }

  // start arrow positioning
  &.arrow-inline-start::before,
  &.arrow-inline-start::after {
    top: calc(50% - $arrow-inset-size);
    inset-inline-start: $arrow-overlap-inset;
  }

  // top-end arrow positioning
  &.arrow-top-end::before,
  &.arrow-top-end::after {
    top: $arrow-overlap-inset;
    inset-inline-end: $arrow-inset-size;
  }

  // top-start arrow positioning
  &.arrow-top-start::before,
  &.arrow-top-start::after {
    top: $arrow-overlap-inset;
    inset-inline-start: $arrow-inset-size;
  }

  // hidden arrow display
  &.hidden-arrow::before,
  &.hidden-arrow::after {
    display: none;
  }

  &:focus-visible {
    .screen {
      &[pos='callout'] {
        .section-main .main-content {
          outline: 2px solid var(--fc-accent-color);
          border-color: transparent;

          @media (prefers-contrast) {
            border-color: var(--fc-background);
          }
        }
      }
    }

    &.callout-arrow::after {
      outline: 2px solid var(--fc-accent-color);
    }
  }
}