@openeuropa/bcl-subscription-block 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020-2021 Mark Otto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`OE - Subscription Block renders correctly 1`] = `
4
+ <jest>
5
+ <div
6
+ class="bg-light px-4-5 pt-4 pb-4-5"
7
+ >
8
+ <div
9
+ class="fs-2 fw-normal"
10
+ >
11
+ Subscribe
12
+ </div>
13
+ <p
14
+ class="fw-bold"
15
+ >
16
+ Get notified lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
17
+ </p>
18
+ <div
19
+ class="pb-2"
20
+ >
21
+ <button
22
+ class="btn btn-secondary btn-lg"
23
+ data-bs-target="#subscribeModal"
24
+ data-bs-toggle="modal"
25
+ type="button"
26
+ >
27
+ Subscribe
28
+ <svg
29
+ class="ms-2-5 bi icon--fluid"
30
+ >
31
+ <use
32
+ xlink:href="/icons.svg#chevron-right"
33
+ />
34
+ </svg>
35
+ </button>
36
+ </div>
37
+ </div>
38
+ </jest>
39
+ `;
package/data/data.js ADDED
@@ -0,0 +1,19 @@
1
+ const drupalAttribute = require("drupal-attribute");
2
+
3
+ module.exports = {
4
+ title: "Subscribe",
5
+ content:
6
+ "<p class='fw-bold'>Get notified lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>",
7
+ button: {
8
+ label: "Subscribe",
9
+ variant: "secondary",
10
+ size: "lg",
11
+ icon: {
12
+ name: "chevron-right",
13
+ path: "/icons.svg",
14
+ },
15
+ attributes: new drupalAttribute()
16
+ .setAttribute("data-bs-toggle", "modal")
17
+ .setAttribute("data-bs-target", "#subscribeModal"),
18
+ },
19
+ };
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@openeuropa/bcl-subscription-block",
3
+ "author": "European Commission",
4
+ "license": "EUPL-1.2",
5
+ "version": "0.20.0",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "description": "OE - BCL subscription block",
10
+ "dependencies": {
11
+ "@openeuropa/bcl-alert": "^0.20.0",
12
+ "@openeuropa/bcl-button": "^0.20.0",
13
+ "@openeuropa/bcl-form": "^0.20.0",
14
+ "@openeuropa/bcl-modal": "^0.20.0"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/openeuropa/bootstrap-component-library.git"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/openeuropa/bootstrap-component-library.git/issues"
22
+ },
23
+ "homepage": "https://github.com/openeuropa/bootstrap-component-library",
24
+ "keywords": [
25
+ "openeuropa",
26
+ "bootstrap-component-library",
27
+ "design-system",
28
+ "twig"
29
+ ],
30
+ "gitHead": "ea13560489a089d0c198f781e75951a9160d2554"
31
+ }
@@ -0,0 +1,36 @@
1
+ {% spaceless %}
2
+
3
+ {# Parameters:
4
+ - title: (string) (default: '')
5
+ - content: (string) (default: '')
6
+ - button: (button Object) (default: {})
7
+ #}
8
+
9
+ {% set _title = title|default(false) %}
10
+ {% set _content = content|default('') %}
11
+ {% set _button = button|default({}) %}
12
+ {% set _modal = modal|default({}) %}
13
+
14
+ {% if attributes is empty %}
15
+ {% set attributes = create_attribute() %}
16
+ {% endif %}
17
+
18
+ {% set attributes = attributes.addClass(['bg-light', 'px-4-5', 'pt-4', 'pb-4-5']) %}
19
+
20
+ <div
21
+ {{ attributes }}
22
+ >
23
+ {% if _title is not empty %}
24
+ <div class="fs-2 fw-normal">{{ _title }}</div>
25
+ {% endif %}
26
+ {% if _content is not empty %}
27
+ {{ _content }}
28
+ {% endif %}
29
+ {% if _button is not empty %}
30
+ <div class="pb-2">
31
+ {% include '@oe-bcl/bcl-button/button.html.twig' with _button only %}
32
+ </div>
33
+ {% endif %}
34
+ </div>
35
+
36
+ {% endspaceless %}
@@ -0,0 +1,23 @@
1
+ import { withDesign } from "storybook-addon-designs";
2
+ import { correctPaths } from "@openeuropa/bcl-story-utils";
3
+ import subscriptionBlock from "@openeuropa/bcl-subscription-block/subscription-block.html.twig";
4
+ import demoData from "@openeuropa/bcl-subscription-block/data/data.js";
5
+
6
+ export default {
7
+ title: "Compositions/Subscription Block",
8
+ decorators: [withDesign],
9
+ parameters: {
10
+ layout: "fullscreen",
11
+ controls: { disable: true },
12
+ badges: ["stable"],
13
+ design: [
14
+ {
15
+ name: "Mockup",
16
+ type: "figma",
17
+ url: "https://www.figma.com/file/NQlGvTiTXZYN8TwY2Ur5EI/BCL-Features?node-id=5859%3A239083",
18
+ },
19
+ ],
20
+ },
21
+ };
22
+
23
+ export const Default = () => subscriptionBlock(correctPaths(demoData));
@@ -0,0 +1,14 @@
1
+ import { renderTwigFileAsNode } from "@openeuropa/bcl-test-utils";
2
+ import demoData from "@openeuropa/bcl-subscription-block/data/data.js";
3
+
4
+ const template = "@oe-bcl/bcl-subscription-block/subscription-block.html.twig";
5
+
6
+ const render = (params) => renderTwigFileAsNode(template, params, true);
7
+
8
+ describe("OE - Subscription Block", () => {
9
+ test("renders correctly", () => {
10
+ expect.assertions(1);
11
+
12
+ return expect(render(demoData)).resolves.toMatchSnapshot();
13
+ });
14
+ });