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:
parent
f913b1f3d2
commit
8011bbd930
5 changed files with 15 additions and 9 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -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",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ayco/cozy",
|
||||
"version": "0.1.23",
|
||||
"version": "0.1.24",
|
||||
"scripts": {
|
||||
"start": "astro dev",
|
||||
"build": "astro build"
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue