Skip to content

Commit

Permalink
Added ability to hide action button, closes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
aricooperdavis committed Oct 15, 2022
1 parent 4594dce commit 39f0382
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 9 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# v1.0.15
## 15-10-2022

1. [](#new)
* New option to enable or disable the action button
2. [](#improved)
* Improve documentation (README.md)
* Improved default configuration

# v1.0.14
## 15-10-2022

Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,23 @@ enabled: true
content: Custom Text added by the <b>Custom Banner</b> plugin (disable plugin to remove)
position: bottom
button-text: Click me...
button-url: /route-to-page/you-want-to/link-to
button: true
button-url: https://example.com/
dismiss-text: Dismiss
dismiss-button: true
cdn-fix: false
bg-colour: '#EC565C'
fg-colour: 'rgba(255, 255, 255, 0.80)'
bg-colour: '#A1C3B2'
fg-colour: 'rgba(0, 20, 10, 0.90)'
box-shadow: true
show-on-pages:
hide-on-pages:
- /route-to-page/you-want-to/exclude
```
Which creates a default banner that looks like this:
![Screenshot of default banner](./images/default_banner.png)
### Options
The configuration options can broadly be separated into those that change the plugins appearance, and those that change its behaviour. See the above default configuration for examples of valid configuration values.
Expand All @@ -76,6 +81,7 @@ The configuration options can broadly be separated into those that change the pl
| `button-url` | string | The URL that the action button links to. |
| `show-on-pages` | array of strings | List of routes of pages on which the banner should be exclusively shown (i.e. a whitelist). Leave empty to show the banner on all pages. |
| `hide-on-pages` | array of strings | List of routes of pages on which the banner should be hidden (i.e. a blacklist). Takes priority over the `show-on-pages` value for any given page route. |
| `button` | boolean | Whether an action button is shown or not. |
| `dismiss-button` | boolean | Whether a dismiss button is shown or not. |
| `cdn-fix` | boolean | Enable if a CDN is used for cacheing in-front of the site. This uses client-side javascript for the display logic rather than the default behaviour of server-side logic. |

Expand Down
13 changes: 11 additions & 2 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Custom Banner
slug: custom-banner
type: plugin
version: 1.0.14
version: 1.0.15
description: Add a custom banner to your Grav site
icon: bookmark
author:
Expand Down Expand Up @@ -82,7 +82,7 @@ form:
fields:
button-url:
type: text
default: /route-to-page/you-want-to/link-to
default: https://example.com/
label: PLUGIN_CUSTOM_BANNER.BUTTON_URL
help: PLUGIN_CUSTOM_BANNER.BUTTON_URL_HELP
show-on-pages:
Expand All @@ -109,6 +109,15 @@ form:
show_all: false
show_modular: false
show_root: false
button:
type: toggle
label: PLUGIN_CUSTOM_BANNER.BUTTON
help: PLUGIN_CUSTOM_BANNER.BUTTON_HELP
highlight: 1
default: 1
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
dismiss-button:
type: toggle
label: PLUGIN_CUSTOM_BANNER.DISMISS_BUTTON
Expand Down
3 changes: 2 additions & 1 deletion custom-banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public function onOutputGenerated(): void
$content = $config['content'];
$hidden = ($config['cdn-fix'] ? '' : 'shown');
$button_text = $config['button-text'];
$button = ($config['button'] ? 'inline-block' : 'none');
$button_url = $config['button-url'];
$dismiss_text = $config['dismiss-text'];
$dismiss_button = ($config['dismiss-button'] ? 'inline-block' : 'none');
Expand All @@ -139,7 +140,7 @@ public function onOutputGenerated(): void
<div class="custom-banner-content" style="color: $fg_colour;">$content</div>
<div class="custom-banner-actions">
<a class="button custom-banner-dismiss" href="javascript:void(0)" onclick="custom_button_dismiss();" style="display: $dismiss_button;">$dismiss_text</a>
<a class="button custom-banner-button" href="$button_url">$button_text</a>
<a class="button custom-banner-button" href="$button_url" style="display: $button;">$button_text</a>
</div>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions custom-banner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ enabled: true
content: Custom Text added by the <b>Custom Banner</b> plugin (disable plugin to remove)
position: bottom
button-text: Click me...
button-url: /route-to-page/you-want-to/link-to
button: true
button-url: https://example.com/
dismiss-text: Dismiss
dismiss-button: true
cdn-fix: false
bg-colour: '#EC565C'
fg-colour: 'rgba(255, 255, 255, 0.80)'
bg-colour: '#A1C3B2'
fg-colour: 'rgba(0, 20, 10, 0.90)'
box-shadow: true
show-on-pages:
hide-on-pages:
Expand Down
Binary file added images/default_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ en:
BOX_SHADOW_HELP: Display a box shadow beneath the banner
BUTTON_TEXT: Button text
BUTTON_TEXT_HELP: Button text must be valid HTML
BUTTON: Show action button
BUTTON_HELP: Show an action button that points to a URL
BUTTON_URL: Button URL
BUTTON_URL_HELP: The location that the button links to
DISMISS_TEXT: Dismiss button text
Expand Down

0 comments on commit 39f0382

Please sign in to comment.