Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option for hiding header text and logo from the title slide #14

Merged
merged 12 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
clean:
rm -rf docs/*

move:
mv *.html docs/

18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ If you're using version control, you will want to check in this directory.

This filter provides the following options,

| Option | Description |
|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `header` | A simple header text to appear in the top part of the each slide. `header` can be overridden by `title-as-header` or `subtitle-as-header` or slide specific header. |
| `header-logo` | A path for logo image which will appear on the top-left corner of each slide. |
| `sc-sb-title` | `true` or `false`. Specifies whether level1 (`h1`) and level2 (`h2`) slide titles should appear in the slide header automatically when `slide-level` is 2 or 3. |
| `tilte-as-header` | `true` or `false`. Specifies whether the Slide title should appear as the slide header automatically. Will override the `header` text. |
| `subtitle-as-header` | `true` or `false`. Specifies whether the Slide subtitle should appear in the slide header automatically. Will ovverride the `title-as-header`. |

| Option | Description |
|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `header` | A simple header text to appear in the top part of the each slide. `header` can be overridden by `title-as-header` or `subtitle-as-header` or slide specific header. |
| `header-logo` | A path for logo image which will appear on the top-left corner of each slide. |
| `sc-sb-title` | `true` or `false`. Specifies whether level1 (`h1`) and level2 (`h2`) slide titles should appear in the slide header automatically when `slide-level` is 2 or 3. |
| `tilte-as-header` | `true` or `false`. Specifies whether the Slide title should appear as the slide header automatically. Will override the `header` text. |
| `subtitle-as-header` | `true` or `false`. Specifies whether the Slide subtitle should appear in the slide header automatically. Will override the `title-as-header`. |
| `hide-from-titleSlide` | Use `"text"` to remove the header text from title Slide, `"logo"` to remove the logo from top-left corner of header on the title Slide, `"all"` to remove both text and logo from the header on title Slide. |

Therefore an example could be,

Expand Down Expand Up @@ -120,3 +120,5 @@ Also, to change the header text style for slides with simple [`background`](http
- The source code for another example that uses all the options: [example_all.qmd](example_all.qmd) and the live demo of the rendered revealjs slides, [`example_all.html`](https://shafayetshafee.github.io/reveal-header/example_all.html)

- The source code for another example that uses only `sc-sb-title`: [example_section-title.qmd](example_section-title.qmd) and the live demo of the rendered revealjs slides, [`example_section_title.html`](https://shafayetshafee.github.io/reveal-header/example_section_title.html)

- The source code for example where header text is hidden on the title slide: [example_hide_header_text.qmd](example_hide_header_text.qmd) and the [`rendered output`](https://shafayetshafee.github.io/reveal-header/example_hide_header_text.html)
2 changes: 1 addition & 1 deletion _extensions/reveal-header/_extension.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
title: Reveal-header
author: Shafayet Khan Shafee
version: 1.2.4
version: 1.2.5
quarto-required: ">=1.2.0"
contributes:
filters:
Expand Down
43 changes: 29 additions & 14 deletions _extensions/reveal-header/resources/js/add_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ function header() {
};
};

function hide_from_title_slide(element) {
Reveal.on( 'slidechanged' , event => {
if (event.currentSlide.matches('#title-slide')) {
element.style.visibility = 'hidden';
} else {
element.style.visibility = 'visible';
}
});
};


if (Reveal.isReady()) {

Expand Down Expand Up @@ -87,25 +97,30 @@ function header() {
change_header(dyn_header, header_text, header_inner_html);
});

/************** header text in title slide if title or ******/
/************* subtitle is used as header text ******/

/************** header text in title slide if title or ***********************/
/************* subtitle is used as header text ***********************/

var title_text = document.querySelector('.reveal-header .title-text p');

if (title_text != null) {

title_text.style.display = 'none';

Reveal.on( 'slidechanged' , event => {
if (event.currentSlide.matches('#title-slide')) {
title_text.style.display = 'none';
} else {
title_text.style.display = 'block';
}
});
title_text.style.visibility = 'hidden';
hide_from_title_slide(title_text);
};

/*************** hide header text and logo on title slide ********************/

var hide_header_text = document.querySelector('.header-text').getAttribute('data-hide-from-titleslide');
var hide_header_logo = document.querySelector('.header-logo').getAttribute('data-hide-from-titleslide');

if (hide_header_text == 'true') {
header_text.style.visibility = 'hidden';
hide_from_title_slide(header_text);
}

if (hide_header_logo == 'true') {
logo_img.style.visibility = 'hidden';
hide_from_title_slide(logo_img);
}

};
};

Expand Down
11 changes: 11 additions & 0 deletions _extensions/reveal-header/reveal-header.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ if quarto.doc.is_format('revealjs') then
local header_section = pandoc.Div(pandoc.Para(" "), {class = "sc-title"})
local header_sbsection = pandoc.Div(pandoc.Para(" "), {class = "sb-title"})
local header_para = pandoc.Div(pandoc.Para(header_text), header_para_class)
if meta['hide-from-titleSlide'] then
local hide = str(meta['hide-from-titleSlide'])
if hide == "text" then
header_para.attributes['hide-from-titleslide'] = "true"
elseif hide == "logo" then
header_img.attributes['hide-from-titleslide'] = "true"
elseif hide == "all" then
header_para.attributes['hide-from-titleslide'] = "true"
header_img.attributes['hide-from-titleslide'] = "true"
end
end
local div = pandoc.Div(
{
header_img,
Expand Down
125 changes: 81 additions & 44 deletions docs/example.html

Large diffs are not rendered by default.

124 changes: 80 additions & 44 deletions docs/example_all.html

Large diffs are not rendered by default.

Loading