Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
feat: grid mobile warning (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzbo authored Nov 7, 2024
1 parent b042470 commit 42e7e5d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/ModalTemplateDefault.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { modal, closeModal } = useModal()
<div class="flex flex-col rounded-12 bg-neutral-98 p-6 text-center">
<img
:src="modal?.data?.icon || '/images/up-error.png'"
class="mx-auto mb-6 max-w-[150px]"
class="mx-auto mb-6 mt-4 max-w-[150px]"
alt=""
/>
<div class="heading-inter-21-semi-bold pb-4">
Expand Down
16 changes: 16 additions & 0 deletions domains/grid/components/GridView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
gridRowHeightRatio,
selectedGridId,
isSavingGrid,
mobileLimitationsDisplayed,
} = storeToRefs(useGridStore())
const {
saveGrid,
Expand All @@ -21,6 +22,8 @@ const {
getGridById,
gridsForTabs,
} = useGrid()
const { showModal } = useModal()
const { formatMessage } = useIntl()
const gridContainer = ref<HTMLElement | null>(null)
const { width } = useElementSize(gridContainer)
const gridWidgets = ref<GridWidget[]>([])
Expand Down Expand Up @@ -161,6 +164,19 @@ watch(
} else {
hasUnsavedGrid.value = false
}
// show mobile limitations modal (only once)
if (isMobile.value && !mobileLimitationsDisplayed.value) {
showModal<DefaultModalData>({
data: {
icon: '/images/grid.svg',
title: formatMessage('grid_mobile_limitations_title'),
message: formatMessage('grid_mobile_limitations_message'),
confirmButtonText: formatMessage('grid_mobile_limitations_confirm'),
},
})
mobileLimitationsDisplayed.value = true
}
} else {
gridWidgets.value = getSelectedGridWidgets(updatedViewedGrid)
}
Expand Down
6 changes: 6 additions & 0 deletions public/images/grid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions stores/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const useGridStore = defineStore(
const gridRowHeightRatio = ref(DEFAULT_GRID_ROW_HEIGHT_RATIO)
const gridChainId = ref<string>(DEFAULT_NETWORK_CHAIN_ID)
const tempGrids = ref<Record<string, Grid[]>>({})
const mobileLimitationsDisplayed = ref(false)

// We use tempGrid as a proxy to the actual grid data stored in tempGrids
const tempGrid = computed<Grid[]>({
Expand Down Expand Up @@ -45,6 +46,7 @@ export const useGridStore = defineStore(
selectedGridId,
gridRowHeightRatio,
gridChainId,
mobileLimitationsDisplayed,
}
},
{
Expand All @@ -55,6 +57,7 @@ export const useGridStore = defineStore(
'selectedGridId',
'gridRowHeightRatio',
'gridChainId',
'mobileLimitationsDisplayed',
'tempGrids',
],
key: STORAGE_KEY.GRID_STORE,
Expand Down
7 changes: 7 additions & 0 deletions types/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ export type ModalQueryParams = {
export type ModalData = {
[key: string]: any
}

export type DefaultModalData = {
message: string
title?: string
confirmButtonText?: string
icon?: string
}

0 comments on commit 42e7e5d

Please sign in to comment.