Loading cl_components.module +4 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ function cl_components_manager(): ComponentPluginManager { function cl_components_library_info_build() { // Iterate over all the components to get the CSS and JS files. $plugin_manager = cl_components_manager(); $components = $plugin_manager->getAllComponentsWithoutDupes(); $components = $plugin_manager->getAllComponents(); $libraries = array_reduce( $components, static function (array $libraries, Component $component) use ($plugin_manager) { Loading @@ -43,7 +43,9 @@ function cl_components_library_info_build() { catch (InvalidComponentHookException $e) { // The component does not support this hook. It is fine, do nothing. } return array_merge($libraries, [$component->getId() => $library]); $library_name = $component->getLibraryName(); [, $library_id] = explode('/', $library_name); return array_merge($libraries, [$library_id => $library]); }, [] ); Loading cl_components.services.yml +6 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,11 @@ services: tags: - { name: twig.loader, priority: 5 } Drupal\cl_components\ComponentNegotiator: arguments: - '@theme.manager' - '@extension.list.module' Drupal\cl_components\Twig\TwigExtension: arguments: - '@plugin.manager.cl_component' Loading @@ -29,3 +34,4 @@ services: - '@cache.component_registry' - '@config.factory' - '@theme.manager' - '@Drupal\cl_components\ComponentNegotiator' cl_components_examples/templates/components/my-banner/metadata.jsondeleted 100644 → 0 +0 −53 Original line number Diff line number Diff line { "$schema": "https://git.drupalcode.org/project/cl_components/-/raw/1.x/src/metadata.schema.json", "machineName": "my-banner", "name": "Banner", "componentType": "organism", "description": "Banner with title and a CTA link", "variants": [ "tall" ], "schemas": { "props": { "type": "object", "properties": { "heading": { "title": "Heading", "description": "The title for the banner text.", "examples": [ "Join us at The Conference" ], "type": "string" }, "ctaText": { "title": "CTA Text", "type": "string", "examples": [ "Click me!" ] }, "ctaHref": { "title": "CTA Href", "type": "string", "examples": [ "https://www.example.org" ] }, "ctaTarget": { "title": "CTA Target", "type": "string", "enum": [ "", "_blank" ] }, "image": { "title": "Media Image", "description": "Background image for the banner.", "type": "string" } } } }, "status": "READY" } cl_components_examples/templates/components/my-banner/my-banner.component.yml 0 → 100644 +38 −0 Original line number Diff line number Diff line $schema: https://git.drupalcode.org/project/cl_components/-/raw/1.x/src/metadata.schema.json machineName: my-banner name: Banner componentType: organism description: Banner with title and a CTA link variants: - tall schemas: props: type: object properties: heading: title: Heading description: The title for the banner text. examples: - Join us at The Conference type: string ctaText: title: CTA Text type: string examples: - Click me! ctaHref: title: CTA Href type: string examples: - 'https://www.example.org' ctaTarget: title: CTA Target type: string enum: - '' - _blank image: title: Media Image description: Background image for the banner. type: string status: READY cl_components_examples/templates/components/my-banner/my-banner.php +1 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,6 @@ function cl_component_my_banner_form_alter($form, FormStateInterface $form_state '' => \t('- No target -'), '_blank' => \t('Blank'), ]; // @todo: Use the media browser to select an image for the component. // @todo Use the media browser to select an image for the component. return $form; } Loading
cl_components.module +4 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ function cl_components_manager(): ComponentPluginManager { function cl_components_library_info_build() { // Iterate over all the components to get the CSS and JS files. $plugin_manager = cl_components_manager(); $components = $plugin_manager->getAllComponentsWithoutDupes(); $components = $plugin_manager->getAllComponents(); $libraries = array_reduce( $components, static function (array $libraries, Component $component) use ($plugin_manager) { Loading @@ -43,7 +43,9 @@ function cl_components_library_info_build() { catch (InvalidComponentHookException $e) { // The component does not support this hook. It is fine, do nothing. } return array_merge($libraries, [$component->getId() => $library]); $library_name = $component->getLibraryName(); [, $library_id] = explode('/', $library_name); return array_merge($libraries, [$library_id => $library]); }, [] ); Loading
cl_components.services.yml +6 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,11 @@ services: tags: - { name: twig.loader, priority: 5 } Drupal\cl_components\ComponentNegotiator: arguments: - '@theme.manager' - '@extension.list.module' Drupal\cl_components\Twig\TwigExtension: arguments: - '@plugin.manager.cl_component' Loading @@ -29,3 +34,4 @@ services: - '@cache.component_registry' - '@config.factory' - '@theme.manager' - '@Drupal\cl_components\ComponentNegotiator'
cl_components_examples/templates/components/my-banner/metadata.jsondeleted 100644 → 0 +0 −53 Original line number Diff line number Diff line { "$schema": "https://git.drupalcode.org/project/cl_components/-/raw/1.x/src/metadata.schema.json", "machineName": "my-banner", "name": "Banner", "componentType": "organism", "description": "Banner with title and a CTA link", "variants": [ "tall" ], "schemas": { "props": { "type": "object", "properties": { "heading": { "title": "Heading", "description": "The title for the banner text.", "examples": [ "Join us at The Conference" ], "type": "string" }, "ctaText": { "title": "CTA Text", "type": "string", "examples": [ "Click me!" ] }, "ctaHref": { "title": "CTA Href", "type": "string", "examples": [ "https://www.example.org" ] }, "ctaTarget": { "title": "CTA Target", "type": "string", "enum": [ "", "_blank" ] }, "image": { "title": "Media Image", "description": "Background image for the banner.", "type": "string" } } } }, "status": "READY" }
cl_components_examples/templates/components/my-banner/my-banner.component.yml 0 → 100644 +38 −0 Original line number Diff line number Diff line $schema: https://git.drupalcode.org/project/cl_components/-/raw/1.x/src/metadata.schema.json machineName: my-banner name: Banner componentType: organism description: Banner with title and a CTA link variants: - tall schemas: props: type: object properties: heading: title: Heading description: The title for the banner text. examples: - Join us at The Conference type: string ctaText: title: CTA Text type: string examples: - Click me! ctaHref: title: CTA Href type: string examples: - 'https://www.example.org' ctaTarget: title: CTA Target type: string enum: - '' - _blank image: title: Media Image description: Background image for the banner. type: string status: READY
cl_components_examples/templates/components/my-banner/my-banner.php +1 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,6 @@ function cl_component_my_banner_form_alter($form, FormStateInterface $form_state '' => \t('- No target -'), '_blank' => \t('Blank'), ]; // @todo: Use the media browser to select an image for the component. // @todo Use the media browser to select an image for the component. return $form; }