File: tab_group.html

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (204 lines) | stat: -rw-r--r-- 5,816 bytes parent folder | download | duplicates (9)
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
<style>
:host {
  --tabstrip-tab-group-title-height: 22px;
  --tabstrip-tab-group-title-margin: var(--tabstrip-tab-spacing);
  --tab-thumbnail-height-in-group: calc(var(--tabstrip-tab-thumbnail-height) -
      var(--tabstrip-tab-group-title-height) -
      var(--tabstrip-tab-group-title-margin));
  --tab-thumbnail-width-in-group: calc(var(--tab-thumbnail-height-in-group) *
      var(--tabstrip-tab-thumbnail-aspect-ratio));
}

:host(:empty:not([dragging])) {
  /* A tab group can temporarily become empty as a tab is being dragged out. */
  display: none;
}

:host([dragged-out_]) {
  display: none;
}

#tabGroup {
  border-radius: 8px;
  box-shadow: 0 0 0 2px rgb(var(--tabstrip-tab-group-color-rgb));
  padding: var(--tabstrip-tab-spacing);
}

#chipContainer {
  min-width: 100%;
  position: relative;
  width: 0;
}

#chip {
  display: inline-block;
  height: var(--tabstrip-tab-group-title-height);
  margin-bottom: var(--tabstrip-tab-group-title-margin);
  max-width: 100%;
}

#chip:focus {
  outline: none;
}

#title {
  background: rgb(var(--tabstrip-tab-group-color-rgb));
  border-radius: 4px;
  box-sizing: border-box;
  color: rgb(var(--tabstrip-tab-group-text-color-rgb));
  display: inline-block;
  height: var(--tabstrip-tab-group-title-height);
  line-height: var(--tabstrip-tab-group-title-height);
  max-width: 100%;
  overflow: hidden;
  padding: 0 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#title:empty {
  border-radius: 50%;
  height: 16px;
  margin-top: 4px;
  width: 16px;
}

#chip:focus #title {
  box-shadow: 0 0 0 2px var(--color-web-ui-tab-strip-focus-outline);
  outline: none;
}

/*
 * When the drag starts, the tab group will shrink and the tabs will stack
 * together. If the touch position is outside the draggable element the drag
 * will be cancelled. In order to prevent that, the dragHandle is set to the
 * width of the thumbnail to make sure it's still under touch position after
 * the tab group shrinks.
 */
#dragHandle {
  height: 100%;
  position: absolute;
  top: 0;
  width: var(--tab-thumbnail-width-in-group);
}

#tabs {
  display: flex;
  min-width: fit-content;
}

:host ::slotted(tabstrip-tab) {
  --tabstrip-tab-thumbnail-height: var(--tab-thumbnail-height-in-group);
  --tabstrip-tab-thumbnail-width: var(--tab-thumbnail-width-in-group);

  /* Recalculate tab heights and widths off new thumbnail sizes. */
  --tabstrip-tab-height: calc(var(--tabstrip-tab-title-height) +
                              var(--tabstrip-tab-thumbnail-height));
  --tabstrip-tab-width: var(--tabstrip-tab-thumbnail-width);
}

:host([getting-drag-image_]) #dragImage {
  /* Enough padding for the drop shadow on #tabGroup. The position of the
     drag image is translated with the same value as the padding, to ensure
     that the drag image stays in the same position as it would be without
     padding. This is to ensure drag events do not get canceled as drag targets
     move around. */
  --drag-image-padding: 25px;
  padding: var(--drag-image-padding);
  transform: translate(
      calc(var(--drag-image-x-direction, -1) * var(--drag-image-padding)),
      calc(-1 * var(--drag-image-padding)));
}

:host-context([dir='rtl']):host([getting-drag-image_]) #dragImage {
  --drag-image-x-direction: 1;
}

:host([getting-drag-image_]) #tabGroup {
  background: var(--color-web-ui-tab-strip-background);
  border-radius: var(--tabstrip-tab-border-radius);
  box-shadow: var(--tabstrip-tab-dragging-shadow);
  height: var(--tabstrip-tab-height);
  overflow: hidden;
  transform: scale(var(--tabstrip-tab-drag-image-scale));
}

:host([getting-drag-image_]) ::slotted(tabstrip-tab) {
  --tabstrip-tab-active-border-color:
      var(--color-web-ui-tab-strip-tab-separator);
}

:host([getting-drag-image_]) ::slotted(tabstrip-tab:first-child) {
  /* Make sure the first tab is always above the other tabs. */
  z-index: 4;
}

:host([getting-drag-image_]) ::slotted(tabstrip-tab:nth-child(2)),
:host([getting-drag-image_]) ::slotted(tabstrip-tab:nth-child(3)),
:host([getting-drag-image_]) ::slotted(tabstrip-tab:nth-child(4)),
:host([getting-drag-image_]) ::slotted(tabstrip-tab:nth-child(5)) {
  /* Add a negative margin to the 2nd - 5th tab to move them behind the first
     tab to give an impression that they are a stacked group of tabs.
     Transform cannot be used here since we also want the space the tabs
     take up to be moved. */
  margin-inline-start: calc(-1 * var(--tabstrip-tab-width));
}

:host([getting-drag-image_]) ::slotted(tabstrip-tab:nth-child(2)) {
  z-index: 3;
}

:host([getting-drag-image_]) ::slotted(tabstrip-tab:nth-child(3)) {
  z-index: 2;
}

:host([getting-drag-image_]) ::slotted(tabstrip-tab:nth-child(4)) {
  z-index: 1;
}

:host([getting-drag-image_]) ::slotted(tabstrip-tab:nth-child(5)) {
  padding: 0;
  z-index: 0;
}

:host([getting-drag-image_]) ::slotted(tabstrip-tab:nth-child(n + 6)) {
  display: none;
}

:host([dragging]) #dragPlaceholder {
  background: var(--color-web-ui-tab-strip-tab-background);
  border-radius: var(--tabstrip-tab-border-radius);
  height: var(--tabstrip-tab-height);
  opacity: 0.5;
  width: var(--tabstrip-tab-width);
}

:host([dragging]) #dragImage {
  /* Position the actual drag image out of view so it is not visible. */
  position: absolute;
  top: calc(100vh + var(--drag-image-padding));
}

:host([touch_pressed_]) #dragImage {
  transform: scale(1.1);
  transform-origin: center;
  transition-duration: 300ms;
}
</style>

<div id="dragPlaceholder"></div>

<div id="dragImage">
  <div id="tabGroup">
    <div id="chipContainer">
      <div id="chip" tabindex="0" role="button"
         aria-describedby="tabs">
        <div id="title"></div>
        <div id="dragHandle" draggable="true"></div>
      </div>
    </div>
    <div id="tabs">
      <slot></slot>
    </div>
  </div>
</div>