Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const titleId = useId()
<VueFinalModal
v-model="showAdjustments"
teleport-to="body"
:overlay-class="'vfm__overlay bg-scrim/md-scrim!'"
:overlay-class="'vfm__overlay bg-scrim/md-scrim'"
class="flex items-center justify-center p-4"
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ describe('DeleteEntryModal', () => {
const overlay = document.querySelector('.vfm__overlay')

expect(overlay, 'the modal paints an overlay').not.toBeNull()
expect(overlay!.classList.contains('bg-scrim/md-scrim!'), 'the overlay uses the md3 scrim at 32%').toBe(true)
expect(overlay!.classList.contains('bg-scrim/40!'), 'the old 40% scrim is gone').toBe(false)
expect(overlay!.classList.contains('bg-scrim/md-scrim'), 'the overlay uses the md3 scrim at 32%').toBe(true)
expect(overlay!.classList.contains('bg-scrim/40'), 'the old 40% scrim is gone').toBe(false)
})

it('states that deleting a file cannot be undone', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const scope = computed(() =>
v-if="isOpen"
:model-value="isOpen"
teleport-to="body"
:overlay-class="'vfm__overlay bg-scrim/md-scrim!'"
:overlay-class="'vfm__overlay bg-scrim/md-scrim'"
class="flex items-center justify-center p-4"
@update:model-value="(open) => { if (!open) close() }"
>
Expand Down
2 changes: 1 addition & 1 deletion reposilite-frontend/src/components/md/MdDialog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ describe('MdDialog', () => {
await mountDialog()

const overlay = document.querySelector<HTMLElement>('.vfm__overlay')
expect(overlay?.classList.contains('bg-scrim/md-scrim!'), 'the overlay carries the important bg-scrim/md-scrim utility').toBe(true)
expect(overlay?.classList.contains('bg-scrim/md-scrim'), 'the overlay carries the bg-scrim/md-scrim utility').toBe(true)
expect(overlay!.getAttribute('style') ?? '', 'the overlay has no color-mix inline style').not.toContain('color-mix')
})
})
Expand Down
2 changes: 1 addition & 1 deletion reposilite-frontend/src/components/md/MdDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const onKeydown = (event: KeyboardEvent) => {
<VueFinalModal
:model-value="modelValue"
class="z-md-dialog flex items-center justify-center"
overlay-class="bg-scrim/md-scrim!"
overlay-class="bg-scrim/md-scrim"
:overlay-transition="SCRIM_TRANSITION"
:content-class="contentClass"
:content-transition="PANEL_TRANSITION"
Expand Down
5 changes: 3 additions & 2 deletions reposilite-frontend/src/components/md/MdSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,9 @@ onBeforeUnmount(() => {
:key="option.value"
role="option"
:aria-selected="index === selectedIndex ? 'true' : 'false'"
class="md-state-layer relative flex min-h-12 cursor-pointer items-center gap-3 px-4 md-label-large"
:class="[index === selectedIndex ? 'text-primary' : 'text-on-surface', index === active ? 'md-state-focus!' : '']"
class="md-state-layer data-active:md-state-focus relative flex min-h-12 cursor-pointer items-center gap-3 px-4 md-label-large"
:class="index === selectedIndex ? 'text-primary' : 'text-on-surface'"
:data-active="index === active ? '' : undefined"
@click="chooseIndex(index)"
>
<span class="flex size-6 shrink-0 items-center justify-center">
Expand Down
1 change: 0 additions & 1 deletion reposilite-frontend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { loadFrontendSettings } from './store/placeholders'
import { applyAppearance } from './store/appearance'

import './style.css'
import 'vue-final-modal/style.css'

const app = createApp(App as Component)

Expand Down
30 changes: 29 additions & 1 deletion reposilite-frontend/src/style-gate/importantModifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

import { readFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'

// A Tailwind important modifier is a trailing or leading bang on a utility, as in `size-6!` or `!px-2`.
Expand All @@ -25,9 +27,35 @@ describe('important modifier', () => {
'../components/header/LoginModal.vue',
'../components/search/SearchView.vue',
'../components/header/MenuPanel.vue',
'../components/repositories/RepositoriesTable.vue'
'../components/repositories/RepositoriesTable.vue',
'../components/md/MdSelect.vue',
'../components/md/MdDialog.vue',
'../components/browser/AdjustmentsModal.vue',
'../components/browser/DeleteEntryModal.vue'
])('is not used in the template of %s', (path) => {
const source = readFileSync(new URL(path, import.meta.url), 'utf8')
expect(source, `${path} sets a utility with the important modifier`).not.toMatch(IMPORTANT_UTILITY)
})

it.each([
'../components/md/MdSelect.vue',
'../components/md/MdDialog.vue',
'../components/browser/AdjustmentsModal.vue',
'../components/browser/DeleteEntryModal.vue'
])('is not used in a bound class string of %s', (path) => {
const source = readFileSync(new URL(path, import.meta.url), 'utf8')
expect(source, `${path} binds a utility with the important modifier`).not.toMatch(/['"][\w/:-]+!['"]/)
})

// The vue-final-modal stylesheet is unlayered, and an unlayered rule beats every layered utility whatever its
// specificity. That is why the scrim utilities needed the important modifier. Importing the stylesheet into the
// base layer puts it below the utilities, so bg-scrim/md-scrim wins on its own.
it('imports the vue-final-modal stylesheet into a layer below the utilities', () => {
const css = readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'style.css'), 'utf8')
expect(css, 'style.css imports the vue-final-modal stylesheet into the base layer').toMatch(
/@import\s+["'][./]*node_modules\/vue-final-modal\/dist\/style\.css["']\s+layer\(base\)/
)
const main = readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'main.ts'), 'utf8')
expect(main, 'main.ts does not import it a second time, unlayered').not.toContain('vue-final-modal/style.css')
})
})
1 change: 1 addition & 0 deletions reposilite-frontend/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* DESIGN.md next to package.json.
*/
@import "tailwindcss";
@import "../node_modules/vue-final-modal/dist/style.css" layer(base);
@import "./styles/md3/color.css";
@import "./styles/md3/typography.css";
@import "./styles/md3/shape-elevation-motion.css";
Expand Down
Loading