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

Popup: Add standalone control panel link #1193

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 0 additions & 2 deletions src/action/links.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#links {
position: relative;

margin: 1em 0;
padding: 0 1em;
}

Expand Down
50 changes: 23 additions & 27 deletions src/action/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
--in-content-primary-button-background: #0061e0;
--in-content-primary-button-background-hover: #0250bb;
--in-content-primary-button-background-active: #053e94;
--in-content-box-info-background: #f0f0f4;

--black: 21, 20, 25;
--white: 255, 255, 255;
--accent: 10, 132, 255;
--passive-grey: 223, 223, 229;
--active-grey: 207, 207, 216;

--search-highlight: 255, 233, 0;
}

@media (prefers-color-scheme: dark) {
Expand All @@ -24,15 +21,12 @@
--in-content-primary-button-background: #00ddff;
--in-content-primary-button-background-hover: #80ebff;
--in-content-primary-button-background-active: #aaf2ff;
--in-content-box-info-background: #36353e;

--black: 251, 251, 254;
--white: 66, 65, 77;
--accent: 54, 213, 255;
--passive-grey: 83, 83, 94;
--active-grey: 91, 91, 102;

--search-highlight: 0, 62, 170;
}
}

Expand Down Expand Up @@ -63,33 +57,22 @@ body {
user-select: none;
}

#permissions-banner,
#embedded-banner {
box-sizing: border-box;
width: 375px;
min-width: 100%;
max-width: 100%;
padding: 8px 4px;
border-bottom: 1px solid rgb(var(--active-grey));
body.standalone {
width: 100%;
max-width: 632px;
margin: 1ch auto;

text-align: center;
outline: 1px solid rgb(var(--active-grey));
}

#grant-host-permission {
display: block;
padding: 0.5ch 1ch;
border-radius: 0.5ch;
margin: 8px auto 0;

font-family: 'Courier New', Courier, monospace;
line-height: 1;
}
#embedded-banner {
padding: 4px 8px;
border-bottom: 1px solid rgb(var(--active-grey));

#grant-host-permission:focus {
outline: 2px solid rgb(var(--accent));
text-align: center;
}

#permissions-banner:not([hidden]) + #embedded-banner {
body:not(.embedded) #embedded-banner {
display: none;
}

Expand Down Expand Up @@ -184,3 +167,16 @@ input:not(:first-child),
select:not(:first-child) {
margin-left: 1ch;
}

#non-standalone-footer {
display: flex;
justify-content: center;
align-items: center;
padding: 1ch;

border-top: 1px dotted rgb(var(--active-grey));
}

body.standalone #non-standalone-footer {
display: none;
}
12 changes: 4 additions & 8 deletions src/action/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@
<link rel="stylesheet" href="links.css">
</head>
<body>
<header id="permissions-banner" hidden>
&#x26A0;&#xFE0F; XKit Rewritten needs additional permissions in order to apply its enhancements automatically.
<button id="grant-host-permission">Always allow on www.tumblr.com</button>
</header>
<header id="embedded-banner" hidden>
&#x2139;&#xFE0F; XKit Rewritten can also be configured via the button in the browser toolbar.
</header>
<header id="embedded-banner">XKit Rewritten can also be configured via the button in the browser toolbar.</header>
<main>
<nav>
<a href="#configuration" role="button" class="selected">Configuration</a>
Expand Down Expand Up @@ -81,6 +75,9 @@ <h4>Related projects</h4>
<li><a href="https://github.com/AprilSylph/Outbox-for-Tumblr#readme" target="_blank">Outbox for Tumblr</a></li>
<li><a href="https://github.com/AprilSylph/Filtering-Plus#readme" target="_blank">Filtering+ for Tumblr</a></li>
</ul>
<footer id="non-standalone-footer">
<a href="popup.html?standalone=true" target="_blank">open control panel in a tab <i class="ri-external-link-line"></i></a>
</footer>
</section>
</main>

Expand All @@ -99,7 +96,6 @@ <h4 class="title"></h4>
<input type="checkbox" class="toggle-button" aria-label="Enable this feature">
</div>
</summary>
<p class="note"></p>
<ul class="preferences"></ul>
</details>
</template>
Expand Down
8 changes: 6 additions & 2 deletions src/action/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,9 @@ browser.permissions
.then(updatePermissionsBannerVisibility);

const params = new URLSearchParams(location.search);
const pageIsEmbedded = params.get('embedded') === 'true';
document.getElementById('embedded-banner').hidden = !pageIsEmbedded;
if (params.get('embedded') === 'true') {
document.body.classList.add('embedded');
}
if (params.get('standalone') === 'true') {
document.body.classList.add('standalone');
}