diff --git a/assets/scripts/statistics_chart.js b/assets/scripts/statistics_chart.js index ee71acfe..f3ee1950 100644 --- a/assets/scripts/statistics_chart.js +++ b/assets/scripts/statistics_chart.js @@ -10,8 +10,9 @@ function renderChart() { } const styles = getComputedStyle(document.documentElement); - const labelColor = styles.getPropertyValue('--tblr-body-color').trim(); - const primaryColor = styles.getPropertyValue('--tblr-primary').trim(); + const cssVar = (...names) => names.map((name) => styles.getPropertyValue(name).trim()).find(Boolean); + const labelColor = cssVar('--tblr-body-color', '--foreground'); + const primaryColor = cssVar('--tblr-primary', '--primary'); const options = { colors: [primaryColor], @@ -121,7 +122,7 @@ if (element) { const themeObserver = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { - if (mutation.attributeName === 'data-bs-theme') { + if (mutation.attributeName === 'data-bs-theme' || mutation.attributeName === 'data-theme') { chart.destroy(); renderChart(); } diff --git a/bin/switch-admin-theme b/bin/switch-admin-theme index 349abeda..eb553909 100755 --- a/bin/switch-admin-theme +++ b/bin/switch-admin-theme @@ -98,6 +98,7 @@ if [[ ${#themes[@]} -gt 0 ]]; then printf ' themes: [%s]\n' "${list%, }" >> "$config" fi +rm -rf var/cache/* php bin/console cache:clear --quiet # PHP-FPM only revalidates the cached PHP files every 2 seconds (opcache.revalidate_freq): wait for the new container. diff --git a/bin/switch-admin-ui b/bin/switch-admin-ui index 2da4658f..28959841 100755 --- a/bin/switch-admin-ui +++ b/bin/switch-admin-ui @@ -42,13 +42,25 @@ imports: - { resource: '../../src/${Ns}AdminUi/config/app.php' } EOF +if [[ "$to" == shadcn ]]; then + cat > config/packages/app_shadcn_templates.yaml </dev/null \ + | { grep -v '^templates/shadcn/' || true; } \ | xargs -r perl -pi -e "s/\@Sylius${OldNs}AdminUi/\@Sylius${Ns}AdminUi/g; s/sylius_${old_prefix}_admin_ui:/sylius_${prefix}_admin_ui:/g" # The shadcn theme fully replaces the Tom Select stylesheet. perl -pi -e "s#(\"tom-select/dist/css/tom-select.default.css\": )(true|false)#\${1}${tom_select}#" assets/controllers.json +rm -rf var/cache/* php bin/console cache:clear --quiet # PHP-FPM only revalidates the cached PHP files every 2 seconds (opcache.revalidate_freq): wait for the new container. diff --git a/docs/cookbook/admin_panel/basic_operations.md b/docs/cookbook/admin_panel/basic_operations.md index c53008eb..92c74ce9 100644 --- a/docs/cookbook/admin_panel/basic_operations.md +++ b/docs/cookbook/admin_panel/basic_operations.md @@ -311,6 +311,8 @@ return static function (ContainerConfigurator $container): void { {% endtab %} {% endtabs %} +{% tabs %} +{% tab title="BootstrapAdminUi" %} {% code title="templates/book/show/content/body.html.twig" overflow="wrap" lineNumbers="true" %} ```twig {% set book = hookable_metadata.context.book %} @@ -328,6 +330,24 @@ return static function (ContainerConfigurator $container): void { ``` {% endcode %} +{% endtab %} + +{% tab title="ShadcnAdminUi" %} +{% code title="templates/book/show/content/body.html.twig" overflow="wrap" lineNumbers="true" %} +```twig +{% set book = hookable_metadata.context.book %} + + + +

+ {{ book.description|nl2br }} +

+
+
+``` +{% endcode %} +{% endtab %} +{% endtabs %} {% hint style="info" %} Note that you can also [replace the default title](page_titles.md). diff --git a/docs/cookbook/admin_panel/grid_export.md b/docs/cookbook/admin_panel/grid_export.md index 8969704d..114d48b3 100644 --- a/docs/cookbook/admin_panel/grid_export.md +++ b/docs/cookbook/admin_panel/grid_export.md @@ -208,6 +208,8 @@ final class BookGrid extends AbstractGrid You can configure the template for the export action +{% tabs %} +{% tab title="BootstrapAdminUi" %} {% code title="templates/shared/grid/action/export.html.twig" lineNumbers="true" %} ```twig {% set path = options.link.url|default(path(options.link.route|default(grid.requestConfiguration.getRouteName('export')), options.link.parameters|default([]))) %} @@ -223,6 +225,26 @@ You can configure the template for the export action ``` {% endcode %} +{% endtab %} + +{% tab title="ShadcnAdminUi" %} +{% code title="templates/shared/grid/action/export.html.twig" lineNumbers="true" %} +```twig +{% set path = options.link.url|default(path(options.link.route|default(grid.requestConfiguration.getRouteName('export')), options.link.parameters|default([]))) %} + +{% set message = action.label %} +{% if message is empty %} + {% set message = 'app.ui.export' %} +{% endif %} + + + + {{ message|trans }} + +``` +{% endcode %} +{% endtab %} +{% endtabs %} ## Configure the translation key diff --git a/docs/cookbook/admin_panel/logo.md b/docs/cookbook/admin_panel/logo.md index aac9568a..e75652a4 100644 --- a/docs/cookbook/admin_panel/logo.md +++ b/docs/cookbook/admin_panel/logo.md @@ -58,6 +58,10 @@ return static function (ContainerConfigurator $containerConfigurator): void { ``` +{% hint style="info" %} +With ShadcnAdminUi, the logo is configured without a template: see [Branding](../../shadcn-admin-ui/configuration.md#branding-logo-name-title). +{% endhint %} + ## How to customize the login page logo To customize the login page logo,you need to set new logo template at `sylius_admin.security.login.logo` twig hook. Choose the YAML or the PHP version. @@ -108,3 +112,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { ```twig Your Brand name ``` + +{% hint style="info" %} +With ShadcnAdminUi, the logo is configured without a template: see [Branding](../../shadcn-admin-ui/configuration.md#branding-logo-name-title). +{% endhint %} diff --git a/docs/cookbook/admin_panel/state_machine.md b/docs/cookbook/admin_panel/state_machine.md index 46e617c7..2da7ccfe 100644 --- a/docs/cookbook/admin_panel/state_machine.md +++ b/docs/cookbook/admin_panel/state_machine.md @@ -426,6 +426,8 @@ the workflow configuration you set up. You can also include your transition button actions in any Twig template by leveraging the `workflow_can` function. The button will only be generated when your Symfony Workflow config allows it. +{% tabs %} +{% tab title="BootstrapAdminUi" %} {% code lineNumbers=true %} ```twig {% if workflow_can(application, 'cancel') %} @@ -443,3 +445,24 @@ will only be generated when your Symfony Workflow config allows it. {% endif %} ``` {% endcode %} +{% endtab %} + +{% tab title="ShadcnAdminUi" %} +{% code lineNumbers=true %} +```twig +{% if workflow_can(application, 'cancel') %} +
+ + + + {{ 'app.ui.application.cancel'|trans }} + +
+{% endif %} +``` +{% endcode %} +{% endtab %} +{% endtabs %} diff --git a/docs/shadcn-admin-ui/components.md b/docs/shadcn-admin-ui/components.md index 150d767b..8b0d0d72 100644 --- a/docs/shadcn-admin-ui/components.md +++ b/docs/shadcn-admin-ui/components.md @@ -66,8 +66,8 @@ Same macro APIs as `@SyliusBootstrapAdminUi`: only the namespace changes. | `dropdown.html.twig` | `default(params)`, `list(params, items)`, `item(attributes, content, variant)` | | `table.html.twig` | `headers`, `row` | | `pagination.html.twig` | `simple(paginator, options)`, `results_count(paginator)` | -| `accordion.html.twig` | `accordion(items, open, auto_close, flush)` | -| `avatar.html.twig` | `default(img, class, initials)`, `small(img, class, initials)` | +| `accordion.html.twig` | `accordion(items, open, auto_close, flush)`: `auto_close: false` keeps several items open, no `flag` item option | +| `avatar.html.twig` | `default(img, class, initials, size)`, `small(img, class, initials)` | | `palette.html.twig` | [`tone(color, kind)`](theming.md#the-tone-macro) | The button macros accept an extra `variant` param: `default`, `secondary`, `outline`, `ghost`, `destructive`, `link`. @@ -121,6 +121,7 @@ Registered automatically by the bundle. | Identifier | Role | |---------------------------------------------|------------------------------------------------------------------| | `admin--tabs` | Accessible tabs ([see above](#tabs)) | +| `admin--accordion` | Keeps a single item of the `accordion()` macro open | | `admin--grid-selection` | Row selection, "select all", bulk action forms | | `admin--copy-to-clipboard` | Copy buttons | | `admin--dismissible` | Closable flash messages and alerts | @@ -180,27 +181,31 @@ To add a new recipe, pass its name. The files are **overwritten**: `git diff` shows both the changes of the kit and the local changes of the bundle that were lost. Keep the former, restore the latter (`git checkout -p`). -Local changes to restore after an update (as of UX Toolkit 3.6): +Local changes to restore after an update (as of UX Toolkit 3.7): | File | Local change | |------------------------------------------------------------|------------------------------------------------------------------------------| | `DropdownMenu/{Item,CheckboxItem,RadioItem,SubTrigger}` | `cursor-pointer` instead of `cursor-default` | -| `DropdownMenu/Content` | `left` / `right` sides combined with `align` (`start`, `center`, `end`) | | `dropdown_menu_controller.js` | A pointer click focuses the menu, not its first item (no highlighted item) | -| `Sidebar` | Nested sidebar (`sidebar.nested`: `
` instead of `
+ + + + {{ ux_icon('lucide:x', {'aria-hidden': 'true'}) }} + + + {% endfor %} {% endfor %} diff --git a/src/ShadcnAdminUi/templates/shared/crud/common/content/form_error_alert.html.twig b/src/ShadcnAdminUi/templates/shared/crud/common/content/form_error_alert.html.twig index 8a0a3379..0c28ec37 100644 --- a/src/ShadcnAdminUi/templates/shared/crud/common/content/form_error_alert.html.twig +++ b/src/ShadcnAdminUi/templates/shared/crud/common/content/form_error_alert.html.twig @@ -1,9 +1,13 @@ {% set form = hookable_metadata.context.form|default(null) %} {% if form is not null and form.vars.submitted and form.vars.valid == false %} - + {{ 'sylius.ui.error'|trans }} + {{ 'sylius.ui.this_form_contains_errors'|trans }} + {% endif %} diff --git a/src/ShadcnAdminUi/templates/shared/crud/common/sidebar/logo/image.html.twig b/src/ShadcnAdminUi/templates/shared/crud/common/sidebar/logo/image.html.twig index ba82e930..cf1d9b71 100644 --- a/src/ShadcnAdminUi/templates/shared/crud/common/sidebar/logo/image.html.twig +++ b/src/ShadcnAdminUi/templates/shared/crud/common/sidebar/logo/image.html.twig @@ -1,11 +1,3 @@ -{# - # Configure it from your app: - # sylius_twig_hooks: - # hooks: - # 'sylius_admin.common.component.sidebar.logo': - # image: - # configuration: { name: 'Camalo', subtitle: 'WMS', icon: 'lucide:warehouse' } # or image: 'images/logo.svg' - #} {% set configuration = hookable_metadata.configuration %}
{% if configuration.image|default(null) %} diff --git a/src/ShadcnAdminUi/templates/shared/crud/common/sidebar/menu/menu.html.twig b/src/ShadcnAdminUi/templates/shared/crud/common/sidebar/menu/menu.html.twig index 9aff2b3c..30fd309b 100644 --- a/src/ShadcnAdminUi/templates/shared/crud/common/sidebar/menu/menu.html.twig +++ b/src/ShadcnAdminUi/templates/shared/crud/common/sidebar/menu/menu.html.twig @@ -19,7 +19,7 @@ {% if item.getExtra('section', false) %} {% if group_open %}
{% endif %}
-
+
{{ block('label') }}
    diff --git a/src/ShadcnAdminUi/templates/shared/crud/common/sidebar/search.html.twig b/src/ShadcnAdminUi/templates/shared/crud/common/sidebar/search.html.twig index 2f488f08..87efaedc 100644 --- a/src/ShadcnAdminUi/templates/shared/crud/common/sidebar/search.html.twig +++ b/src/ShadcnAdminUi/templates/shared/crud/common/sidebar/search.html.twig @@ -1,13 +1,13 @@
    {{ ux_icon('lucide:search', {class: 'pointer-events-none absolute start-4 top-1/2 mt-1 size-4 -translate-y-1/2 text-muted-foreground', 'aria-hidden': 'true'}) }} - + />
    diff --git a/src/ShadcnAdminUi/templates/shared/crud/index/content/grid/data_table.html.twig b/src/ShadcnAdminUi/templates/shared/crud/index/content/grid/data_table.html.twig index e5673e26..02296368 100644 --- a/src/ShadcnAdminUi/templates/shared/crud/index/content/grid/data_table.html.twig +++ b/src/ShadcnAdminUi/templates/shared/crud/index/content/grid/data_table.html.twig @@ -1,13 +1,20 @@ -{% import '@SyliusShadcnAdminUi/shared/helper/table.html.twig' as table %} -{% import '@SyliusShadcnAdminUi/shared/helper/pagination.html.twig' as pagination %} - {% set resources = resources|default(hookable_metadata.context.resources|default(null)) %} {% set data = resources.data|default([]) %} {% set definition = resources.definition|default(null) %} {% set has_bulk_actions = definition.actionGroups.bulk is defined and definition.getEnabledActions('bulk')|length > 0 %} {% if data|length > 0 %} -
    + + {% import '@SyliusShadcnAdminUi/shared/helper/table.html.twig' as table %} + {% import '@SyliusShadcnAdminUi/shared/helper/pagination.html.twig' as pagination %} + + {% set headers %}{{ table.headers(resources, definition, app.request.attributes) }}{% endset %} + {% set rows %} + {% for row in data %} + {{ table.row(resources, definition, row) }} + {% endfor %} + {% endset %} +
    {% if has_bulk_actions %}
    @@ -21,20 +28,14 @@
    -
    - - - - {{ table.headers(resources, resources.definition, app.request.attributes) }} - - - - {% for row in resources.data %} - {{ table.row(resources, resources.definition, row) }} - {% endfor %} - -
    -
    + + + {{ headers }} + + + {{ rows }} + +
    @@ -44,5 +45,5 @@ {{ pagination.simple(data) }}
    -
    + {% endif %} diff --git a/src/ShadcnAdminUi/templates/shared/crud/index/content/grid/filters.html.twig b/src/ShadcnAdminUi/templates/shared/crud/index/content/grid/filters.html.twig index 96d50fc5..6e7cd11e 100644 --- a/src/ShadcnAdminUi/templates/shared/crud/index/content/grid/filters.html.twig +++ b/src/ShadcnAdminUi/templates/shared/crud/index/content/grid/filters.html.twig @@ -5,8 +5,6 @@ # Inner hooks: "filters#trigger" (inside the trigger, after its title) and "filters#summary" (between the trigger # and the form, visible when the panel is collapsed). #} -{% from '@SyliusShadcnAdminUi/shared/helper/ui.html.twig' import button_class %} - {% set resources = resources|default(hookable_metadata.context.resources|default(null)) %} {% set path = path(app.request.attributes.get('_route'), app.request.attributes.all('_route_params')) %} {% set criteria = app.request.query.all('criteria') %} @@ -53,14 +51,14 @@ {% endfor %}
- - + + {{ ux_icon('lucide:rotate-ccw', {'data-icon': 'inline-start', 'aria-hidden': 'true'}) }} {{ 'sylius.ui.reset'|trans }} - +
diff --git a/src/ShadcnAdminUi/templates/shared/grid/action/apply_transition.html.twig b/src/ShadcnAdminUi/templates/shared/grid/action/apply_transition.html.twig index df4a0381..2bddb9d0 100644 --- a/src/ShadcnAdminUi/templates/shared/grid/action/apply_transition.html.twig +++ b/src/ShadcnAdminUi/templates/shared/grid/action/apply_transition.html.twig @@ -1,4 +1,4 @@ -{% from '@SyliusShadcnAdminUi/shared/helper/ui.html.twig' import button_class %} +{% from '@SyliusShadcnAdminUi/shared/helper/palette.html.twig' import tone %} {% if workflow_can(data, action.name) %} {% if options.link.url is defined %} @@ -8,14 +8,15 @@ {% endif %} {% set message = action.label|default('sylius.ui.apply_transition') %} - {% set variants = {danger: 'destructive', red: 'destructive', primary: 'default', green: 'secondary', success: 'secondary'} %} + {% set color = options.class|default('')|replace({'outline-': '', 'ghost-': ''}) %} + {% set icon_attributes = {'aria-hidden': 'true'}|merge(color ? {class: tone(color, 'text')|trim} : {}) %}
- +
{% endif %} diff --git a/src/ShadcnAdminUi/templates/shared/helper/accordion.html.twig b/src/ShadcnAdminUi/templates/shared/helper/accordion.html.twig index ed1cea2f..fdd046bf 100644 --- a/src/ShadcnAdminUi/templates/shared/helper/accordion.html.twig +++ b/src/ShadcnAdminUi/templates/shared/helper/accordion.html.twig @@ -1,18 +1,33 @@ -{# Same signature as the BootstrapAdminUi macro, based on the shadcn Collapsible controller. #} +{# Same signature as the BootstrapAdminUi macro, based on the shadcn Collapsible component. The "flag" item option is not supported. #} {% macro accordion(items, open = false, auto_close = null, flush = false) %} -
+ {% set accordion_id = 'accordion-' ~ random() %} + {% set auto_close = auto_close is not same as(false) %} + + {% for item in items %} {% set item = {open: open, icon: null}|merge(item) %} -
- -
+ {% set content_id = item.id|default(accordion_id ~ '-' ~ loop.index) %} + + +

+ +

+
+ {{ item.content|default('Content') }} -
-
+ + {% endfor %} -
+ {% endmacro %} diff --git a/src/ShadcnAdminUi/templates/shared/helper/avatar.html.twig b/src/ShadcnAdminUi/templates/shared/helper/avatar.html.twig index 741ff087..ccb3e4bb 100644 --- a/src/ShadcnAdminUi/templates/shared/helper/avatar.html.twig +++ b/src/ShadcnAdminUi/templates/shared/helper/avatar.html.twig @@ -1,15 +1,15 @@ -{% macro default(img, class, initials) %} - +{% macro default(img, class, initials, size = 'default') %} + {% if img %} - + {% else %} - - {% if initials %}{{ initials }}{% else %}{{ ux_icon('lucide:user', {class: 'size-4'}) }}{% endif %} - + + {% if initials %}{{ initials }}{% else %}{{ ux_icon('lucide:user', {class: 'size-4', 'aria-hidden': 'true'}) }}{% endif %} + {% endif %} - + {% endmacro %} {% macro small(img, class, initials) %} - {{ _self.default(img, 'size-6 ' ~ class, initials) }} + {{ _self.default(img, class, initials, 'sm') }} {% endmacro %} diff --git a/src/ShadcnAdminUi/templates/shared/helper/breadcrumbs.html.twig b/src/ShadcnAdminUi/templates/shared/helper/breadcrumbs.html.twig index 657a6304..a9fba743 100644 --- a/src/ShadcnAdminUi/templates/shared/helper/breadcrumbs.html.twig +++ b/src/ShadcnAdminUi/templates/shared/helper/breadcrumbs.html.twig @@ -1,22 +1,22 @@ {# Same signature as the BootstrapAdminUi macro: items = [{name, url?, active?}, ...] #} {% macro breadcrumbs(items) %} {% set items = items|filter(item => item is not empty) %} - + + {% endmacro %} diff --git a/src/ShadcnAdminUi/templates/shared/helper/dropdown.html.twig b/src/ShadcnAdminUi/templates/shared/helper/dropdown.html.twig index fbb663bf..e758d4c8 100644 --- a/src/ShadcnAdminUi/templates/shared/helper/dropdown.html.twig +++ b/src/ShadcnAdminUi/templates/shared/helper/dropdown.html.twig @@ -1,10 +1,8 @@ {# # Same signature as the BootstrapAdminUi macros (default / list), rendered with the shadcn - # DropdownMenu controller. params.id makes the generated ids stable (random otherwise). + # DropdownMenu components. params.id makes the generated ids stable (random otherwise). #} {% macro default(params) %} - {% from '@SyliusShadcnAdminUi/shared/helper/ui.html.twig' import button_class %} - {% set params = { id: 'dropdown-' ~ random(), button: {}, @@ -13,57 +11,30 @@ customTrigger: null, direction: 'down', }|merge(params) %} - {% set trigger_id = 'dropdown-menu-' ~ params.id ~ '-trigger' %} - {% set content_id = 'dropdown-menu-' ~ params.id ~ '-content' %} - {% set align_class = params.direction == 'down-end' ? 'end-0 ltr:origin-top-right rtl:origin-top-left' : 'start-0 ltr:origin-top-left rtl:origin-top-right' %} -
- {% set trigger_attributes %} - id="{{ trigger_id }}" data-slot="dropdown-menu-trigger" data-shadcn--dropdown-menu-target="trigger" aria-haspopup="menu" aria-controls="{{ content_id }}" aria-expanded="false" data-state="closed" data-action="click->shadcn--dropdown-menu#toggle keydown->shadcn--dropdown-menu#onTriggerKeydown" - {% endset %} - {% if params.customTrigger %} -
{{ params.customTrigger }}
- {% else %} - {% set button = {text: 'Menu', icon: null, class: null}|merge(params.button) %} - - {% endif %} - -
+ + {% endmacro %} {# content is printed raw: escape user data before passing it. #} {% macro item(attributes = {}, content = '', variant = 'default') %} - {% from '@SyliusShadcnAdminUi/shared/helper/ui.html.twig' import html_attributes %} - {% set tag = attributes.href is defined ? 'a' : 'button' %} - <{{ tag }} - role="menuitem" - tabindex="-1" - data-slot="dropdown-menu-item" - data-variant="{{ variant }}" - data-shadcn--dropdown-menu-target="item" - data-close-on-select="true" - data-action="click->shadcn--dropdown-menu#closeFromItem" - {% if tag == 'button' %}type="button"{% endif %} - class="relative flex w-full cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden transition-colors select-none hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4 {{ variant == 'destructive' ? 'text-destructive hover:bg-destructive/10 hover:text-destructive focus:bg-destructive/10 focus:text-destructive' : '' }}" - {{- html_attributes(attributes) }} - >{{ content|raw }} + {% set attributes = attributes|filter((value, key) => 'href' != key or value) %} + {{ content|raw }} {% endmacro %} {% macro list(params, items) %} @@ -71,12 +42,13 @@ {% for item in items %} {% set item = {type: null, class: null, icon: null}|merge(item) %} {% if item.type == 'header' %} -
{{ item.title|trans }}
+ {{ item.title|trans }} {% elseif item.type == 'divider' %} - + {% else %} + {% set title = item.title|trans %} {% set icon = item.icon ? ux_icon(item.icon, {'aria-hidden': 'true'}) : '' %} - {{ _self.item({href: item.url, class: item.class}, icon ~ (item.title|trans|e)) }} + {{ _self.item({href: item.url|default(null), class: item.class}|merge(sylius_test_form_attribute('user-dropdown-item', title).attr|default({})), icon ~ (title|e)) }} {% endif %} {% endfor %} {% endset %} diff --git a/src/ShadcnAdminUi/tests/Functional/.application/config/packages/copy_components_hooks.yaml b/src/ShadcnAdminUi/tests/Functional/.application/config/packages/copy_components_hooks.yaml new file mode 100644 index 00000000..346950f2 --- /dev/null +++ b/src/ShadcnAdminUi/tests/Functional/.application/config/packages/copy_components_hooks.yaml @@ -0,0 +1,12 @@ +sylius_twig_hooks: + hooks: + 'app.copy_to_clipboard': + copy: + component: 'sylius_shadcn_admin_ui:copy_to_clipboard' + props: + value: '@=_context.value' + 'app.copyable': + copy: + component: 'sylius_shadcn_admin_ui:copyable' + props: + value: '@=_context.value' diff --git a/src/ShadcnAdminUi/tests/Functional/AccordionMacroTest.php b/src/ShadcnAdminUi/tests/Functional/AccordionMacroTest.php new file mode 100644 index 00000000..d46e0971 --- /dev/null +++ b/src/ShadcnAdminUi/tests/Functional/AccordionMacroTest.php @@ -0,0 +1,77 @@ +crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/accordion.html.twig' as accordion %} + {{ accordion.accordion([ + {title: 'First 1', content: 'A'}, + {title: 'Second', content: 'B', open: true, id: 'second'}, + ]) }} + TWIG); + + $triggers = $crawler->filter('button[data-shadcn--collapsible-target="trigger"]'); + self::assertSame(['false', 'true'], $triggers->each(static fn ($trigger): string => (string) $trigger->attr('aria-expanded'))); + self::assertStringContainsString('First 1', $triggers->eq(0)->text()); + + self::assertSame('second', $triggers->eq(1)->attr('aria-controls')); + self::assertSame('collapsible-content', $crawler->filter('#second')->attr('data-slot')); + self::assertSame('collapsible-content', $crawler->filter('#' . $triggers->eq(0)->attr('aria-controls'))->attr('data-slot')); + self::assertCount(2, $crawler->filter('h2 > button[data-shadcn--collapsible-target="trigger"]')); + } + + public function testItWiresTheSingleOpenControllerByDefault(): void + { + $crawler = $this->crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/accordion.html.twig' as accordion %} + {{ accordion.accordion([{title: 'A', content: 'A'}]) }} + TWIG); + + $card = $crawler->filter('[data-slot="card"]'); + self::assertSame('admin--accordion', $card->attr('data-controller')); + self::assertSame('click->shadcn--collapsible#toggle admin--accordion#closeOthers', $crawler->filter('button[data-shadcn--collapsible-target="trigger"]')->attr('data-action')); + } + + public function testEachChevronFollowsItsOwnTrigger(): void + { + $crawler = $this->crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/accordion.html.twig' as accordion %} + {{ accordion.accordion([{title: 'Outer', open: true, content: accordion.accordion([{title: 'Inner', content: 'A'}])}]) }} + TWIG); + + $triggers = $crawler->filter('button.group\/trigger'); + self::assertSame(['open', 'closed'], $triggers->each(static fn ($trigger): string => (string) $trigger->attr('data-state'))); + self::assertCount(0, $crawler->filter('.group\/collapsible')); + $triggers->each(static fn ($trigger) => self::assertStringContainsString('group-data-[state=open]/trigger:rotate-180', (string) $trigger->filter('svg')->last()->attr('class'))); + } + + public function testAutoCloseFalseAllowsSeveralOpenItems(): void + { + $crawler = $this->crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/accordion.html.twig' as accordion %} + {{ accordion.accordion([{title: 'A', content: 'A'}, {title: 'B', content: 'B'}], true, false) }} + TWIG); + + self::assertNull($crawler->filter('[data-slot="card"]')->attr('data-controller')); + self::assertCount(2, $crawler->filter('button[aria-expanded="true"]')); + } +} diff --git a/src/ShadcnAdminUi/tests/Functional/AvatarMacroTest.php b/src/ShadcnAdminUi/tests/Functional/AvatarMacroTest.php new file mode 100644 index 00000000..b7ea4d4b --- /dev/null +++ b/src/ShadcnAdminUi/tests/Functional/AvatarMacroTest.php @@ -0,0 +1,70 @@ +crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/avatar.html.twig' as avatar %} + {{ avatar.default('/avatar.jpg', 'my-avatar', 'jd') }} + TWIG); + + $root = $crawler->filter('[data-slot="avatar"]'); + self::assertSame('default', $root->attr('data-size')); + self::assertStringContainsString('my-avatar', (string) $root->attr('class')); + $image = $crawler->filter('img[data-slot="avatar-image"]'); + self::assertSame('/avatar.jpg', $image->attr('src')); + self::assertNotContains('hidden', explode(' ', (string) $image->attr('class'))); + self::assertCount(0, $crawler->filter('[data-slot="avatar-fallback"]')); + } + + public function testItRendersTheInitialsWithoutImage(): void + { + $crawler = $this->crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/avatar.html.twig' as avatar %} + {{ avatar.default(null, '', 'jd') }} + TWIG); + + self::assertCount(0, $crawler->filter('img')); + self::assertSame('jd', trim($crawler->filter('[data-slot="avatar-fallback"]')->text())); + } + + public function testItRendersAnIconWithoutImageNorInitials(): void + { + $crawler = $this->crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/avatar.html.twig' as avatar %} + {{ avatar.default(null, '') }} + TWIG); + + self::assertCount(0, $crawler->filter('img')); + self::assertCount(1, $crawler->filter('[data-slot="avatar-fallback"] svg')); + } + + public function testSmallRendersTheSmallSize(): void + { + $crawler = $this->crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/avatar.html.twig' as avatar %} + {{ avatar.small(null, '', 'JD') }} + TWIG); + + self::assertSame('sm', $crawler->filter('[data-slot="avatar"]')->attr('data-size')); + self::assertSame('JD', trim($crawler->filter('[data-slot="avatar-fallback"]')->text())); + } +} diff --git a/src/ShadcnAdminUi/tests/Functional/BreadcrumbsMacroTest.php b/src/ShadcnAdminUi/tests/Functional/BreadcrumbsMacroTest.php new file mode 100644 index 00000000..d6be6ec0 --- /dev/null +++ b/src/ShadcnAdminUi/tests/Functional/BreadcrumbsMacroTest.php @@ -0,0 +1,46 @@ +crawl(<<<'TWIG' + {% from '@SyliusShadcnAdminUi/shared/helper/breadcrumbs.html.twig' import breadcrumbs %} + {{ breadcrumbs([{name: 'Dashboard', url: '/admin'}, null, {name: 'Speakers', url: '/admin/speakers'}, {name: 'Julien', active: true}, {name: 'Edit'}]) }} + TWIG); + + self::assertSame(4, $crawler->filter('[data-slot="breadcrumb-item"]')->count()); + self::assertSame(3, $crawler->filter('[data-slot="breadcrumb-separator"]')->count()); + self::assertSame(['/admin', '/admin/speakers'], $crawler->filter('a[data-slot="breadcrumb-link"]')->each(static fn ($link): string => (string) $link->attr('href'))); + self::assertSame('Julien', trim($crawler->filter('[data-slot="breadcrumb-item"]')->eq(2)->text())); + self::assertSame(['Edit'], $crawler->filter('[aria-current="page"]')->each(static fn ($page): string => trim($page->text()))); + } + + public function testAnActiveItemIsNotALink(): void + { + $crawler = $this->crawl(<<<'TWIG' + {% from '@SyliusShadcnAdminUi/shared/helper/breadcrumbs.html.twig' import breadcrumbs %} + {{ breadcrumbs([{name: 'Dashboard', url: '/admin'}, {name: 'Books', url: '/admin/books', active: true}]) }} + TWIG); + + self::assertSame(1, $crawler->filter('a[data-slot="breadcrumb-link"]')->count()); + self::assertSame('Books', trim($crawler->filter('[data-slot="breadcrumb-page"][aria-current="page"]')->text())); + } +} diff --git a/src/ShadcnAdminUi/tests/Functional/CopyToClipboardComponentTest.php b/src/ShadcnAdminUi/tests/Functional/CopyToClipboardComponentTest.php new file mode 100644 index 00000000..c7028bde --- /dev/null +++ b/src/ShadcnAdminUi/tests/Functional/CopyToClipboardComponentTest.php @@ -0,0 +1,209 @@ +crawl(''); + + $controller = $crawler->filter(self::CONTROLLER); + self::assertCount(1, $controller); + self::assertSame('customer@example.com', $controller->attr('data-admin--copy-to-clipboard-value-value')); + self::assertSame($this->trans('sylius.ui.copied_to_clipboard'), $controller->attr('data-admin--copy-to-clipboard-copied-label-value')); + self::assertSame($this->trans('sylius.ui.unable_to_copy_to_clipboard'), $controller->attr('data-admin--copy-to-clipboard-error-label-value')); + + $button = $controller->filter('button[data-test-copy-to-clipboard]'); + self::assertCount(1, $button); + self::assertSame('button', $button->attr('type')); + self::assertSame('admin--copy-to-clipboard#copy', $button->attr('data-action')); + self::assertSame($this->trans('sylius.ui.copy_to_clipboard'), $button->attr('aria-label')); + self::assertSame($this->trans('sylius.ui.copy_to_clipboard'), $button->attr('title')); + self::assertSame('button', $button->attr('data-admin--copy-to-clipboard-target')); + self::assertNull($button->attr('data-bs-toggle')); + } + + public function testItSafelyRendersAValueContainingSpecialCharacters(): void + { + $value = 'customer+"' %} + + TWIG); + + self::assertCount(0, $crawler->filter('script')); + self::assertSame('', trim($crawler->filter(self::CONTAINER)->text())); + } + + public function testItRendersThroughTwigHooks(): void + { + $crawler = $this->crawl("{% hook 'app.copyable' with { value: 'ABC-123' } %}"); + + self::assertSame('ABC-123', trim($crawler->filter(self::CONTAINER)->text())); + self::assertCount(1, $crawler->filter('button')); + self::assertCount(0, $crawler->filter('[hookableMetadata]')); + } + + public function testItDisablesCopyingAnAbsentValueButPreservesCustomContent(): void + { + $crawler = $this->crawl(<<<'TWIG' + + Not available + + TWIG); + + self::assertSame('Not available', trim($crawler->filter(self::CONTAINER)->text())); + self::assertCount(1, $crawler->filter('button[disabled]')); + } +} diff --git a/src/ShadcnAdminUi/tests/Functional/DropdownMacroTest.php b/src/ShadcnAdminUi/tests/Functional/DropdownMacroTest.php new file mode 100644 index 00000000..4beb5925 --- /dev/null +++ b/src/ShadcnAdminUi/tests/Functional/DropdownMacroTest.php @@ -0,0 +1,115 @@ +crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/dropdown.html.twig' as dropdown %} + {{ dropdown.list({id: 'user', button: {text: 'Menu'}}, [ + {type: 'header', title: 'Account'}, + {title: 'Profile', url: '/profile', class: 'my-item'}, + {type: 'divider'}, + {title: 'Logout', url: '/logout'}, + ]) }} + TWIG); + + self::assertSame('dropdown-menu-user-content', $crawler->filter('#dropdown-menu-user-trigger')->attr('aria-controls')); + self::assertSame('Account', trim($crawler->filter('[data-slot="dropdown-menu-label"]')->text())); + self::assertCount(1, $crawler->filter('[data-slot="dropdown-menu-separator"]')); + + $profile = $crawler->filter('a[role="menuitem"][href="/profile"]'); + self::assertStringContainsString('my-item', (string) $profile->attr('class')); + self::assertSame('Profile', $profile->attr('data-test-user-dropdown-item')); + self::assertCount(2, $crawler->filter('[data-test-user-dropdown-item]')); + } + + public function testTheButtonTriggerOpensTheMenuAndKeepsItsClass(): void + { + $crawler = $this->crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/dropdown.html.twig' as dropdown %} + {{ dropdown.default({id: 'limit', button: {text: 'Show 10', class: 'h-7'}, content: ''}) }} + TWIG); + + $trigger = $crawler->filter('button#dropdown-menu-limit-trigger'); + self::assertSame('trigger', $trigger->attr('data-shadcn--dropdown-menu-target')); + self::assertStringContainsString('shadcn--dropdown-menu#toggle', (string) $trigger->attr('data-action')); + $classes = explode(' ', (string) $trigger->attr('class')); + self::assertContains('h-7', $classes); + self::assertNotContains('h-8', $classes); + } + + public function testAListItemWithoutUrlIsAButton(): void + { + $crawler = $this->crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/dropdown.html.twig' as dropdown %} + {{ dropdown.list({id: 'list'}, [{title: 'Refresh'}]) }} + TWIG); + + self::assertCount(0, $crawler->filter('a[role="menuitem"]')); + self::assertNull($crawler->filter('button[role="menuitem"]')->attr('href')); + } + + public function testItemRendersALinkOnlyWithAnHref(): void + { + $crawler = $this->crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/dropdown.html.twig' as dropdown %} + {{ dropdown.item({href: '/books'}, 'Books') }} + {{ dropdown.item({href: ''}, 'Empty') }} + {{ dropdown.item({href: null}, 'Null') }} + TWIG); + + self::assertSame(['/books'], $crawler->filter('a[role="menuitem"]')->each(static fn ($link): string => (string) $link->attr('href'))); + self::assertCount(2, $crawler->filter('button[role="menuitem"]')); + self::assertCount(0, $crawler->filter('button[href]')); + } + + public function testItemRendersAButtonWithItsVariant(): void + { + $crawler = $this->crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/dropdown.html.twig' as dropdown %} + {{ dropdown.default({id: 'row', customTrigger: 'More', content: dropdown.item({}, 'Delete', 'destructive'), direction: 'down-end'}) }} + TWIG); + + self::assertSame('end', $crawler->filter('[data-slot="dropdown-menu-content"]')->attr('data-align')); + $trigger = $crawler->filter('#dropdown-menu-row-trigger'); + self::assertSame('button', $trigger->attr('role')); + self::assertSame('dropdown-menu-row-content', $trigger->attr('aria-controls')); + self::assertSame('trigger', $trigger->attr('data-shadcn--dropdown-menu-target')); + self::assertStringContainsString('shadcn--dropdown-menu#toggle', (string) $trigger->attr('data-action')); + $item = $crawler->filter('button[role="menuitem"]'); + self::assertSame('destructive', $item->attr('data-variant')); + self::assertSame('Delete', trim($item->text())); + } + + public function testTheCustomTriggerOpensTheMenuWithEnterAndSpace(): void + { + $crawler = $this->crawl(<<<'TWIG' + {% import '@SyliusShadcnAdminUi/shared/helper/dropdown.html.twig' as dropdown %} + {{ dropdown.default({id: 'row', customTrigger: 'More'}) }} + TWIG); + + $actions = explode(' ', (string) $crawler->filter('#dropdown-menu-row-trigger')->attr('data-action')); + self::assertContains('click->shadcn--dropdown-menu#toggle', $actions); + self::assertContains('keydown.enter->shadcn--dropdown-menu#toggle', $actions); + self::assertContains('keydown.space->shadcn--dropdown-menu#onTriggerKeydown:prevent', $actions); + self::assertContains('keyup.space->shadcn--dropdown-menu#toggle', $actions); + } +} diff --git a/src/ShadcnAdminUi/tests/Functional/HtmlAttrTokensTest.php b/src/ShadcnAdminUi/tests/Functional/HtmlAttrTokensTest.php new file mode 100644 index 00000000..58e2bc0c --- /dev/null +++ b/src/ShadcnAdminUi/tests/Functional/HtmlAttrTokensTest.php @@ -0,0 +1,39 @@ +render(<<<'TWIG' + {{ html_attr({'data-action': 'click->a#b'|html_attr_type('sst')}, {'data-action': 'keydown->c#d'|html_attr_type('sst')}) }} + TWIG); + + self::assertSame('data-action="click->a#b keydown->c#d"', trim($html)); + } + + public function testHtmlAttrOmitsAnAttributeWhoseListIsFalse(): void + { + $html = $this->render(<<<'TWIG' + {{ html_attr({'data-action': false|html_attr_type('sst'), 'data-x': 'y'}) }} + TWIG); + + self::assertSame('data-x="y"', trim($html)); + } +} diff --git a/src/ShadcnAdminUi/tests/Functional/RendersTwigTrait.php b/src/ShadcnAdminUi/tests/Functional/RendersTwigTrait.php index 2f85c5c5..94b56eb4 100644 --- a/src/ShadcnAdminUi/tests/Functional/RendersTwigTrait.php +++ b/src/ShadcnAdminUi/tests/Functional/RendersTwigTrait.php @@ -18,16 +18,22 @@ trait RendersTwigTrait { - private function render(string $template): string + /** + * @param array $context + */ + private function render(string $template, array $context = []): string { /** @var Environment $twig */ $twig = self::getContainer()->get('twig'); - return $twig->createTemplate($template)->render(); + return $twig->createTemplate($template)->render($context); } - private function crawl(string $template): Crawler + /** + * @param array $context + */ + private function crawl(string $template, array $context = []): Crawler { - return new Crawler($this->render($template)); + return new Crawler($this->render($template, $context)); } } diff --git a/src/ShadcnAdminUi/tests/Unit/Twig/Extension/SpaceSeparatedTokensTest.php b/src/ShadcnAdminUi/tests/Unit/Twig/Extension/SpaceSeparatedTokensTest.php new file mode 100644 index 00000000..c4c45caa --- /dev/null +++ b/src/ShadcnAdminUi/tests/Unit/Twig/Extension/SpaceSeparatedTokensTest.php @@ -0,0 +1,55 @@ +getValue()); + self::assertSame('a#b c#d', (string) $tokens); + } + + public function testItMergesIntoAPreviousList(): void + { + $merged = (new SpaceSeparatedTokens('b'))->mergeInto(new SpaceSeparatedTokens('a')); + + self::assertSame('a b', $merged->getValue()); + } + + public function testItAppendsFromANewList(): void + { + $appended = (new SpaceSeparatedTokens('a'))->appendFrom(['b', 'c']); + + self::assertSame('a b c', $appended->getValue()); + } + + public function testItIgnoresNullAndFalseTokens(): void + { + self::assertSame('a b', (new SpaceSeparatedTokens(['a', null, false, 'b']))->getValue()); + } + + public function testAnEmptyListHasNoValue(): void + { + $tokens = new SpaceSeparatedTokens([null]); + + self::assertNull($tokens->getValue()); + self::assertSame('', (string) $tokens); + } +} diff --git a/templates/shadcn/book/show/content/page_body.html.twig b/templates/shadcn/book/show/content/page_body.html.twig new file mode 100644 index 00000000..0b7e6e50 --- /dev/null +++ b/templates/shadcn/book/show/content/page_body.html.twig @@ -0,0 +1,32 @@ +{% set book = hookable_metadata.context.resource %} + + + +
+
+
{{ 'app.ui.title'|trans }}
+
+ + {{ book.title }} + +
+
+
+
{{ 'app.ui.author'|trans }}
+
+ + {{ book.authorName }} + +
+
+
+
{{ 'app.ui.category'|trans }}
+
+ + {{ book.category.value }} + +
+
+
+
+
diff --git a/templates/shadcn/component/new_speakers.html.twig b/templates/shadcn/component/new_speakers.html.twig new file mode 100644 index 00000000..3b941b78 --- /dev/null +++ b/templates/shadcn/component/new_speakers.html.twig @@ -0,0 +1,31 @@ + + + {{ 'app.ui.new_speakers'|trans }} + + + {{ 'app.ui.show_all'|trans }} + + + + + + + {% for speaker in new_speakers|default([]) %} + + + + {% if speaker.avatar %} + + {% endif %} + {{ speaker.firstName|first }}{{ speaker.lastName|first }} + + + + {{ speaker.fullName }} + {{ speaker.companyName }} + + + {% endfor %} + + + diff --git a/templates/shadcn/component/new_talks.html.twig b/templates/shadcn/component/new_talks.html.twig new file mode 100644 index 00000000..fd250841 --- /dev/null +++ b/templates/shadcn/component/new_talks.html.twig @@ -0,0 +1,38 @@ + + + {{ 'app.ui.new_talks'|trans }} + + + {{ 'app.ui.show_all'|trans }} + + + + + + + {% for talk in new_talks|default([]) %} + {% set first_speaker = talk.speakers.first %} + + {% if first_speaker %} + + + {% if first_speaker.avatar %} + + {% endif %} + {{ first_speaker.firstName|first }}{{ first_speaker.lastName|first }} + + + {% endif %} + + {{ talk.title }} + + {%- for speaker in talk.speakers -%} + {% if not loop.first %}, {% endif %}{{ speaker.fullName }} + {%- endfor -%} + + + + {% endfor %} + + + diff --git a/templates/shadcn/component/statistics.html.twig b/templates/shadcn/component/statistics.html.twig new file mode 100644 index 00000000..f0ce0101 --- /dev/null +++ b/templates/shadcn/component/statistics.html.twig @@ -0,0 +1,9 @@ +
+ {% hook 'statistics' with { + statistics_data: statistics, + period, + } %} +
diff --git a/templates/shadcn/dashboard/index/content/last_updates.html.twig b/templates/shadcn/dashboard/index/content/last_updates.html.twig new file mode 100644 index 00000000..e5fa2175 --- /dev/null +++ b/templates/shadcn/dashboard/index/content/last_updates.html.twig @@ -0,0 +1,3 @@ +
+ {% hook 'latest_updates' %} +
diff --git a/templates/shadcn/dashboard/index/content/statistics_chart.html.twig b/templates/shadcn/dashboard/index/content/statistics_chart.html.twig new file mode 100644 index 00000000..c1b8492c --- /dev/null +++ b/templates/shadcn/dashboard/index/content/statistics_chart.html.twig @@ -0,0 +1,55 @@ +{% set statistics_data = hookable_metadata.context.statistics_data %} +{% set period = hookable_metadata.context.period %} + + + + {{ 'app.ui.talks'|trans }} + +
+ {% for range in [ + {period: '2 weeks', interval: 'day', label: 'app.ui.statistics.2weeks'}, + {period: 'month', interval: 'day', label: 'app.ui.statistics.month'}, + {period: 'year', interval: 'month', label: 'app.ui.statistics.year', test: 'year-split-into-months'}, + ] %} + + {{ range.label|trans }} + + {% endfor %} +
+
+ + + + + + +
+
+
+ +
+
+
diff --git a/templates/shadcn/dashboard/index/content/statistics_grid.html.twig b/templates/shadcn/dashboard/index/content/statistics_grid.html.twig new file mode 100644 index 00000000..3fc7ac48 --- /dev/null +++ b/templates/shadcn/dashboard/index/content/statistics_grid.html.twig @@ -0,0 +1,3 @@ +
+ {% hook 'statistics_grid' %} +
diff --git a/templates/shadcn/dashboard/index/content/statistics_grid/conferences.html.twig b/templates/shadcn/dashboard/index/content/statistics_grid/conferences.html.twig new file mode 100644 index 00000000..62841e7a --- /dev/null +++ b/templates/shadcn/dashboard/index/content/statistics_grid/conferences.html.twig @@ -0,0 +1,13 @@ +{% set statistics_data = hookable_metadata.context.statistics_data %} + + + + {{ 'app.ui.conferences'|trans }} + + {{ statistics_data.business_activity_summary.totalConferences }} + + + + + + diff --git a/templates/shadcn/dashboard/index/content/statistics_grid/speakers.html.twig b/templates/shadcn/dashboard/index/content/statistics_grid/speakers.html.twig new file mode 100644 index 00000000..8b2e9834 --- /dev/null +++ b/templates/shadcn/dashboard/index/content/statistics_grid/speakers.html.twig @@ -0,0 +1,13 @@ +{% set statistics_data = hookable_metadata.context.statistics_data %} + + + + {{ 'app.ui.speakers'|trans }} + + {{ statistics_data.business_activity_summary.totalSpeakers }} + + + + + + diff --git a/templates/shadcn/dashboard/index/content/statistics_grid/talks.html.twig b/templates/shadcn/dashboard/index/content/statistics_grid/talks.html.twig new file mode 100644 index 00000000..7227a847 --- /dev/null +++ b/templates/shadcn/dashboard/index/content/statistics_grid/talks.html.twig @@ -0,0 +1,13 @@ +{% set statistics_data = hookable_metadata.context.statistics_data %} + + + + {{ 'app.ui.talks'|trans }} + + {{ statistics_data.business_activity_summary.totalTalks }} + + + + + + diff --git a/templates/shadcn/shared/grid/action/export.html.twig b/templates/shadcn/shared/grid/action/export.html.twig new file mode 100644 index 00000000..a83ad846 --- /dev/null +++ b/templates/shadcn/shared/grid/action/export.html.twig @@ -0,0 +1,11 @@ +{% set path = options.link.url|default(path(options.link.route|default(grid.requestConfiguration.getRouteName('export')), options.link.parameters|default([]))) %} + +{% set message = action.label %} +{% if message is empty %} + {% set message = 'app.ui.export' %} +{% endif %} + + + + {{ message|trans }} +