Mattias Bodlund 1 week ago
parent
commit
8ece7b030d
8 changed files with 41 additions and 3 deletions
  1. +2
    -2
      Gemfile.lock
  2. +10
    -0
      app/assets/stylesheets/application.css
  3. +2
    -0
      app/javascript/application.js
  4. +20
    -0
      app/javascript/share_controller.js
  5. +4
    -0
      app/views/game/results.html.erb
  6. +1
    -1
      app/views/layouts/application.html.erb
  7. +1
    -0
      config/importmap.rb
  8. +1
    -0
      config/locales/en.yml

+ 2
- 2
Gemfile.lock View File

@ -176,7 +176,7 @@ GEM
i18n (>= 0.6.10, < 2)
request_store (~> 1.0)
msgpack (1.8.2)
net-imap (0.6.4)
net-imap (0.6.4.1)
date
net-protocol
net-pop (0.1.2)
@ -473,7 +473,7 @@ CHECKSUMS
minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
mobility (1.3.2) sha256=32fbbb0e53118ef42de20daa6ac94dbb758c628874092eba311b968a1e1d757b
msgpack (1.8.2) sha256=e440d11c99d6dfe8b2fbc4feb74c3518c1ba024357c70bbd734d9bb1a44d0d25
net-imap (0.6.4) sha256=9a5598c67a3022c284d98430ef1d4948e7dbdb62596f61081ea8ca933270a02b
net-imap (0.6.4.1) sha256=29f0360d75a7efd3539f16ac1957dea5c0a51ddeceb348db4553c3120914ea0d
net-pop (0.1.2) sha256=848b4e982013c15b2f0382792268763b748cce91c9e91e36b0f27ed26420dff3
net-protocol (0.2.2) sha256=aa73e0cba6a125369de9837b8d8ef82a61849360eba0521900e2c3713aa162a8
net-smtp (0.5.1) sha256=ed96a0af63c524fceb4b29b0d352195c30d82dd916a42f03c62a3a70e5b70736


+ 10
- 0
app/assets/stylesheets/application.css View File

@ -465,6 +465,16 @@ form:has(.cta) {
text-decoration: none;
}
.share-container {
display: flex;
margin-block-end: 0.5rem;
& .cta {
background-color: transparent;
border: 1px solid var(--clr-black);
}
}
.play-time {
font: var(--td-s);
display: inline-flex;


+ 2
- 0
app/javascript/application.js View File

@ -5,6 +5,7 @@ import LanguageMenuController from "language_menu_controller"
import CarouselController from "carousel_controller"
import IntroController from "intro_controller"
import ChanceController from "chance_controller"
import ShareController from "share_controller"
const application = Application.start()
@ -12,6 +13,7 @@ application.register("language-menu", LanguageMenuController)
application.register("carousel", CarouselController)
application.register("intro", IntroController)
application.register("chance", ChanceController)
application.register("share", ShareController)
// Configure Stimulus development experience
application.debug = false


+ 20
- 0
app/javascript/share_controller.js View File

@ -0,0 +1,20 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static values = { url: String }
async share() {
const url = this.urlValue || window.location.origin
if (navigator.share) {
try {
await navigator.share({ url })
return
} catch (e) {
if (e.name === "AbortError") return
}
}
try {
await navigator.clipboard.writeText(url)
} catch {}
}
}

+ 4
- 0
app/views/game/results.html.erb View File

@ -80,5 +80,9 @@
<% end %>
</div>
<div class="share-container" data-controller="share" data-share-url-value="<%= root_url %>">
<button type="button" class="cta" data-action="share#share"><%= tag.span t("game.share") %></button>
</div>
<%= button_to tag.span(t("game.save_another_tomato")), start_path, class: "cta" %>

+ 1
- 1
app/views/layouts/application.html.erb View File

@ -17,7 +17,7 @@
<link rel="icon" sizes="192x192" href="/ikea-favicon-300x300.png">
<%= stylesheet_link_tag "reset", "application" %>
<%= frontend_javascript_importmap_tags %w[application @hotwired/turbo-rails @hotwired/stimulus language_menu_controller carousel_controller intro_controller chance_controller] %>
<%= frontend_javascript_importmap_tags %w[application @hotwired/turbo-rails @hotwired/stimulus language_menu_controller carousel_controller intro_controller chance_controller share_controller] %>
</head>
<body>
<%= content_for :header %>


+ 1
- 0
config/importmap.rb View File

@ -18,3 +18,4 @@ pin "language_menu_controller", preload: false
pin "carousel_controller", preload: false
pin "intro_controller", preload: false
pin "chance_controller", preload: false
pin "share_controller", preload: false

+ 1
- 0
config/locales/en.yml View File

@ -33,6 +33,7 @@ en:
join_our_newsletter_desc: We'd love to keep you in the loop and share stories about our partners and the important work they're doing.
sounds_good: Sounds good!
save_another_tomato: Save another tomato
share: Share game
results:
best:


Loading…
Cancel
Save