Skip to content

Commit 40acb52

Browse files
committed
Updates
1 parent 8c062b9 commit 40acb52

File tree

6 files changed

+283
-274
lines changed

6 files changed

+283
-274
lines changed

docs/_data/config-header.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
brand:
2-
type: link
2+
type: button
33
image: https://executablebooks.org/en/latest/_static/logo.svg
44
url: https://sphinx-book-theme.readthedocs.io
55
start:
@@ -23,22 +23,23 @@ start:
2323
- content: Feature Voting
2424
url: https://executablebooks.org/en/latest/feature-vote.html
2525

26-
- type: link
26+
- type: button
2727
content: Book gallery
28-
external: true
29-
newwindow: true
3028
url: http://gallery.jupyterbook.org/
3129

3230

3331
end:
34-
- type: icon-links
35-
icons:
36-
- icon: fab fa-twitter-square
37-
name: Twitter
32+
- type: group
33+
items:
34+
- type: button
35+
icon: fab fa-twitter-square
36+
title: Twitter
3837
url: https://twitter.com/executablebooks
39-
- icon: fab fa-github-square
40-
name: GitHub
38+
- type: button
39+
icon: fab fa-github-square
40+
title: GitHub
4141
url: https://github.com/executablebooks
42-
- icon: fas fa-comments
43-
name: Forum
42+
- type: button
43+
icon: fas fa-comments
44+
title: Forum
4445
url: https://github.com/orgs/executablebooks/discussions

docs/customize/header.md

Lines changed: 103 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -161,26 +161,101 @@ html_theme_options = {
161161

162162
The rest of these sections describe the components you can use:
163163

164-
### Link and text components
164+
### Buttons
165+
166+
Buttons are flexible UI components that trigger various actions when clicked.
167+
They can be links, or they can trigger arbitrary JavaScript that you provide.
168+
Use them as call-to-action items, or as a way to trigger events on your page if you are using custom JavaScript.
169+
170+
Clicking a button can trigger one of two actions:
171+
172+
- **Link to an internal or external page**
173+
- **Trigger a JavaScript function**
174+
175+
Buttons have three visual sections that you may control, that roughly follow this structure:
176+
177+
```html
178+
<button>
179+
<button-icon><button-image><button-content>
180+
</button>
181+
```
182+
183+
- **`icon`**: A small, square icon. May be configured with **FontAwesome** icons or a path to an image (local or remove).
184+
- **`image`**: A larger image that may be rectangular. May be configured with **FontAwesome** icons or a path to an image (local or remove).
185+
- **`content`**: Arbitrary text (or extra HTML) to put inside the button.
165186

166-
To add text and link components to header sections, use the following component configuration:
187+
To add buttons components to header sections, use the following component configuration:
167188

168189
```python
169190

170191
# Provided as a list item to `start:` or `end:`
171192
{
172-
# Specifies a `text` component
173-
"type": "text",
174-
# The URL to which the link points
175-
"url": "https://jupyterbook.org",
176-
# The text to be displayed
177-
"content": "Jupyter Book",
193+
# Specifies the `button` component
194+
"type": "button",
195+
196+
## Controls button behavior ##
197+
# If provided, the button will be a link to another page.
198+
"url": "https://google.com",
199+
# If provided, clicking the button will trigger this JavaScript.
200+
"onclick": "SomeFunction()",
201+
202+
## Controls button style ##
203+
# An icon that will be displayed before the text
204+
# Can be a set of fontawesome classes, or a path to an image
205+
"icon": "fas fa-bars",
206+
# An image path that will be displayed before the text
207+
"image": "https://executablebooks.org/en/latest/_static/logo.svg",
208+
# The text that will be displayed inside the button.
209+
"content": "My button's text",
178210
# An optional list of classes to add
179211
"classes": ["one", "two"]
180-
},
212+
}
181213
```
182214

183-
To add text without a link, simply omit the `url:` parameter.
215+
Note tha **url** and **onclick** cannot both be provided in the same button's configuration.
216+
217+
#### Button icons
218+
219+
There are two kinds of icons you can control with the `icon` parameter:
220+
221+
- **FontAwesome icons**: FontAwesome icon classes like `fas fa-arrow-right`. See [the FontAwesome documentation](https://fontawesome.com/icons) for a list of classes and icons. For example:
222+
223+
```python
224+
# Provided as a list item to `start:` or `end:`
225+
{
226+
# Specifies the `button` component
227+
"type": "button",
228+
"icon": "fab fa-github"
229+
"url": "https://github.com"
230+
}
231+
```
232+
- **A path to an image**: Any local image you include with your documentation.
233+
234+
For example, with a remote image:
235+
236+
```python
237+
# Provided as a list item to `start:` or `end:`
238+
{
239+
# Specifies the `button` component
240+
"type": "button",
241+
"image": "https://executablebooks.org/en/latest/_static/logo.svg"
242+
"url": "https://executablebooks.org"
243+
}
244+
```
245+
246+
With a local image:
247+
248+
```python
249+
# Provided as a list item to `start:` or `end:`
250+
{
251+
# Specifies the `button` component
252+
"type": "button",
253+
"image": "./_static/myimage.png"
254+
"url": "https://executablebooks.org"
255+
}
256+
```
257+
258+
Finally, if a button is configured **only with an icon**, it will have a special class `icon-button` added to it that will make it contract slightly in size and spacing.
184259

185260
### Dropdown menus
186261

@@ -196,7 +271,7 @@ To add dropdown components to header sections, use the following component confi
196271
"type": "dropdown",
197272
# Text to be displayed on the button
198273
"content": "EBP Projects",
199-
# A list of dropdown links. Each defines a content string and a url
274+
# A list of dropdown links. Each is a configuration for a button.
200275
"items": [
201276
{
202277
"url": "https://executablebooks.org",
@@ -212,79 +287,38 @@ To add dropdown components to header sections, use the following component confi
212287
},
213288
```
214289

215-
### Icon links
290+
### Groups
216291

217-
You can add a list of icon links to your header that link to external sites and services.
218-
These are often used to link to social media accoutns like GitHub, Twitter, discussion forums, etc.
219-
They will be displayed horizontally whether on wide or narrow screens.
292+
Groups are a way of telling the theme that several UI components should be grouped together.
293+
They will have a wrapping container, will have less spacing between them, and will be displayed _horizontally_ on narrow screens.
220294

221-
There are two kinds of icons you can control with `icon-links`:
222-
223-
- **FontAwesome icons**: FontAwesome icon classes like `fas fa-arrow-right`. See [the FontAwesome documentation](https://fontawesome.com/icons) for a list of classes and icons.
224-
- **A path to an image**: Any local image you include with your documentation.
225-
226-
To add icon link components to header sections, use the following component configuration:
295+
For example, to group several icon buttons together use a configuration like so:
227296

228297
```python
229298
# Provided as a list item to `start:` or `end:`
230299
{
231-
# Specifies the `icon-links` component
232-
"type": "icon-links",
233-
# A list of icon links to include
234-
"icons": [
235-
# Configuration for icon one uses FontAwesome
300+
# Specifies a `group` type
301+
"type": "group",
302+
# A list of group items. Each is a configuration for a button.
303+
"items": [
236304
{
237-
# Specifies that this icon is a FontAwesome icon
238-
"type": "fontawesome",
239-
# A url for icon one
240-
"url": "https://twitter.com/executablebooks",
241-
# A tooltip for icon one
242-
"name": "Twitter",
243-
# A FontAwesome icon class
244-
"icon": "fab fa-twitter-square",
305+
"icon": "fab fa-github",
306+
"url": "https://github.com
245307
},
246-
# Configuration for icon two uses a local image path
247308
{
248-
# Specifies that this icon is a local image
249-
"type": "local",
250-
# A url for icon two
251-
"url": "https://github.com/orgs/executablebooks/discussions",
252-
# A tooltip for icon two
253-
"name": "Discussions image",
254-
# A path to a local image relative to conf.py
255-
"icon": "./path/to/image.png",
309+
"icon": "fab fa-twitter",
310+
"url": "https://twitter.com
311+
},
312+
{
313+
"icon": "fab fa-discourse",
314+
"url": "https://discourse.com
256315
},
257316
],
258-
},
259-
```
260-
261-
### Buttons
262-
263-
Buttons are larger and more visually-noticeable.
264-
They can either be links, or they can trigger arbitrary JavaScript that you provide.
265-
Use them as call-to-action items, or as a way to trigger events on your page if you are using custom JavaScript.
266-
267-
To add buttons components to header sections, use the following component configuration:
268-
269-
```python
270-
271-
# Provided as a list item to `start:` or `end:`
272-
{
273-
# Specifies the `button` component
274-
"type": "button",
275-
# The text that will be displayed inside the button.
276-
"content": "end",
277-
# If provided, the button will be a link to another page.
278-
"url": "https://google.com",
279-
# If provided, clicking the button will trigger this JavaScript.
280-
"onclick": "SomeFunction()",
281317
# An optional list of classes to add
282318
"classes": ["one", "two"]
283-
}
319+
},
284320
```
285321

286-
Note tha **url** and **onclick** cannot both be provided in the same button's configuration.
287-
288322
### HTML Snippets
289323

290324
You may provide custom HTML snippets that are inserted into the header as-is.

0 commit comments

Comments
 (0)