@playpilot/tpi 8.5.0 → 8.5.2

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": "@playpilot/tpi",
3
- "version": "8.5.0",
3
+ "version": "8.5.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -43,7 +43,7 @@
43
43
  let recentlyExpanded = false
44
44
 
45
45
  onMount(() => {
46
- if (expandable) expandFirstAvailableTrailer()
46
+ if (expandable) expandWhenFirstInView()
47
47
  })
48
48
 
49
49
  function openTitle(event: MouseEvent | null, titles: TitleData[], index: number): void {
@@ -75,18 +75,15 @@
75
75
  onclick(title)
76
76
  }
77
77
 
78
- async function expandFirstAvailableTrailer(delay = 500): Promise<void> {
78
+ async function expandFirstAvailableTrailer(): Promise<void> {
79
79
  const response = await titles
80
-
81
80
  const title = await getFirstTitleWithAvailableTrailer(response)
82
- if (!title) return
83
81
 
84
- setTimeout(() => {
85
- if (expandedTitle) return
86
- if (expandedRailKey && expandedRailKey !== key) return
82
+ if (!title) return
83
+ if (expandedTitle) return
84
+ if (expandedRailKey && expandedRailKey !== key) return
87
85
 
88
- expandTitleIntoTrailer(title)
89
- }, delay)
86
+ expandTitleIntoTrailer(title)
90
87
  }
91
88
 
92
89
  function expandTitleIntoTrailer(title: TitleData): void {
@@ -98,14 +95,14 @@
98
95
  if (expandedRailKey === key) return
99
96
 
100
97
  const elements = Array.from(document.querySelectorAll('[data-role="expandable-rail"]')) as HTMLElement[]
101
- const elementsInView = elements.filter(element => element.getBoundingClientRect().top > 0)
98
+ const elementsInView = elements.filter(element => element.getBoundingClientRect().top >= 0)
102
99
  const elementsSortedByDistance = elementsInView.sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top)
103
100
 
104
101
  if (elementsSortedByDistance[0] !== element) return
105
102
 
106
103
  expandedTitle = null
107
104
  expandedRailKey = null
108
- expandFirstAvailableTrailer(0)
105
+ expandFirstAvailableTrailer()
109
106
  }
110
107
 
111
108
  function isExpanded(title: TitleData): boolean {
@@ -185,7 +182,7 @@
185
182
  <!-- svelte-ignore a11y_click_events_have_key_events -->
186
183
  <!-- svelte-ignore a11y_no_static_element_interactions -->
187
184
  <div class="aside" {onclick} data-testid="aside">
188
- {title.description}
185
+ {title.blurb || title.description}
189
186
  </div>
190
187
  {/if}
191
188
  </div>
@@ -345,7 +342,7 @@
345
342
  overflow: hidden;
346
343
  color: theme(rail-text-color, text-color-alt) !important;
347
344
  font-size: 0.9em;
348
- line-height: 1.2;
345
+ line-height: 1.3;
349
346
  }
350
347
 
351
348
  .skeleton {
@@ -69,7 +69,7 @@ describe('TitlesRail.svelte', () => {
69
69
 
70
70
  expect(getByTestId('title').classList).not.toContain('expanded')
71
71
 
72
- await new Promise(res => setTimeout(res, 1000))
72
+ await new Promise(res => setTimeout(res, 200))
73
73
 
74
74
  expect(getByTestId('title').classList).toContain('expanded')
75
75
  })
@@ -79,7 +79,7 @@ describe('TitlesRail.svelte', () => {
79
79
 
80
80
  expect(getByTestId('title').classList).not.toContain('expanded')
81
81
 
82
- await new Promise(res => setTimeout(res, 1000))
82
+ await new Promise(res => setTimeout(res, 200))
83
83
 
84
84
  expect(getByTestId('title').classList).not.toContain('expanded')
85
85
  })
@@ -89,32 +89,24 @@ describe('TitlesRail.svelte', () => {
89
89
 
90
90
  expect(getByTestId('title').classList).not.toContain('expanded')
91
91
 
92
- await new Promise(res => setTimeout(res, 1000))
93
-
94
92
  expect(getByTestId('title').classList).not.toContain('expanded')
95
93
  })
96
94
 
97
95
  it('Should not expand if a different rail key is given', async () => {
98
96
  const { getAllByTestId } = render(TitlesRail, { titles: [title], expandable: true, expandedRailKey: 'Not this rail' })
99
97
 
100
- await new Promise(res => setTimeout(res, 1000))
101
-
102
98
  expect(getAllByTestId('title')[0].classList).not.toContain('expanded')
103
99
  })
104
100
 
105
101
  it('Should not expand if a title is given that is not present in this rail', async () => {
106
102
  const { getAllByTestId } = render(TitlesRail, { titles: [title], expandable: true, expandedTitle: { ...title, sid: 'not' } })
107
103
 
108
- await new Promise(res => setTimeout(res, 1000))
109
-
110
104
  expect(getAllByTestId('title')[0].classList).not.toContain('expanded')
111
105
  })
112
106
 
113
107
  it('Should not expand if a title is given that is in this rail but expandedRailKey is not this rail', async () => {
114
108
  const { getAllByTestId } = render(TitlesRail, { titles: [title], expandable: true, expandedTitle: title, expandedRailKey: 'Not this rail' })
115
109
 
116
- await new Promise(res => setTimeout(res, 1000))
117
-
118
110
  expect(getAllByTestId('title')[0].classList).not.toContain('expanded')
119
111
  })
120
112