Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Implemented Calendar List View #445

Merged
merged 4 commits into from
Nov 6, 2024

Conversation

tylersocholotuik
Copy link
Contributor

What issue is this referencing?

#394 specifically, this comment

Here is the first iteration of the idea @dgmouris had for the calendar list view. The events should be grouped by month, but there are unfortunately only events in November at the moment so I am not certain this works.

Let me know your thoughts on anything that could be improved!

list-vew

Do these code changes work locally and have you tested that they fix the issue yourself?

  • yes!

Does the following command run without warnings or errors?

  • yes! npm run pr-checks

Have you taken a look at our contributing guidelines?

  • yes!

My node version matches the one suggested when running nvm use?

  • yes!

@tylersocholotuik
Copy link
Contributor Author

tylersocholotuik commented Nov 6, 2024

Update: I fixed the height of the cards based on feedback from @johnjovero98, and I set the default view to list on mobile (<768px).

default-list-view

@MandyMeindersma
Copy link
Contributor

LOVE this! I am going to let another person look this over too.

I am a BE dev by day so my FE is a little rusty

@arashsheyda
Copy link
Collaborator

the card width on mobile view is not quite responsive I think. also if we use computed for isMobile it would be better (I think we can even combine selectedView with defaultView using a computed)

Screenshot 2024-11-05 at 7 33 16 PM

@tylersocholotuik
Copy link
Contributor Author

Ah ok I will try to fix that. I think the calendar view has the same issue on mobile as well.

@arashsheyda
Copy link
Collaborator

@tylersocholotuik thanks! (it's not a big deal though, if you ask me. we can merge it for now and add a fix later. looks great! thanks)

@tylersocholotuik
Copy link
Contributor Author

@tylersocholotuik thanks! (it's not a big deal though, if you ask me. we can merge it for now and add a fix later. looks great! thanks)

Ok sounds good! If I have some time later today I will try to tackle the responsive issue. Changing isMobile and selected view to computed caused an issue, however.

const isMobile = computed(() => useMediaQuery('(max-width: 768px)').value)
const selectedView = computed(() => isMobile.value ? 'list' : 'calendar')

This will now change the view automatically based on the window size, and clicking on the tabs no longer works. Is there something I am missing?

My original idea was that the default view is set only when the page loads based on the window size, then the user will have control with the tabs after that. If we want both (automatic switching + user control with tabs), I'm not sure how to get the tabs to work now.

@arashsheyda
Copy link
Collaborator

selectedView should stay ref in this case.

@tylersocholotuik
Copy link
Contributor Author

tylersocholotuik commented Nov 6, 2024

selectedView should stay ref in this case.

ok, so keep isMobile as computed, but change the others back to the way it was before?

const isMobile = computed(() => useMediaQuery('(max-width: 768px)').value)
const defaultView = isMobile.value ? 'list' : 'calendar'
const selectedView = ref(defaultView)

I could put the expression for defaultView in the ref if you prefer fewer lines.

@arashsheyda
Copy link
Collaborator

@tylersocholotuik my bad, I didn't notice useMediaQuery is from @vueuse and it is a computed already so no need for that. but how about something lik this:

const isMobile = useMediaQuery('(max-width: 768px)')
const calendarView = useCookie('calendarView', { default: () => 'calendar' })
const selectedView = computed({
  get: () => isMobile.value ? 'list' : calendarView.value,
  set: value => calendarView.value = value,
})

this way we save the users choice (in cookies) also do you think we should hide the tabs in mobile view since it wouldn't change the view anyway?
sorry again for the confusion about useMediaQuery

@tylersocholotuik
Copy link
Contributor Author

@arashsheyda thanks for the help with the view selection, I have not learned about cookies yet. I made that change, plus hid the tabs on mobile view and changed the border colors.

@tylersocholotuik
Copy link
Contributor Author

I realized I may have commited too hastily. I had the thought that maybe it isn't a good idea to prevent the option of using the calendar view on mobile? Or maybe I can change the media query to a smaller size where the calendar view really doesn't look great.

@dgmouris
Copy link
Collaborator

dgmouris commented Nov 6, 2024

@arashsheyda thanks for the thorough review and @tylersocholotuik for the work.

On mobile, the calendar view might need some work, and it's a bit difficult to use (I think it'll be some vue-cal config options).

I think the cookie is great but as long as we have the default as the list view that's awesome.

I'm a fan of this implementation

const isMobile = useMediaQuery('(max-width: 768px)')
const calendarView = useCookie('calendarView', { default: () => 'calendar' })
const selectedView = computed({
  get: () => isMobile.value ? 'list' : calendarView.value,
  set: value => calendarView.value = value,
})

</div>
</div>
</div>
<div class="p-4 event-description">
Copy link
Collaborator

Choose a reason for hiding this comment

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

@tylersocholotuik sometimes the events are going to have a bit of a longer description because of markdown from.

This technique I wouldn't use all the time but I think this will solve our problem and look good.

Suggested change
<div class="p-4 event-description">
<div
class="p-4 event-description"
:class="{ 'max-w-sm': isMobile }"
>

The mobile view on pixel 7:
image

The desktop view:
image

@arashsheyda @tylersocholotuik let me know what you think.

I'd be ready to merge this once this implemented so that it doesn't break on mobile formats.

Comment on lines 25 to 41
const groupedEvents = computed(() => {
return props.group.items.reduce((acc: any, event: any) => {
// creating a key to group the events by month in format "Month Year"
const monthKey = event.start.toLocaleDateString('en-US', { year: 'numeric', month: 'long' })

// check if there are already events in this month
// if not, initialize an empty array for this month
if (!acc[monthKey]) {
acc[monthKey] = []
}

// add current in the same month to the array
acc[monthKey].push(event)

return acc
}, {})
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Awesome I like the use of using a computed value to group the events. I personally might change the acc on line 26 to something like monthEvents but not a show stopper whatsoever.

Copy link
Collaborator

@dgmouris dgmouris left a comment

Choose a reason for hiding this comment

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

Once the above is fixed I'm good with merging this in:)

Great job @tylersocholotuik and thanks @arashsheyda, @MandyMeindersma for reviewing this too:)

@tylersocholotuik
Copy link
Contributor Author

@dgmouris Thanks a lot for all the suggestions! I made all the changes you suggested and I also made the time and date on the cards move underneath the title header on mobile view to help with the width overflow issue. I also decided to do the media query at 700px rather than 768px because I think people would like to use the calendar view on tablets. Let me know if you agree with that.

Here is the new mobile view
image

@dgmouris dgmouris merged commit 2f42c91 into devedmonton:main Nov 6, 2024
4 checks passed
@tylersocholotuik tylersocholotuik deleted the calendar_list_view_394 branch November 6, 2024 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants