@penskemediacorp/larva-patterns 1.77.1 → 1.79.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.
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# google-preferred-button
|
|
2
|
+
|
|
3
|
+
A module that renders a Google Preferred Source button — a linked call-to-action allowing readers to add the site as a Google Preferred Source.
|
|
4
|
+
|
|
5
|
+
## Data contract
|
|
6
|
+
|
|
7
|
+
| Key | Type | Required | Description |
|
|
8
|
+
|-----|------|----------|-------------|
|
|
9
|
+
| `google_preferred_button_url` | string | No | Destination URL. Defaults to `https://www.google.com/preferences/source?q=<home_url>` via controller. |
|
|
10
|
+
| `google_preferred_button_classes` | string | No | Additional modifier classes on the root `<a>`. |
|
|
11
|
+
| `google_preferred_button_icon_url` | string | No | If set, renders an `<img>` with this URL. If empty, falls back to `c-icon` (sprite). |
|
|
12
|
+
| `google_preferred_button_icon_classes` | string | No | Additional classes on the `<img>` icon element. |
|
|
13
|
+
| `c_icon` | object | No | Passed to `c-icon` component when no `icon_url` is set. Defaults to `google-preferred` sprite icon. |
|
|
14
|
+
| `c_span` | object | No | Passed to `c-span` component for the button label. |
|
|
15
|
+
|
|
16
|
+
## Icon strategy
|
|
17
|
+
|
|
18
|
+
- **Default (sprite):** Uses the `google-preferred` SVG from `@penskemediacorp/larva-svg`.
|
|
19
|
+
- **Brand override:** Pass `icon_url` from the controller to render a brand-specific raster image via `<img>`.
|
|
20
|
+
|
|
21
|
+
## Controller entry point
|
|
22
|
+
|
|
23
|
+
`PMC\Larva\Controllers\Modules\Google_Preferred_Button` in the `pmc-larva` plugin.
|
|
24
|
+
|
|
25
|
+
The controller re-injects `label_text` via `C_Span` after mock-stripping removes the prototype `_text` value.
|
|
26
|
+
|
|
27
|
+
## Theme-level styling
|
|
28
|
+
|
|
29
|
+
The base module ships no CSS. Brands should add their own one-off stylesheet scoped to a brand modifier class (e.g. `o-google-preferred-button--rs`).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const clonedeep = require( 'lodash.clonedeep' );
|
|
2
|
+
|
|
3
|
+
const c_icon = clonedeep(
|
|
4
|
+
require( '@penskemediacorp/larva-patterns/components/c-icon/c-icon.prototype' )
|
|
5
|
+
);
|
|
6
|
+
const c_span = clonedeep(
|
|
7
|
+
require( '@penskemediacorp/larva-patterns/components/c-span/c-span.prototype' )
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
c_icon.c_icon_name = 'google-preferred';
|
|
11
|
+
c_icon.c_icon_screen_reader_text = '';
|
|
12
|
+
c_icon.c_icon_screen_reader_title_attr = '';
|
|
13
|
+
c_icon.c_icon_screen_reader_tag_text = '';
|
|
14
|
+
c_icon.c_icon_link_screen_reader_text = 'Icon Link';
|
|
15
|
+
c_icon.c_icon_link_classes = '';
|
|
16
|
+
c_icon.c_icon_url = false;
|
|
17
|
+
|
|
18
|
+
c_span.c_span_classes = 'u-font-family-basic';
|
|
19
|
+
c_span.c_span_text = 'Add us as a Google Preferred Source';
|
|
20
|
+
c_span.c_span_url = false;
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
google_preferred_button_classes: 'lrv-u-flex lrv-u-align-items-center',
|
|
24
|
+
google_preferred_button_icon_url: '',
|
|
25
|
+
google_preferred_button_icon_classes: '',
|
|
26
|
+
c_icon,
|
|
27
|
+
c_span,
|
|
28
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<button class="o-google-preferred-button {{ google_preferred_button_classes }}" aria-label="Add us as a Google Preferred Source" data-track data-track-category="Article" data-track-action="Google Preferred Source" data-track-label="Click">
|
|
2
|
+
{% if google_preferred_button_icon_url %}
|
|
3
|
+
<img src="{{ google_preferred_button_icon_url }}" alt="" aria-hidden="true" class="o-google-preferred-button__icon {{ google_preferred_button_icon_classes }}">
|
|
4
|
+
{% else %}
|
|
5
|
+
{% include "@larva/components/c-icon/c-icon.twig" with c_icon %}
|
|
6
|
+
{% endif %}
|
|
7
|
+
|
|
8
|
+
{% include "@larva/components/c-span/c-span.twig" with c_span %}
|
|
9
|
+
</button>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@penskemediacorp/larva-patterns",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.79.0",
|
|
4
4
|
"description": "Larva markup patterns.",
|
|
5
5
|
"author": "laras126 <laras126@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/Penske-Media-Corp/pmc-larva/tree/master/packages/patterns#readme",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"url": "https://github.com/Penske-Media-Corp/pmc-larva/issues"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@penskemediacorp/larva-css": "^1.
|
|
24
|
-
"@penskemediacorp/larva-js": "^1.
|
|
25
|
-
"@penskemediacorp/larva-svg": "^1.
|
|
23
|
+
"@penskemediacorp/larva-css": "^1.79.0",
|
|
24
|
+
"@penskemediacorp/larva-js": "^1.79.0",
|
|
25
|
+
"@penskemediacorp/larva-svg": "^1.79.0",
|
|
26
26
|
"lodash.clonedeep": "^4"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "39d2e12edc65e6e554b2e8c2856bf242a392cbe7"
|
|
29
29
|
}
|