]> git.cworth.org Git - lmno.games/commitdiff
Add a button to copy the game URL for sharing and tighten up text
authorCarl Worth <cworth@cworth.org>
Sat, 6 Jun 2020 19:30:23 +0000 (12:30 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 6 Jun 2020 19:30:23 +0000 (12:30 -0700)
The way we are styling <h2> right now makes it far too wasteful of
vertical screen real estate. Instead, use the same font size/weight
but inline with the sentence.

Also, this button for copying the game URL should be handy,
particularly on phones, etc.

scribe/scribe.jsx
style.css

index 06a8541297059bdc046f6f40ae3ac129d8ff2e74..be0de3799acf1f6bedaeb2171de86e9588832c38 100644 (file)
@@ -79,14 +79,31 @@ events.addEventListener("game-state", event => {
  * Game and supporting classes                           *
  *********************************************************/
 
+function copy_to_clipboard(id)
+{
+  const tmp = document.createElement("input");
+  tmp.setAttribute("value", document.getElementById(id).innerHTML);
+  document.body.appendChild(tmp);
+  tmp.select();
+  document.execCommand("copy");
+  document.body.removeChild(tmp);
+}
+
 function GameInfo(props) {
   if (! props.id)
     return null;
 
   return (
     <div className="game-info">
-      <h2>{props.id}</h2>
-      Invite a friend to play by sending this URL: {props.url}
+      <span className="game-id">{props.id}</span>
+      {" "}
+      Share this link to invite a friend:{" "}
+      <span id="game-share-url">{props.url}</span>
+      {" "}
+      <button
+        className="inline"
+        onClick={() => copy_to_clipboard('game-share-url')}
+      >Copy Link</button>
     </div>
   );
 }
@@ -132,7 +149,7 @@ function PlayerInfo(props) {
 
   return (
     <div className="player-info">
-      <h2>Players</h2>
+      <span className="players-header">Players: </span>
       {props.player.name}
       {props.player.team ? ` (${props.player.team})` : ""}
       {props.first_move ? "" : " "}
index 91cee834c83438a92d7b698418e0588587a69f24..6d5bdca00e551c151988d68649e0885e7d10550e 100644 (file)
--- a/style.css
+++ b/style.css
@@ -319,3 +319,14 @@ button:hover {
 .hide-button:hover {
     color: var(--danger-color-dark);
 }
+
+/*\
+|*|
+|*| Game-specific markup
+|*|
+\*/
+
+.game-id, .players-header {
+    font-size: 110%;
+    font-weight: bold;
+}