From 3d9ae29c8642433a9e31f19d289ea2b9297884fb Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Wed, 8 Nov 2023 15:22:12 +0000 Subject: [PATCH 1/8] feat: change header bar based on more environments --- app/assets/stylesheets/limber/colours.scss | 6 ++ app/assets/stylesheets/limber/screen.scss | 91 +++++++++++++++++----- app/helpers/application_helper.rb | 4 - app/views/application/_header.html.erb | 2 +- app/views/layouts/application.html.erb | 2 +- 5 files changed, 79 insertions(+), 26 deletions(-) diff --git a/app/assets/stylesheets/limber/colours.scss b/app/assets/stylesheets/limber/colours.scss index e852f478c..3fc6edc01 100644 --- a/app/assets/stylesheets/limber/colours.scss +++ b/app/assets/stylesheets/limber/colours.scss @@ -1,3 +1,9 @@ +/* Colours defined per environment */ +$production: $gray-800 !default; +$training: $green !default; +$staging: $red !default; +$development: $gray-100 !default; + @mixin shade-aliquot($base_colour, $text_colour) { &.aliquot, &.pool_name { diff --git a/app/assets/stylesheets/limber/screen.scss b/app/assets/stylesheets/limber/screen.scss index d0b64f0a6..e57d09da6 100644 --- a/app/assets/stylesheets/limber/screen.scss +++ b/app/assets/stylesheets/limber/screen.scss @@ -9,52 +9,103 @@ body { margin-bottom: 50px; } -header.limber-header { +/* Background colours for different environments */ +.bg-production { + background-color: $production; +} +.bg-training { + background-color: $training; +} +.bg-staging { + background-color: $staging; +} +.bg-development { + background-color: $development; +} + +// navbar styles +%navbar-dark-style { nav { - @extend .navbar; - @extend .navbar-expand-md; @extend .navbar-dark; } + .navbar-text { + @extend .text-light; + } } - -#app { - margin-bottom: 100px; +%navbar-light-style { + nav { + @extend .navbar-light; + } + .navbar-text { + @extend .text-dark; + } + @extend .border-bottom; // add border to bottom to increase visibility + border-bottom-color: #eaecef !important; // set border color to match jumbotron background } -#flashes { - @extend .col-12; +// development and unknown environments +header.limber-header { + @extend %navbar-light-style; + nav { + @extend .navbar; + @extend .navbar-expand-md; + @extend .py-3; + @extend .bg-development; + } } -#plate-title, -#tube-title, -.card-header, -#tube-rack-title { - font-weight: 300; +.environment { + @extend .badge; + @extend .badge-light; + @extend .mr-2; } +// Set the background color of the navbar based on the environment .production { header.limber-header { + @extend %navbar-dark-style; nav { - @extend .bg-dark; + @extend .bg-production; } .environment { display: none; } } } -.nonproduction { + +.training { header.limber-header { + @extend %navbar-dark-style; nav { - @extend .bg-danger; + @extend .bg-training; } - .environment { - @extend .badge; - @extend .badge-light; - @extend .mr-2; + } +} + +.staging { + header.limber-header { + @extend %navbar-dark-style; + nav { + @extend .bg-staging; } } } +#app { + margin-bottom: 100px; +} + +#flashes { + @extend .col-12; +} + +#plate-title, +#tube-title, +.card-header, +#tube-rack-title { + font-weight: 300; +} + .tube-list, .plate-list { @extend .list-group; diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1663b324c..f244f7180 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -27,10 +27,6 @@ def environment Rails.env end - def environment_type_class - Rails.env.production? ? 'production' : 'nonproduction' - end - def each_robot(&block) Robots.each_robot(&block) end diff --git a/app/views/application/_header.html.erb b/app/views/application/_header.html.erb index 65953ac28..441549f80 100644 --- a/app/views/application/_header.html.erb +++ b/app/views/application/_header.html.erb @@ -12,7 +12,7 @@ - + <% if logged_in? %> Currently logged in as, <%= user_name.titlecase %> <%= session_switcher %> <% else %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 665cd180c..278234420 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -25,7 +25,7 @@ - +
<%= render 'header' %> <%= render partial: 'flash_messages' %> From 4e972f63161d756ea2389809418e115e60a0a145 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 9 Nov 2023 14:13:12 +0000 Subject: [PATCH 2/8] feat: change favicon based on environment --- app/helpers/application_helper.rb | 29 +++++++++++ app/views/layouts/application.html.erb | 3 +- public/apple-touch-icon-development.png | Bin 0 -> 6074 bytes public/apple-touch-icon-staging.png | Bin 0 -> 6152 bytes public/apple-touch-icon-training.png | Bin 0 -> 6125 bytes public/favicon-development.ico | Bin 0 -> 4286 bytes public/favicon-staging.ico | Bin 0 -> 4286 bytes public/favicon-training.ico | Bin 0 -> 4286 bytes spec/helpers/application_helper_spec.rb | 61 ++++++++++++++++++++++++ 9 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 public/apple-touch-icon-development.png create mode 100644 public/apple-touch-icon-staging.png create mode 100644 public/apple-touch-icon-training.png create mode 100644 public/favicon-development.ico create mode 100644 public/favicon-staging.ico create mode 100644 public/favicon-training.ico create mode 100644 spec/helpers/application_helper_spec.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f244f7180..e00f68ae0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -36,4 +36,33 @@ def pipeline_groups return [] if Settings.pipelines.list.empty? Settings.pipelines.map(&:pipeline_group).uniq.sort end + + # Returns the appropriate icon suffix for the current environment + # Returns empty string for production + # Returns "-#{environment}" for training, staging + # Returns "-development" for any other environment + # @return [String] The suffix to append to the icon name + def icon_suffix + environment = Rails.env + case environment + when 'production' + '' + when 'training', 'staging' + "-#{environment}" + else + '-development' + end + end + + # Return the appropriate favicon for the current environment + # @return [String] The path to the favicon + def favicon + "favicon#{icon_suffix}.ico" + end + + # Return the appropriate apple icon for the current environment + # @return [String] The path to the apple icon + def apple_icon + "apple-icon#{icon_suffix}.png" + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 278234420..32e685b58 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -21,9 +21,10 @@ <% end %> - + +
diff --git a/public/apple-touch-icon-development.png b/public/apple-touch-icon-development.png new file mode 100644 index 0000000000000000000000000000000000000000..cb7ba65362bbba3b949c015a09efc1de46a5d701 GIT binary patch literal 6074 zcmeHLd010d77ycy5i6jgr3GpTphXPX$pT>si$n_|M2r#9m*gb`vKc}GD0LwU3Mxxc zLC|8giWXeJrAk!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^`c>{p+8axTBD=cI?z#U^@Aswb}TFNW$0bW zM;eb;L^LBf435J_t#d<^@RZkXh`-*6ZxWfrnYWrkZ;L*#f!w$;Mh6r^OCiF;zhh<);kDBDo zH<&x)s8h`4NOW$o4JZW0VzdYDd{tW{dSRwo@GoPJ)ry8Q*C~tiv30kATD6ei{8-Xz zv90pj{=2Fwq~J;2>)js5)` zANF}#!%72|6^&3=Mbsb1Akd554WLSc8PyUXK(NSGBuqr1|$X9j0a8`=_T~6J_g| zdN%2E@sIMS3-dxUn}$!SIem3W0z&Z=4r_pJo*1cgaq^n-5YEh?D?Dq(QQW@*i8w{NRl# zKrOE0QseRYPZtIwDt-2>@70BQ{|ibZFwKVA8yfzzE>b1On;oFIKL(B5zp*@T_`X*O zr(N7!e9S5S`Cg;%+>Yj)9FUhe8|{}7h$cS&gSqpG6 zw`xzl$S0F73p*x%azIogIrc~b|9btWC8Ay~hC;dUxLI|!a(=jnb||y@v|&Tj-BV4? wBRqam%Kb%SJ7%p6Ln*;!^7ikIcNjODz@F@iyaA7y$j?2;&D*tzwPD-e0H7*rZvX%Q literal 0 HcmV?d00001 diff --git a/public/apple-touch-icon-training.png b/public/apple-touch-icon-training.png new file mode 100644 index 0000000000000000000000000000000000000000..5ba98fd52f36d898da9a167303435d5cb728f14e GIT binary patch literal 6125 zcmeHKc~n!^)(=t#P>=!+;1t7Pffq6d5(!AcYy&(%Kos%j=7xlj!6eLx1E56sx-`_x>|$<=%VF+2?om{_Wr1 z$xZY1cGuH2)x}^idY&FGe&Ak>erL@9S615$GPpIy2L!A9pct%NArpuq5v(dsj$n~k zkpP2K2fAobUd+8lc<$IX1`=Bq5Jc1pInEF{8e zW2W`Kd<)$Sx{0%;&w!z6#gIyeZ&7!K>iCAzmDEG8C zZI}7{$}ee`$6KjTH8XuTN_g_2wxNxVtx<5>oqufTyNuW&g*#h-AlESZ#OhYx%&@qy|QHE z=;ciAt$h;#>>|vW!#C_6ZY^4e{byJHx;KlD&Rw-bu&+)_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^j4Z}?$E?{H?{ zOtY$|E7!aovFoB=`p4j&@x-=JFgRK#PN4mV~;wm&2Bz%ygz0n zbnJ50;7OzC`gA>+f8id&OTEx}>=i!G$7O91hjeRfQl+Ko1Mx*iy*kHU@VMiOpoZRs pqjUAPsxh;`W$N~Se6BCtqLpFfGT^-vH-!GCd%AkNRIoR0|2MCpZm|FW literal 0 HcmV?d00001 diff --git a/public/favicon-development.ico b/public/favicon-development.ico new file mode 100644 index 0000000000000000000000000000000000000000..5dacd724849498d8f3ba171a071cedf45a1bcebf GIT binary patch literal 4286 zcmZQzU<5)11qKkwutI==L5zWcK?8_^LJST-3=#(epqvml1VaQE81^4M{eKjXhQVkW zz@G*-?b!RDkDvd)x`rkYYZ1ihS$R~?SBgq1|2J;iLv?eBjeA#jum8Ohrw*9?xrHVF zQ!}y$%>L=K7yP%ea~LrDx9vIfUsg_j!0ZR56D@7s|0~vQ9xyiq28aD`Z0#H{`>X1j z{zpW|4Ve9lmaqM9U}QXC_U}D(;=iHp@P`v)ux9GzYNPnefZ0ED%HjX<5pxI3 z{`AB}|0i_s9WeXN^&9^m+;?}t?3Wf!`+xn)$NzF-nFHpA-P>>ew=roQF#Ee&cmB^! zUp8R&M+DCJKY!No0kdC6rTqWt6VC?Beo%dN`NG@(Dl!EF=7u#Z&j0sz=^rrrtIO8^ zuPNIwVD@`C_x)eD>f(UeuPmMa|H{Sp17<%c4LVwO4XFLZw%bP4;cwfIG*5-<<`NtC>rO5EAKT|QVD>kx zDEZ&LzJ9>$4{CM#zvJS@0khvAL+<~rcUS+b$Ky|{#KtE%>drho_TR2dcfi76;eqM@ zvu4B$nEgfbQvc7`)i+@FyH=b0KX&`TfZ4B^DDnT!`)mJoQltmW4F|68`tQ|XIbilr z-q!KIVo~;h*`G2w?EkW(a|g_Rt0K++7oMCNF#AE}){WPf{u^a04wxG@on8GuqRV5z z>~CFN`M-5d)qvR_-s%2-%lS0}X1`&U!vC9ZFAtdgpfu>;YB!+vlT&|>>KVAU(_jpH J*f_vI(EvQ|scirN literal 0 HcmV?d00001 diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb new file mode 100644 index 000000000..c8eecce79 --- /dev/null +++ b/spec/helpers/application_helper_spec.rb @@ -0,0 +1,61 @@ +require './app/helpers/application_helper' + +describe ApplicationHelper do + describe '#favicon' do + subject(:favicon) { helper.favicon } + + it 'returns the favicon path for the production environment' do + allow(Rails).to receive(:env).and_return('production') + expect(favicon).to eq('favicon.ico') + end + + it 'returns the favicon path for the training environment' do + allow(Rails).to receive(:env).and_return('training') + expect(favicon).to eq('favicon-training.ico') + end + + it 'returns the favicon path for the staging environment' do + allow(Rails).to receive(:env).and_return('staging') + expect(favicon).to eq('favicon-staging.ico') + end + + it 'returns the favicon path for the development environment' do + allow(Rails).to receive(:env).and_return('development') + expect(favicon).to eq('favicon-development.ico') + end + + it 'returns the favicon path for an unknown environment' do + allow(Rails).to receive(:env).and_return('unknown') + expect(favicon).to eq('favicon-development.ico') + end + end + + describe '#apple_icon' do + subject(:apple_icon) { helper.apple_icon } + + it 'returns the apple icon path for the production environment' do + allow(Rails).to receive(:env).and_return('production') + expect(apple_icon).to eq('apple-icon.png') + end + + it 'returns the apple icon path for the training environment' do + allow(Rails).to receive(:env).and_return('training') + expect(apple_icon).to eq('apple-icon-training.png') + end + + it 'returns the apple icon path for the staging environment' do + allow(Rails).to receive(:env).and_return('staging') + expect(apple_icon).to eq('apple-icon-staging.png') + end + + it 'returns the apple icon path for the development environment' do + allow(Rails).to receive(:env).and_return('development') + expect(apple_icon).to eq('apple-icon-development.png') + end + + it 'returns the apple icon path for an unknown environment' do + allow(Rails).to receive(:env).and_return('unknown') + expect(apple_icon).to eq('apple-icon-development.png') + end + end +end From a316d3a36ebe60e57ffbbcf1773f1b153154c80c Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 9 Nov 2023 14:31:45 +0000 Subject: [PATCH 3/8] feat: change logout button based on environment and fix formatting --- app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/limber/icons.scss | 50 +++++++++++++++++++++++ app/assets/stylesheets/limber/screen.scss | 28 +++++++++++++ app/helpers/session_helper.rb | 2 +- app/views/application/_header.html.erb | 9 ++-- 5 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 app/assets/stylesheets/limber/icons.scss diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 956fd4b79..313f6fba9 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -4,6 +4,7 @@ @import 'limber/_labware-mixins'; @import 'bootstrap'; @import 'limber/screen'; +@import 'limber/icons'; @import 'limber/plate'; @import 'limber/tube'; @import 'limber/tube-rack'; diff --git a/app/assets/stylesheets/limber/icons.scss b/app/assets/stylesheets/limber/icons.scss new file mode 100644 index 000000000..719aa7dc9 --- /dev/null +++ b/app/assets/stylesheets/limber/icons.scss @@ -0,0 +1,50 @@ +// Bare Bones Icon System +// Created by Stephen Hulme, 2023-11-9 + +// Usage: +// +// Where {name} is the name of the icon and {color} is the bootstrap theme color +// (e.g. icon-user-primary, icon-user-secondary, icon-user-success, etc.) + +$icon-size: 24px; + +/// Replace `$search` with `$replace` in `$string` +/// @author Kitty Giraudel +/// @param {String} $string - Initial string +/// @param {String} $search - Substring to replace +/// @param {String} $replace ('') - New value +/// @return {String} - Updated string +@function str-replace($string, $search, $replace: '') { + $index: str-index($string, $search); + + @if $index { + @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace); + } + + @return $string; + } + +@mixin icon($name, $path, $theme-color) { + // split theme color into name and value + $theme-color-name: nth($theme-color, 1); + $theme-color-value: nth($theme-color, 2); + // escape characters for html + $escaped-color: str-replace(inspect($theme-color-value), "#", "%23"); + + .icon-#{$name}-#{$theme-color-name} { + display: inline-block; + width: $icon-size; + height: $icon-size; + background-image: url('data:image/svg+xml, #{$path} '); + background-repeat: no-repeat; + background-position: center; + background-size: $icon-size; + } +} + +// icons list +// (add new icons here) +@each $theme-color in $theme-colors { + // iterate over bootstrap theme colors + @include icon('user', '', $theme-color); +} diff --git a/app/assets/stylesheets/limber/screen.scss b/app/assets/stylesheets/limber/screen.scss index e57d09da6..49857f6ea 100644 --- a/app/assets/stylesheets/limber/screen.scss +++ b/app/assets/stylesheets/limber/screen.scss @@ -31,6 +31,9 @@ body { .navbar-text { @extend .text-light; } + .icon-user { + @extend .icon-user-light; + } } %navbar-light-style { nav { @@ -39,6 +42,13 @@ body { .navbar-text { @extend .text-dark; } + .icon-user { + @extend .icon-user-secondary; + } + .btn-logout { + @extend .btn-light; + @extend .border; + } @extend .border-bottom; // add border to bottom to increase visibility border-bottom-color: #eaecef !important; // set border color to match jumbotron background } @@ -70,6 +80,10 @@ header.limber-header { .environment { display: none; } + .btn-logout { + @extend .btn-danger; + @extend .border-0; + } } } @@ -79,6 +93,10 @@ header.limber-header { nav { @extend .bg-training; } + .btn-logout { + @extend .btn-success; + border-color: darken($training, 5%) !important + } } } @@ -88,6 +106,10 @@ header.limber-header { nav { @extend .bg-staging; } + .btn-logout { + @extend .btn-danger; + border-color: darken($staging, 5%) !important + } } } @@ -173,6 +195,12 @@ nav.robots-list { font-weight: lighter; } +.btn-logout { + @extend .btn; + @extend .btn-secondary; + @extend .rounded; +} + .logged_in { .logged_out_only { display: none; diff --git a/app/helpers/session_helper.rb b/app/helpers/session_helper.rb index cf2e1cb0c..326b0862f 100644 --- a/app/helpers/session_helper.rb +++ b/app/helpers/session_helper.rb @@ -30,6 +30,6 @@ def check_for_login! end def session_switcher - link_to 'Log Out', logout_sessions_path, class: 'btn btn-danger' if logged_in? + link_to 'Log Out', logout_sessions_path, class: 'btn-logout' if logged_in? end end diff --git a/app/views/application/_header.html.erb b/app/views/application/_header.html.erb index 441549f80..1c2a78425 100644 --- a/app/views/application/_header.html.erb +++ b/app/views/application/_header.html.erb @@ -12,11 +12,14 @@ - <% if logged_in? %> - Currently logged in as, <%= user_name.titlecase %> <%= session_switcher %> + + + <%= user_name.titlecase %> + + <%= session_switcher %> <% else %> - Not logged in + Not logged in <% end %>
From cfb71df42fef897bfd5edf3c9844f13baa310404 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 9 Nov 2023 14:52:44 +0000 Subject: [PATCH 4/8] fix: improve display of environment badge --- app/assets/stylesheets/limber/screen.scss | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/limber/screen.scss b/app/assets/stylesheets/limber/screen.scss index 49857f6ea..50b52b652 100644 --- a/app/assets/stylesheets/limber/screen.scss +++ b/app/assets/stylesheets/limber/screen.scss @@ -65,8 +65,17 @@ header.limber-header { } .environment { - @extend .badge; - @extend .badge-light; + // surround in bold square brackets + &:before { + content: '['; + font-weight: bold; + } + &:after { + content: ']'; + font-weight: bold; + } + @extend .navbar-text; + @extend .small; @extend .mr-2; } @@ -193,6 +202,7 @@ nav.robots-list { font-style: oblique; font-stretch: ultra-condensed; font-weight: lighter; + @extend .mr-2; } .btn-logout { From 5834460dfffca1c9ca77273f10cc89629bc7c356 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 9 Nov 2023 14:54:01 +0000 Subject: [PATCH 5/8] fix: normalise sizes of flash notice --- app/views/application/_flash_messages.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/application/_flash_messages.html.erb b/app/views/application/_flash_messages.html.erb index 2d02be224..f85ef35aa 100644 --- a/app/views/application/_flash_messages.html.erb +++ b/app/views/application/_flash_messages.html.erb @@ -1,8 +1,8 @@
<% flash.each do |name, message| %>
-

<%= name.titleize %>

-
    <% Array(message).each do |m| %>
  • <%= m %> <% end %>
+ <%= name.titleize %> +
    <% Array(message).each do |m| %>
  • <%= m %> <% end %>
<% end %>
From 65bde5f80f0108709c6fde600a900ac8c8c804ed Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 9 Nov 2023 14:59:50 +0000 Subject: [PATCH 6/8] style: lint --- app/assets/stylesheets/limber/icons.scss | 51 +++++++++++++---------- app/assets/stylesheets/limber/screen.scss | 12 +++--- spec/helpers/application_helper_spec.rb | 6 ++- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/app/assets/stylesheets/limber/icons.scss b/app/assets/stylesheets/limber/icons.scss index 719aa7dc9..c0aef06f8 100644 --- a/app/assets/stylesheets/limber/icons.scss +++ b/app/assets/stylesheets/limber/icons.scss @@ -15,36 +15,41 @@ $icon-size: 24px; /// @param {String} $replace ('') - New value /// @return {String} - Updated string @function str-replace($string, $search, $replace: '') { - $index: str-index($string, $search); + $index: str-index($string, $search); - @if $index { - @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace); - } - - @return $string; + @if $index { + @return str-slice($string, 1, $index - 1) + $replace + + str-replace(str-slice($string, $index + str-length($search)), $search, $replace); } + @return $string; +} + @mixin icon($name, $path, $theme-color) { - // split theme color into name and value - $theme-color-name: nth($theme-color, 1); - $theme-color-value: nth($theme-color, 2); - // escape characters for html - $escaped-color: str-replace(inspect($theme-color-value), "#", "%23"); - - .icon-#{$name}-#{$theme-color-name} { - display: inline-block; - width: $icon-size; - height: $icon-size; - background-image: url('data:image/svg+xml, #{$path} '); - background-repeat: no-repeat; - background-position: center; - background-size: $icon-size; - } + // split theme color into name and value + $theme-color-name: nth($theme-color, 1); + $theme-color-value: nth($theme-color, 2); + // escape characters for html + $escaped-color: str-replace(inspect($theme-color-value), '#', '%23'); + + .icon-#{$name}-#{$theme-color-name} { + display: inline-block; + width: $icon-size; + height: $icon-size; + background-image: url('data:image/svg+xml, #{$path} '); + background-repeat: no-repeat; + background-position: center; + background-size: $icon-size; + } } // icons list // (add new icons here) @each $theme-color in $theme-colors { - // iterate over bootstrap theme colors - @include icon('user', '', $theme-color); + // iterate over bootstrap theme colors + @include icon( + 'user', + '', + $theme-color + ); } diff --git a/app/assets/stylesheets/limber/screen.scss b/app/assets/stylesheets/limber/screen.scss index 50b52b652..80bc2a471 100644 --- a/app/assets/stylesheets/limber/screen.scss +++ b/app/assets/stylesheets/limber/screen.scss @@ -49,7 +49,7 @@ body { @extend .btn-light; @extend .border; } - @extend .border-bottom; // add border to bottom to increase visibility + @extend .border-bottom; // add border to bottom to increase visibility border-bottom-color: #eaecef !important; // set border color to match jumbotron background } @@ -82,7 +82,7 @@ header.limber-header { // Set the background color of the navbar based on the environment .production { header.limber-header { - @extend %navbar-dark-style; + @extend %navbar-dark-style; nav { @extend .bg-production; } @@ -98,26 +98,26 @@ header.limber-header { .training { header.limber-header { - @extend %navbar-dark-style; + @extend %navbar-dark-style; nav { @extend .bg-training; } .btn-logout { @extend .btn-success; - border-color: darken($training, 5%) !important + border-color: darken($training, 5%) !important; } } } .staging { header.limber-header { - @extend %navbar-dark-style; + @extend %navbar-dark-style; nav { @extend .bg-staging; } .btn-logout { @extend .btn-danger; - border-color: darken($staging, 5%) !important + border-color: darken($staging, 5%) !important; } } } diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index c8eecce79..1bb169ed2 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,6 +1,8 @@ -require './app/helpers/application_helper' +# frozen_string_literal: true -describe ApplicationHelper do +require 'spec_helper' + +RSpec.describe ApplicationHelper do describe '#favicon' do subject(:favicon) { helper.favicon } From 489255e0572c560fa7e64b21f610a54deab82920 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 9 Nov 2023 16:24:38 +0000 Subject: [PATCH 7/8] docs: update attributions --- app/assets/stylesheets/limber/icons.scss | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/limber/icons.scss b/app/assets/stylesheets/limber/icons.scss index c0aef06f8..1c477d831 100644 --- a/app/assets/stylesheets/limber/icons.scss +++ b/app/assets/stylesheets/limber/icons.scss @@ -1,5 +1,4 @@ // Bare Bones Icon System -// Created by Stephen Hulme, 2023-11-9 // Usage: // @@ -44,9 +43,12 @@ $icon-size: 24px; } // icons list -// (add new icons here) +// (add new icons here, note names must not contain dashes '-') @each $theme-color in $theme-colors { // iterate over bootstrap theme colors + + // icons by Heroicons https://heroicons.com/ + // user-circle @include icon( 'user', '', From 8445c19617b5fc1491d7c9e77fee19892e853ad2 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Tue, 14 Nov 2023 10:32:16 +0000 Subject: [PATCH 8/8] fix: rename apple-icon -> apple-touch-icon --- app/helpers/application_helper.rb | 8 ++++---- app/views/layouts/application.html.erb | 2 +- spec/helpers/application_helper_spec.rb | 24 ++++++++++++------------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e00f68ae0..22916a7fa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -60,9 +60,9 @@ def favicon "favicon#{icon_suffix}.ico" end - # Return the appropriate apple icon for the current environment - # @return [String] The path to the apple icon - def apple_icon - "apple-icon#{icon_suffix}.png" + # Return the appropriate apple-touch-icon for the current environment + # @return [String] The path to the apple-touch-icon + def apple_touch_icon + "apple-touch-icon#{icon_suffix}.png" end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 32e685b58..d7eff1795 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -21,7 +21,7 @@ <% end %> - + diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 1bb169ed2..4b6658db1 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -32,32 +32,32 @@ end end - describe '#apple_icon' do - subject(:apple_icon) { helper.apple_icon } + describe '#apple_touch_icon' do + subject(:apple_touch_icon) { helper.apple_touch_icon } - it 'returns the apple icon path for the production environment' do + it 'returns the apple-touch-icon path for the production environment' do allow(Rails).to receive(:env).and_return('production') - expect(apple_icon).to eq('apple-icon.png') + expect(apple_touch_icon).to eq('apple-touch-icon.png') end - it 'returns the apple icon path for the training environment' do + it 'returns the apple-touch-icon path for the training environment' do allow(Rails).to receive(:env).and_return('training') - expect(apple_icon).to eq('apple-icon-training.png') + expect(apple_touch_icon).to eq('apple-touch-icon-training.png') end - it 'returns the apple icon path for the staging environment' do + it 'returns the apple-touch-icon path for the staging environment' do allow(Rails).to receive(:env).and_return('staging') - expect(apple_icon).to eq('apple-icon-staging.png') + expect(apple_touch_icon).to eq('apple-touch-icon-staging.png') end - it 'returns the apple icon path for the development environment' do + it 'returns the apple-touch-icon path for the development environment' do allow(Rails).to receive(:env).and_return('development') - expect(apple_icon).to eq('apple-icon-development.png') + expect(apple_touch_icon).to eq('apple-touch-icon-development.png') end - it 'returns the apple icon path for an unknown environment' do + it 'returns the apple-touch-icon path for an unknown environment' do allow(Rails).to receive(:env).and_return('unknown') - expect(apple_icon).to eq('apple-icon-development.png') + expect(apple_touch_icon).to eq('apple-touch-icon-development.png') end end end