Should i use @container instead of @media?

Hi, if do not care about browser support should i completely discard @media usage ?
225 Replies
ἔρως
ἔρως3mo ago
you use the tool you need container queries can't do everything that media queries can do
b1mind
b1mind3mo ago
tech they can
ἔρως
ἔρως3mo ago
everything? even the prefers-reduced-motion stuff? and media print?
Eso
EsoOP3mo ago
okay i see
b1mind
b1mind3mo ago
look smart ass 😄
Eso
EsoOP3mo ago
you use grid layout frequently or flex?
b1mind
b1mind3mo ago
not wrong but I think in this question we can assume they meant for @meda screen 😄
ἔρως
ἔρως3mo ago
resizing elements for printing is a valid usecase
b1mind
b1mind3mo ago
both, but mostly Grid for layout and flex to flex items
Eso
EsoOP3mo ago
"flex to flex items" can you explain what do you mean by that? or example
ἔρως
ἔρως3mo ago
for example, tags breadcrumbs
Eso
EsoOP3mo ago
oh i see
ἔρως
ἔρως3mo ago
maybe even a menu in the header
b1mind
b1mind3mo ago
when I want children to become their max-content size by default and align next to each other and maybe need wrap
ἔρως
ἔρως3mo ago
things that don't fit in a grid, usually
Eso
EsoOP3mo ago
would you use a overlay grid layout to overlay something or absolute positioning?
b1mind
b1mind3mo ago
grid grid and absolute is a thing too 😉
ἔρως
ἔρως3mo ago
depends on the intention
Eso
EsoOP3mo ago
okay i see
ἔρως
ἔρως3mo ago
grid with position absolute solves a lot
b1mind
b1mind3mo ago
we are getting offtopic though 😄
Eso
EsoOP3mo ago
:)) i just shoot my questions XD
b1mind
b1mind3mo ago
@container can be used like @media screen was my orignal point
Eso
EsoOP3mo ago
yea i think mostly @container is enough
ἔρως
ἔρως3mo ago
yes, think of it as a sub-set of @media but only applies to a parent element, instead of the entire screen or entire presentation device
b1mind
b1mind3mo ago
you can make it just work off the screen if you don't set a parent container
ἔρως
ἔρως3mo ago
yeah, but that's not a less supported @media query, in the end
Eso
EsoOP3mo ago
this only can be true if we can emulate completely @container behaviour inside of media which is i am not sure
ἔρως
ἔρως3mo ago
well, with some effort, you sorta-ish can-ish
b1mind
b1mind3mo ago
if do not care about browser support
ἔρως
ἔρως3mo ago
oh, good point
Eso
EsoOP3mo ago
guys lastly
ἔρως
ἔρως3mo ago
but seriously, using both is fine
Eso
EsoOP3mo ago
omg i forgot my question XD
b1mind
b1mind3mo ago
yea don't fall into this trap of container vs media.... grid vs flex....
Eso
EsoOP3mo ago
nvm
b1mind
b1mind3mo ago
Use all the tools
Eso
EsoOP3mo ago
but layout should be well defined beforehand otherwise needs refactoring and grid and flex works completely different
ἔρως
ἔρως3mo ago
exactly different tools for different results and situations
Eso
EsoOP3mo ago
btw my last question for my excuse you would prefer tricky linear interpolation way to implement font sizing only one line clamp() method or just traditional media query way?
ἔρως
ἔρως3mo ago
yes
b1mind
b1mind3mo ago
not wrong but 🤷‍♂️ people tend to trap themselves into only using flex for some odd reason. Which has done layout for years, thing is we have better layout tools now 😄
ἔρως
ἔρως3mo ago
yes, and then i see people trying to make things align perfectly with flex...
b1mind
b1mind3mo ago
Also how you build a page layout really #depends on the design restrictions, skill of using the right tools to overcome or work with those restrictions while also making things responsive xD
ἔρως
ἔρως3mo ago
you know, align stuff in a grid, but with flex
b1mind
b1mind3mo ago
clamp for LARGE headings, media query for rest most the times I never change the font size 16px looks good on mobile and PC and long as you are respecting user font choice with rem then all is well in the world
Eso
EsoOP3mo ago
what about user preference is not 16px?
ἔρως
ἔρως3mo ago
(but don't set it to 16px, use 1rem)
b1mind
b1mind3mo ago
That is me personally though. If I need it to change its typically one time... media query works just fine. I don't like fonts that change on screen size, I find lots of times it just looks worse. You can also do container query to make sure font fits the parent.
Eso
EsoOP3mo ago
what is the problem with that?
ἔρως
ἔρως3mo ago
it's an absolute horrible experience it's like using an hammer to screw a piece of plastic to a metal sheet
Eso
EsoOP3mo ago
align-items: start? or something
b1mind
b1mind3mo ago
that is default 😄
Eso
EsoOP3mo ago
no i mean when use align-items: start it align perfectly what is the problem or other value
b1mind
b1mind3mo ago
more its hard to align same flex items on the page with lets say other flex items not the child in the parent
ἔρως
ἔρως3mo ago
^ it's like trying to make everything have somewhat the same size like how you get with grid
Eso
EsoOP3mo ago
align-items: scretch? i really do not get the point XD
b1mind
b1mind3mo ago
We are talking bigger picture alignment not the flex child properties
b1mind
b1mind3mo ago
Kevin Powell
YouTube
No, Flexbox isn't "good enough"
I love flexbox. It's a fantastic tool. But there is a reason we have two layout tools, and it's because it can't do everything, and some solutions with it are overly complicated. We have grid for a reason, and it's not as complicated as it might seem at first. 🔗 Links ✅ Learn Grid the easy way: https://youtu.be/8QSqwbSztnA ✅ Flexbox doesn't ...
b1mind
b1mind3mo ago
Maybe teacher Kevin can help
Eso
EsoOP3mo ago
you mean container inside bunch of flex containers?
ἔρως
ἔρως3mo ago
like if you want to have a zone with cards or something
Eso
EsoOP3mo ago
okay i will watch
ἔρως
ἔρως3mo ago
and you want the cards to be the same size
Eso
EsoOP3mo ago
ouu i see but you said not child?
b1mind
b1mind3mo ago
Flex children by default are max-content
Eso
EsoOP3mo ago
still it should be inside of some container
ἔρως
ἔρως3mo ago
yeah, but doing it with flex is horrible
b1mind
b1mind3mo ago
becomes magic numbering almost
ἔρως
ἔρως3mo ago
with grid, it's just grid-template-columns: 1fr 1fr 1fr
Eso
EsoOP3mo ago
okay you mean when want structural thing which every thing defined before hand sizes then use grid
ἔρως
ἔρως3mo ago
and there you go, 3 columns
b1mind
b1mind3mo ago
lol I'm not the only one that find repeat() more truble than typing out a few 1fr's 😄
ἔρως
ἔρως3mo ago
it's also shorter
b1mind
b1mind3mo ago
granted you get into repeat(5, 1fr) I might 😄
Eso
EsoOP3mo ago
btw guys i can animate both template-columns and template-rows at the same time?
ἔρως
ἔρως3mo ago
repeat with a variable is amazing you can animate multiple properties at once if it will look good is another matter
Eso
EsoOP3mo ago
it is a little bit tricky to animate grid-template for some reason some times it doesnt work I do not still get it
b1mind
b1mind3mo ago
animating template is rather "new" I haven't played with it enough yet, its got quirks I'm sure.
ἔρως
ἔρως3mo ago
it's the same as animating display still pretty new and funky
b1mind
b1mind3mo ago
yea
Eso
EsoOP3mo ago
then how people do layout animation before?
ἔρως
ἔρως3mo ago
almost nobody does that
Eso
EsoOP3mo ago
it is popular these days
b1mind
b1mind3mo ago
javascript help 😄
ἔρως
ἔρως3mo ago
i've almost never seen people do it i can't even give you an example of an animating layout maybe masonry, or what it is called
Eso
EsoOP3mo ago
there are some libraries for example it shows images in grid and when move grid cell the grid cells of container animating. they use js for that?
ἔρως
ἔρως3mo ago
but that's it
b1mind
b1mind3mo ago
Lots of animations are based on transition matrix and absolute position. just #depends what its doing You are talking about FLIP its a specific pattern to record state and use that to animate correctly. We totally sent this thread into the either now 🤣
b1mind
b1mind3mo ago
David Khourshid
CSS-Tricks
Animating Layouts With The FLIP Technique | CSS-Tricks
User interfaces are most effective when they are intuitive and easily understandable to the user. Animation plays a major role in this - as Nick Babich said,
b1mind
b1mind3mo ago
old but probably still valid.
ἔρως
ἔρως3mo ago
it looks nice
b1mind
b1mind3mo ago
The whole Flipping.js thing I would avoid and at that point (it uses gsap) I would just use GSAP.flip only thing I could see that is out of date. (gsap didn't have flip plugin yet or for free)
Eso
EsoOP3mo ago
EXACTLY THANKS
ἔρως
ἔρως3mo ago
personally, i would use a dialog and deal with the lack of animations
b1mind
b1mind3mo ago
Fun fact I use GSAP.Flip to faux ViewTransition API feels 😄 which is a good case for using CSRouting >.>;;
Eso
EsoOP3mo ago
I do not do advanced animation thing but can people avoid GSAP? or it does so much thing?
b1mind
b1mind3mo ago
You can avoid anything you want.
ἔρως
ἔρως3mo ago
you just have to implement it yourself
Eso
EsoOP3mo ago
I mean it is extremely hard or not?
b1mind
b1mind3mo ago
GSAP is the leader in web animations, I like it but there are others and CSS animations are become much better.
Eso
EsoOP3mo ago
for example i am pretty sure view port thing can be achieved Observer very easily
b1mind
b1mind3mo ago
IO is harder to use than GSAP (which uses it under the hood) 😄 that is just imo
ἔρως
ἔρως3mo ago
try it
b1mind
b1mind3mo ago
but! CSS scroll animations look to be pretty easy too easier than IO too
Eso
EsoOP3mo ago
what do you mean IO?
b1mind
b1mind3mo ago
IO isn't really hard... its just annoying when you want to do anyting complex Intersection Observer
Eso
EsoOP3mo ago
obeserver returns 0..1 value to indicate animation progress
b1mind
b1mind3mo ago
I know how it works 😄 again I'm just saying you want complex trigger animation IO is limited imo
ἔρως
ἔρως3mo ago
i use intersection observers to pause animations in css, or videos outside the viewport it's a much better use case
b1mind
b1mind3mo ago
yea that use case I'm sure it works great 😄
Eso
EsoOP3mo ago
"pause animations in css" how you do that? iterating over elements? you use it for specific elements or generally all the website?
b1mind
b1mind3mo ago
you have access to css animations in JS
Eso
EsoOP3mo ago
ou i know this but this property also manage states for us?
b1mind
b1mind3mo ago
oh TIL
ἔρως
ἔρως3mo ago
animation paused it's paused, not stopped
Eso
EsoOP3mo ago
i mean when i play it plays exactly wheere it remained oh very cool but very weird that browser does not do that for us
ἔρως
ἔρως3mo ago
why would it?
Eso
EsoOP3mo ago
why animate something user does not see? i think default should be reversed
ἔρως
ἔρως3mo ago
what if you want the animation to keep running off screen?
Eso
EsoOP3mo ago
it should be something we can do if really we want
ἔρως
ἔρως3mo ago
you can, with intersection observer and changing the play state
b1mind
b1mind3mo ago
ἔρως
ἔρως3mo ago
ive never used that
b1mind
b1mind3mo ago
its 🔥
ἔρως
ἔρως3mo ago
i've never had the need to everything i've animated is very easily paused with that single property
b1mind
b1mind3mo ago
new Web Animations API is pretty slick
ἔρως
ἔρως3mo ago
im not much for animations 🤣
b1mind
b1mind3mo ago
yes I know 🥲
ἔρως
ἔρως3mo ago
but sometimes, they are the best tool i used it for a carousel
Eso
EsoOP3mo ago
but maybe your element has multiple animations
ἔρως
ἔρως3mo ago
no, usually just 1
Eso
EsoOP3mo ago
then how you know which animation you wanna stop
ἔρως
ἔρως3mo ago
i think it pauses all
Eso
EsoOP3mo ago
yea probably i think it is usefull when u do animations programatic way
ἔρως
ἔρως3mo ago
animation-play-state: paused, running, running; <-- you can do this
Eso
EsoOP3mo ago
but this is very weird
ἔρως
ἔρως3mo ago
and it pauses the animations set in animation-name which can have multiple names too
Eso
EsoOP3mo ago
i think method is better if multi animation
ἔρως
ἔρως3mo ago
it might be, i've never tried i barely use animations what i use more is transitions
Eso
EsoOP3mo ago
that is another topic difference between transition and animation
b1mind
b1mind3mo ago
keyframes need love
Eso
EsoOP3mo ago
can you explain? animation = keyframes = multiple transitions?
b1mind
b1mind3mo ago
that is debate based on context. In this sense though its keyframes vs transition like hover is a transition
Eso
EsoOP3mo ago
but in theory same thing can be done with animation keyframes 0%, 50%, 100%
b1mind
b1mind3mo ago
sure
ἔρως
ἔρως3mo ago
yes it's a pretty terrible option, but yes
b1mind
b1mind3mo ago
keyframes get timelines I might use them more 🥲 but yea any complex animations I'm reaching for GSAP sorry not sorry (unless for some reason I really need them to work without JS)
ἔρως
ἔρως3mo ago
you need to remember to set and remove the animation in EVERY SINGLE STATE you want to animate for transitions, all you need to set is the transition style and done yeah, i can see why you would use it
Eso
EsoOP3mo ago
A transition is an animation, just one that is performed between two distinct states - i.e. a start state and an end state. Like a drawer menu, the start state could be open and the end state could be closed, or vice versa.

If you want to perform something that does not specifically involve a start state and an end state, or you need more fine-grained control over the keyframes in a transition, then you've got to use an animation.
A transition is an animation, just one that is performed between two distinct states - i.e. a start state and an end state. Like a drawer menu, the start state could be open and the end state could be closed, or vice versa.

If you want to perform something that does not specifically involve a start state and an end state, or you need more fine-grained control over the keyframes in a transition, then you've got to use an animation.
b1mind
b1mind3mo ago
idk that last part is kinda confusing imo
ἔρως
ἔρως3mo ago
that sounds like it was made by ai
b1mind
b1mind3mo ago
but yea works yea it does sound like AI 🤣
Eso
EsoOP3mo ago
stackoverflow
ἔρως
ἔρως3mo ago
i would never say that a transition is an animation that's like saying a car is a tyre
Eso
EsoOP3mo ago
maybe under the hood it uses same technique
ἔρως
ἔρως3mo ago
it very likely does
Eso
EsoOP3mo ago
guys btw canvas uses pure CPU? or can use GPU as well?
ἔρως
ἔρως3mo ago
i would say that an animation is just a set of transitions that you can define in a timeline yes that's the correct answer: yes canvas can be 2d and 3d which means, it can be driven by the cpu and gpu and since it is using (sorta-ish) the same tech as opengl, with webgl, it can also use the cpu or gpu for 3d so, in short: yes
Eso
EsoOP3mo ago
it depends on context it think. when it use webGL context utils GPU but not sure for other default api to draw
ἔρως
ἔρως3mo ago
webgl can be executed by the cpu too
Eso
EsoOP3mo ago
no way 100% sure
ἔρως
ἔρως3mo ago
if you don't have a gpu with 3d acceleration, yes
Eso
EsoOP3mo ago
openGL is GRAPHICS API which talks with GPU driver no way if you do not have hardware which supports openGL via driver then it just crush when you wanna use openGL
ἔρως
ἔρως3mo ago
you can do software rendering it's as crappy as you can imagine, but it's possible
Eso
EsoOP3mo ago
but software rendering is completely different implementation we cannot use same webGL code in software rendering
ἔρως
ἔρως3mo ago
you can
Eso
EsoOP3mo ago
how would you run shader? in CPU
ἔρως
ἔρως3mo ago
mesa softpipe is a software rendered, and it can run the openfl stuff in the cpu you don't want to run shaders on a cpu but if you try, im sure it will run like crap
Eso
EsoOP3mo ago
maybe it just uses some library translates openGL calls to something
b1mind
b1mind3mo ago
webGPU ❤️
Eso
EsoOP3mo ago
I think it is not possible even you wanna 1000k Vulkan code to draw triangle for +=10FPS no thanks
b1mind
b1mind3mo ago
I mean it is going to be the successor solves those issues too
Eso
EsoOP3mo ago
I do not understand they just f** everything Vulkan cannot replace openGL Vulkan is supposed to be low level thing but openGL is accesible it is something like they wanna replace JavaScript with Assembly
ἔρως
ἔρως3mo ago
you mean, webassembly?
Eso
EsoOP3mo ago
apple completely discard openGL last years
b1mind
b1mind3mo ago
na thats not a fair comparison its still a JS API for one
ἔρως
ἔρως3mo ago
by the way, apple does support vulkan and their metal api
b1mind
b1mind3mo ago
WASM is not working with the browser its working against it 😄 just so BE devs can have their way AYO
Eso
EsoOP3mo ago
analogy. openGL/WebGL = Javascript Vulkan/Metal/DirectX12 = Assembly
ἔρως
ἔρως3mo ago
yeah, but i don't think it is a replacement but an addition
Eso
EsoOP3mo ago
companies tries to get rid of openGL
ἔρως
ἔρως3mo ago
it allows rust to run in the browser
Eso
EsoOP3mo ago
rust in browser even worse than python in browser
b1mind
b1mind3mo ago
I mean I like the looks of Blazor but it goes against my core being
ἔρως
ἔρως3mo ago
how about running a php server in the browser, and host wordpress on it?
b1mind
b1mind3mo ago
Cause I rather use frameworks that leverage the browsers
ἔρως
ἔρως3mo ago
i believe that webassembly is a nice gimmick
Eso
EsoOP3mo ago
if php can run back-end and front-end i would use it
ἔρως
ἔρως3mo ago
it can, but it's a terrible idea
Eso
EsoOP3mo ago
it uses http methods to call serverside thing i do not mean that pure client side code
ἔρως
ἔρως3mo ago
you mean, something sorta like laravel livewire?
Eso
EsoOP3mo ago
nah it uses http also they all tries to communicate with server i mean something like javascript recently analyzed laravel source code. that is terrible in some aspects taylor tries to create something cool rather than simple
ἔρως
ἔρως3mo ago
the source-code of libraries and frameworks is usually full of unholy code
b1mind
b1mind3mo ago
livewire is like exactly that Also you want something that can communicate with the server 😄 Its how you can do fun things like progressivly enhanced forms
Eso
EsoOP3mo ago
like they use seperate blade directives for true and false logic no wait
ἔρως
ἔρως3mo ago
yuck, blade
Eso
EsoOP3mo ago
@isset($records)
// $records is defined and is not null...
@endisset

@empty($records)
// $records is "empty"...
@endempty
@isset($records)
// $records is defined and is not null...
@endisset

@empty($records)
// $records is "empty"...
@endempty
ἔρως
ἔρως3mo ago
those are different conditions you can just use @if
Eso
EsoOP3mo ago
ou my bad blade does not allow expression inside of @if @if($s.count() === 0) ...
ἔρως
ἔρως3mo ago
that's because you're doing it wrong
b1mind
b1mind3mo ago
can't you also just use Twig if you wanted? I though Laravel let you change template langs?
ἔρως
ἔρως3mo ago
probably does smarty is easier
b1mind
b1mind3mo ago
I'm sure it does
Eso
EsoOP3mo ago
there are macros
ἔρως
ἔρως3mo ago
what you have can be read as: causes a Fatal error: Uncaught ArgumentCountError: count() expects at least 1 argument, 0 given in ... you have to use @if(!count($x))
Eso
EsoOP3mo ago
@if(count($s) === 0) ... LOL
ἔρως
ἔρως3mo ago
that's calling the variable $count
Eso
EsoOP3mo ago
is that valid? expression inside @if?
ἔρως
ἔρως3mo ago
yes
Eso
EsoOP3mo ago
then why laravel has @isset
ἔρως
ἔρως3mo ago
shortcut
Eso
EsoOP3mo ago
or even @auth
ἔρως
ἔρως3mo ago
to make sure you don't fuck up authorization and/or authentication
Eso
EsoOP3mo ago
it has shortcuts but also macros i do not like it
ἔρως
ἔρως3mo ago
yeah, but it has it's uses i don't like the language either but @auth is EXTREMELLY useful @isset is just convenience instead of @if(isset($value)) you use the @isset
Eso
EsoOP3mo ago
<div {{ $attributes->merge(['data-controller' => $attributes->prepends('profile-controller')]) }}>
{{ $slot }}
</div>
<div {{ $attributes->merge(['data-controller' => $attributes->prepends('profile-controller')]) }}>
{{ $slot }}
</div>
this merge behaves different when key is "class" or "style"
ἔρως
ἔρως3mo ago
because class tries to keep everything separated by space laravel does some magic to try to keep that
Eso
EsoOP3mo ago
GitHub
view/ComponentAttributeBag.php at master · illuminate/view
[READ ONLY] Subtree split of the Illuminate View component (see laravel/framework) - illuminate/view
b1mind
b1mind3mo ago
Hey at this point I really should be enforcing a new post We have gone from the OT to like 3 other things now xD
ἔρως
ἔρως3mo ago
you're right, this is so off-topic it is in another continent
b1mind
b1mind3mo ago
facts
ἔρως
ἔρως3mo ago
maybe in another castle too
Eso
EsoOP3mo ago
thanks bye
Want results from more Discord servers?
Add your server