diff --git a/pkg/interface/contacts/src/js/components/lib/card.js b/pkg/interface/contacts/src/js/components/lib/card.js index fe8e4e978f..0c6fe82395 100644 --- a/pkg/interface/contacts/src/js/components/lib/card.js +++ b/pkg/interface/contacts/src/js/components/lib/card.js @@ -1,10 +1,182 @@ import React, { Component } from 'react'; import { Sigil } from './icons/sigil'; +import { uxToHex } from '/lib/util'; +import { api } from '/api'; import { Route, Link } from 'react-router-dom'; export class ContactCard extends Component { + constructor() { + super(); + this.state = { + edit: false, + colorToSet: "" + } + this.editToggle = this.editToggle.bind(this); + this.sigilColorSet = this.sigilColorSet.bind(this); + } + + editToggle() { + let editSwitch = this.state.edit; + editSwitch = !editSwitch; + this.setState({edit: editSwitch}); + } + + sigilColorSet(event) { + //TODO regex for complete hex value and submit as change + this.setState({colorToSet: event.target.value}); + } + + shipParser(ship) { + switch(ship.length) { + case 3: return "Galaxy"; + case 6: return "Star"; + case 13: return "Planet"; + case 56: return "Comet"; + default: return "Unknown"; + } + } + + renderEditCard() { + //TODO if the path is our special invite flow path, autofill the details from /~/default's version of your contact, not this one + let shipType = this.shipParser(this.props.ship); + + let currentColor = (this.props.contact.color) ? this.props.contact.color : "0x0"; + let hexColor = uxToHex(currentColor); + + let sigilColor = "" + + if (this.props.contact.avatar === "TODO") { //TODO change to empty string once we have avatars + sigilColor = ( +
+

Sigil Color

+ +
+ ) + //TODO The fields to actually edit, using the api hooks for those atomic actions + } + + return ( +
+
+ + {sigilColor} + + +
+

Ship Name

+

~{this.props.ship}

+

Ship Type

+

{shipType}

+ +
+
+
+
+ ) + } + + renderCard() { + let shipType = this.shipParser(this.props.ship); + let currentColor = (this.props.contact.color) ? this.props.contact.color : "0x0"; + let hexColor = uxToHex(currentColor); + + + return ( +
+
+ {/*TODO default to sigil, but show avatar if exists for contact */} + +
+

Ship Name

+

~{this.props.ship}

+

Ship Type

+

{shipType}

+ +
+
+ {(() => { + if (this.props.contact.nickname) { + return ( +
+

Nickname

+

{this.props.contact.nickname}

+
+ ) + } + + if (this.props.contact.email) { + return ( +
+

Email

+

{this.props.contact.email}

+
+ ) + } + if (this.props.contact.phone) { + return ( +
+

Phone

+

{this.props.contact.phone}

+
+ ) + } + if (this.props.contact.website) { + return ( +
+

Website

+

{this.props.contact.website}

+
+ ) + } + if (this.props.contact.notes) { + return ( +
+

Notes

+

{this.props.contact.notes}

+
+ ) + } + })()} +
+
+
+
+ ) + } + render() { + + let ourOption = (this.props.ship === window.ship) + ? "dib" + : "dn"; + + let localOption = ((this.props.ship === window.ship) && (this.props.path === "/~/default")) + ? "dib" + : "dn"; + + let editInfoText = (this.state.edit) + ? "Finish Editing" + : "Edit Contact Info"; + + let adminOption = (this.props.path.includes(window.ship) && (this.props.ship !== window.ship)) + ? "dib" + : "dn"; + + let card = (this.state.edit) + ? this.renderEditCard() + : this.renderCard(); + //TODO "Share card" if it's /me -> sends to /~/default of recipient return (
@@ -12,18 +184,19 @@ export class ContactCard extends Component { {"⟵"}
- -
-
-
- {/*TODO default to sigil, but show avatar if exists for contact */} - -
-

Ship Name

-

~{this.props.ship}

-
-
+ + +
+ {card} ) } diff --git a/pkg/interface/contacts/src/js/components/lib/new.js b/pkg/interface/contacts/src/js/components/lib/new.js index 93314f51d4..afa2aca1cc 100644 --- a/pkg/interface/contacts/src/js/components/lib/new.js +++ b/pkg/interface/contacts/src/js/components/lib/new.js @@ -7,7 +7,7 @@ import urbitOb from 'urbit-ob'; export class NewScreen extends Component { constructor(props) { super(props); - + this.state = { groupName: '', invites: '', @@ -15,30 +15,30 @@ export class NewScreen extends Component { groupNameError: false, inviteError: false }; - + this.groupNameChange = this.groupNameChange.bind(this); this.invChange = this.invChange.bind(this); // this.colorChange = this.colorChange.bind(this); } - + groupNameChange(event) { this.setState({ groupName: event.target.value }); } - + invChange(event) { this.setState({ invites: event.target.value }); } - + // colorChange(event) { // this.setState({ // color: event.target.value // }); // } - + onClickCreate() { const { props, state } = this; if (!state.groupName) { @@ -49,21 +49,21 @@ export class NewScreen extends Component { return; } let group = `/~${window.ship}` + `/${state.groupName}`; - + let aud = []; let isValid = true; - + if (state.invites.length > 2) { aud = state.invites.split(',') .map((mem) => `~${deSig(mem.trim())}`); - + aud.forEach((mem) => { if (!urbitOb.isValidPatp(mem)) { isValid = false; } }); } - + if (!isValid) { this.setState({ inviteError: true, @@ -71,7 +71,7 @@ export class NewScreen extends Component { }); return; } - + if (this.textarea) { this.textarea.value = ''; } @@ -90,96 +90,97 @@ export class NewScreen extends Component { }); }); } - + render() { - + let groupNameErrElem = (); if (this.state.groupNameError) { groupNameErrElem = ( - Group must have a valid name. + Group must have a valid name. - ); - } - - let invErrElem = (); - if (this.state.inviteError) { - invErrElem = ( - + ); + } + + let invErrElem = (); + if (this.state.inviteError) { + invErrElem = ( + Invites must be validly formatted ship names. - - ); - } - - return ( -
-
+ + ); + } + + return ( +
+
{"⟵ All Groups"} -
-
+
+

Create New Group

Group Name

Alphanumeric characters and hyphens only