Skip to content

Commit

Permalink
v.1.5.0 - improve table of contents
Browse files Browse the repository at this point in the history
  • Loading branch information
robole committed Nov 10, 2023
1 parent faa14d0 commit b5c069d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 12 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.5.0] - 2023-11-10

### Changed

- Improve table of contents:
- Add `.bookmark` element to individual extension sections to ensure there is an accurate location from the table of contents that does not result in upper rows of the snippets table being partially obscured.
- Add an entry for category sections to table of contents even if there are no snippets for that category.
- Add a custom margin for paragraphs to make spacing more consistent.

## [1.4.0] - 2023-11-10

### Changed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"description": "View and edit all your snippets in one purty place. Yee-haw!",
"icon": "img/logo.webp",
"version": "1.4.0",
"version": "1.5.0",
"engines": {
"vscode": "^1.4.0",
"node": ">=12.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/view/category-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let {
} = require("./file-section");
let format = require("../helper/format");

const notFoundHTML = `<p class="empty">Oucho Gaucho! 🌵 Nothing to round up! 🤠</p>`;
const notFoundHTML = `<p>Oucho Gaucho! 🌵 Nothing to round up! 🤠</p>`;

/**
* Creates the HTML for a section for a category of snippets e.g. "project" for snippets defined in
Expand Down Expand Up @@ -44,7 +44,7 @@ let createExtensionCategorySection = (extensions) => {

extensions.forEach((extension) => {
let id = format.slugify(extension.id);
section += `<div><h3 id="${id}">${extension.name}</h3>`;
section += `<div class="extension"><div id="${id}" class="bookmark"></div><h3>${extension.name}</h3>`;

extension.snippetsFiles.forEach((snippetsFile) => {
section += createExtensionFileSection(snippetsFile);
Expand Down
11 changes: 10 additions & 1 deletion src/view/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ body {
}
}

p {
margin: 0;
margin-block-start: 1.5rem;
}

code {
font-family: var(--vscode-editor-font-family);
font-size: calc(14px + 0.15vw);
Expand Down Expand Up @@ -173,8 +178,12 @@ section {
margin-block-end: 4rem;
}

.extension,
.file-section {
position: relative;
}

.file-section {
margin-block-end: 2.5rem;
}

Expand Down Expand Up @@ -254,7 +263,7 @@ section#extension header :is(p, div) {
top: calc(var(--h2-height) * -1);
}

section#extension .bookmark {
.extension .file-section .bookmark {
top: calc((var(--h2-height) + var(--extension-h3-height)) * -1);
}

Expand Down
9 changes: 6 additions & 3 deletions src/view/table-of-contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ const createCategoryEntry = (category, snippetsFiles) => {
entries += createSnippetsFileEntry(snippetsFile);
});

let title = `${format.capitalize(category)} Snippets`;
html += `<li><a href="#${category}">${title}</a>`;

if (entries !== "") {
let title = `${format.capitalize(category)} Snippets`;
html += `<li><a href="#${category}">${title}</a><ul>`;
html += `${entries}</ul></li>`;
html += `<ul>${entries}</ul>`;
}

html += `</li>`;

return html;
};

Expand Down
4 changes: 2 additions & 2 deletions test/suite/view/category-section.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ describe("category-section.js", () => {
assert.strictEqual(section.includes(expected), true);
});

it("should create a section that states there are no snippets when there are no snippets", () => {
it("should state there are no snippets", () => {
let section = createCategorySection([], "user");
let expected = `<p class="empty">Oucho Gaucho!`;
let expected = `<p>Oucho Gaucho!`;

assert.strictEqual(section.includes(expected), true);
});
Expand Down
3 changes: 0 additions & 3 deletions todo.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# To Do

1. Redo creating webp of logo. Quality is a bit too low.
1. TOC entry for an extension leds to view with first row of the first file table being slightly obscured.

## Changes to consider

1. Support for multi-root workspaces. For multi-root workspaces, a sub workspace can have its own snippets in its *.vscode* folder. You would need look in the `.code-workspace` to discover the sub workspaces and inspect them.
Expand Down

0 comments on commit b5c069d

Please sign in to comment.