-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: custom components for week grid (#3)
- Loading branch information
1 parent
cf1cb95
commit 0edba78
Showing
23 changed files
with
1,662 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
describe('Custom events test', () => { | ||
beforeEach(() => { | ||
cy.visit('/cypress/pages/002-custom-events/002-custom-events.html') | ||
}) | ||
|
||
it('should render custom events', () => { | ||
cy.contains('Event 1').should('exist') | ||
cy.contains('Event 2').should('exist') | ||
cy.contains('Event 3').should('exist') | ||
cy.contains('Event 4').should('exist') | ||
cy.contains('Title: Event 5').should('exist') | ||
cy.contains('Id: 5').should('exist') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<script setup lang="ts"> | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
import { ScheduleXCalendar } from '../../..' | ||
import { createCalendar, viewDay, viewWeek } from '@schedule-x/calendar' | ||
import '@schedule-x/theme-default/dist/index.css' | ||
import CustomDateGridEvent from '../../../development/components/CustomDateGridEvent.vue' | ||
import CustomTimeGridEvent from '../../../development/components/CustomTimeGridEvent.vue' | ||
const calendarApp = createCalendar({ | ||
views: [viewWeek, viewDay], | ||
selectedDate: '2023-12-18', | ||
events: [ | ||
{ | ||
id: 1, | ||
title: 'Event 1', | ||
start: '2023-12-18', | ||
end: '2023-12-18', | ||
}, | ||
{ | ||
id: 2, | ||
title: 'Event 2', | ||
start: '2023-12-17', | ||
end: '2023-12-21', | ||
}, | ||
{ | ||
id: 3, | ||
title: 'Event 3', | ||
start: '2023-12-22', | ||
end: '2023-12-28', | ||
}, | ||
{ | ||
id: 4, | ||
title: 'Event 4', | ||
start: '2023-12-22', | ||
end: '2023-12-28', | ||
}, | ||
{ | ||
id: 5, | ||
title: 'Event 5', | ||
start: '2023-12-18 04:15', | ||
end: '2023-12-18 05:15', | ||
}, | ||
], | ||
}) | ||
const customComponents = { | ||
dateGridEvent: CustomDateGridEvent, | ||
timeGridEvent: CustomTimeGridEvent, | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="app"> | ||
<ScheduleXCalendar | ||
:calendar-app="calendarApp" | ||
:custom-components="customComponents" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<style> | ||
.app { | ||
width: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" | ||
/> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | ||
<title>Browser test | Vue Calendar | Custom events</title> | ||
<style> | ||
body { | ||
margin: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="002-custom-events.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import '@fontsource/open-sans' | ||
import '@fontsource/open-sans/300.css' | ||
import '@fontsource/open-sans/500-italic.css' | ||
import '@fontsource/open-sans/700.css' | ||
import '@fontsource/open-sans/700-italic.css' | ||
import { createApp } from 'vue' | ||
import '../style.css' | ||
import App from './002-custom-events-App.vue' | ||
|
||
createApp(App).mount('#root') |
80 changes: 80 additions & 0 deletions
80
cypress/pages/002-custom-events/components/CustomDateGridEvent.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<template> | ||
<div | ||
class="custom-date-grid-event" | ||
:style="{ | ||
width: '100%', | ||
height: '100%', | ||
border: '2px solid black', | ||
borderRadius: '4px', | ||
}" | ||
> | ||
<div class="left-arrow">←</div> | ||
|
||
{{ calendarEvent.title }} | ||
|
||
<div class="right-arrow">→</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { PropType } from 'vue' | ||
defineProps({ | ||
calendarEvent: { | ||
type: Object as PropType<{ title: string; id: number | string }>, | ||
required: true, | ||
}, | ||
}) | ||
</script> | ||
|
||
<style lang="scss"> | ||
.custom-date-grid-event { | ||
position: relative; | ||
overflow: hidden; | ||
padding: 0 4px; | ||
font-size: 14px; | ||
font-weight: bold; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
background-color: #fff; | ||
color: #000; | ||
border-radius: 4px; | ||
border: 2px solid black; | ||
box-sizing: border-box; | ||
cursor: pointer; | ||
user-select: none; | ||
transition: background-color 0.2s ease; | ||
&:hover { | ||
background-color: #eee; | ||
} | ||
.sx__date-grid-event--overflow-left & { | ||
padding-left: 24px; | ||
} | ||
} | ||
.left-arrow { | ||
position: absolute; | ||
left: 8px; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
display: none; | ||
.sx__date-grid-event--overflow-left & { | ||
display: block; | ||
} | ||
} | ||
.right-arrow { | ||
position: absolute; | ||
right: 8px; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
display: none; | ||
.sx__date-grid-event--overflow-right & { | ||
display: block; | ||
} | ||
} | ||
</style> |
31 changes: 31 additions & 0 deletions
31
cypress/pages/002-custom-events/components/CustomTimeGridEvent.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<template> | ||
<div class="custom-time-grid-event"> | ||
<input type="checkbox" /> | ||
<div>Id: {{ calendarEvent.id }}</div> | ||
<div>Title: {{ calendarEvent.title }}</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { PropType } from 'vue' | ||
defineProps({ | ||
calendarEvent: { | ||
type: Object as PropType<{ title: string; id: number | string }>, | ||
required: true, | ||
}, | ||
}) | ||
</script> | ||
|
||
<style> | ||
.custom-time-grid-event { | ||
border: 2px solid black; | ||
border-radius: 4px; | ||
background-color: #fff; | ||
font-family: inherit; | ||
line-height: 1.5; | ||
padding: 0.125rem; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.