jekyll-bulma-tabs 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +10 -0
- data/README.md +102 -0
- data/Rakefile +8 -0
- data/docs/tabs.css +7 -0
- data/docs/tabs.js +40 -0
- data/lib/jekyll/bulma/tabs/version.rb +9 -0
- data/lib/jekyll/bulma/tabs.rb +58 -0
- data/lib/jekyll/bulma/template.erb +20 -0
- data/sig/jekyll/bulma/tabs.rbs +8 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7077c00bf3aaeb0ed31fc92548e513d7c7c11210c2fca8ee539dd7a0413a9da4
|
4
|
+
data.tar.gz: 6794ebc37b5996b9f72f035f3bdcf5cd8f868f8d23608065019499767de37534
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b9a369230e6f040ad968147c4ccec08fa14d1f4a014a905923252be77a9eaa27b59c2f64af93cd11155c54911f1d4767a92e655ee78363aa06bb15fdb866105
|
7
|
+
data.tar.gz: f5d16e3363b2cf0270f310fdb8f0b4b33eb51c6345bb8db9e1627d8fe363499392fb38fa776a0f67ce7bf16a1cd5f0c71d571f0286f62d605c67a53557c77697
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# Jekyll Bulma Tabs Plugin
|
2
|
+
|
3
|
+
This is a Jekyll tags plugin to add [bulma](https://bulma.io/) style tabs to the GitHub pages
|
4
|
+
along with the [bulma-clean-theme](https://github.com/chrisrhymes/bulma-clean-theme).
|
5
|
+
|
6
|
+
This plugin was created based on the [Jekyll Tabs](https://github.com/Ovski4/jekyll-tabs) plugin.
|
7
|
+
Like the Jekyll Tabs does, Jekyll Bulma Tabs has features:
|
8
|
+
- works with multiple tab panels on the same page
|
9
|
+
- doesn't require a specific JavaScript framework
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
#### Plugin
|
14
|
+
|
15
|
+
Add the plugin in the Jekyll GitHub pages `Gemfile`.
|
16
|
+
```ruby
|
17
|
+
group :jekyll_plugins do
|
18
|
+
# ... other gems
|
19
|
+
gem "jekyll-bulma-tabs"
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
Also, add the plugin in the Jekyll Github pages `_config.yml`.
|
24
|
+
```yml
|
25
|
+
plugins:
|
26
|
+
- jekyll-bulma-tabs
|
27
|
+
```
|
28
|
+
|
29
|
+
Run the command below to install the plugin.
|
30
|
+
```bash
|
31
|
+
bundle install
|
32
|
+
```
|
33
|
+
|
34
|
+
#### JavaScript and CSS
|
35
|
+
Copy JavaScript and CSS files to the Jekyll Github pages public directory.
|
36
|
+
In general, the places are `assets/js` and `assets/css`.
|
37
|
+
- JavaScript: [https://raw.githubusercontent.com/yokolet/jekyll-bulma-tabs/main/docs/tabs.js](https://raw.githubusercontent.com/yokolet/jekyll-bulma-tabs/main/docs/tabs.js)
|
38
|
+
- CSS: [https://raw.githubusercontent.com/yokolet/jekyll-bulma-tabs/main/docs/tabs.css](https://raw.githubusercontent.com/yokolet/jekyll-bulma-tabs/main/docs/tabs.css)
|
39
|
+
|
40
|
+
Add `tabs.js` and `tabs.css` to GitHub pages' header/footer area. Exactly what file depends on how the GitHub pages are
|
41
|
+
created. For example, if the theme is bulma-clean-theme, the `tabs.js` goes to `_includes/footer-scripts.html` while the
|
42
|
+
`tabs.css` goes to `_includes/head.html`.
|
43
|
+
|
44
|
+
Example:
|
45
|
+
- `_includes/footer-scripts.html`
|
46
|
+
```html
|
47
|
+
<script src="{{ "/assets/js/tabs.js" | prepend: site.baseurl }}" type="text/javascript"></script>
|
48
|
+
```
|
49
|
+
- `_includes/head.html`
|
50
|
+
```html
|
51
|
+
<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/tabs.css">
|
52
|
+
```
|
53
|
+
|
54
|
+
## Usage
|
55
|
+
|
56
|
+
#### Markup
|
57
|
+
The markup looks like below:
|
58
|
+
|
59
|
+
````markdown
|
60
|
+
{% tabs data-struct is-centered is-boxed %}
|
61
|
+
|
62
|
+
{% tab data-struct yaml %}
|
63
|
+
```yaml
|
64
|
+
hello:
|
65
|
+
- 'whatsup'
|
66
|
+
- 'hi'
|
67
|
+
```
|
68
|
+
{% endtab %}
|
69
|
+
|
70
|
+
{% tab data-struct json %}
|
71
|
+
```json
|
72
|
+
{
|
73
|
+
"hello": ["whatsup", "hi"]
|
74
|
+
}
|
75
|
+
```
|
76
|
+
{% endtab %}
|
77
|
+
|
78
|
+
{% endtabs %}
|
79
|
+
````
|
80
|
+
|
81
|
+
#### Description
|
82
|
+
The syntax is:
|
83
|
+
```markdown
|
84
|
+
{% tabs tabs-group-id bulma-tabs-options %}
|
85
|
+
{% tab tabs-group-id tab-title-1 %}
|
86
|
+
contents1
|
87
|
+
{% endtab %}
|
88
|
+
{% tab tabs-group-id tab-title-2 %}
|
89
|
+
contents2
|
90
|
+
{% endtab %}
|
91
|
+
{% endtabs %}
|
92
|
+
```
|
93
|
+
|
94
|
+
- tabs-group-id: (mandate) The id of tabs group and used to switch contents.
|
95
|
+
- bulma-tabs-options: (optional) Among the bulma tabs styling options, those used with tabs class are supported such as `is-centered` or `is-boxed`.
|
96
|
+
- tab-title: (mandate) The title appears in the tab.
|
97
|
+
- contents: (mandate) The contents tied to the tab title.
|
98
|
+
|
99
|
+
|
100
|
+
## License
|
101
|
+
|
102
|
+
The theme is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/docs/tabs.css
ADDED
data/docs/tabs.js
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
const TABS = [...document.querySelectorAll('div.tabs ul li')];
|
2
|
+
const CONTENTS = [...document.querySelectorAll('div.tab-content')];
|
3
|
+
const ACTIVE_CLASS = 'is-active';
|
4
|
+
|
5
|
+
const updateActiveTab = (selected) => {
|
6
|
+
let tabs_group = selected.substring(0, selected.lastIndexOf('-'));
|
7
|
+
TABS.forEach((tab) => {
|
8
|
+
let data = tab.getAttribute('data-tab');
|
9
|
+
if (tab && data.startsWith(tabs_group) && tab.classList.contains(ACTIVE_CLASS)) {
|
10
|
+
tab.classList.remove(ACTIVE_CLASS);
|
11
|
+
}
|
12
|
+
if (data === selected) {
|
13
|
+
tab.classList.add(ACTIVE_CLASS);
|
14
|
+
}
|
15
|
+
});
|
16
|
+
}
|
17
|
+
|
18
|
+
const updateActiveContent = (selected) => {
|
19
|
+
let tabs_group = selected.substring(0, selected.lastIndexOf('-'));
|
20
|
+
CONTENTS.forEach((content) => {
|
21
|
+
let data = content.getAttribute('data-content');
|
22
|
+
if (content && data.startsWith(tabs_group) && content.classList.contains(ACTIVE_CLASS)) {
|
23
|
+
content.classList.remove(ACTIVE_CLASS);
|
24
|
+
}
|
25
|
+
if (data === selected) {
|
26
|
+
content.classList.add(ACTIVE_CLASS);
|
27
|
+
}
|
28
|
+
});
|
29
|
+
}
|
30
|
+
|
31
|
+
window.addEventListener('load', (event) => {
|
32
|
+
TABS.forEach((tab) => {
|
33
|
+
tab.addEventListener('click', (event) => {
|
34
|
+
event.preventDefault();
|
35
|
+
let selected = tab.getAttribute('data-tab');
|
36
|
+
updateActiveTab(selected);
|
37
|
+
updateActiveContent(selected);
|
38
|
+
});
|
39
|
+
});
|
40
|
+
});
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "tabs/version"
|
4
|
+
|
5
|
+
module Jekyll
|
6
|
+
module Bulma
|
7
|
+
module Tabs
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
class TabsBlock < Liquid::Block
|
11
|
+
def initialize(tag_name, markup, options)
|
12
|
+
super
|
13
|
+
markups = markup.split(' ', 2)
|
14
|
+
if markups.length == 0
|
15
|
+
raise SyntaxError.new("Block #{tag_name} requires 1 attribute")
|
16
|
+
end
|
17
|
+
@tabs_group = markups[0]
|
18
|
+
@tabs_opts = markups[1]
|
19
|
+
end
|
20
|
+
|
21
|
+
def render(context)
|
22
|
+
super
|
23
|
+
environment = context.environments.first
|
24
|
+
currentDirectory = File.dirname(__FILE__)
|
25
|
+
templateFile = File.read(currentDirectory + '/template.erb')
|
26
|
+
template = ERB.new(templateFile)
|
27
|
+
template.result(binding)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class TabBlock < Liquid::Block
|
32
|
+
alias_method :render_block, :render
|
33
|
+
|
34
|
+
def initialize(tag_name, markup, options)
|
35
|
+
super
|
36
|
+
markups = markup.split(' ', 2)
|
37
|
+
if markups.length != 2
|
38
|
+
raise SyntaxError.new("Block #{tag_name} requires 2 attributes")
|
39
|
+
end
|
40
|
+
@tabs_group = markups[0]
|
41
|
+
@tab_id = markups[1]
|
42
|
+
end
|
43
|
+
|
44
|
+
def render(context)
|
45
|
+
super
|
46
|
+
site = context.registers[:site]
|
47
|
+
converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
|
48
|
+
environment = context.environments.first
|
49
|
+
environment["tabs-#{@tabs_group}"] ||= {}
|
50
|
+
environment["tabs-#{@tabs_group}"][@tab_id] = converter.convert(render_block(context))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
Liquid::Template.register_tag('tab', Jekyll::Bulma::Tabs::TabBlock)
|
58
|
+
Liquid::Template.register_tag('tabs', Jekyll::Bulma::Tabs::TabsBlock)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="tabs <%= @tabs_opts %>" id="<%= @tabs_group %>">
|
2
|
+
<div class="container">
|
3
|
+
<ul>
|
4
|
+
<% environment["tabs-#{@tabs_group}"].each_with_index do |(key, value), index| %>
|
5
|
+
<li<%= index == 0 ? ' class="is-active"' : ''%>
|
6
|
+
data-tab="<%= @tabs_group + '-' + index.to_s %>">
|
7
|
+
<a><span><%= key %></span></a>
|
8
|
+
</li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
<div id="<%= @tabs_group %>-content">
|
14
|
+
<div class="container box">
|
15
|
+
<% environment["tabs-#{@tabs_group}"].each_with_index do |(key, value), index| %>
|
16
|
+
<div<%= index == 0 ? ' class="is-active tab-content"' : ' class="tab-content"'%>
|
17
|
+
data-content="<%= @tabs_group + '-' + index.to_s %>"><%= value %></div>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</div>
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-bulma-tabs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yoko Harada
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.6'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.6'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
description: Generate a tabbed interface with bulma as a CSS framework.
|
34
|
+
email:
|
35
|
+
- yokolet@gmail.com
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- Gemfile
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- docs/tabs.css
|
44
|
+
- docs/tabs.js
|
45
|
+
- lib/jekyll/bulma/tabs.rb
|
46
|
+
- lib/jekyll/bulma/tabs/version.rb
|
47
|
+
- lib/jekyll/bulma/template.erb
|
48
|
+
- sig/jekyll/bulma/tabs.rbs
|
49
|
+
homepage: https://github.com/yokolet/jekyll-bulma-tabs.
|
50
|
+
licenses:
|
51
|
+
- MIT
|
52
|
+
metadata:
|
53
|
+
homepage_uri: https://github.com/yokolet/jekyll-bulma-tabs.
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.6.0
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubygems_version: 3.3.7
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: A Jekyll plugin to add bulma compatible tabs.
|
73
|
+
test_files: []
|