Browse Source

fix(nc-gui): change size automatically

pull/7734/head
DarkPhoenix2704 10 months ago
parent
commit
abf25dd0d0
  1. 4
      packages/nc-gui/components/nc/DateWeekSelector.vue
  2. 31
      packages/nc-gui/components/smartsheet/calendar/YearView.vue
  3. 33
      packages/nc-gui/components/smartsheet/calendar/index.vue

4
packages/nc-gui/components/nc/DateWeekSelector.vue

@ -202,7 +202,7 @@ const paginate = (action: 'next' | 'prev') => {
'text-[10px]': size === 'small', 'text-[10px]': size === 'small',
}" }"
class="flex items-center uppercase justify-center text-gray-500" class="flex items-center uppercase justify-center text-gray-500"
>{{ size === 'small' ? day[0] : day }}</span >{{ day[0] }}</span
> >
</div> </div>
<div <div
@ -240,7 +240,7 @@ const paginate = (action: 'next' | 'prev') => {
'h-1.5 w-1.5': size === 'large', 'h-1.5 w-1.5': size === 'large',
'h-1 w-1': size === 'medium', 'h-1 w-1': size === 'medium',
'h-0.75 w-0.75': size === 'small', 'h-0.75 w-0.75': size === 'small',
'top-1 right-1': size != 'small', 'top-1 right-1': size !== 'small',
'top-0.5 right-0.5': size === 'small', 'top-0.5 right-0.5': size === 'small',
}" }"
class="absolute z-2 rounded-full bg-brand-500" class="absolute z-2 rounded-full bg-brand-500"

31
packages/nc-gui/components/smartsheet/calendar/YearView.vue

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
const { selectedDate, activeDates, calendarMetaData } = useCalendarViewStoreOrThrow() const { selectedDate, activeDates } = useCalendarViewStoreOrThrow()
const months = computed(() => { const months = computed(() => {
const months = [] const months = []
@ -9,14 +9,32 @@ const months = computed(() => {
return months return months
}) })
const size = computed(() => calendarMetaData.value?.meta?.yearViewSize ?? 'small') const calendarContainer = ref<HTMLElement | null>(null)
const { width } = useWindowSize()
const size = ref('small')
const handleResize = () => {
if (width.value < 1608) {
size.value = 'small'
} else if (width.value < 2000) {
size.value = 'medium'
} else {
size.value = 'large'
}
}
onMounted(() => {
handleResize()
})
watch(width, handleResize)
</script> </script>
<template> <template>
<div <div ref="calendarContainer" class="overflow-auto flex my-3 justify-center nc-scrollbar-md">
class="flex flex-wrap gap-3 py-3 items-center justify-center overflow-auto nc-scrollbar-md" <div class="grid grid-cols-4 justify-items-center gap-3" data-testid="nc-calendar-year-view">
data-testid="nc-calendar-year-view"
>
<NcDateWeekSelector <NcDateWeekSelector
v-for="(_, index) in months" v-for="(_, index) in months"
:key="index" :key="index"
@ -28,6 +46,7 @@ const size = computed(() => calendarMetaData.value?.meta?.yearViewSize ?? 'small
disable-pagination disable-pagination
/> />
</div> </div>
</div>
</template> </template>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

33
packages/nc-gui/components/smartsheet/calendar/index.vue

@ -54,7 +54,6 @@ const {
pageDate, pageDate,
showSideMenu, showSideMenu,
selectedDateRange, selectedDateRange,
updateCalendarMeta,
paginateCalendarView, paginateCalendarView,
} = useCalendarViewStoreOrThrow() } = useCalendarViewStoreOrThrow()
@ -166,14 +165,6 @@ const headerText = computed(() => {
return dayjs(selectedDate.value).format('YYYY') return dayjs(selectedDate.value).format('YYYY')
} }
}) })
const updateCalendarSize = async (size: string) => {
await updateCalendarMeta({
meta: {
yearViewSize: size,
},
})
}
</script> </script>
<template> <template>
@ -261,30 +252,6 @@ const updateCalendarSize = async (size: string) => {
{{ $t('activity.goToToday') }} {{ $t('activity.goToToday') }}
</span> </span>
</NcButton> </NcButton>
<NcDropdown v-if="activeCalendarView === 'year'" :auto-close="false" :trigger="['click']">
<NcButton
v-if="!isMobileMode"
v-e="`['c:calendar:calendar-${activeCalendarView}-toggle-sidebar']`"
data-testid="nc-calendar-side-bar-btn"
size="small"
type="secondary"
>
Calendar Size
</NcButton>
<template #overlay>
<NcMenu>
<NcMenuItem
v-for="size in ['small', 'medium', 'large']"
:key="size"
class="capitalize"
data-testid="nc-calendar-view-size"
@click="updateCalendarSize(size)"
>
{{ size }}
</NcMenuItem>
</NcMenu>
</template>
</NcDropdown>
<span class="opacity-0" data-testid="nc-active-calendar-view"> <span class="opacity-0" data-testid="nc-active-calendar-view">
{{ activeCalendarView }} {{ activeCalendarView }}
</span> </span>

Loading…
Cancel
Save