Skip to content

Conversation

@susnux
Copy link
Contributor

@susnux susnux commented Sep 15, 2025

☑️ Resolves

This consists of multiple refactoring as you can review individually with each commit.
Basically this migrates the component to Typescript and then to script-setup with new consistent tag order.
By doing so also removed the last JS util (Timer) and just uses the useIntervalFn from vueuse.

🏁 Checklist

  • ⛑️ Tests are included or are not applicable
  • 📘 Component documentation has been extended, updated or is not applicable
  • 2️⃣ Backport to stable8 for maintained Vue 2 version or not applicable

@susnux susnux added this to the 9.0.0 milestone Sep 15, 2025
@susnux susnux added 3. to review Waiting for reviews feature: modal Related to the modal component refactor ♻️ Pull request that is neither a fix nor a feature labels Sep 15, 2025
@susnux susnux force-pushed the refactor/nc-modal-ts branch from a488070 to 09e25d7 Compare September 15, 2025 09:09
@susnux susnux force-pushed the refactor/nc-modal-ts branch from 09e25d7 to 8ad5ebb Compare September 15, 2025 09:20
@Antreesy Antreesy modified the milestones: 9.0.0, 9.0.1 Oct 1, 2025
@susnux susnux modified the milestones: 9.0.1, 9.0.2 Oct 6, 2025
@susnux susnux modified the milestones: 9.0.2, 9.1.0 Oct 14, 2025
@susnux susnux removed the request for review from st3iny November 4, 2025 11:31
@susnux susnux modified the milestones: 9.1.0, 9.2.0 Nov 4, 2025
- Use Typescript for component
- Use vueuse composable instead of custom Timer class

Signed-off-by: Ferdinand Thiessen <[email protected]>
Instead of dialog example where we recommend to use NcDialog we should
provide an example on how to use the slideshow feature.

Signed-off-by: Ferdinand Thiessen <[email protected]>
1. Script
2. Template
3. Styles
4. Docs

Signed-off-by: Ferdinand Thiessen <[email protected]>
@susnux susnux force-pushed the refactor/nc-modal-ts branch from 8ad5ebb to d4641da Compare November 7, 2025 17:11
@susnux
Copy link
Contributor Author

susnux commented Nov 7, 2025

(just a rebase for CI)

@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 50 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.20%. Comparing base (82d7687) to head (d4641da).

Files with missing lines Patch % Lines
src/components/NcModal/NcModal.vue 50.00% 37 Missing and 13 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7514      +/-   ##
==========================================
+ Coverage   51.41%   52.20%   +0.78%     
==========================================
  Files          96       95       -1     
  Lines        3147     3090      -57     
  Branches      867      863       -4     
==========================================
- Hits         1618     1613       -5     
+ Misses       1279     1235      -44     
+ Partials      250      242       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@susnux susnux requested a review from ShGKme November 12, 2025 20:38
@ShGKme
Copy link
Contributor

ShGKme commented Nov 12, 2025

I'll check on the morning

@ShGKme ShGKme removed this from the 9.2.0 milestone Nov 14, 2025
@ShGKme ShGKme added this to the 9.3.0 milestone Nov 14, 2025
Copy link
Contributor

@ShGKme ShGKme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicks only.

Thanks for splitting into commits.

Comment on lines +1015 to +1016
--slideshow-duration: v-bind('cssSlideshowDelay');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this variable needed? Cannot we use v-bind('cssSlideshowDelay') directly where the variable is used? Otherwise it looks like creating a CSS variable just to define another CSS variable just to use it in a single place.

}>()
const modalId = createElementId()
const maskElement = useTemplateRef<HTMLDivElement>('mask')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const maskElement = useTemplateRef<HTMLDivElement>('mask')
const maskElement = useTemplateRef('mask')

const modalId = createElementId()
const maskElement = useTemplateRef<HTMLDivElement>('mask')
const internalShow = ref(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me we can simplify the component by just using defineModel. Then we don't need the second state, and the rest around the value is simpler. Is there anything blocking it I'm missing?

useHotKey('Escape', () => {
const trapStack = getTrapStack()
// Only close the most recent focus trap modal
if (trapStack.length === 0 || trapStack[trapStack.length - 1] === focusTrap) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (trapStack.length === 0 || trapStack[trapStack.length - 1] === focusTrap) {
if (trapStack.at(-1) === focusTrap) {

import { mdiChevronLeft, mdiChevronRight, mdiClose, mdiPause, mdiPlay } from '@mdi/js'
import { useIntervalFn, useSwipe } from '@vueuse/core'
import { createFocusTrap } from 'focus-trap'
import { computed, nextTick, onMounted, onUnmounted, ref, toRef, useTemplateRef, warn as VueWarn, watch, watchEffect } from 'vue'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warn as VueWarn

Seems like we can just use warn now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews feature: modal Related to the modal component refactor ♻️ Pull request that is neither a fix nor a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants