toolbarbuttons.css (19838B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 @namespace html url("http://www.w3.org/1999/xhtml"); 6 7 :root { 8 --toolbar-start-end-padding: 8px; 9 10 --toolbarbutton-hover-background: color-mix(in srgb, currentColor 17%, transparent); 11 --toolbarbutton-active-background: color-mix(in srgb, currentColor 30%, transparent); 12 --toolbarbutton-outline-color: transparent; 13 --toolbarbutton-hover-outline-color: transparent; 14 --toolbarbutton-active-outline-color: transparent; 15 --toolbarbutton-selected-outline-color: var(--toolbarbutton-active-outline-color); 16 --toolbarbutton-outline: 1px solid var(--toolbarbutton-outline-color); 17 --toolbarbutton-outline-offset: -1px; 18 19 @media (prefers-contrast) { 20 --toolbarbutton-hover-outline-color: currentColor; 21 --toolbarbutton-active-outline-color: currentColor; 22 } 23 24 @media (forced-colors) { 25 --toolbarbutton-outline-color: ButtonText; 26 --toolbarbutton-hover-outline-color: SelectedItem; 27 --toolbarbutton-active-outline-color: ButtonText; 28 --toolbarbutton-selected-outline-color: SelectedItem; 29 30 &[lwtheme] { 31 --toolbarbutton-outline-color: currentColor; 32 } 33 } 34 35 --toolbarseparator-color: color-mix(in srgb, currentColor 60%, transparent); 36 37 /*** Button sizes w/ adjustments for small windows and uidensity modes. ***/ 38 39 --toolbarbutton-outer-padding: 2px; 40 --toolbarbutton-inner-padding: 8px; 41 --bookmark-block-padding: 4px; 42 43 &:where([uidensity="touch"]) { 44 --toolbarbutton-inner-padding: 9px; 45 --bookmark-block-padding: 7px; 46 } 47 @media (width <= 900px) { 48 --toolbarbutton-outer-padding: 1px; 49 } 50 @media (width <= 800px) { 51 --toolbarbutton-inner-padding: 7px; 52 &:where([uidensity="touch"]) { 53 --toolbarbutton-inner-padding: 8px; 54 } 55 } 56 /* 700px is just above half of the popular 1366px screen width, so two browser 57 windows put next to each other will be below this threshold. */ 58 @media (width <= 700px) { 59 --toolbarbutton-inner-padding: 6px; 60 } 61 &:where([uidensity="compact"]) { 62 --toolbarbutton-inner-padding: 6px; 63 --bookmark-block-padding: 1px; 64 } 65 } 66 67 #TabsToolbar { 68 /* Override the inner padding to ensure the dimensions match the tabs, but also making sure 69 different types of buttons (combined-buttons-dropmarker or text) still look correct. */ 70 @media (width > 900px) { 71 --toolbarbutton-inner-padding: calc((var(--tab-min-height) - 16px) / 2); 72 } 73 } 74 75 /* Primary toolbar buttons */ 76 77 .toolbarbutton-1 { 78 :root:not([customizing]) &[disabled] { 79 opacity: var(--toolbarbutton-disabled-opacity); 80 } 81 82 /* Special-case the overflow and the hamburger button so they show up disabled 83 in customize mode. */ 84 &:is(#nav-bar-overflow-button, #PanelUI-menu-button)[disabled] { 85 fill-opacity: var(--toolbarbutton-disabled-opacity); 86 } 87 88 > .toolbarbutton-icon, 89 > .toolbarbutton-badge-stack > .toolbarbutton-icon { 90 width: 16px; 91 } 92 } 93 94 /* Taskbar Tab windows will hide all toolbar buttons that are not on the following list */ 95 96 :root[taskbartab] toolbar { 97 .chromeclass-toolbar-additional { 98 display: none; 99 } 100 #back-button, 101 #forward-button, 102 #stop-reload-button, 103 #customizableui-special-spring1, 104 #customizableui-special-spring2, 105 #downloads-button, 106 #unified-extensions-button, 107 .unified-extensions-item, 108 #save-page-button, 109 #print-button, 110 #find-button, 111 #zoom-controls, 112 #edit-controls, 113 #characterencoding-button, 114 #email-link-button, 115 #screenshot-button, 116 #nav-bar-overflow-button, 117 #taskbar-tabs-audio:is([soundplaying], [muted]), 118 #fullscreen-button { 119 display: revert; 120 } 121 } 122 123 toolbar .toolbarbutton-1 { 124 appearance: none; 125 margin: 0; 126 padding: 0 var(--toolbarbutton-outer-padding); 127 justify-content: center; 128 129 > .toolbarbutton-icon, 130 > .toolbarbutton-text, 131 > .toolbarbutton-badge-stack { 132 padding: var(--toolbarbutton-inner-padding); 133 border-radius: var(--toolbarbutton-border-radius); 134 outline: var(--toolbarbutton-outline); 135 outline-offset: var(--toolbarbutton-outline-offset); 136 } 137 138 &:focus-visible { 139 outline: none; 140 141 > .toolbarbutton-icon, 142 > .toolbarbutton-text, 143 > .toolbarbutton-badge-stack { 144 outline: var(--focus-outline); 145 outline-offset: var(--focus-outline-inset); 146 } 147 } 148 149 > .toolbarbutton-icon { 150 /* horizontal padding + actual icon width */ 151 width: calc(2 * var(--toolbarbutton-inner-padding) + 16px); 152 height: calc(2 * var(--toolbarbutton-inner-padding) + 16px); 153 } 154 155 > .toolbarbutton-text { 156 padding-top: calc(var(--toolbarbutton-inner-padding) - 1px); 157 padding-bottom: 0; 158 /* To make the hover feedback line up with sibling buttons, it needs the same 159 * height as the button icons and the same vertical padding, but as a minimum, 160 * because otherwise an increase in text sizes would break things. 161 */ 162 min-height: calc(16px + 2 * var(--toolbarbutton-inner-padding)); 163 164 @media (-moz-platform: macos) { 165 padding-top: calc(var(--toolbarbutton-inner-padding) + 1px); 166 } 167 } 168 169 &:not([disabled]) { 170 &:hover > :is(.toolbarbutton-icon, .toolbarbutton-text, .toolbarbutton-badge-stack) { 171 background-color: var(--toolbarbutton-hover-background); 172 color: inherit; 173 } 174 175 &:is(:hover:active, [open], [checked]) > :is(.toolbarbutton-icon, .toolbarbutton-text, .toolbarbutton-badge-stack) { 176 background-color: var(--toolbarbutton-active-background); 177 color: inherit; 178 } 179 180 &:not(:focus-visible) { 181 &:hover > :is(.toolbarbutton-icon, .toolbarbutton-text, .toolbarbutton-badge-stack) { 182 outline-color: var(--toolbarbutton-hover-outline-color); 183 } 184 185 &:hover:active > :is(.toolbarbutton-icon, .toolbarbutton-text, .toolbarbutton-badge-stack) { 186 outline-color: var(--toolbarbutton-active-outline-color); 187 } 188 189 &:is([open], [checked]) > :is(.toolbarbutton-icon, .toolbarbutton-text, .toolbarbutton-badge-stack) { 190 outline-color: var(--toolbarbutton-selected-outline-color); 191 } 192 } 193 } 194 195 &.avatar-button-background > .toolbarbutton-badge-stack { 196 border: 1px solid var(--border-color-card); 197 } 198 } 199 200 #TabsToolbar .toolbarbutton-1 { 201 margin: 0; 202 203 > .toolbarbutton-icon, 204 > .toolbarbutton-text, 205 > .toolbarbutton-badge-stack { 206 border-radius: var(--tab-border-radius); 207 } 208 } 209 210 #PanelUI-menu-button { 211 /* Adds padding to end of toolbar while making that space click the first button */ 212 padding-inline-end: var(--toolbar-start-end-padding); 213 } 214 215 toolbar .toolbaritem-combined-buttons { 216 margin-inline: 2px; 217 218 > .toolbarbutton-1 { 219 padding-inline: 0; 220 } 221 222 > .toolbarbutton-combined-buttons-dropmarker > .toolbarbutton-icon { 223 /* same height as regular buttons, but narrower, and for a 12x12 image */ 224 padding-inline: 2px; 225 padding-block: calc(var(--toolbarbutton-inner-padding) + (16px - 12px) / 2); 226 width: calc(2 * 2px + 12px); 227 } 228 } 229 230 .toolbaritem-combined-buttons { 231 > separator { 232 width: 0; 233 height: 16px; 234 pointer-events: none; 235 236 /* place the border on a pseudo-element so that 237 the separator doesn't take up any space */ 238 &::before { 239 content: ""; 240 border-inline-start: 1px solid currentColor; 241 } 242 243 toolbar & { 244 color: light-dark(color-mix(in srgb, currentColor 20%, transparent), color-mix(in srgb, currentColor 30%, transparent)); 245 } 246 } 247 248 > separator:has(+ toolbarbutton:not([disabled]):hover), 249 > toolbarbutton:not([disabled]):hover + separator { 250 opacity: 0; 251 } 252 } 253 254 .toolbarbutton-combined-buttons-dropmarker { 255 appearance: none; 256 -moz-context-properties: fill; 257 fill: currentColor; 258 list-style-image: url("chrome://global/skin/icons/arrow-down-12.svg"); 259 } 260 261 /* Toolbar button animations */ 262 263 .toolbarbutton-animatable-box { 264 display: block; 265 position: absolute; 266 overflow: hidden; 267 z-index: 2; 268 pointer-events: none; 269 270 > .toolbarbutton-animatable-image { 271 animation-fill-mode: forwards; 272 animation-iteration-count: 1; 273 list-style-image: none; 274 } 275 } 276 277 /* Navigation toolbar overflow button with animation */ 278 279 #nav-bar-overflow-button { 280 list-style-image: url("chrome://global/skin/icons/chevron.svg"); 281 282 #nav-bar:not([overflowing], [nonemptyoverflow], [customizing]) > & { 283 display: none; 284 } 285 286 /* The button should look both disabled and open in customize mode. */ 287 #nav-bar[customizing] > & > .toolbarbutton-icon { 288 background-color: var(--toolbarbutton-active-background); 289 } 290 291 > .toolbarbutton-animatable-box { 292 visibility: hidden; 293 top: calc(50% - 8px); /* Vertically center the 16px tall animatable image */ 294 width: 16px; /* Width of each frame within the SVG sprite */ 295 height: 16px; /* Height of each frame within the SVG sprite */ 296 -moz-context-properties: fill, stroke; 297 fill: var(--toolbarbutton-icon-fill); 298 stroke: var(--toolbarbutton-icon-fill-attention); 299 300 > .toolbarbutton-animatable-image { 301 background-image: url("chrome://browser/skin/chevron-animation.svg"); 302 width: 848px; 303 height: 16px; 304 transform: translateX(0); 305 } 306 } 307 308 &[animate] { 309 > .toolbarbutton-icon { 310 fill: transparent; 311 } 312 313 > .toolbarbutton-animatable-box { 314 visibility: visible; 315 316 > .toolbarbutton-animatable-image { 317 animation-name: overflow-animation; 318 animation-timing-function: steps(52); 319 animation-duration: calc(52 * 16.667ms); 320 } 321 } 322 } 323 } 324 325 @keyframes overflow-animation { 326 from { 327 transform: translateX(0); 328 } 329 /* Bug 1831300 is on file for this. */ 330 /* stylelint-disable-next-line keyframe-block-no-duplicate-selectors */ 331 from { 332 transform: translateX(-832px); 333 } 334 } 335 336 /* Combined Stop and Reload button with animation */ 337 338 #reload-button:not([displaystop]) + #stop-button, 339 #reload-button[displaystop] { 340 display: none; 341 } 342 343 /* The reload-button is only disabled temporarily when it becomes visible 344 to prevent users from accidentally clicking it. We don't however need 345 to show this disabled state, as the flicker that it generates is short 346 enough to be visible but not long enough to explain anything to users. */ 347 #reload-button[disabled]:not(:-moz-window-inactive) > .toolbarbutton-icon { 348 opacity: 1 !important; 349 } 350 351 @keyframes stop-to-reload { 352 /* pause on the first frame (step 0) for 6 frames of time */ 353 from { 354 /* 0 */ 355 transform: translateX(0); 356 } 357 /* resume at 7/35 and animate across the next 14 frames */ 358 17.14% { 359 animation-timing-function: steps(14); 360 transform: translateX(calc(0 * -20px)); 361 } 362 /* pause on the last frame for the remainder of the duration */ 363 54.29% { 364 transform: translateX(calc(14 * -20px)); 365 } 366 to { 367 /* end state for animation: */ 368 transform: translateX(calc(var(--anim-frames) * -20px)); 369 } 370 } 371 372 @keyframes reload-to-stop { 373 /* pause on the first frame (step 0) for 6 frames of time */ 374 from { 375 /* 0 */ 376 transform: translateX(0); 377 animation-timing-function: steps(12); 378 } 379 /* pause at 13/15 for 3 frames */ 380 86.67% { 381 transform: translateX(calc(var(--anim-frames) * -20px)); 382 } 383 to { 384 /* end state for animation: */ 385 transform: translateX(calc(var(--anim-frames) * -20px)); 386 } 387 } 388 389 :is(#reload-button, #stop-button) > .toolbarbutton-animatable-box { 390 top: calc(50% - 10px); /* Vertically center the 20px tall animatable image */ 391 width: 20px; /* Width of each frame within the SVG sprite */ 392 height: 20px; /* Height of each frame within the SVG sprite */ 393 394 /* The animations for the reload-button and stop-button are disabled 395 outside of the nav-bar due to bug 1382894. */ 396 :not(#nav-bar-customization-target) > #stop-reload-button > & { 397 display: none; 398 } 399 } 400 401 #stop-reload-button[animate] { 402 > #reload-button > .toolbarbutton-icon, 403 > #reload-button[displaystop] + #stop-button > .toolbarbutton-icon { 404 fill: transparent; 405 } 406 407 > #reload-button, 408 > #stop-button { 409 position: relative; 410 } 411 412 > #reload-button > .toolbarbutton-animatable-box > .toolbarbutton-animatable-image { 413 background-image: url("chrome://browser/skin/stop-to-reload.svg"); 414 /* transition from stop icon to reload icon 415 pause at frame 0 for 6 ticks, 416 pause at frame 15 for 16 ticks 417 total 35 steps */ 418 --anim-frames: 14; 419 --anim-steps: calc(var(--anim-frames) + 21); /* Add steps for doing the pause at the start and end */ 420 width: calc(20px * (var(--anim-frames) + 1)); 421 height: 20px; 422 423 /* initial state for animation */ 424 transform: translateX(0); 425 } 426 427 > #reload-button:not([displaystop]) > .toolbarbutton-animatable-box > .toolbarbutton-animatable-image { 428 animation-name: stop-to-reload; 429 } 430 431 > #reload-button[displaystop] + #stop-button > .toolbarbutton-animatable-box > .toolbarbutton-animatable-image { 432 background-image: url("chrome://browser/skin/reload-to-stop.svg"); 433 /* transition from reload icon to stop icon 434 pause at end for 3 frames of time 435 pause at ... 436 total 15 steps */ 437 --anim-frames: 12; 438 --anim-steps: calc(var(--anim-frames) + 3); /* Add steps for doing the pause at the start and end */ 439 width: calc(20px * (var(--anim-frames) + 1)); 440 height: 20px; 441 442 /* initial state for animation */ 443 transform: translateX(0); 444 445 animation-name: reload-to-stop; 446 animation-duration: calc(var(--anim-steps) * 16.667ms); 447 } 448 } 449 450 #reload-button:not([displaystop]) > .toolbarbutton-animatable-box > .toolbarbutton-animatable-image { 451 animation-duration: calc(var(--anim-steps) * 16.667ms); 452 } 453 454 #reload-button > .toolbarbutton-animatable-box > .toolbarbutton-animatable-image { 455 transform: translateX(-700px); 456 } 457 458 #reload-button[displaystop] + #stop-button > .toolbarbutton-animatable-box > .toolbarbutton-animatable-image { 459 animation-timing-function: steps(15); 460 animation-duration: 0.25s; 461 transform: translateX(-300px); 462 } 463 464 /* Bookmark buttons */ 465 466 #personal-toolbar-empty-description, 467 toolbarbutton.bookmark-item:not(.subviewbutton) { 468 margin: 2px; 469 padding: var(--bookmark-block-padding) 4px; 470 } 471 472 #PersonalToolbar { 473 /* These should match the sizing of the bookmark-items in the inline axis 474 * (padding and margin, respectively) */ 475 --toolbarbutton-inner-padding: 4px; 476 --toolbarbutton-outer-padding: 2px; 477 478 :root[uidensity="compact"] & { 479 --toolbarbutton-outer-padding: 1px; 480 } 481 482 .toolbarbutton-1 { 483 margin-block: 2px; 484 485 /* Allow icons to grow with the toolbar to match bookmark item heights 486 * 487 * NOTE(emilio): This matches pre-existing behavior but it's inconsistent with 488 * how e.g. combined items work, and maybe we should just remove this. 489 */ 490 align-items: stretch; 491 > .toolbarbutton-icon { 492 height: auto; 493 } 494 > .toolbarbutton-badge-stack { 495 align-items: center; 496 } 497 } 498 } 499 500 toolbarbutton.bookmark-item:not(.subviewbutton) { 501 border-radius: var(--toolbarbutton-border-radius); 502 max-width: 13em; 503 appearance: none; 504 outline: var(--toolbarbutton-outline); 505 outline-offset: var(--toolbarbutton-outline-offset); 506 507 &:not([disabled], [open]):hover { 508 background-color: var(--toolbarbutton-hover-background); 509 color: inherit; 510 outline-color: var(--toolbarbutton-hover-outline-color); 511 } 512 513 &:hover:active:not([disabled]), 514 &[open="true"] { 515 background-color: var(--toolbarbutton-active-background); 516 color: inherit; 517 outline-color: var(--toolbarbutton-active-outline-color); 518 } 519 520 &:focus-visible { 521 outline: var(--focus-outline); 522 outline-offset: var(--focus-outline-inset); 523 } 524 525 :root[uidensity="compact"] & { 526 margin-inline: 1px; 527 } 528 } 529 530 .bookmark-item > .toolbarbutton-icon { 531 width: 16px; 532 height: 16px; 533 534 #PlacesToolbarItems > & { 535 margin-inline-end: 0; 536 } 537 } 538 539 /* This rule applies to bookmark menu items too */ 540 .bookmark-item > label { 541 /* Ensure we use the direction of the bookmarks label instead of the 542 browser locale. */ 543 unicode-bidi: plaintext; 544 /* Preserve whitespace in bookmark names. */ 545 white-space: pre; 546 } 547 548 #personal-toolbar-empty-description { 549 -moz-window-dragging: no-drag; 550 551 /* Ensure that the description is always at least as big as a bookmarks item, 552 * where its icon is 16px (which may be more than inline text height); */ 553 min-height: calc(16px + 2 * var(--bookmark-block-padding)); 554 } 555 556 #bookmarks-toolbar-placeholder { 557 max-width: unset; 558 } 559 560 #bookmarks-toolbar-placeholder, 561 #bookmarks-toolbar-button { 562 display: none; 563 } 564 565 toolbarpaletteitem[place="toolbar"] > #personal-bookmarks > #bookmarks-toolbar-placeholder, 566 toolbarpaletteitem[place="palette"] > #personal-bookmarks > #bookmarks-toolbar-button, 567 #personal-bookmarks:is([overflowedItem="true"], [cui-areatype="panel"]) > #bookmarks-toolbar-button { 568 display: flex; 569 } 570 571 #nav-bar-customization-target > #personal-bookmarks, 572 toolbar:not(#TabsToolbar) > #wrapper-personal-bookmarks, 573 toolbar:not(#TabsToolbar) > #personal-bookmarks { 574 flex: 1 auto; 575 } 576 577 /* Force the display of the label for bookmarks */ 578 .bookmark-item > .toolbarbutton-text { 579 display: flex !important; 580 } 581 582 #PlacesToolbar, 583 #PlacesToolbarItems { 584 min-width: 0; 585 } 586 587 #personal-bookmarks { 588 /* Make sure there's at least space for the chevron */ 589 min-width: calc(16px + 2 * var(--toolbarbutton-inner-padding) + 2 * var(--toolbarbutton-outer-padding)); 590 } 591 592 #managed-bookmarks > .toolbarbutton-icon, 593 #bookmarks-toolbar-placeholder > .toolbarbutton-icon, 594 #PlacesToolbarItems > .bookmark-item > .toolbarbutton-icon[label]:not([label=""]), 595 #PersonalToolbar #import-button > .toolbarbutton-icon, 596 #PersonalToolbar #aboutwelcome-button > .toolbarbutton-icon, 597 #PersonalToolbar #fxms-bmb-button > .toolbarbutton-icon, 598 #OtherBookmarks.bookmark-item[container] > .toolbarbutton-icon { 599 margin-inline-end: 4px; 600 } 601 602 /* Separators */ 603 604 toolbarseparator { 605 color: var(--toolbarseparator-color); 606 padding-block: var(--toolbarbutton-inner-padding); 607 608 #PlacesToolbarItems > & { 609 /* Make separators wider so they're easier to drag. Make them also a bit 610 * smaller visually on the vertical axis */ 611 padding: 4px; 612 } 613 } 614 615 /* Toolbarbutton badge */ 616 617 .toolbarbutton-badge { 618 /* The bookmarks toolbar is smaller than the other toolbars, so we 619 * need to override the badge position to not be cut off. */ 620 #PersonalToolbar & { 621 margin-top: -1px !important; 622 623 :root[uidensity="touch"] & { 624 margin-top: -4px !important; 625 } 626 } 627 628 /* Remove a pixel of margin on the end so that the badge doesn't 629 * overflow the toolbar and push the button into the overflow menu. */ 630 :root[uidensity="compact"] & { 631 margin-inline-end: -7px !important; 632 } 633 634 /* Alternative style for .toolbarbutton-badge used by CFR notifications */ 635 &.feature-callout { 636 width: 14px; 637 height: 14px; 638 min-width: auto; 639 box-shadow: none; 640 border: none; 641 padding: 0; 642 display: block; 643 margin: -7px 0 0 !important; 644 margin-inline-end: -6px !important; 645 background: url(chrome://global/skin/icons/badge-blue.svg); 646 } 647 } 648 649 /* Flexible spacer sizing */ 650 651 toolbarpaletteitem[place="toolbar"][id^="wrapper-customizableui-special-spring"], 652 toolbarspring { 653 flex: 1; 654 min-width: 28px; 655 max-width: 112px; 656 657 #nav-bar &:where(:not(#vertical-spacer)) { 658 flex: 80 80; 659 /* Ensure flexible spacers don't shrink to nothing so they can be 660 * manipulated in customize mode. */ 661 min-width: 10px; 662 } 663 } 664 665 #nav-bar:not([customizing]) toolbarspring:not(#vertical-spacer) { 666 /* Allow flexible spacers to shrink further outside of customize mode. */ 667 min-width: 1px; 668 } 669 670 /* Keyboard navigation */ 671 672 toolbar[keyNav]:not([collapsed], [customizing]) toolbartabstop, 673 #tabbrowser-tabs[orient="vertical"] #tabs-newtab-button, 674 #vertical-tabs-newtab-button { 675 -moz-user-focus: normal; 676 } 677 678 /* IP Protection */ 679 #ipprotection-button.toolbarbutton-1 > .toolbarbutton-icon { 680 width: calc(2 * var(--toolbarbutton-inner-padding) + 35px); 681 padding-block: 0; 682 }