From 1b9549900864902938626428ad3fbba0a8184de6 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sun, 17 Nov 2019 23:02:05 -0500 Subject: [PATCH] fix: use radio buttons for pinning timelines (#1644) * fix: use radio buttons for pinning timelines more work on #1633 * cleanup styles --- .../_components/community/PageListItem.html | 58 ++++++++++-- src/routes/_components/radio/RadioGroup.html | 4 +- .../_components/radio/RadioGroupButton.html | 17 +++- src/routes/_pages/community/index.html | 92 +++++++++++-------- tests/spec/037-pin-timelines.js | 38 ++++++++ 5 files changed, 160 insertions(+), 49 deletions(-) create mode 100644 tests/spec/037-pin-timelines.js diff --git a/src/routes/_components/community/PageListItem.html b/src/routes/_components/community/PageListItem.html index a1b800a6..ada58682 100644 --- a/src/routes/_components/community/PageListItem.html +++ b/src/routes/_components/community/PageListItem.html @@ -5,12 +5,16 @@ {label} {#if pinnable} - + + + {/if} @@ -52,6 +56,42 @@ text-overflow: ellipsis; } + /* TODO: begin copypasta from IconButton.html */ + + :global(.pinnable-button) { + background: none; + border: none; + padding: 6px 10px; + } + + :global(.pinnable-button .pinnable-svg) { + fill: var(--action-button-fill-color); + width: 24px; + height: 24px; + } + + :global(.pinnable-button:hover .pinnable-svg) { + fill: var(--action-button-fill-color-hover); + } + + :global(.pinnable-button:active .pinnable-svg) { + fill: var(--action-button-fill-color-active); + } + + :global(.pinnable-button.checked .pinnable-svg) { + fill: var(--action-button-fill-color-pressed); + } + + :global(.pinnable-button.checked:hover .pinnable-svg) { + fill: var(--action-button-fill-color-pressed-hover); + } + + :global(.pinnable-button.checked:active .pinnable-svg) { + fill: var(--action-button-fill-color-pressed-active); + } + + /* TODO: end copypasta */ + @media (max-width: 767px) { .page-list-item a { padding: 20px 10px; @@ -77,8 +117,8 @@ diff --git a/tests/spec/037-pin-timelines.js b/tests/spec/037-pin-timelines.js new file mode 100644 index 00000000..5522b78c --- /dev/null +++ b/tests/spec/037-pin-timelines.js @@ -0,0 +1,38 @@ +import { + communityNavButton, getUrl, goBack, reload +} from '../utils' +import { loginAsFoobar } from '../roles' +import { Selector as $ } from 'testcafe' + +fixture`037-pin-timelines.js` + .page`http://localhost:4002` + +test('Can pin a timeline', async t => { + await loginAsFoobar(t) + + const pinLocal = $('button[aria-label="Pin Local Timeline"]') + const pinFederated = $('button[aria-label="Pin Federated Timeline"]') + const pinnedNav = $('.main-nav-li:nth-child(3)') + const pinnedNavLink = $('.main-nav-li:nth-child(3) a') + + await t + .click(communityNavButton) + .expect(getUrl()).contains('/community') + .expect(pinLocal.getAttribute('aria-checked')).eql('true') + .expect(pinFederated.getAttribute('aria-checked')).eql('false') + .expect(pinnedNavLink.getAttribute('aria-label')).eql('Local') + .click(pinFederated) + .expect(pinLocal.getAttribute('aria-checked')).eql('false') + .expect(pinFederated.getAttribute('aria-checked')).eql('true') + .expect(pinnedNavLink.getAttribute('aria-label')).eql('Federated') + .click(pinnedNav) + .expect(getUrl()).contains('/federated') + await goBack() + await t + .expect(getUrl()).contains('/community') + await reload() + await t + .expect(getUrl()).contains('/community') + .expect(pinLocal.getAttribute('aria-checked')).eql('false') + .expect(pinFederated.getAttribute('aria-checked')).eql('true') +})