@pocketprep/ui-kit 3.3.1 → 3.4.0

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.
@@ -71,7 +71,7 @@ export default class Checkbox extends Vue {
71
71
  .uikit-checkbox {
72
72
  background: $white;
73
73
  border: 1px solid $steel;
74
- border-radius: 2px;
74
+ border-radius: 3px;
75
75
  width: 18px;
76
76
  height: 18px;
77
77
  display: flex;
@@ -150,7 +150,6 @@ export default class Checkbox extends Vue {
150
150
  color: $white;
151
151
  width: 12px;
152
152
  height: 11.5px;
153
- margin-top: 2px;
154
153
 
155
154
  &--dark {
156
155
  color: $brand-black;
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="uikit-overflow-tooltip">
2
+ <div class="uikit-overflow-tooltip" ref="uikit-overflow-tooltip">
3
3
  <Tooltip
4
4
  v-if="textOverflows && showTooltip"
5
5
  class="uikit-overflow-tooltip__tooltip"
@@ -41,8 +41,33 @@ export default class OverflowTooltip extends Vue {
41
41
  textOverflows = false
42
42
  measurementComplete = false
43
43
  uid = Math.floor(Math.random() * 1e9)
44
+ intersectionObserver: IntersectionObserver | null = null
45
+ isVisible = false
44
46
 
45
47
  mounted () {
48
+ this.checkTextOverflows()
49
+
50
+ // Watch for changes in the element's visibility to recalculate whether the text overflows
51
+ const containerEl = this.$refs['uikit-overflow-tooltip'] as HTMLDivElement | undefined
52
+ if (containerEl) {
53
+ this.intersectionObserver = new IntersectionObserver((entries) => {
54
+ if (!this.isVisible && entries[0]?.isIntersecting) {
55
+ this.measurementComplete = false
56
+ this.$nextTick(() => {
57
+ this.isVisible = true
58
+ this.checkTextOverflows()
59
+ })
60
+ }
61
+ })
62
+ this.intersectionObserver.observe(containerEl)
63
+ }
64
+ }
65
+
66
+ unmounted () {
67
+ this.intersectionObserver?.disconnect()
68
+ }
69
+
70
+ checkTextOverflows () {
46
71
  const content = this.$refs[`content_${this.uid}`] as HTMLElement
47
72
  const contentFullWidth = this.$refs[`content_fullwidth_${this.uid}`] as HTMLElement
48
73
 
@@ -46,22 +46,23 @@ export default class Tooltip extends Vue {
46
46
  mounted () {
47
47
  this.$nextTick(() => {
48
48
  const tooltipEl = document.querySelector(`.uikit-tooltip-popup#tooltip-${this.tooltipId}`) as HTMLElement
49
- const tooltipWidth = tooltipEl.clientWidth
50
49
  const body = document.querySelector('body') as HTMLElement
51
- const leftOffset = this.theme === 'rightalign'
52
- ? 20
53
- : this.theme === 'leftalign'
54
- ? tooltipWidth - 20
55
- : Math.floor(tooltipWidth / 2)
56
- const left = Math.round(tooltipEl.getBoundingClientRect().left + window.pageXOffset - leftOffset)
57
- const top = Math.round(tooltipEl.getBoundingClientRect().top + window.pageYOffset)
58
50
 
51
+ // Get original positioning before adding element to body
52
+ const clientRectTop = tooltipEl.getBoundingClientRect().top
53
+ const clientRectLeft = tooltipEl.getBoundingClientRect().left
54
+ const computedStyle = getComputedStyle(tooltipEl)
55
+ const singleLineTooltipHeight = parseInt(computedStyle.lineHeight)
56
+ + parseInt(computedStyle.paddingTop)
57
+ + parseInt(computedStyle.paddingBottom)
58
+
59
+ // Move element to body
59
60
  tooltipEl.parentNode?.removeChild(tooltipEl)
60
61
  body.appendChild(tooltipEl)
61
- tooltipEl.style.zIndex = '1002'
62
- tooltipEl.style.top = `${top}px`
63
- tooltipEl.style.left = `${left}px`
64
62
  tooltipEl.style.position = 'absolute'
63
+ tooltipEl.style.zIndex = '1002'
64
+
65
+ // Apply Prop styles
65
66
  const propStyle = this.styles
66
67
  if (propStyle) {
67
68
  Object.keys(propStyle).forEach(styleProp => {
@@ -74,6 +75,22 @@ export default class Tooltip extends Vue {
74
75
  triangleEl.style.borderColor = `${tooltipEl.style.backgroundColor} transparent transparent`
75
76
  }
76
77
  }
78
+
79
+ // Apply horizontal positioning before vertical positioning (because the height depends on text wrap)
80
+ const tooltipWidth = tooltipEl.clientWidth
81
+ const leftOffset = this.theme === 'rightalign'
82
+ ? 20
83
+ : this.theme === 'leftalign'
84
+ ? tooltipWidth - 20
85
+ : Math.floor(tooltipWidth / 2)
86
+ const left = Math.round(clientRectLeft + window.pageXOffset - leftOffset)
87
+ tooltipEl.style.left = `${left}px`
88
+
89
+ // Apply vertical positioning
90
+ const top = Math.round(clientRectTop + window.pageYOffset)
91
+ - tooltipEl.clientHeight
92
+ + singleLineTooltipHeight
93
+ tooltipEl.style.top = `${top}px`
77
94
  })
78
95
  }
79
96
 
@@ -102,7 +119,6 @@ export default class Tooltip extends Vue {
102
119
  display: inline-block;
103
120
  cursor: default;
104
121
  user-select: none;
105
- word-wrap: none;
106
122
 
107
123
  &--dark {
108
124
  color: $brand-black;
@@ -112,7 +128,8 @@ export default class Tooltip extends Vue {
112
128
  span {
113
129
  position: relative;
114
130
  z-index: 1;
115
- white-space: nowrap;
131
+ max-width: 400px;
132
+ display: block;
116
133
  }
117
134
 
118
135
  &__triangle {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pocketprep/ui-kit",
3
- "version": "3.3.1",
3
+ "version": "3.4.0",
4
4
  "description": "Pocket Prep UI Kit",
5
5
  "author": "pocketprep",
6
6
  "scripts": {