
Contract Ruby / JS Developer - Founder @tech_talks_io - @BristolJS organiser - - Creative Coder - Hardware Hacker - Photographer - More @ https://xitter.cf/t.co/dWYhHelw0p
Bristol, UK
Joined May 2007
- Tweets6.7K
- Following1.4K
- Followers1.4K
- Likes2.3K
Adam Butler retweeted
Day 1 at #RailsWorld! Can’t wait to watch the awesome talks today! And ready for my talk tomorrow about Demystifying some of the magic behind Rails at 11:15am on Track 2!
Adam Butler retweeted
🚨We just dropped in on Farage’s election rally with a beaming picture of Putin. Nigel was not pleased.
Adam Butler retweeted
If you’re in #London next Wednesday 1st, I’m speaking at the Ruby in London Meetup about Solid Queue! Come along and find out if my live demo works or not 😅 #rubyfriends #ruby #rails meetup.com/ruby-in-london/ev…
Adam Butler retweeted
Maths peeps. What’s the best trig/linear algebra for dummies resource out there?
Adam Butler retweeted
Looks like I'm a bit late to the party on this one, but the `has_scope` gem has been lovely to use as I simplify the filtering logic in my apps
github.com/heartcombo/has_sc…
Adam Butler retweeted
What if the scrollbar went around the corner? 👀
CSS could do that ✨
Adam Butler retweeted
CSS Tip! 💪
You can create these tab controls with CSS :has() + radio buttons ✨
.tabs:has(input:nth-of-type(3)) { --count: 3; }
.tabs:has(:checked:nth-of-type(3)) { --active: 2; }
.tabs::after { translate: calc(var(--active, 0) * 100%) 0;
width: calc(100% / var(--count));
}
Two CSS :has() tricks here combined with a rendering trick 🤙
The tab control is a container using display: grid. You can use :has() to count the number of tabs in the container:
.tabs:has(input:nth-of-type(3)) { --count: 3; }
.tabs:has(input:nth-of-type(4)) { --count: 4; }
Using the cascade, the last valid :has() gives you the number of tabs 🫶
Once you know the number of tabs, you know how to size the indicator:
.tabs::after {
content: "";
position: absolute;
height: 100%;
width: calc(100% / var(--count));
}
It's a pseudoelement that uses --count to determine its size 📏
The next :has() trick is determining which tab is active or :checked as it's an input [type=radio]
.tabs:has(:checked:nth-of-type(2)) { --active: 1; }
.tabs:has(:checked:nth-of-type(3)) { --active: 2; }
You can use a zero-indexed translation here. If the second input is :checked, set --active: 1, then translate the pseudoelement on the tabs to that position 👉
.tabs::after { translate: calc(var(--active, 0) * 100%) 0; }
The last rendering trick is using mix-blend-mode 👀
The tabs have a black background-color, the pseudoelement is white, and the label text is white. When you use mix-blend-mode: difference on the pseudoelement it will give this effect that the text transitions from white to black sliding across 😎
.tabs::after {
color: hsl(0 0% 100%);
mix-blend-mode: difference;
}
You can totally mix up the colors here though and go with a different effect. The mechanics of how you can use CSS :has() is the main point here 🙏
As always, any questions, suggestions, etc. let me know
@CodePen link below! 👇 (There's even a @tailwindcss play for this one too 👀)
Adam Butler retweeted
🤼♂️ Sort ActiveRecord models by an enum value (in SQL!) using `in_order_of`
Super handy to float results to the top of a list
![# Sort ActiveRecord models by an enum value (in SQL)
#
# Use `in_order_of` and specify the sort order to generate
# a SQL CASE statement for ORDERing
#
# You can also chain additional `order` calls!
#
class Proposal < ApplicationRecord
enum status: {
in_review: 0,
accepted: 1,
rejected: 2
}
end
Proposal
.in_order_of(:status, %[accepted in_review rejected])
.order(:name)](https://pbs.twimg.com/media/FhNuNhOXkAcsxma.jpg?name=small&format=webp)
ALT # Sort ActiveRecord models by an enum value (in SQL) # # Use `in_order_of` and specify the sort order to generate # a SQL CASE statement for ORDERing # # You can also chain additional `order` calls! # class Proposal < ApplicationRecord enum status: { in_review: 0, accepted: 1, rejected: 2 } end Proposal .in_order_of(:status, %[accepted in_review rejected]) .order(:name)
Adam Butler retweeted
Today I learned that @stripe charges £0.40 per API call to calculate taxes.
That is absurd. Taxes are absurd. Somebody please, for the love of all that is holy, fix this.
Adam Butler retweeted
The second part of RailsCasts Retrospective is finally up! The Fire: rbates.dev/railscasts-retros…
Adam Butler retweeted
Love this thread from Jake Rodkin on how the new Steam Deck OLED ad was made using a giant metal orb rig for lighting with Steam Decks!
mastodon.social/@ja2ke@idlet…
Adam Butler retweeted
My favorite color generator tool as a designer. ✨💙
You'll love it → randoma11y.com/
Adam Butler retweeted
Launching my ✨new Rails tool✨ — railsg.xyz 🥳 (it's free!)
RAILSG is a command builder 🔨 for the Ruby on Rails generator commands.
Use the GUI to write your commands and see all their flags and options (rather than the CLI)
Check it out! railsg.xyz
Adam Butler retweeted
In the previous episode we added Search, Sort, and Pagination to a data table.
Turbo Frames will help us make it work WITHOUT PAGE REFRESH 🔄❌
😵💫 Along the way we will have to solve some potential problems (page refresh, URL update, redirects).
WATCH:
superails.com/posts/rails-14…
Adam Butler retweeted
This site is so cool railsinspire.com/
Adam Butler retweeted
Learn more about front-end development and UX/UI design with this video from Pixel Pioneers 2023
CSS, #Javascript and Accessibility – Ire Aderinokun | Pixel Pioneers 2023
youtube.com/watch?v=imn7WGFq…
#Js #PixelPioneers
Adam Butler retweeted
Now this is cool and useful as heck. Draw something at shapecatcher.com/ and it'll show you the closest Unicode matches to what you drew.























