fix: address bar nav buttons are enabled on home (#54)

* fix: disable the nav buttons on home

* style: subtler color of address bar text

* 0.1.24
This commit is contained in:
Ayo Ayco 2023-06-15 10:04:10 +02:00 committed by GitHub
parent f913b1f3d2
commit 8011bbd930
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 9 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "@ayco/cozy",
"version": "0.1.23",
"version": "0.1.24",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@ayco/cozy",
"version": "0.1.23",
"version": "0.1.24",
"dependencies": {
"@astrojs/netlify": "^2.2.2",
"@extractus/article-extractor": "^7.2.15",

View file

@ -1,6 +1,6 @@
{
"name": "@ayco/cozy",
"version": "0.1.23",
"version": "0.1.24",
"scripts": {
"start": "astro dev",
"build": "astro build"

View file

@ -70,6 +70,7 @@ const placeholder = 'Type the URL of an article here';
border-radius: 5px;
border: 1px solid #eee;
padding: 0.5rem;
color: #555;
}
:global(button#app-home),

View file

@ -31,7 +31,7 @@ const {postDivSelector, skipSave = false} = Astro.props;
const cachedRequests = (await cache.keys())
.filter(request => {
const urlObj = new URL(request.url);
return urlObj.search !== '';
return urlObj.search !== '' && urlObj.searchParams.get('url') !== '';
});
if(cachedRequests?.length) {
@ -64,7 +64,7 @@ const {postDivSelector, skipSave = false} = Astro.props;
link.onclick = async (e) => {
e.preventDefault();
localStorage.setItem('scrollPosition', window.scrollY.toString());
scroll(0,0);
scrollTo(0,0);
renderPost(responseText, url, postDivSelector?.value)
}
const item = document.createElement('li');

View file

@ -71,19 +71,24 @@ export function renderPost(responseText, url, postDivSelector: string, preventPu
const newPost = html.querySelector('body')?.querySelector('#post');
if (postDiv && newPost?.innerHTML) {
postDiv.innerHTML = newPost.innerHTML
const homeBtn = document.getElementById('app-home') as HTMLButtonElement;
homeBtn.removeAttribute('disabled');
const appUrl = document.getElementById('app-url') as HTMLInputElement;
const cozyUrl = html.querySelector('meta[property="cozy:url"]')?.getAttribute('content');
const homeBtn = document.getElementById('app-home') as HTMLButtonElement;
const submitBtn = document.getElementById('submit') as HTMLButtonElement;
if(cozyUrl !== '/') {
appUrl.value = cozyUrl || '';
homeBtn.removeAttribute('disabled');
submitBtn.removeAttribute('disabled');
} else {
appUrl.value = '';
homeBtn.setAttribute('disabled', 'true');
submitBtn.setAttribute('disabled', 'true');
}
if(!preventPushState) {
window.history.pushState({url}, '', url);
}
const submitBtn = document.getElementById('submit') as HTMLButtonElement;
submitBtn.removeAttribute('disabled');
}
}