@citizenplane/pimp 18.10.2 → 18.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citizenplane/pimp",
3
- "version": "18.10.2",
3
+ "version": "18.10.3",
4
4
  "scripts": {
5
5
  "dev": "storybook dev -p 8081",
6
6
  "build-storybook": "storybook build --output-dir ./docs",
@@ -184,17 +184,6 @@ const getUnderlineElement = () => {
184
184
  return underlineElement
185
185
  }
186
186
 
187
- // NOTE: fix mimatch width between active underline & focus outline of active tab
188
- const getUnderlineInset = () => {
189
- if (props.variant !== 'underline') return 0
190
-
191
- const rootStyle = getComputedStyle(document.documentElement)
192
- const rootFontSize = Number.parseFloat(rootStyle.fontSize)
193
- const insetRem = Number.parseFloat(rootStyle.getPropertyValue('--cp-dimensions-0_5'))
194
-
195
- return rootFontSize * insetRem
196
- }
197
-
198
187
  const setUnderlineStyle = () => {
199
188
  const activeTabElement = getActiveTabElement()
200
189
  const underlineElement = getUnderlineElement()
@@ -202,10 +191,12 @@ const setUnderlineStyle = () => {
202
191
 
203
192
  if (!activeTabElement || !underlineElement || !containerElement) return
204
193
 
205
- const inset = getUnderlineInset()
194
+ const containerRect = containerElement.getBoundingClientRect()
195
+ const tabRect = activeTabElement.getBoundingClientRect()
196
+ const left = tabRect.left - containerRect.left + containerElement.scrollLeft
206
197
 
207
- underlineElement.style.width = `${activeTabElement.offsetWidth - inset * 2}px`
208
- underlineElement.style.transform = `translate3d(${activeTabElement.offsetLeft + inset}px, 0, 0)`
198
+ underlineElement.style.width = `${tabRect.width}px`
199
+ underlineElement.style.transform = `translate3d(${left}px, 0, 0)`
209
200
  }
210
201
 
211
202
  const scrollToActiveElement = (behavior: ScrollBehavior = 'smooth') => {
@@ -298,7 +289,7 @@ watch(
298
289
  opacity 300ms ease;
299
290
 
300
291
  &:focus-visible {
301
- outline-offset: calc(var(--cp-dimensions-0_5) * -1);
292
+ outline-offset: 0;
302
293
  }
303
294
 
304
295
  &--isLoading {
@@ -349,6 +340,25 @@ watch(
349
340
  .cpTabs__tab:focus-visible {
350
341
  border-bottom-left-radius: 0;
351
342
  border-bottom-right-radius: 0;
343
+ outline: none;
344
+
345
+ &::before {
346
+ position: absolute;
347
+ border: var(--cp-dimensions-0_5) solid var(--cp-border-accent-solid);
348
+ border-radius: inherit;
349
+ border-bottom: none;
350
+ content: '';
351
+ inset: 0;
352
+ pointer-events: none;
353
+ }
354
+
355
+ &.cpTabs__tab--isActive::before {
356
+ border-bottom: var(--cp-dimensions-0_5) solid var(--cp-border-accent-solid);
357
+ }
358
+ }
359
+
360
+ .cpTabs__tab--isActive:focus-visible ~ .cpTabs__activeUnderline--isUnderline {
361
+ opacity: 0;
352
362
  }
353
363
  }
354
364