Skip to content
Open
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
6 changes: 3 additions & 3 deletions cms/src/components/BasePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const router = useRouter();
const isEditContentPage = computed(() => router.currentRoute.value.name === "edit");
const isEditLanguagePage = computed(() => router.currentRoute.value.name === "language");
const breakpoints = useBreakpoints(breakpointsTailwind);
const isMobileScreen = breakpoints.smaller("lg");
const isLargeScreen = breakpoints.smaller("lg");
Comment thread
GitTaijitu marked this conversation as resolved.

const handleMobileSidebarToggle = () => {
if (isEditContentPage.value) router.push({ name: "overview" });
Expand All @@ -54,15 +54,15 @@ const handleMobileSidebarToggle = () => {
]"
>
<button
v-if="isEditContentPage || isMobileScreen || isEditLanguagePage"
v-if="isEditContentPage || isLargeScreen || isEditLanguagePage"
type="button"
data-test="chevron-icon"
class="text-zinc-500 max-sm:ml-5"
@click="handleMobileSidebarToggle"
>
<span class="sr-only">Open sidebar</span>
<Bars3Icon
v-if="!isEditContentPage && !isEditLanguagePage && isMobileScreen"
v-if="!isEditContentPage && !isEditLanguagePage && isLargeScreen"
class="h-6 w-6"
aria-hidden="true"
/>
Expand Down
10 changes: 5 additions & 5 deletions cms/src/components/button/LButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { type Component, computed, useSlots, ref } from "vue";
import { cva, type VariantProps } from "cva";
import { twMerge } from "tailwind-merge";
import { isMobileScreen } from "@/globalConfig";
import { isLargeScreen } from "@/globalConfig";

const buttonClasses = cva({
base: "group inline-flex items-center justify-center gap-x-1.5 rounded-md text-sm font-semibold ring-inset focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-default relative",
Expand Down Expand Up @@ -218,8 +218,8 @@ function handleSegmentClick(segment: Segment, event: MouseEvent) {
[iconVariants[variant]]: $slots.default,
'-mr-0.5': iconRight && $slots.default,
'-ml-0.5': !iconRight && $slots.default,
'size-4': smallIcon && isMobileScreen,
'size-5': !smallIcon || !isMobileScreen,
'size-4': smallIcon && isLargeScreen,
'size-5': !smallIcon || !isLargeScreen,
[iconClass!]: iconClass,
}"
/>
Expand Down Expand Up @@ -266,8 +266,8 @@ function handleSegmentClick(segment: Segment, event: MouseEvent) {
$slots.default ? iconVariants[variant] : '',
iconRight && $slots.default ? '-mr-0.5' : '',
!iconRight && $slots.default ? '-ml-0.5' : '',
smallIcon && isMobileScreen ? 'h-4 w-4' : '',
!smallIcon || !isMobileScreen ? 'h-5 w-5' : '',
smallIcon && isLargeScreen ? 'h-4 w-4' : '',
!smallIcon || !isLargeScreen ? 'h-5 w-5' : '',
iconClass,
)
"
Expand Down
2 changes: 1 addition & 1 deletion cms/src/components/common/LPaginator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ vi.mock("@/globalConfig", async (importOriginal) => {
return {
...(actual as any),
isSmallScreen: ref(false),
isMobileScreen: ref(false),
isLargeScreen: ref(false),
};
});

Expand Down
14 changes: 5 additions & 9 deletions cms/src/components/forms/LCombobox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const selectedOptions = defineModel<Array<string | number>>("selectedOptions", {
const showEditModal = defineModel<boolean>("showEditModal", { default: false });

const breakpoints = useBreakpoints(breakpointsTailwind);
const isMobileScreen = breakpoints.smaller("sm");
const isLargeScreen = breakpoints.smaller("sm");

// Reference to the combobox input element and parent wrapper
const inputElement = ref<HTMLInputElement>();
Expand Down Expand Up @@ -295,9 +295,7 @@ const onInlineBackspace = () => {
type="button"
tabindex="-1"
>
<ChevronUpDownIcon
class="h-5 w-5 text-zinc-400 hover:cursor-pointer"
/>
<ChevronUpDownIcon class="h-5 w-5 text-zinc-400 hover:cursor-pointer" />
</button>
</div>

Expand All @@ -307,8 +305,8 @@ const onInlineBackspace = () => {
class="relative flex w-full justify-between gap-2 rounded-md bg-white focus-within:outline focus-within:outline-offset-[-2px] focus-within:outline-zinc-950"
:class="{
'border-[1px] border-zinc-300': !noBorder,
'pl-1 pr-3': smallInput && isMobileScreen,
'pl-3 pr-3': !smallInput || !isMobileScreen,
'pl-1 pr-3': smallInput && isLargeScreen,
'pl-3 pr-3': !smallInput || !isLargeScreen,
}"
tabindex="0"
v-bind="attrsWithoutStyles"
Expand All @@ -329,9 +327,7 @@ const onInlineBackspace = () => {
ref="inputElement"
class="z-0 w-full flex-1 border-0 bg-transparent p-0 text-zinc-900 ring-zinc-300 placeholder:text-sm placeholder:text-zinc-400 focus:ring-0"
:class="[
smallInput && isMobileScreen
? 'h-[30px] text-sm'
: 'h-[38px]',
smallInput && isLargeScreen ? 'h-[30px] text-sm' : 'h-[38px]',
{ 'w-96': $slots.actions && !isSmallScreen },
]"
:placeholder="placeholder ?? 'Type to select...'"
Expand Down
6 changes: 3 additions & 3 deletions cms/src/components/groups/EditAclByGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { type GroupDto, AclPermission, type GroupAclEntryDto } from "luminary-sh
import { capitaliseFirstLetter, getTheFirstLetter } from "@/util/string";
import { validDocTypes, isPermissionAvailable } from "./permissions";
import _ from "lodash";
import { isMobileScreen } from "@/globalConfig";
import { isLargeScreen } from "@/globalConfig";
import DisplayCard from "@/components/common/DisplayCard.vue";
import LModal from "../modals/LModal.vue";
import LButton from "@/components/button/LButton.vue";
Expand Down Expand Up @@ -119,7 +119,7 @@ onMounted(() => {
<div class="flex items-center justify-between">
<div
class="flex-shrink-0 whitespace-nowrap pl-3 font-medium"
:class="isMobileScreen ? 'text-xs' : 'text-sm'"
:class="isLargeScreen ? 'text-xs' : 'text-sm'"
>
{{ assignedGroup.name }}
</div>
Expand Down Expand Up @@ -220,7 +220,7 @@ onMounted(() => {
<LButton
variant="secondary"
size="sm"
:class="isMobileScreen ? '!px-2 !py-2 text-xs' : ''"
:class="isLargeScreen ? '!px-2 !py-2 text-xs' : ''"
mainDynamicCss="text-zinc-600"
>
Add / Remove
Expand Down
2 changes: 1 addition & 1 deletion cms/src/components/groups/EditAclEntry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ vi.mock("@/globalConfig", async (importOriginal) => {
const actual = await importOriginal();
return {
...(actual as any),
isMobileScreen: ref(false),
isLargeScreen: ref(false),
isSmallScreen: ref(false),
};
});
Expand Down
4 changes: 2 additions & 2 deletions cms/src/components/groups/EditAclEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { capitaliseFirstLetter } from "@/util/string";
import { isPermissionAvailable, validateAclEntry } from "./permissions";
import { CheckCircleIcon } from "@heroicons/vue/20/solid";
import _ from "lodash";
import { isMobileScreen } from "@/globalConfig";
import { isLargeScreen } from "@/globalConfig";
import { PencilSquareIcon } from "@heroicons/vue/24/outline";
import LDropdown from "@/components/common/LDropdown.vue";
type Props = {
Expand Down Expand Up @@ -51,7 +51,7 @@ const activePermissions = computed(() => {
<div v-if="aclEntry" class="contents">
<div
class="flex h-full items-center border-b border-zinc-200 pr-2 font-medium"
:class="isMobileScreen ? 'text-[13px]' : 'text-sm'"
:class="isLargeScreen ? 'text-[13px]' : 'text-sm'"
>
{{ capitaliseFirstLetter(aclEntry.type) }}
</div>
Expand Down
34 changes: 28 additions & 6 deletions cms/src/components/images/ImageEditor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ vi.mock("@/globalConfig", async (importOriginal) => {
...(actual as any),
clientAppUrl: ref("http://localhost:4174"),
isSmallScreen: ref(false),
isMobileScreen: ref(false),
isLargeScreen: ref(false),
};
});

Expand Down Expand Up @@ -181,7 +181,13 @@ describe("ImageEditor", () => {
const origBuckets = [...mockImageBuckets.value];
mockImageBuckets.value = [
...origBuckets,
{ _id: "bucket-2", name: "Second", publicUrl: "http://test2.com", storageType: "image", mimeTypes: ["image/*"] },
{
_id: "bucket-2",
name: "Second",
publicUrl: "http://test2.com",
storageType: "image",
mimeTypes: ["image/*"],
},
];

const parent: ContentParentDto = {
Expand All @@ -195,7 +201,11 @@ describe("ImageEditor", () => {

const component = wrapper.vm as any;
const mockFile = new File(["img"], "test.jpg", { type: "image/jpeg" });
const fileList = { 0: mockFile, length: 1, item: (i: number) => (i === 0 ? mockFile : null) };
const fileList = {
0: mockFile,
length: 1,
item: (i: number) => (i === 0 ? mockFile : null),
};

component.handleFiles(fileList);
await wrapper.vm.$nextTick();
Expand Down Expand Up @@ -241,7 +251,11 @@ describe("ImageEditor", () => {
const mockFile = new File(["image-data"], "test.jpg", { type: "image/jpeg" });
Object.defineProperty(mockFile, "size", { value: 1024 }); // Small file

const fileList = { 0: mockFile, length: 1, item: (i: number) => (i === 0 ? mockFile : null) };
const fileList = {
0: mockFile,
length: 1,
item: (i: number) => (i === 0 ? mockFile : null),
};

const component = wrapper.vm as any;
component.handleFiles(fileList);
Expand All @@ -268,7 +282,11 @@ describe("ImageEditor", () => {
const mockFile = new File(["x"], "huge.jpg", { type: "image/jpeg" });
Object.defineProperty(mockFile, "size", { value: largeSize });

const fileList = { 0: mockFile, length: 1, item: (i: number) => (i === 0 ? mockFile : null) };
const fileList = {
0: mockFile,
length: 1,
item: (i: number) => (i === 0 ? mockFile : null),
};

const component = wrapper.vm as any;
component.handleFiles(fileList);
Expand All @@ -294,7 +312,11 @@ describe("ImageEditor", () => {
// An actual upload is a real user edit and should persist the effective bucket.
const mockFile = new File(["x"], "img.jpg", { type: "image/jpeg" });
Object.defineProperty(mockFile, "size", { value: 1024 });
const fileList = { 0: mockFile, length: 1, item: (i: number) => (i === 0 ? mockFile : null) };
const fileList = {
0: mockFile,
length: 1,
item: (i: number) => (i === 0 ? mockFile : null),
};
(wrapper.vm as any).handleFiles(fileList);
await wrapper.vm.$nextTick();

Expand Down
4 changes: 2 additions & 2 deletions cms/src/components/languages/LanguageDisplayCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { db, type LanguageDto } from "luminary-shared";
import LBadge from "@/components/common/LBadge.vue";
import { DateTime } from "luxon";
import { ClockIcon } from "@heroicons/vue/24/outline";
import { isMobileScreen } from "@/globalConfig";
import { isLargeScreen } from "@/globalConfig";

type Props = {
languagesDoc: LanguageDto;
Expand Down Expand Up @@ -52,7 +52,7 @@ const isLocalChanges = db.isLocalChangeAsRef(props.languagesDoc._id);
db
.toDateTime(languagesDoc.updatedTimeUtc)
.toLocaleString(
isMobileScreen
isLargeScreen
? DateTime.DATE_SHORT
: DateTime.DATETIME_SHORT,
)
Expand Down
36 changes: 29 additions & 7 deletions cms/src/components/media/MediaEditor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ vi.mock("@/globalConfig", async (importOriginal) => {
...(actual as any),
cmsLanguageIdAsRef: ref("lang-eng"),
isSmallScreen: ref(false),
isMobileScreen: ref(false),
isLargeScreen: ref(false),
};
});

Expand Down Expand Up @@ -192,7 +192,13 @@ describe("MediaEditor.vue", () => {
const origBuckets = [...mockMediaBuckets.value];
mockMediaBuckets.value = [
...origBuckets,
{ _id: "bucket-media-2", name: "Second Media", publicUrl: "http://test2.com", storageType: "media", mimeTypes: ["audio/*"] },
{
_id: "bucket-media-2",
name: "Second Media",
publicUrl: "http://test2.com",
storageType: "media",
mimeTypes: ["audio/*"],
},
];

parent.mediaBucketId = undefined;
Expand All @@ -202,7 +208,11 @@ describe("MediaEditor.vue", () => {
});

const mockFile = new File(["audio"], "test.mp3", { type: "audio/mp3" });
const fileList = { 0: mockFile, length: 1, item: (i: number) => (i === 0 ? mockFile : null) };
const fileList = {
0: mockFile,
length: 1,
item: (i: number) => (i === 0 ? mockFile : null),
};

const component = wrapper.vm as any;
component.handleFiles(fileList);
Expand Down Expand Up @@ -245,7 +255,9 @@ describe("MediaEditor.vue", () => {

// Language selector dialog should open
const dialogs = wrapper.findAllComponents(LDialog);
const languageDialog = dialogs.find((d) => d.props("title") === "Select Language for Audio");
const languageDialog = dialogs.find(
(d) => d.props("title") === "Select Language for Audio",
);
expect(languageDialog).toBeDefined();
expect(languageDialog?.props("open")).toBe(true);
});
Expand All @@ -260,15 +272,21 @@ describe("MediaEditor.vue", () => {

// Open language selector
const mockFile = new File(["audio"], "test.mp3", { type: "audio/mp3" });
const fileList = { 0: mockFile, length: 1, item: (i: number) => (i === 0 ? mockFile : null) };
const fileList = {
0: mockFile,
length: 1,
item: (i: number) => (i === 0 ? mockFile : null),
};

const component = wrapper.vm as any;
component.handleFiles(fileList);
await wrapper.vm.$nextTick();

// Cancel
const dialogs = wrapper.findAllComponents(LDialog);
const languageDialog = dialogs.find((d) => d.props("title") === "Select Language for Audio");
const languageDialog = dialogs.find(
(d) => d.props("title") === "Select Language for Audio",
);
const cancelAction = languageDialog?.props("secondaryAction") as Function;
cancelAction();
await wrapper.vm.$nextTick();
Expand Down Expand Up @@ -314,7 +332,11 @@ describe("MediaEditor.vue", () => {

// Open language selector
const mockFile = new File(["audio"], "test.mp3", { type: "audio/mp3" });
const fileList = { 0: mockFile, length: 1, item: (i: number) => (i === 0 ? mockFile : null) };
const fileList = {
0: mockFile,
length: 1,
item: (i: number) => (i === 0 ? mockFile : null),
};

const component = wrapper.vm as any;
component.handleFiles(fileList);
Expand Down
6 changes: 3 additions & 3 deletions cms/src/components/modals/LModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ watch(modalRef, (el) => {
});

const breakpoints = useBreakpoints(breakpointsTailwind);
const isMobileScreen = breakpoints.smaller("sm");
const isLargeScreen = breakpoints.smaller("sm");
</script>

<template>
<LTeleport v-if="isVisible">
<div
:class="[
'fixed inset-x-0 top-0 z-50 flex h-[100dvh] items-center justify-center bg-zinc-800 bg-opacity-50 backdrop-blur-sm',
stickToEdges && isMobileScreen ? '' : 'p-2',
stickToEdges && isLargeScreen ? '' : 'p-2',
]"
@mousedown.self="tryDismiss()"
data-test="modal-backdrop"
Expand All @@ -66,7 +66,7 @@ const isMobileScreen = breakpoints.smaller("sm");
data-test="modal-content"
:class="[
'relative z-50 flex max-h-[100dvh] flex-col rounded-lg bg-white/90 p-5 shadow-xl focus:outline-none',
isMobileScreen && stickToEdges
isLargeScreen && stickToEdges
? 'w-[100vw] max-w-none rounded-none'
: largeModal
? 'w-fit min-w-[448px] max-w-[100%]'
Expand Down
2 changes: 1 addition & 1 deletion cms/src/components/navigation/SideBar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ vi.mock("@/globalConfig", async (importOriginal) => {
isDevMode: false,
sidebarSectionExpanded: ref({ posts: false, tags: false, access: false }),
isSmallScreen: ref(false),
isMobileScreen: ref(false),
isLargeScreen: ref(false),
};
});

Expand Down
2 changes: 1 addition & 1 deletion cms/src/components/redirects/RedirectOverview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ vi.mock("@/globalConfig", async (importOriginal) => {
return {
...(actual as any),
isSmallScreen: ref(false),
isMobileScreen: ref(false),
isLargeScreen: ref(false),
};
});

Expand Down
4 changes: 2 additions & 2 deletions cms/src/globalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const windowWidth = ref(window.innerWidth);
window.addEventListener("resize", () => {
windowWidth.value = window.innerWidth;
});
export const isMobileScreen = computed(() => windowWidth.value < 1024);
export const isSmallScreen = computed(() => windowWidth.value < 1500);
export const isLargeScreen = computed(() => windowWidth.value < 1024);
export const isSmallScreen = computed(() => windowWidth.value < 640);
Comment on lines +35 to +36

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need to rethink this. Perhaps better to use the Tailwind breakpoints instead of a pixel value (see how it is done in Basepage)

Perhaps just export the breakpoints variable, and use e.g. breakpoints.smaller("lg") in the actual code where we need to determine the screen size programatically

export const sidebarSectionExpanded = ref({ posts: false, tags: false, access: false });

/**
Expand Down
Loading
Loading