diff --git a/app/UI/app.tsx b/app/UI/app.tsx index c391e19..eec197d 100644 --- a/app/UI/app.tsx +++ b/app/UI/app.tsx @@ -309,12 +309,6 @@ type AppProps = { }; export class AppComponent extends Component { - events = this.props.eventBus.onChange(); - - componentWillUnmount() { - this.events.close(); - } - render(props: AppProps) { const t = Date.now(); const model = props.model; @@ -404,22 +398,11 @@ export class AppComponent extends Component { ); } - const final = ( -
- - + let profileEditorNode: VNode | undefined; + if (model.navigationModel.activeNav == "Profile") { + profileEditorNode = (
{ />
+ ); + } + + const final = ( +
+ + {profileEditorNode} {publicNode} {dmVNode} {aboutNode} diff --git a/app/UI/edit-profile.tsx b/app/UI/edit-profile.tsx index 996b067..ef07514 100644 --- a/app/UI/edit-profile.tsx +++ b/app/UI/edit-profile.tsx @@ -1,24 +1,17 @@ -import { createRef, Fragment, h } from "https://esm.sh/preact@10.17.1"; -import { - CenterClass, - DividerClass, - InputClass, - LinearGradientsClass, - NoOutlineClass, -} from "./components/tw.ts"; +import { createRef, h } from "https://esm.sh/preact@10.17.1"; import { ProfileData } from "../features/profile.ts"; import { DividerBackgroundColor, - ErrorColor, HintLinkColor, HintTextColor, - HoverButtonBackgroundColor, + PlaceholderColor, PrimaryTextColor, SecondaryBackgroundColor, } from "./style/colors.ts"; -import { Component, ComponentChildren } from "https://esm.sh/preact@10.11.3"; +import { Component } from "https://esm.sh/preact@10.11.3"; import { emitFunc } from "../event-bus.ts"; import { NostrAccountContext } from "../../libs/nostr.ts/nostr.ts"; +import { UserIcon } from "./icons/user-icon.tsx"; export type SaveProfile = { type: "SaveProfile"; @@ -26,12 +19,6 @@ export type SaveProfile = { ctx: NostrAccountContext; }; -type profileItem = { - key: string; - value?: string; - hint?: ComponentChildren; -}; - type Props = { ctx: NostrAccountContext; profile: ProfileData; @@ -49,134 +36,112 @@ export class EditProfile extends Component { profileData: undefined, }; + newFieldKey = createRef(); + newFieldValue = createRef(); + componentDidMount(): void { this.setState({ profileData: this.props.profile, }); } - render() { - const profileItems: profileItem[] = [ - { - key: "name", - value: this.state.profileData?.name, - }, - { - key: "banner", - value: this.state.profileData?.banner, - }, - { - key: "picture", - value: this.state.profileData?.picture, - hint: ( - + render(props: Props, state: State) { + return ( +
+ + +
+
+ +
+ Profile +
+
+

+ Name +

+ this.onInput(e, "name")} + type="text" + class={`focus:outline-none focus:border-white w-full px-4 py-3 rounded-lg resize-y bg-transparent border-[2px] border-[${DividerBackgroundColor}] placeholder-[${PlaceholderColor}] text-[${PrimaryTextColor}] `} + /> +

+ Profile Image URL +

+ this.onInput(e, "picture")} + type="text" + class={`focus:outline-none focus:border-white w-full px-4 py-3 rounded-lg resize-y bg-transparent border-[2px] border-[${DividerBackgroundColor}] placeholder-[${PlaceholderColor}] text-[${PrimaryTextColor}] `} + /> + You can upload your images on websites like{" "} - + nostr.build - ), - }, - { - key: "about", - value: this.state.profileData?.about, - }, - { - key: "website", - value: this.state.profileData?.website, - }, - ]; +

+ Banner Image URL +

+ this.onInput(e, "banner")} + type="text" + class={`focus:outline-none focus:border-white w-full px-4 py-3 rounded-lg resize-y bg-transparent border-[2px] border-[${DividerBackgroundColor}] placeholder-[${PlaceholderColor}] text-[${PrimaryTextColor}]`} + /> +

+ About +

+ this.onInput(e, "about")} + type="text" + class={`focus:outline-none focus:border-white w-full px-4 py-3 rounded-lg resize-y bg-transparent border-[2px] border-[${DividerBackgroundColor}] placeholder-[${PlaceholderColor}] text-[${PrimaryTextColor}] `} + /> +

+ Website +

+ this.onInput(e, "website")} + type="text" + class={`focus:outline-none focus:border-white w-full px-4 py-3 rounded-lg resize-y bg-transparent border-[2px] border-[${DividerBackgroundColor}] placeholder-[${PlaceholderColor}] text-[${PrimaryTextColor}]`} + /> +
- const items = profileItems.map((item) => ( - -

- {item.key} -

- - {item.hint} -
- )); - - return ( -
- {items} - -
-

Custom Fields

- - Create your own custom fields, anything goes! - - -

- Field name -

- - {this.state.newFieldKeyError} - -

- Field value -

- - - - -
- - -
+ Update Profile + +
); } - styles = { - container: `py-4 bg-[${SecondaryBackgroundColor}]`, - banner: { - container: `h-72 w-full rounded-lg mb-20 relative`, - }, - field: { - title: `text-[${PrimaryTextColor}] mt-8`, - input: `${InputClass}`, - hint: { - text: `text-sm text-[${HintTextColor}]`, - link: `text-[${HintLinkColor}]`, - }, - }, - addButton: - `w-full mt-6 p-3 rounded-lg ${NoOutlineClass} text-[${PrimaryTextColor}] bg-[${DividerBackgroundColor}] hover:bg-[${HoverButtonBackgroundColor}] ${CenterClass}`, - submitButton: - `w-full p-3 rounded-lg ${NoOutlineClass} text-[${PrimaryTextColor}] ${CenterClass} ${LinearGradientsClass} hover:bg-gradient-to-l`, - divider: `${DividerClass}`, - custom: { - title: `text-[${PrimaryTextColor}] font-bold text-sm`, - text: `text-[${HintTextColor}] text-sm`, - error: `text-sm text-[${ErrorColor}]`, - }, - }; - - newFieldKey = createRef(); - newFieldValue = createRef(); - - onInput = (e: h.JSX.TargetedEvent, key?: string) => { + onInput = (e: h.JSX.TargetedEvent, key?: string) => { const lines = e.currentTarget.value.split("\n"); e.currentTarget.setAttribute( "rows", @@ -205,6 +170,9 @@ export class EditProfile extends Component { return; } + console.log(`Adding field ${this.newFieldKey.current.value}`); + console.log(`Adding field ${this.newFieldValue.current.value}`); + this.setState({ profileData: { ...this.state.profileData, @@ -217,7 +185,8 @@ export class EditProfile extends Component { this.newFieldValue.current.value = ""; }; - onSubmit = () => { + onSubmit = (e: h.JSX.TargetedEvent) => { + e.preventDefault(); this.props.emit({ type: "SaveProfile", ctx: this.props.ctx, diff --git a/app/UI/icons/plus-circle-icon.tsx b/app/UI/icons/plus-circle-icon.tsx new file mode 100644 index 0000000..41230bd --- /dev/null +++ b/app/UI/icons/plus-circle-icon.tsx @@ -0,0 +1,29 @@ +/** @jsx h */ +import { h } from "https://esm.sh/preact@10.17.1"; + +export function PlusCircleIcon(props: { + class?: string | h.JSX.SignalLike | undefined; + style?: + | string + | h.JSX.CSSProperties + | h.JSX.SignalLike + | undefined; +}) { + return ( + + + + ); +} diff --git a/app/UI/icons/user-icon.tsx b/app/UI/icons/user-icon.tsx index 888e237..cf10a9a 100644 --- a/app/UI/icons/user-icon.tsx +++ b/app/UI/icons/user-icon.tsx @@ -13,17 +13,17 @@ export function UserIcon(props: { - - - + ); }