🐛 state-derived properties and chidren

This commit is contained in:
kawamataryo 2023-08-17 20:03:49 +09:00
parent 2e8fc6f5ed
commit 02abeab4f5

View File

@ -1,7 +1,8 @@
import type { ProfileView, ViewerState } from "@atproto/api/dist/client/types/app/bsky/actor/defs" import type { ProfileView, ViewerState } from "@atproto/api/dist/client/types/app/bsky/actor/defs"
import van from 'vanjs-core' import van from 'vanjs-core'
const { a, div, p, img, button } = van.tags
const { a, div, p, img, button, span } = van.tags
export type UserCellBtnLabel = { export type UserCellBtnLabel = {
add: string, add: string,
@ -46,7 +47,7 @@ const ActionButton = ({ statusKey, profile, btnLabel, addAction, removeAction }:
} }
const onMouseover = () => { const onMouseover = () => {
if( if (
isProcessing.val || isProcessing.val ||
isJustApplied.val || isJustApplied.val ||
!isStateOfBeing.val !isStateOfBeing.val
@ -59,18 +60,18 @@ const ActionButton = ({ statusKey, profile, btnLabel, addAction, removeAction }:
if (isJustApplied.val) { if (isJustApplied.val) {
isJustApplied.val = false isJustApplied.val = false
} }
if(!isStateOfBeing.val) return if (!isStateOfBeing.val) return
label.val = `${btnLabel.progressive} on Bluesky` label.val = `${btnLabel.progressive} on Bluesky`
} }
return () => button({ return button({
class: `action-button ${beingClass.val} ${processingClass.val} ${justAppliedClass.val}`, class: () => `action-button ${beingClass.val} ${processingClass.val} ${justAppliedClass.val}`,
onclick: onClick, onclick: onClick,
onmouseover: onMouseover, onmouseover: onMouseover,
onmouseout: onMouseout, onmouseout: onMouseout,
}, },
label.val, () => label.val,
) )
} }
@ -92,7 +93,7 @@ export const BskyUserCell = ({
removeAction: () => Promise<void> removeAction: () => Promise<void>
}) => { }) => {
return div({ class: "bsky-user-content" }, return div({ class: "bsky-user-content" },
div({ class: "icon-section"}, div({ class: "icon-section" },
a({ href: `https://bsky.app/profile/${profile.handle}`, target: "_blank", rel: "noopener" }, a({ href: `https://bsky.app/profile/${profile.handle}`, target: "_blank", rel: "noopener" },
Avatar({ avatar: profile.avatar }), Avatar({ avatar: profile.avatar }),
), ),