diff options
author | Anthony Wang | 2023-02-15 16:22:43 -0500 |
---|---|---|
committer | Anthony Wang | 2023-02-15 16:22:43 -0500 |
commit | 091ff04c2420c8549ff581399212b4e3346864ee (patch) | |
tree | 746ad8767db3f3eab288eab4f08b74c37742777e /components/name.js | |
parent | fb3c976380e704a1c129f141f0bdb7f5f4576611 (diff) |
Delete all files except for demo
Diffstat (limited to 'components/name.js')
-rw-r--r-- | components/name.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/components/name.js b/components/name.js new file mode 100644 index 0000000..ea44f95 --- /dev/null +++ b/components/name.js @@ -0,0 +1,56 @@ +export const Name = { + + props: ["of"], + + methods: { + name(objects) { + const nameObjects = objects + .filter(o=> + 'name' in o && + 'of' in o && + 'timestamp' in o && + typeof o.name == 'string' && + o.of == this.of && + o._by == this.of && + typeof o.timestamp == 'number') + .sortBy('-timestamp') + + return nameObjects.length? + nameObjects[0].name : 'anonymous' + } + }, + + template: ` + <graffiti-objects :tags="[of]" v-slot="{objects}"> + {{ name(objects) }} + </graffiti-objects>` +} + +export const SetMyName = { + + props: ["tags"], + + data: ()=> ({ + name: '' + }), + + methods: { + setMyName() { + this.$graffitiUpdate({ + name: this.name, + timestamp: Date.now(), + of: this.$graffitiMyID, + _tags: this.tags + }) + this.name = '' + } + }, + + template: ` + <form @submit.prevent="setMyName"> + <label for="nameBox">Change your name:</label> + <input v-model="name" id="nameBox"/> + <br> + <input type="submit" value="Submit"/> + </form>` +} |