lmc / spirit-web-twig-bundle
This is Symfony bundle with twig implementation of the Spirit Design System components and extends the twig implementation with an HTML-like syntax.
Installs: 12 285
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 11
Forks: 0
Open Issues: 18
Language:Twig
Type:symfony-bundle
Requires
- php: ^8.1
- ext-simplexml: *
- lmc/twigx-bundle: ^3.3
- symfony/config: ^4.4 || ^5.4 || ^6.1
- symfony/dependency-injection: ^4.4 || ^5.4 || ^6.1
- symfony/http-foundation: ^4.4 || ^5.4 || ^6.1
- symfony/http-kernel: ^4.4 || ^5.4 || ^6.1
- symfony/polyfill-php80: ^1.23
- twig/twig: ^2.12.5 || ^3.0.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.42
- lmc/coding-standard: ^4.1
- mockery/mockery: ^1.5
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.2
- phpstan/phpstan-mockery: ^1.0
- phpstan/phpstan-symfony: ^1.0
- phpunit/phpunit: ^9
- spatie/phpunit-snapshot-assertions: ^4.2.12
- symfony/yaml: ^4.4 || ^5.4 || ^6.1
- dev-main
- 3.4.1
- 3.4.0
- 3.2.0
- 3.1.0
- 3.0.0
- 2.16.0
- 2.15.0
- 2.14.1
- 2.14.0
- 2.13.0
- 2.12.1
- 2.12.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.0
- 1.34.1
- 1.34.0
- 1.33.0
- 1.32.0
- 1.31.0
- 1.30.0
- 1.29.0
- 1.28.1
- 1.28.0
- 1.27.0
- 1.26.0
- 1.25.1
- 1.25.0
- 1.24.0
- 1.23.0
- 1.22.0
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.0
- 1.17.0
- 1.16.0
- 1.15.0
- 1.14.0
- 1.13.0
- 1.12.0
- 1.11.0
- 1.10.0
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.0
- 0.1.0
- 0.0.2
- 0.0.1
- dev-fix/web-twig-raw-issue
This package is auto-updated.
Last update: 2024-11-14 12:22:26 UTC
README
This is a Symfony bundle with Twig implementation of Spirit Design System components, extended with JSX-like syntax.
Requirements
- PHP >= 8.1
- Symfony 4.4+ || 5.4+ || ^6.1
- Twig >=2.12.5 || 3+
Changelog
See CHANGELOG
How to install
Step 1
Download using composer
Install package
composer require lmc/spirit-web-twig-bundle
Step 2
Add SpiritWebTwigBundle
into bundles (under all
bundles). If you use Symfony flex, it will be configured automatically.
bundles.php
return [ ..., Lmc\SpiritWebTwigBundle\SpiritWebTwigBundle::class => ['all' => true], ];
Step 3 (optional)
If you want to change the default settings, create a config
config/packages/spirit_web_twig.yml
# all parameters are optional spirit_web_twig: # define one or more paths to expand or overload components (uses glob patterns) paths: - '%kernel.project_dir%/templates/components' paths_alias: 'jobs-ui' # default is 'spirit' html_syntax_lexer: false # default is true spirit_css_class_prefix: 'jobs' # default is null icons: # optional settings for svg assets paths: - '%kernel.project_dir%/assets/icons' # define paths for svg icons set alias: 'jobs-icons' # default is 'icons-assets'
Usage
For detailed usage see TwigX bundle
Unescaped Props
All props that internally uses the raw filter are prefixed with UNSAFE_
.
This is considered a way how you can pass down HTML strings.
<Checkbox UNSAFE_helperText="<strong>Help!</strong>" />
Spirit Components
For available components see the components directory.
if you want to extend these components, an example guide is here. if you want to contribute, read the guide here.
Additional Attributes
All components accept additional attributes that are passed down to the root element of the component. This is useful for adding custom event handlers, accessibility attributes, or other attributes that are not supported by the component API.
ℹ️ If you need to pass down event handlers to the native form elements in our form components,
you can use the inputProps
prop.
Supported attributes are:
on*
(eg.onclick
)data-*
aria-*
id
If the component sets a value for any of these attributes, the value passed in will be overwritten.
Styling
Spirit components are designed to be consistent across all Alma Career applications. They include built-in styling that has been considered carefully, and extensively tested. In general, customizing Spirit design is discouraged, but most components do offer control over layout and other aspects. In addition, you can use Spirit defined design tokens to ensure your application conforms to your design requirements, and is adaptive across platform scales and color schemes.
Style Props
All Spirit components accept a set of props that can be used to control their outer spacing. The props are:
margin
marginTop
marginRight
marginBottom
marginLeft
marginX
marginY
These props accept a spacing token (eg. space-100
), auto
or an object with breakpoint keys and spacing token
values or auto
. We use these props to set global CSS utility classes on the root element of the component.
Examples:
<Alert marginBottom="space-100" /> <Button marginX="{{ { mobile: 'space-100', tablet: 'space-200' } }}" /> <Button marginLeft="{{ { mobile: 'space-100', tablet: 'space-200', desktop: 'auto' } }}" />
If you need more control over the styling of a component, you can use escape hatches.
Escape Hatches
While we encourage teams to utilize Spirit design as it is, we do realize that sometimes product specific customizations may be needed. In these cases, we encourage you or your designers to talk to us. We may be able to suggest an alternative implementation strategy, or perhaps your design can help propose future Spirit additions.
While the traditional class and style props are not supported in Spirit Web Twig components, there are two escape hatches that you can use at your own risk. These are UNSAFE_className and UNSAFE_style. Use of these props should be considered a last resort. They can be used to work around bugs or limitations in Spirit Web Twig, but should not be used in the long term.
The reasoning behind this is that future updates to Spirit design may cause unintended breaking changes in products. If the internal DOM structure or CSS properties of a Spirit Web Twig component change, this may lead to conflicts with CSS overrides in products. For this reason, className and style are unsafe, and if you use them know that you are doing so at your own risk.
Please consult additional styling with web package documentation.
Deprecations
This package uses the deprecation warnings for props, functions and components that will be removed or replaced in the next major release. Check your Symfony console or log to see if you are using any of the deprecated functionality.