Skip to content

Commit

Permalink
update README for release
Browse files Browse the repository at this point in the history
  • Loading branch information
saade committed Jan 27, 2022
1 parent 6f082e1 commit 4319fc2
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 19 deletions.
176 changes: 157 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
# The Most Popular JavaScript Calendar integrated with Filament 💛
# The Most Popular JavaScript Calendar as a Filament Widget 💛

![Monthly Calendar](./art/fullcalendar-widget.png)

[![Latest Version on Packagist](https://img.shields.io/packagist/v/saade/filament-fullcalendar.svg?style=flat-square)](https://packagist.org/packages/saade/filament-fullcalendar)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/saade/filament-fullcalendar/run-tests?label=tests)](https://github.com/saade/filament-fullcalendar/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/saade/filament-fullcalendar/Check%20&%20fix%20styling?label=code%20style)](https://github.com/saade/filament-fullcalendar/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/saade/filament-fullcalendar.svg?style=flat-square)](https://packagist.org/packages/saade/filament-fullcalendar)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
# Features

## Support us
- Accepts all configurations from [FullCalendar](https://fullcalendar.io/docs#toc)
- Event click and drop events

[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/filament-fullcalendar.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/filament-fullcalendar)
### Upcoming
- Modal view when clicking on an event
- Tailwindcss theme 💙

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
<br>

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
## Support Filament

## Installation
<a href="https://github.com/sponsors/danharrin">
<img width="320" alt="filament-logo" src="https://filamentadmin.com/images/sponsor-banner.jpg">
</a>

You can install the package via composer:

```bash
composer require saade/filament-fullcalendar
```
<br>

# Installation

You can publish and run the migrations with:
You can install the package via composer:

```bash
php artisan vendor:publish --tag="filament-fullcalendar-migrations"
php artisan migrate
composer require saade/filament-fullcalendar
```

You can publish the config file with:
Expand All @@ -39,23 +44,156 @@ php artisan vendor:publish --tag="filament-fullcalendar-config"
This is the contents of the published config file:

```php
<?php

/**
* Consider this file the root configuration object for FullCalendar.
* Any configuration added here, will be added to the calendar.
* @see https://fullcalendar.io/docs#toc
*/

return [
'timeZone' => config('app.timezone'),

'locale' => config('app.locale'),

'headerToolbar' => [
'left' => 'prev,next today',
'center' => 'title',
'right' => 'dayGridMonth,dayGridWeek,dayGridDay'
],

'navLinks' => true,

'editable' => true,

'dayMaxEvents' => true
];
```

Optionally, you can publish the views using
<br>

# Usage

Since the package **does not** automatically add the `FullCalendarWidget` widget to your Filament panel, you are free to extend the widget and customise it yourself.


1. First, create a [Filament Widget](https://filamentadmin.com/docs/2.x/admin/dashboard#getting-started):

```bash
php artisan vendor:publish --tag="filament-fullcalendar-views"
php artisan make:filament-widget CalendarWidget
```

> This will create a new `App\Filament\Widgets\CalendarWidget` class in your project.
<br>

2. Your newly created widget should extends the `Saade\FilamentFullCalendar\Widgets\FullCalendarWidget` class of this package

```php
<?php

namespace App\Filament\Widgets;

use App\Models\Meeting;
use App\Filament\Resources\MeetingResource;
use Saade\FilamentFullCalendar\Widgets\FullCalendarWidget;

class CalendarWidget extends FullCalendarWidget
{

public function getViewData(): array
{
return [
[
'id' => 1,
'title' => 'Breakfast!',
'start' => now()
],
[
'id' => 2,
'title' => 'Meeting with Pamela',
'start' => now()->addDay(),
'url' => MeetingResource::getUrl('view', ['record' => 2])
]
];
}
}
```

## Usage
> You should return an array of FullCalendar [EventObject](https://fullcalendar.io/docs/event-object).

<br>

# Configuration
This is the contents of the default config file.

You can use any property that FullCalendar uses on its root object.
Please refer to: [FullCalendar Docs](https://fullcalendar.io/docs#toc) to see the available options. It supports all of them, really.

```php
$filamentFullCalendar = new Saade\FilamentFullCalendar();
echo $filamentFullCalendar->echoPhrase('Hello, Saade!');
<?php

/**
* Consider this file the root configuration object for FullCalendar.
* Any configuration added here, will be added to the calendar.
* @see https://fullcalendar.io/docs#toc
*/

return [
'timeZone' => config('app.timezone'),

'locale' => config('app.locale'),

'headerToolbar' => [
'left' => 'prev,next today',
'center' => 'title',
'right' => 'dayGridMonth,dayGridWeek,dayGridDay'
],

'navLinks' => true,

'editable' => true,

'dayMaxEvents' => true
];
```

<br>

# Listening for events

The only events supported right now are: [EventClick](https://fullcalendar.io/docs/eventClick) and [EventDrop](https://fullcalendar.io/docs/eventDrop)

They're commented out by default so livewire does not spam requests without they being used. You are free to paste them in your `CalendarWidget` class. See: [FiresEvents](https://github.com/saade/filament-fullcalendar/blob/main/src/Widgets/Concerns/FiresEvents.php)

```php
/**
* Triggered when the user clicks an event.
*
* Commented out so we can save some requests :) Feel free to extend it.
* @see https://fullcalendar.io/docs/eventClick
*/
public function onEventClick($event): void
{
//
}

/**
* Triggered when dragging stops and the event has moved to a different day/time.
*
* Commented out so we can save some requests :) Feel free to extend it.
* @see https://fullcalendar.io/docs/eventDrop
*/
public function onEventDrop($oldEvent, $newEvent, $relatedEvents): void
{
//
}
```

<br>

## Testing

```bash
Expand Down
Binary file added art/fullcalendar-widget.png
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 art/fullcalendar-widget.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
LastWriterPackageFamilyName=Microsoft.ScreenSketch_8wekyb3d8bbwe
ZoneId=3

0 comments on commit 4319fc2

Please sign in to comment.