-
[/akitok/CSSいじり 0212](https://scrapbox.io/akitok/CSSいじり 0212) task:
-
I want to make Scrapbox my homepage for daily life.
-
I want to be able to check tasks without page transitions.
-
I want to display the date prominently.
-
I want to be able to see all the day’s schedule.
-
-
I wanted to try using [React] in a Scrapbox Userscript, so this is a perfect task.
- 🙏🙏(axokxi)
- I’ve always thought it would be more practical to use pin-diary-3 and go back to using it as a diary. But the weekly view is easier to enter tasks and if a page is added every day, it might look messy in the overview. So please forgive me for being selfish.🙏
- Right now, I manually move today’s schedule to the top and make it visible in the list view.
- I’ve always thought it would be more practical to use pin-diary-3 and go back to using it as a diary. But the weekly view is easier to enter tasks and if a page is added every day, it might look messy in the overview. So please forgive me for being selfish.🙏
- 🙏🙏(axokxi)
-
For now, I aim to reproduce something similar to /akitok’s current setup.
-
The detection of the top page seems possible by referring to pin-diary-3.
- It doesn’t seem possible to refer to pin-diary-4 and later because they have a different mechanism.
- The repeated processing with a timer is probably to respond to changes in page cards.
- It sounds difficult.
- It seems like we don’t need to do that this time?
-
Let’s use preact.
-
Let’s start with adding simple DOM elements.
-
I think I don’t need the logic for showing and hiding based on scrapbox.layout.
.app .container [2]
is hidden if it’s not the top page, so if we insert the elements there, it should be fine.
-
I can’t quite grasp the timing of the render.
- I don’t understand the mechanism either.
- I don’t understand why the original div disappears when rendering a new div.
- It’s probably misinterpreting the differences.
style.css
.util {
background-color: gray;
height: 50px;
width: 100%;
}
.util .sub-title {
color: white;
font-size: 10px;
}
.util .title {
color: white;
font-size: 20px;
}
Test task source
script.js
import {html, render} from 'https://scrapbox.io/api/code/programming-notes/htm@3.0.4%2Fpreact/script.js';
const projectName = "blu3mo"
const taskSource = "task source" // to be made into a function that returns a value dynamically
const getSentencesInPage = async (projectName, pageName) => {
const response = await fetch(`https://scrapbox.io/api/pages/${projectName}/${pageName}/text`)
const text = await response.text();
return text.split("\n");
}
const getTasksInPage = async (projectName, pageName) => {
const sentences = getSentencesInPage(projectName, pageName);
sentences.
}
getTasks(projectName, taskSource)
.then(text => {
console.log("test");
console.log(text);
})
let isListPage = true;
const Util = (props) => {
return (html`
<Fragment>
<div className="util">
<p className="sub-title">Tuesday 2022</p>
<p className="title">Feb 26</p>
</div>
</Fragment>
`)
}
handleLayoutChange()
scrapbox.on('layout:changed', handleLayoutChange)
function handleLayoutChange () {
const app = document.querySelectorAll('.app .container')[2];
isListPage = (scrapbox.Layout === "list");
render(html`<${Util} isListPage=${isListPage}/>`, app);
console.log(isListPage)
}
(() => {
})()