Skip to content

Commit

Permalink
add view transitions for sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
JensRavens committed Oct 16, 2024
1 parent f98e760 commit c65ceab
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 23 deletions.
21 changes: 10 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ GEM
chunky_png (1.4.0)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
countries (6.0.1)
unaccent (~> 0.3)
Expand Down Expand Up @@ -194,7 +194,7 @@ GEM
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
i18n-tasks (1.0.14)
activesupport (>= 4.0.2)
Expand All @@ -218,7 +218,7 @@ GEM
activesupport (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.7.2)
irb (1.14.0)
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jmespath (1.6.2)
Expand Down Expand Up @@ -261,7 +261,7 @@ GEM
mime-types-data (3.2024.0604)
mini_magick (4.13.1)
mini_mime (1.1.5)
minitest (5.24.1)
minitest (5.25.1)
mission_control-jobs (0.2.1)
importmap-rails
rails (~> 7.1)
Expand Down Expand Up @@ -321,7 +321,7 @@ GEM
rspec-support (~> 3.12)
raabro (1.4.0)
racc (1.8.1)
rack (3.1.7)
rack (3.1.8)
rack-proxy (0.7.7)
rack
rack-session (2.0.0)
Expand Down Expand Up @@ -377,7 +377,7 @@ GEM
psych (>= 4.0.0)
redcarpet (3.6.0)
regexp_parser (2.9.2)
reline (0.5.9)
reline (0.5.10)
io-console (~> 0.5)
responders (3.1.1)
actionpack (>= 5.2)
Expand Down Expand Up @@ -488,7 +488,7 @@ GEM
temple (0.10.3)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.3.1)
thor (1.3.2)
thread_safe (0.3.6)
tilt (2.3.0)
time_will_tell (0.1.0)
Expand All @@ -501,9 +501,8 @@ GEM
launchy
netrc
thor
turbo-rails (2.0.6)
turbo-rails (2.0.11)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -532,14 +531,14 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
webrick (1.8.2)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
yael (0.0.3)
zeitwerk (2.6.17)
zeitwerk (2.7.0)

PLATFORMS
aarch64-linux
Expand Down
1 change: 1 addition & 0 deletions app/javascript/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { start } from '@nerdgeschoss/shimmer';
import { Application } from '@hotwired/stimulus';
import { registerControllers } from 'stimulus-vite-helpers';
import 'chartkick/chart.js';
import './sprinkles/view_transition';

const application = Application.start();
const controllers = import.meta.glob('./controllers/**/*_controller.ts', {
Expand Down
13 changes: 13 additions & 0 deletions app/javascript/sprinkles/view_transition.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
addEventListener('turbo:before-render', (event) => {
if (document.startViewTransition) {
const originalRender = event.detail.render;
event.detail.render = (currentElement, newElement) => {
const isErrorPage = !!newElement.querySelector('#console');
if (isErrorPage) return originalRender(currentElement, newElement);

document.startViewTransition(() =>
originalRender(currentElement, newElement)
);
};
}
});
7 changes: 5 additions & 2 deletions app/views/users/_user.html.slim
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
- salary = user.current_salary
.card
.card style="view-transition-name: user-card-#{user.id}"
.card__header
.card__icon: img src=user.avatar_image(size: 80)
.card__header-content
a.card__title href=user_path(user) = user.display_name
a.card__title href=user_path(user)
= user.full_name
- if user.nick_name.present?
= " (#{user.nick_name})"
.card__subtitle
= t(".days_of_holidays_remaining",days: user.remaining_holidays)
- if user.unpaid_holidays_this_year_total.positive?
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "MIT",
"dependencies": {
"@hotwired/stimulus": "^3.2.2",
"@hotwired/turbo-rails": "^8.0.5",
"@hotwired/turbo-rails": "^8.0.12",
"@nerdgeschoss/shimmer": "^0.0.10",
"chart.js": "^3.7.0",
"chartkick": "^4.1.1",
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,18 @@
resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.2.2.tgz#071aab59c600fed95b97939e605ff261a4251608"
integrity sha512-eGeIqNOQpXoPAIP7tC1+1Yc1yl1xnwYqg+3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A==

"@hotwired/turbo-rails@^8.0.5":
version "8.0.5"
resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-8.0.5.tgz#18c2f0e4f7f952307650308590edf5eb9544b0d3"
integrity sha512-1A9G9u28IRAl0C57z8Ka3AhNPyJdwfOrbjr+ABZk2ZEUw2QO7cJ0pgs77asUj2E/tzn1PgrxrSVu24W+1Q5uBA==
"@hotwired/turbo-rails@^8.0.12":
version "8.0.12"
resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-8.0.12.tgz#6f1a2661122c0a2bf717f3bc68b5106638798c89"
integrity sha512-ZXwu9ez+Gd4RQNeHIitqOQgi/LyqY8J4JqsUN0nnYiZDBRq7IreeFdMbz29VdJpIsmYqwooE4cFzPU7QvJkQkA==
dependencies:
"@hotwired/turbo" "^8.0.5"
"@hotwired/turbo" "^8.0.12"
"@rails/actioncable" "^7.0"

"@hotwired/turbo@^8.0.5":
version "8.0.5"
resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.5.tgz#abae6dad018a891e4286e87fa0959217e3866d5a"
integrity sha512-TdZDA7fxVQ2ZycygvpnzjGPmFq4sO/E2QVg+2em/sJ3YTSsIWVEis8HmWlumz+c9DjWcUkcCuB+muF08TInpAQ==
"@hotwired/turbo@^8.0.12":
version "8.0.12"
resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.12.tgz#50aa8345d7f62402680c6d2d9814660761837001"
integrity sha512-l3BiQRkD7qrnQv6ms6sqPLczvwbQpXt5iAVwjDvX0iumrz6yEonQkNAzNjeDX25/OJMFDTxpHjkJZHGpM9ikWw==

"@humanwhocodes/config-array@^0.9.2":
version "0.9.2"
Expand Down

0 comments on commit c65ceab

Please sign in to comment.