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

Twig Component and Stimulus #63

Open
tacman opened this issue Oct 6, 2023 · 1 comment
Open

Twig Component and Stimulus #63

tacman opened this issue Oct 6, 2023 · 1 comment

Comments

@tacman
Copy link
Contributor

tacman commented Oct 6, 2023

One of the goals of this bundle could be to be able to customize fullcalendar without ever writing javascript. That is, to replace the section https://github.com/tattali/CalendarBundle#basic-functionalities with some twig calls.

Stimulus is the obvious choice, and could be wrapped in a twig component to make it even easier.

Brainstorming about the format.

{# events is an array of events, event contains at a minimum keys of title and start) #}
<div {{ stimulus_controller('calendar', {
        events: events
    })) }}>
</div>

OR

<twig:Calendar :events="events" />

Both of these work in the demo app at https://github.com/tacman/micro-calendar

image

Obviously, we'll want to move the twig component and stimulus controller to the bundle, but it's considerably easier to work in the demo app first. But when that happens, the developer simply needs to create events, e.g.

        $dt = new \DateTime(); // for the demo, start with the current date
        $events = [];
        $events[] = ['title' => 'now()', 'start' => $dt->format('c')];
        $events[] = ['title' => 'Set Goals', 'start' => $dt->format("Y-m-01")];
        $events[] = ['title' => 'Reflect', 'start' => $dt->format("Y-m-t")];

And pass them to the twig template, and in twig, call the component. ZERO JAVASCRIPT from the developer! Even what libraries to load will be hidden, since the bundle auto-registers everything, as long as the base loads the assets:

        {% block javascripts %}
            {{ importmap() }}
        {% endblock %}

So before moving the stimulus controller and twig component to the bundle, what are the options we want to expose via attributes? Obviously events and initialView, which for my application was actually enough to be usable. But fullcalendar has TONS of options, I imagine we'll start with the easy ones. I'm working on the icalendar plugin first.

@tacman
Copy link
Contributor Author

tacman commented Oct 6, 2023

This probably makes more sense as a discussion rather than an issue, but I don't think discussions are enabled.

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

No branches or pull requests

1 participant