Skip to content
Open
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
34 changes: 0 additions & 34 deletions menu/satus.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,6 @@
margin-top: 0 !important;
}

.satus-button--general, .satus-button--appearance, .satus-button--player {
margin-left: 9px !important;
margin-right: -18px !important;
max-width: 272px !important;
}
div:not([home-style="list"]) .satus-button--themes, div:not([home-style="list"]) .satus-button--playlist,div:not([home-style="list"]) .satus-button--channel, div:not([home-style="list"]) .satus-button--shortcuts {
transform: scale(0.91);
margin-top: -10px !important;
margin-left: -5px !important;
margin-right: -28px !important;
}
div:not([home-style="list"]) .satus-button--blocklist, div:not([home-style="list"]) .satus-button--analyzer {
transform: scale(0.78);
margin-top: -22px !important;
margin-left: 110px !important;
margin-right: -150px !important;
}

div[home-style="list"] .satus-button--themes, div[home-style="list"] .satus-button--playlist,div[home-style="list"] .satus-button--channel, div[home-style="list"] .satus-button--shortcuts {
transform: scale(0.92);
margin-bottom: -17px !important;
margin-left:3px !important;
max-width: 197px !important;
margin-top:2px !important;
}
div[home-style="list"] .satus-button--blocklist, div[home-style="list"] .satus-button--analyzer {
transform: scale(0.75);
margin-left: 165px !important;
max-width: 141px !important;
margin-top: -72px !important;
}
div[home-style="list"] .satus-button--analyzer {margin-top: -16px !important;}


/*--------------------------------------------------------------
# SCROLLBAR
--------------------------------------------------------------*/
Expand Down
9 changes: 8 additions & 1 deletion menu/styles/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
width: calc(100% / 3);
height: unset;
margin: 8px 0 0;
padding: 8px 0;
padding: 4px 0;
}

.satus-base:not([improvedtube-home='list'])[page] .satus-section--home .satus-button {
Expand Down Expand Up @@ -75,6 +75,13 @@
left: 2px;
}

/* layout "list": one column, rows of one size. Nine of them fit above the panel at the bottom of the popup */
.satus-base[home-style='list'] .satus-section--card > :is(.satus-button--general, .satus-button--player, .satus-button--appearance, .satus-button--shortcuts, .satus-button--channel, .satus-button--playlist, .satus-button--themes, .satus-button--blocklist, .satus-button--analyzer) {
height: 30px;
min-height: 0;
padding: 0 12px;
}

.satus-base[home-style='list'] .satus-button--general > span:first-child,
.satus-base[home-style='list'] .satus-button--appearance > span:first-child,
.satus-base[home-style='list'] .satus-button--themes > span:first-child,
Expand Down
75 changes: 75 additions & 0 deletions tests/unit/home-screen-layout.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// The popup's home screen shows the nine categories either as "bubbles" or as a
// "list" (Settings > Home screen > Layout). Both are now even:
// bubbles: a grid of three columns with circles of one size
// list: one column with rows of one size
// Before, both layouts had three tiers of sizes (bubbles: circles of 60, 55 and
// 47px in rows of 3, 4 and 2 whose columns did not line up; list: Blocklist and
// Analyzer squeezed in beside the other rows), and hiding categories could push a
// bubble outside the popup.

const fs = require('fs');
const path = require('path');

const CATEGORIES = ['general', 'player', 'appearance', 'shortcuts', 'channel', 'playlist', 'themes', 'blocklist', 'analyzer'];

// every rule of a stylesheet as { selector, body }
function rules (css) {
return [...css.replace(/\/\*[\s\S]*?\*\//g, '').matchAll(/([^{}]+)\{([^{}]*)\}/g)].map(match => ({
selector: match[1].trim().replace(/\s+/g, ' '),
body: match[2]
}));
}

// the categories a selector names, e.g. '.satus-button--general > span' -> ['general']
function categoriesIn (selector) {
return CATEGORIES.filter(name => new RegExp('\\.satus-button--' + name + '\\b').test(selector));
}

describe('Home screen: even layouts', () => {
let satusCss, homeCss;

beforeAll(() => {
satusCss = fs.readFileSync(path.join(__dirname, '../../menu/satus.css'), 'utf8');
homeCss = fs.readFileSync(path.join(__dirname, '../../menu/styles/home.css'), 'utf8');
});

test('bubbles: three columns', () => {
const button = rules(homeCss).find(rule => rule.selector === '.satus-section--home .satus-button');

expect(button.body).toMatch(/width:\s*calc\(100% \/ 3\);/);
});

test('bubbles: one circle size for every category', () => {
const circle = rules(homeCss).find(rule => rule.selector === '.satus-section--home .satus-button> :nth-child(1)');

expect(circle.body).toMatch(/width:\s*60px;/);
expect(circle.body).toMatch(/height:\s*60px;/);
});

test('list: one row height for every category', () => {
const rows = rules(homeCss).filter(rule => rule.selector.startsWith(".satus-base[home-style='list'] .satus-section--card >"));

expect(rows).toHaveLength(1);
expect(categoriesIn(rows[0].selector)).toEqual(CATEGORIES);
expect(rows[0].body).toMatch(/height:\s*30px;/);
});

test('no category is sized, scaled or shifted on its own, in either layout', () => {
const layout = /transform|margin|padding|(^|[\s;-])(width|height)\s*:/;

for (const stylesheet of [satusCss, homeCss]) {
for (const rule of rules(stylesheet)) {
const named = categoriesIn(rule.selector);

if (named.length === 0 || !layout.test(rule.body)) continue;

// a rule that lays out category buttons has to name all nine
expect({ selector: rule.selector, categories: named }).toEqual({ selector: rule.selector, categories: CATEGORIES });
}
}
});

test('the shared stylesheet (satus.css) has no rules for single categories any more', () => {
expect(rules(satusCss).filter(rule => categoriesIn(rule.selector).length > 0)).toHaveLength(0);
});
});