From bb8315f3589175f2d7263d8e24a0ab5ed39a4f8c Mon Sep 17 00:00:00 2001 From: Ned Zimmerman Date: Thu, 12 Mar 2020 15:00:04 -0600 Subject: [PATCH] feat: indicate when a subscription is required (resolves #218) (#223) * feat: indicate when a subscription is required (resolves #218) * fix: add screen reader text * fix: use aria-hidden --- app/Controllers/Partials/Resource.php | 11 +++++++++++ resources/assets/images/lock.svg | 1 + resources/assets/styles/layouts/_resources.scss | 9 +++++++++ .../views/partials/content-lc_resource.blade.php | 3 +++ .../partials/content-single-lc_resource.blade.php | 7 ++++++- 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 resources/assets/images/lock.svg diff --git a/app/Controllers/Partials/Resource.php b/app/Controllers/Partials/Resource.php index 621362a..b3b3de8 100644 --- a/app/Controllers/Partials/Resource.php +++ b/app/Controllers/Partials/Resource.php @@ -330,4 +330,15 @@ public static function isFavorited() } return false; } + + public static function requiresSubscription() + { + global $post; + + if ($post->post_type == 'lc_resource') { + return (get_post_meta($post->ID, 'lc_resource_has_paywall', true) === 'on'); + } + + return false; + } } diff --git a/resources/assets/images/lock.svg b/resources/assets/images/lock.svg new file mode 100644 index 0000000..fb9c16d --- /dev/null +++ b/resources/assets/images/lock.svg @@ -0,0 +1 @@ + diff --git a/resources/assets/styles/layouts/_resources.scss b/resources/assets/styles/layouts/_resources.scss index d3c1a7c..2610071 100644 --- a/resources/assets/styles/layouts/_resources.scss +++ b/resources/assets/styles/layouts/_resources.scss @@ -32,3 +32,12 @@ list-style: none; padding-left: 0; } + +.card__meta.card__subscription, +.resource__meta.resource__subscription { + color: var(--red-500); + + svg { + color: inherit; + } +} diff --git a/resources/views/partials/content-lc_resource.blade.php b/resources/views/partials/content-lc_resource.blade.php index 6c5bc2e..641b46d 100644 --- a/resources/views/partials/content-lc_resource.blade.php +++ b/resources/views/partials/content-lc_resource.blade.php @@ -1,6 +1,9 @@

{!! Archive::getShortTitle() !!}

+ @if(Archive::requiresSubscription()) +

@svg('lock', 'icon--lock', ['focusable' => 'false', 'aria-hidden' => 'true']) {{ __('Subscription required to access this resource', 'coop-library') }}

+ @endif @if(Archive::getAuthors())
@endif