-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
looking great! next thing is <Focus.Add/>, etc.
- Loading branch information
Showing
19 changed files
with
708 additions
and
1,448 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
export class StackBlock { | ||
#anchor = document.createComment(0); | ||
|
||
constructor({ source, loader }) { | ||
this.source = source; | ||
this.updates = loader(this); | ||
} | ||
|
||
async #start() { | ||
const { updates } = this; | ||
for await(const message of this.source) { | ||
const [key, value] = Object.entries(message)[0]; | ||
updates[key](value); | ||
} | ||
} | ||
|
||
replace(input) { | ||
compose(this.#anchor, input); | ||
} | ||
|
||
append(input) { | ||
compose(this.#anchor, input, true); | ||
} | ||
|
||
remove() { | ||
compose(this.#anchor, null); | ||
} | ||
|
||
render() { | ||
this.#start(); | ||
return this.#anchor; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { consume } from 'azoth/chronos/channels'; | ||
import { Updater } from 'azoth/maya'; | ||
|
||
export function CurrentFocus({ current, update }) { | ||
const Focus = updatableFocus(update); | ||
consume(current, current => Focus.update(current)); | ||
return Focus; | ||
} | ||
|
||
function updatableFocus(update) { | ||
const handleEnter = ({ key, target }) => { | ||
if(key === 'Enter' && document.hasFocus(target)) { | ||
target.blur(); | ||
} | ||
}; | ||
|
||
const handleInput = ({ target: { innerHTML, ariaLabel } }) => { | ||
update({ [ariaLabel]: innerHTML === '<br>' ? '' : innerHTML }); | ||
}; | ||
|
||
return Updater.for(({ priority, exit }) => <div class="current-focus"> | ||
<h2 contenteditable | ||
aria-label="priority" | ||
aria-placeholder="Declared Priority" | ||
oninput={handleInput} | ||
onkeydown={handleEnter} | ||
innerHTML={priority || ''} /> | ||
|
||
<p contenteditable | ||
aria-label="exit" | ||
aria-placeholder="Clear exit seen and understood" | ||
oninput={handleInput} | ||
onkeydown={handleEnter} | ||
innerHTML={exit || ''} /> | ||
</div >); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { branch } from 'azoth/chronos/channels'; | ||
|
||
function Toggle({ on: predicate }, slottable) { | ||
return payload => predicate(payload) ? slottable : null; | ||
} | ||
|
||
export function FocusPath({ stack, add, remove }) { | ||
const Add = <ChangeButton onclick={add} text="add" />; | ||
|
||
const [Remove, Path] = branch(stack, | ||
<Toggle on={s => s.length}> | ||
<ChangeButton onclick={remove} text="remove" /> | ||
</Toggle>, | ||
s => s.map(focus => <Focus {...focus} />), | ||
// [Focus, { map: true }], | ||
); | ||
|
||
return { Path, Add, Remove }; | ||
} | ||
|
||
function Focus({ priority, exit }) { | ||
return <li> | ||
<span class="priority">{priority}</span> | ||
{exit} | ||
</li>; | ||
} | ||
|
||
function ChangeButton({ onclick, text }) { | ||
return <button onclick={onclick}>{text}</button>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { FocusPath } from './FocusPath.jsx'; | ||
import { CurrentFocus } from './CurrentFocus.jsx'; | ||
import { useFocus } from './useFocus.jsx'; | ||
import './focus.css'; | ||
|
||
function FocusPlayButton() { | ||
return <button class="ico-button"> | ||
<label> | ||
<input name="check-working" type="checkbox" checked /> | ||
</label> | ||
</button>; | ||
} | ||
|
||
export default function FocusPlay() { | ||
const [current, stack, { update, ...changeFocus }] = useFocus(); | ||
const { Add, Remove, Path } = <FocusPath stack={stack} {...changeFocus} />; | ||
|
||
return <section class="focus-play"> | ||
<FocusPlayButton /> | ||
<ul><Path /></ul> | ||
<section class="focus-section"> | ||
<Remove className="remove-button" /> | ||
<CurrentFocus current={current} update={update} /> | ||
</section> | ||
<Add className="add-button" /> | ||
</section>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
section.focus-play { | ||
|
||
.ico-button { | ||
outline: 0; | ||
margin: 0; | ||
padding: 0; | ||
border: 0; | ||
appearance: none; | ||
background: transparent; | ||
|
||
&:has(input:checked)+.focus { | ||
display: block; | ||
} | ||
} | ||
|
||
label { | ||
opacity: .9; | ||
font-size: 3em; | ||
cursor: pointer; | ||
|
||
&::before { | ||
position: relative; | ||
content: '🛝'; | ||
top: -0.25em; | ||
} | ||
|
||
&:has(input:checked)::before { | ||
position: relative; | ||
content: '🎯'; | ||
top: -.28em; | ||
} | ||
|
||
input { | ||
display: none; | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
.focus-section {} | ||
|
||
.current-focus { | ||
|
||
p { | ||
font-size: 1.2em; | ||
} | ||
|
||
[contenteditable] { | ||
font-size: 26px; | ||
padding: .25em 0em; | ||
margin: 1em 0; | ||
transition: padding .3s ease-in-out; | ||
} | ||
|
||
[contenteditable]:hover, | ||
[contenteditable]:focus { | ||
padding: .25em; | ||
} | ||
|
||
[contenteditable]:hover { | ||
background: #fafafa; | ||
outline: 2px solid #eee; | ||
} | ||
|
||
[contenteditable]:focus { | ||
background: #efefef; | ||
outline: 2px solid blue; | ||
} | ||
|
||
[contenteditable]:empty:not(:focus):before { | ||
content: attr(aria-placeholder); | ||
opacity: .8 | ||
} | ||
|
||
[contenteditable]:empty:focus:before { | ||
content: ' '; | ||
opacity: .8 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.focus-stack { | ||
background: lime; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { unicast } from 'azoth/chronos/generators'; | ||
import { branch } from 'azoth/chronos/channels'; | ||
import { useLocalStorageJSON } from '../local-storage.js'; | ||
import './focus.css'; | ||
|
||
const newFocus = () => ({ priority: '', exit: '' }); | ||
|
||
export function useFocus() { | ||
const [foci, setLocal] = useLocalStorageJSON('FOP.FOCI', [newFocus()]); | ||
const save = () => setLocal(foci); | ||
const [asyncFoci, changeFocus] = unicast(() => foci, null); | ||
|
||
const [current, stack] = branch(asyncFoci, | ||
foci => foci.at(-1), | ||
foci => foci.slice(0, -1), | ||
); | ||
|
||
const update = updates => { | ||
Object.assign(foci.at(-1), updates); | ||
save(); | ||
}; | ||
|
||
const add = () => { | ||
foci.push(newFocus()); | ||
save(); | ||
changeFocus(); | ||
}; | ||
|
||
const remove = () => { | ||
if(foci.length === 1) return; | ||
foci.pop(); | ||
save(); | ||
changeFocus(); | ||
}; | ||
|
||
return [current, stack, { add, remove, update }]; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.