blowater/UI/event-detail.tsx

58 lines
2.0 KiB
TypeScript
Raw Normal View History

/** @jsx h */
import { Fragment, h } from "https://esm.sh/preact@10.11.3";
import { CenterClass, InputClass } from "./components/tw.ts";
import { PrimaryTextColor, SecondaryBackgroundColor, TitleIconColor } from "./style/colors.ts";
import { Component } from "https://esm.sh/preact@10.11.3";
2023-11-11 11:19:21 +00:00
import { AboutIcon } from "./icons/about-icon.tsx";
2023-11-15 02:45:34 +00:00
import { CopyButton } from "./components/copy-button.tsx";
export type EventDetailItem = {
title: string;
fields: string[];
};
type Props = {
items: EventDetailItem[];
};
export class EventDetail extends Component<Props> {
styles = {
2023-12-18 10:23:15 +00:00
container: `py-6 px-4 bg-[${SecondaryBackgroundColor}]`,
header: {
2023-12-18 10:23:15 +00:00
container: `text-[${PrimaryTextColor}] text-xl flex`,
icon: `w-8 h-8 mr-4 text-[${TitleIconColor}] fill-current`,
},
2023-12-18 10:23:15 +00:00
title: `mt-7 text-[${PrimaryTextColor}]`,
field: {
2023-12-18 10:23:15 +00:00
container: `relative ${InputClass} resize-none flex p-0 mt-4`,
pre: `whitespace-pre flex-1 overflow-x-auto px-4 py-3`,
copyButton: `w-14 ${CenterClass}`,
},
};
render() {
return (
<div class={this.styles.container}>
<p class={this.styles.header.container}>
<AboutIcon class={this.styles.header.icon} />
Details
</p>
{this.props.items.map((item) => (
<Fragment>
<p class={this.styles.title}>{item.title}</p>
{item.fields.map((field) => (
<div class={this.styles.field.container}>
<pre class={this.styles.field.pre}>{field}</pre>
<div class={this.styles.field.copyButton}>
2023-11-15 02:45:34 +00:00
<CopyButton text={field} />
</div>
</div>
))}
</Fragment>
))}
</div>
);
}
}