This package contains a list of useful stimulus components that can be conveniently reused in numerous projects.
- AjaxModal - This component makes it easy to fetch html from any URL to display in a modal window.
- AjaxSortable - This component uses "Stimulus Sortable" and sends an ajax request "onUpdate" to save the changed items order.
- ClosableController - A controller to close/remove items on clicking a specific target.
- DirtyForm - If there is a form on the current page, this component checks if there are unsaved changes and warns the user when leaving the page that the changes will be lost.
- ThemeSwitch - Provides a function to switch the theme between "light" and "dark" and stores the selected configuration in the localStorage.
- TooltipController - A controller using tippy.js to create fancy tooltips.
yarn add @barbieswimcrew/stimulus-components
To use one of the included controllers simply consume in bootstrap.js as follows:
import { startStimulusApp } from "@symfony/stimulus-bridge";
//...
import ThemeSwitchController from "@barbieswimcrew/stimulus-components/src/controllers/theme-switch/theme_switch";
//...
export const app = startStimulusApp(
require.context(
"@symfony/stimulus-bridge/lazy-controller-loader!./controllers",
true,
/\.(j|t)sx?$/
)
);
//...
app.register("theme-switch", ThemeSwitchController);
//...