austral / design-bundle
Austral Design Bundle: design system of the Austral administration (Twig components, styles and scripts)
Package info
github.com/austral-project/design-bundle
Language:JavaScript
Type:symfony-bundle
pkg:composer/austral/design-bundle
Requires
- php: ^8.0 || ^8.1 || ^8.2
- symfony/twig-bundle: ^5.4 || ^6.4
- twig/extra-bundle: ^3.0
- twig/string-extra: ^3.2
- twig/twig: ^3.0
Requires (Dev)
None
Suggests
- austral/admin-bundle: ^3.1
Provides
None
Conflicts
None
Replaces
None
README
Design system of Austral: Twig components, form theme, styles and JavaScript of the front and of the administration.
This bundle is part of Austral, a modular back office and CMS for Symfony.
Requirements
- PHP 8.4 or higher
- Symfony 7.4
- symfony/ux-twig-component 2
The bundle ships no compiled build: the project builds the design system with Node.js 22.18 or higher (see Building the design system).
Installation
composer require austral/design-bundle php bin/console assets:install
If you do not use Symfony Flex, register the bundle in config/bundles.php:
return [ // ... Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true], Austral\DesignBundle\AustralDesignBundle::class => ['all' => true], ];
Usage
Styles and scripts
The bundle is a library: it ships the sources of the design system (assets/), not a build.
- Administration: admin-bundle builds the design system with the styles and scripts of the admin, in the entry
austral-admin, from thewebpack.config.mjsof the project (installed by the recipe of admin-bundle), and includes it withaustral_admin_styles()/austral_admin_scripts(). - Front: the project builds its own entries with
encore.mjs(see Building the design system) and includes them as usual.
The scripts need no inline code: the texts come from the attributes written by Twig. For example, a form of the administration asks for a confirmation before it is sent:
<form method="post" action="{{ url }}" data-confirm="{{ 'confirm.delete'|trans }}" data-confirm-yes="{{ 'confirm.yes'|trans }}" data-confirm-no="{{ 'confirm.no'|trans }}">
Twig components
<twig:Austral:Button entitled="Save" theme="solid" color="primary" /> <twig:Austral:Picto name="check" /> <twig:Austral:Modal modalId="confirm">...</twig:Austral:Modal>
Components: Austral:Button, Austral:Buttons, Austral:Link, Austral:Modal, Austral:Pagination, Austral:Picto, Austral:Picture, Austral:Spacer, Austral:Text, Austral:Title, Austral:Form and its fields (Austral:Form:Row, Austral:Form:Label, Austral:Form:Fields:*).
The templates of the components follow the folders of src/Twig/Components/, in lowercase and kebab-case, one folder
per component: Austral:Button is @AustralDesign/components/button/button.html.twig, Austral:Buttons is
@AustralDesign/components/button/buttons.html.twig, Austral:Form:Fields:ChoiceList is
@AustralDesign/components/form/fields/choice-list.html.twig. To override one, copy it into
templates/bundles/AustralDesignBundle/ of the project, with the same path (components/button/button.html.twig).
The pictos are SVG files, named by their path without extension in a folder of pictos:
<twig:Austral:Picto name="austral-picto/check" /> renders assets/svg/austral-picto/check.svg of the bundle,
name="loader/spinner" its loader. The project adds its own folders, searched before the pictos of the bundle:
a file of the project replaces the picto of the bundle with the same name (austral-picto/check.svg), and the
pictos of the bundle are always available.
# config/packages/austral_design.yaml austral_design: picto: paths: ['%kernel.project_dir%/assets/svg'] # name="my-folder/my-picto" → assets/svg/my-folder/my-picto.svg default: austral-picto/circle-help # picto rendered without name (default value)
Only SVG files are read: the component writes the file into the page.
The default values of the components (sizes, themes, colors) are the parameter austral_design.component_default_value.
Form theme
The form theme renders the forms of austral/form-bundle (fieldsets, groups, modals, upload, collections, wysiwyg) with the components:
# config/packages/twig.yaml twig: form_themes: ['@AustralDesign/form/austral-layout.html.twig']
List and filter themes
The list theme renders the view of a list, built by austral/list-bundle (contract in its README): list-bundle builds the data, the markup is here, and this bundle does not depend on list-bundle. The filter theme renders the view of a group of austral/filter-bundle.
{{ include('@AustralDesign/list/austral-list.html.twig', {list: view}) }}
<twig:Austral:List list="{{ view }}"/>
{{ include('@AustralDesign/filter/austral-filter.html.twig', {filter: views.default}) }}
A theme of the application extends them and overrides some blocks. The button of an action is the block
austral_list_action_button (variables action, label, place: toolbar, row or menu, tag, type, href,
attr): a theme wraps it in a form (class austral-list-form) for a POST action without writing the button again.
The theme reuses the components: the actions are Austral:Buttons, the pagination is Austral:Pagination (props
urls, previousUrl, nextUrl: the URLs of the view), the switch is drawn as the toggle of the forms (variables
--form-toggle-*, also set by the colors of a SwitchColumn).
Building the design system
The design system is built by the project, never in the bundle: there is no compiled file to update in the repository after a change of the sources.
For the administration, nothing to add here: the webpack.config.mjs of the project calls
configureAustralAdmin() of admin-bundle, which calls configureAustralDesign() and installs the libraries of the
components (SunEditor, Cropper.js, choices.js…). Add the entries of the project to the same configuration.
On the front, call configureAustralDesign() of encore.mjs:
// webpack.config.mjs of the project import path from "node:path"; import Encore from "@symfony/webpack-encore"; import configureAustralDesign from "./vendor/austral/design-bundle/encore.mjs"; configureAustralDesign(Encore, { debugContext: false }) .setOutputPath("public/build/") .setPublicPath("/build") .addEntry("app", "./assets/app.js") .enableSingleRuntimeChunk(); const config = await Encore.getWebpackConfig(); // the packages imported by the bundle are installed in the node_modules of the project config.resolve.modules = [path.resolve("node_modules"), "node_modules"]; export default config;
// assets/app.js import "@austral/design/styles/app.scss"; import { Loader } from "@austral/design"; window.addEventListener("DOMContentLoaded", () => Loader.initialize());
The libraries used by the components are optional peerDependencies of @austral/design (package.json of the
bundle): the project installs those of the components it uses, with Encore, webpack, Babel, sass and sass-loader.
A file of assets/theme in the project replaces the file of the same path in assets/styles/theme of the bundle
(colors of the light and dark modes); change the folder with the option themePath.
After a change of the pictos used by the wysiwyg editor, regenerate its icons in the bundle:
npm run icons # assets/components/form/fields/textarea/wysiwyg/icons.js
Structure
The bundle follows the structure recommended by Symfony, at the root of the package:
| Folder | Content |
|---|---|
assets/ |
Sources of the design system (JavaScript, SCSS, SVG pictos), package @austral/design |
config/ |
Services (Twig components) |
public/ |
Images, copied into public/bundles/australdesign/ by assets:install |
src/ |
PHP classes (bundle, Twig components) |
templates/ |
Templates of the components (one folder per component) and form theme, namespace @AustralDesign, in lowercase and kebab-case |
translations/ |
Translations, domain austral |
Documentation
The guides and the components are documented in the Storybook of the bundle (storybook/). The full documentation is available at https://austral.dev.
Versions
| Bundle | Symfony | PHP | Branch |
|---|---|---|---|
| 4.x | 7.4 | ≥ 8.4 | 4.x |
| 3.1 | 5.4 / 6.4 | ≥ 8.0 | 3.1 (maintenance) |
See the CHANGELOG and, to upgrade from 3.1, UPGRADE-4.0.
Contributing
Contributions are welcome: see the contributing guide. To report a security issue, follow the security policy.
License
MIT, see LICENSE.
Credits
Created by Matthieu Beurel. Sponsored by Yipikai Studio.