Scenario generator for vore roleplay and story ideas.
https://scenario-generator.deliciousreya.net/responses
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.1 KiB
26 lines
1.1 KiB
import type { RollTableResultSet } from '../rolltable';
|
|
import { Fragment } from 'preact';
|
|
|
|
export type AttributionSetProps = Pick<RollTableResultSet, "name"|"id"|"global">
|
|
|
|
export function reconstituteAttributionSetIfExists(element: HTMLParagraphElement | null, partial?: Partial<AttributionSetProps>|null): AttributionSetProps|null {
|
|
if (!element || partial === null) {
|
|
return null
|
|
}
|
|
return reconstituteAttributionSet(element, partial)
|
|
}
|
|
|
|
export function reconstituteAttributionSet(p: HTMLParagraphElement, partial?: Partial<AttributionSetProps>): AttributionSetProps {
|
|
return {
|
|
id: partial?.id ?? parseInt(p.dataset.id!!),
|
|
name: partial?.name ?? p.querySelector<HTMLElement>(".setName")?.innerText ?? null,
|
|
global: partial?.global ?? p.classList.contains('global'),
|
|
}
|
|
}
|
|
|
|
export function AttributionSet({global, name, id}: AttributionSetProps) {
|
|
return <p class={`resultSet${global ? ' global' : ''}`} data-id={id}>
|
|
<span class="setRelation">in {name ? 'the' : 'a'} {global ? 'global' : 'server-local'} set</span>
|
|
{name && <Fragment>{' '}<span class="setName">{name}</span></Fragment>}
|
|
</p>
|
|
}
|
|
|