Skip to content

Commit 13dc45d

Browse files
committed
Allow user to show/hide status icons
1 parent 348f016 commit 13dc45d

File tree

6 files changed

+29
-10
lines changed

6 files changed

+29
-10
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The short code has the following configuration options.
3838
- `location` ... The name of the location that you want to display opening hours for. *(mandatory)*
3939
- `display_type` ... The layout of hours information. Options are `table`, `grid` and `stacked`. Defaults to `grid`. *(optional)*
4040
- `num_weeks` ... The number of weeks of opening hours to display. Accepted values are `1`, `2` and `3`. Defaults to `3`. *(optional)*
41+
- `show_status_icon` ... Show status icon for whether a library is open. Defaults to `true`. *(optional)*
4142
- `today_only` ... Show hours for the current day only. Note if this is set to `true` it supersedes the `num_week` option. Defaults to `false`. *(optional)*
4243

4344
### Examples
@@ -52,6 +53,7 @@ The short code has the following configuration options.
5253

5354
`[wplibcalhours location="Art (Sloane) Library" today_only=true]` - Prints the opening hours for the "Art Library" for today.
5455

56+
`[wplibcalhours location="Art (Sloane) Library" today_only=true show_status_icon=false]` - Prints the opening hours for the "Art Library" for today without the open/closed status icon.
5557
## API
5658

5759
This plugin also exposes opening hours via a read-only, public API endpoint.

config/deploy.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set :application, 'hours-of-operation'
2+
set :repo_url, 'https://github.com/UNC-Libraries/wplibcalhours.git'
3+
4+
set :linked_dirs, %w[vendor]
5+
6+
set :deploy_to, "/net/deploy/#{fetch(:stage)}/#{fetch(:application)}"
7+
8+
set :pty, true

config/deploy/qa.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
server 'www-dev.lib.unc.edu', roles: [:app], user: 'swallow'
2+
3+
set :branch, 'main'

public/class-wplibcalhours-public.php

+2
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,11 @@ public function wplibcalhours_sc(array $attrs = []): string
138138
'location' => '',
139139
'display_type' => 'grid',
140140
'today_only' => false,
141+
'show_status_icon' => true,
141142
'num_weeks' => self::DEFAULT_NUM_WEEKS
142143
], $attrs);
143144

145+
$show_status_icon = $attrs['show_status_icon'] == 'true';
144146
$num_weeks = (int) $attrs['num_weeks'];
145147

146148
$today_only = $attrs['today_only'] == 'true';

public/css/wplibcalhours-public.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@
8686
}
8787

8888
.circle-red {
89-
background: #f14668;
89+
background: #BFEBDB;
9090
}
9191

9292
.circle-green {
93-
background: #48c78e;
93+
background: #027150;
9494
}
9595

9696
.open-text {

public/partials/grid.php

+12-8
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@
99
<?php if ($stacked): ?>
1010
<h2><?php echo $location ?> Hours</h2>
1111
<?php endif ?>
12-
<div class="open-indicator">
13-
<div class="circle <?php echo $open_class ?>"></div>
14-
<div>
15-
<span class="open-text"><?php echo $first_day ?></span>
16-
<?php if ($first_day == 'open'):
17-
echo $this->openUntil($days[array_key_first($days)]);
18-
endif ?>
12+
13+
<?php if ($show_status_icon): ?>
14+
<div class="open-indicator">
15+
<div class="circle <?php echo $open_class ?>"></div>
16+
<div>
17+
<span class="open-text"><?php echo $first_day ?></span>
18+
<?php if ($first_day == 'open'):
19+
echo $this->openUntil($days[array_key_first($days)]);
20+
endif ?>
21+
</div>
1922
</div>
20-
</div>
23+
<?php endif ?>
24+
2125
<?php $chunked_weeks = $this->weekBlocks($days); ?>
2226

2327
<?php foreach ($chunked_weeks as $week_number => $chunked_week): ?>

0 commit comments

Comments
 (0)