File tree Expand file tree Collapse file tree 6 files changed +68
-15
lines changed Expand file tree Collapse file tree 6 files changed +68
-15
lines changed Original file line number Diff line number Diff line change @@ -15,3 +15,6 @@ $grey-l: lighten( $grey, 20% );
1515$almost-white : #F0F0F0 ;
1616
1717$red-d : darken ( #E97777 , 20% );
18+
19+ $shadow-access : -1px 0px $spacer / 3 #0002 , 1px 0px $spacer / 3 #0002 ,
20+ 0px -1px $spacer / 3 #0002 , 0px 1px $spacer / 3 #0002 ;
Original file line number Diff line number Diff line change 11<template lang="html">
2- <Message :author =" msg.author" :colour =" msg.colour" >
3- <canvas :id =" getID(msg)" ></canvas>
2+ <Message
3+ @copy =" handleCopy"
4+ :copyable =" true"
5+ :author =" msg.author"
6+ :colour =" msg.colour"
7+ >
8+ <canvas :id =" getID" ></canvas>
49 </Message>
510</template >
611
@@ -18,13 +23,18 @@ export default {
1823 default : () => new Message ()
1924 }
2025 },
26+ computed: {
27+ getID () {
28+ return " canvas-" + this .msg .hash ;
29+ }
30+ },
2131 methods: {
22- getID ( msg ) {
23- return " canvas- " + msg . hash ;
32+ handleCopy ( ) {
33+ this . $store . dispatch ( " compose/copy " , this . msg ) ;
2434 }
2535 },
2636 mounted () {
27- const canv = document .getElementById (this .getID ( this . msg ) );
37+ const canv = document .getElementById (this .getID );
2838 this .notepad = new Notepad (192 , 64 , canv);
2939 this .notepad .loadImageData (this .msg .raw ());
3040 }
Original file line number Diff line number Diff line change 11<template lang="html">
22 <div class =" ratio" >
33 <div class =" inner" v-bind:style =" { borderColor: this.borderCol }" >
4- <span
4+ <div
55 class =" author"
66 v-bind:style =" { background: this.colour, borderColor: this.borderCol }"
77 >
8- {{ author }}
9- </span>
8+ <span >{{ author }}</span>
9+ <span v-if =" copyable" class =" copy" title =" Copy this message" >
10+ <font-awesome-icon @click =" $emit('copy')" class =" icn" icon =" copy" />
11+ </span>
12+ </div>
1013 <div class =" content" >
1114 <slot ></slot>
1215 </div>
@@ -25,6 +28,10 @@ export default {
2528 colour: {
2629 type: String ,
2730 default: " #e97777"
31+ },
32+ copyable: {
33+ type: Boolean ,
34+ default: false
2835 }
2936 },
3037 computed: {
@@ -46,6 +53,7 @@ $perc-spacer: 1%;
4653}
4754
4855.inner {
56+ z-index : 0 ;
4957 position : absolute ;
5058 top : 0 ;
5159 left : 0 ;
@@ -58,6 +66,8 @@ $perc-spacer: 1%;
5866}
5967
6068.content {
69+ position : relative ;
70+ z-index : -1 ;
6171 width : 100% ;
6272 height : 100% ;
6373}
@@ -78,7 +88,29 @@ $perc-spacer: 1%;
7888 color : #fff ;
7989 font-family : " pixel 5x7" ;
8090 user-select : none ;
81- text-shadow : -1px 0px $spacer / 3 #0002 , 1px 0px $spacer / 3 #0002 ,
82- 0px -1px $spacer / 3 #0002 , 0px 1px $spacer / 3 #0002 ;
91+ text-shadow : $shadow-access ;
92+
93+ .copy {
94+ max-width : 0 ;
95+ opacity : 0 ;
96+ overflow : hidden ;
97+ display : inline-block ;
98+ height : 3 * $spacer ;
99+ transition : all 200ms ease-in-out ;
100+ cursor : pointer ;
101+
102+ .icn {
103+ display : block ;
104+ margin-left : $spacer ;
105+ padding : $spacer / 4 ;
106+ width : 3 * $spacer ;
107+ height : 3 * $spacer ;
108+ }
109+ }
110+
111+ & :hover > .copy {
112+ max-width : 4vw ;
113+ opacity : 1 ;
114+ }
83115}
84116 </style >
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import {
1212 faDoorOpen ,
1313 faBug ,
1414 faHeart ,
15- faCodeBranch
15+ faCodeBranch ,
16+ faCopy
1617} from "@fortawesome/free-solid-svg-icons" ;
1718import { faDotCircle } from "@fortawesome/free-regular-svg-icons" ;
1819import { faTwitter } from "@fortawesome/free-brands-svg-icons" ;
@@ -32,7 +33,8 @@ library.add(
3233 faBug ,
3334 faHeart ,
3435 faTwitter ,
35- faCodeBranch
36+ faCodeBranch ,
37+ faCopy
3638) ;
3739
3840Vue . component ( "font-awesome-icon" , FontAwesomeIcon ) ;
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ const routes = [
2929 path : "/room/:id" ,
3030 name : "room" ,
3131 component : ( ) => import ( /* webpackChunkName: "room" */ "../views/Room.vue" )
32+ } ,
33+ {
34+ path : "/room" ,
35+ redirect : "/"
3236 }
3337] ;
3438
Original file line number Diff line number Diff line change @@ -36,8 +36,8 @@ const actions = {
3636 clear : ( ) => {
3737 window . _sketch . clear ( ) ;
3838 } ,
39- copy : ( { rootState } , id ) => {
40- if ( id == null ) {
39+ copy : ( { rootState } , msg ) => {
40+ if ( ! msg ) {
4141 var msgs = rootState . messages . history
4242 . sort ( ( a , b ) => {
4343 a . id - b . id ;
@@ -48,7 +48,9 @@ const actions = {
4848 console . error ( "No messages to copy!" ) ;
4949 return ;
5050 }
51- const msg = msgs [ 0 ] ;
51+ msg = msgs [ 0 ] ;
52+ window . _sketch . loadImageData ( msg . raw ( ) ) ;
53+ } else {
5254 window . _sketch . loadImageData ( msg . raw ( ) ) ;
5355 }
5456 } ,
You can’t perform that action at this time.
0 commit comments