From 5e6ed7d9bd4944cc3ce6578938c7464d312341d9 Mon Sep 17 00:00:00 2001 From: "jacek.lebioda" <jacek.lebioda@uni.lu> Date: Fri, 22 Mar 2019 14:58:05 +0100 Subject: [PATCH] #23 Alert tag --- _plugins/alert.rb | 24 ++++++++++++++++++++++++ _plugins/alert_header.rb | 18 ++++++++++++++++++ _sass/minima/_lcsb.scss | 25 +++++++++++++++++++++++++ index.md | 12 +++++++++++- jekyll-theme-lcsb-default.gemspec | 2 +- 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 _plugins/alert.rb create mode 100644 _plugins/alert_header.rb diff --git a/_plugins/alert.rb b/_plugins/alert.rb new file mode 100644 index 0000000..72a968a --- /dev/null +++ b/_plugins/alert.rb @@ -0,0 +1,24 @@ +module Jekyll + module Tags + class AlertTag < Liquid::Block + def initialize(tag_name, block_options, liquid_options) + super + @class = block_options.strip + end + + def render(context) + context.stack do + context["class"] = @class + @content = super + end + output = <<~EOS + <div class="alert #{@class}"> + #{@content} + </div> + EOS + end + end + end +end + +Liquid::Template.register_tag('alert', Jekyll::Tags::AlertTag) \ No newline at end of file diff --git a/_plugins/alert_header.rb b/_plugins/alert_header.rb new file mode 100644 index 0000000..2f1617d --- /dev/null +++ b/_plugins/alert_header.rb @@ -0,0 +1,18 @@ +module Jekyll + module Tags + class AlertHeaderTag < Liquid::Block + def initialize(tag_name, block_options, liquid_options) + super + end + + def render(context) + context.stack do + @content = super + end + output = "<h3>#{@content}</h3>" + end + end + end +end + +Liquid::Template.register_tag('alert_header', Jekyll::Tags::AlertHeaderTag) \ No newline at end of file diff --git a/_sass/minima/_lcsb.scss b/_sass/minima/_lcsb.scss index 7ec1390..f88e740 100644 --- a/_sass/minima/_lcsb.scss +++ b/_sass/minima/_lcsb.scss @@ -10,6 +10,31 @@ height: 50px; } +div.alert { + padding: .75rem 1.25rem; + border: 1px solid transparent; + border-radius: 3px; + margin: 10px; + font-weight: 300; +} + +div.alert > h3 { + font-weight: 600; + margin-bottom: 3px +} + +div.alert.warning { + border-color: #feedbb; + background-color: #fef5cf; + color: #846102; +} + +div.alert.info { + border-color: #baeeff; + background-color: #c3e5ff; + color: #045689; +} + // Normal (desktop) ======================================================== .img-uni-lu { bottom: -2px; diff --git a/index.md b/index.md index 880ce3b..d621f6b 100644 --- a/index.md +++ b/index.md @@ -14,4 +14,14 @@ The theme is displayed via Gitlab [pages](https://core-services.pages.uni.lu/jek Read the [README](https://git-r3lab.uni.lu/core-services/jekyll-theme-lcsb-default/blob/master/README.md) file to know how to use in your project. -To start a new page for your repository, you can fork [this project](https://git-r3lab.uni.lu/core-services/pages-jekyll-lcsb-template) and start to modify it directly. \ No newline at end of file +To start a new page for your repository, you can fork [this project](https://git-r3lab.uni.lu/core-services/pages-jekyll-lcsb-template) and start to modify it directly. + +{% alert info %} +{% alert_header %}Header{% endalert_header %} +This is a test info alert +{% endalert %} + +{% alert warning %} +{% alert_header %}Header{% endalert_header %} +This is a test warning alert +{% endalert %} \ No newline at end of file diff --git a/jekyll-theme-lcsb-default.gemspec b/jekyll-theme-lcsb-default.gemspec index 65eef03..dd127ef 100644 --- a/jekyll-theme-lcsb-default.gemspec +++ b/jekyll-theme-lcsb-default.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |spec| spec.name = "jekyll-theme-lcsb-default" - spec.version = "0.2.18" + spec.version = "0.2.19" spec.authors = ["Trefex", "jaceklebioda_lux"] spec.email = ["lcsb-sysadmins@uni.lu"] -- GitLab