CSS findings from the Threads app
ishadeed.com
ishadeed.com
Any CSS work eventually devolves to adjusting numbers until everything falls in line, adjusting for the 2 pixels of padding there or the borders of some other thing. Maybe nowadays there is calc where you don't need to do that, but it didn't exist back when I did CSS.
IMO the browser makers are at fault for making the viewport be partially obscured under the UI.
The viewport should be just that: viewable.
The only exception I've encountered in my career is CSS. I'm no more effective at it than I was when I first tried using it.
There are now thousands of properties and their values, and browser engines have gone to heroic lengths to produce mostly consistent results from these often conflicting directives. But I still keep looking up basic things because the API is simultaneously sprawling and inexpressive and context-sensitive.
IMO, the core sin of CSS is mixing up three separate concerns: element styling, layout, and compositing. It’s mostly ok for the first. It’s insanely confusing for the second. And it mostly tries to pretend it’s not about the third at all, which leads to weird situations around implicit compositing groups.
We ended up here because CSS started as basically a copy of a handful of Microsoft Word dialog boxes (hence “float” etc.) And as soon as we had got the word processing use case barely working, everybody decided they wanted to build dynamic applications with this same engine instead.
Computed properties, custom properties and media queries are well designed.
Of course there’s some downsides, but it’s refreshing to use.
It wasn't that hard, once you accept that it'll require it's own study and practice. I put in maybe 20 hours dedicated study and got a lot better out of it.
I did a few video courses on LinkedIn Learning (formerly Lynda.com) through my public library. I did a general CSS course and a flexbox CSS course. Then I set out to design pages I needed without pulling some random blog theme and calling it a day.
I've gotten a bit better at design as well, although it is a much intrinsic field than CSS and requires a lot more study. The biggest difference was once I treated the design stage with respect as its own discipline and started designing in a design tool (figma) instead of "doing it live" by trying to tweak the design in code as I went. It made me 100% focused in that stage at the design problems and the feedback loop got a lot tighter compared to editing and running code to see how it looked.
Which is why if you don't interact with it day to day basis, you'll need some trial and error, as well as references and examples.
Opposite to backend or usual programming where `foo = foo + 1` is most of the time do an increment by one (exception apply)
Combing through the CSS and the computed styles panel in dev tools gave me nothing.
It turned out there is an option to disable the standard OS form theming which isn't communicated at all in dev tools for that element (and I hadn't seen --webkit-apperance used before as the guide says you really shouldn't mess with it): https://developer.mozilla.org/en-US/docs/Web/CSS/appearance
CSS and usual programming are identical. If you don't give yourself the time to learn the fundamentals, you'll always run into tedious problems.
A good place to learn how CSS was designed to work is Every Layout at https://every-layout.dev/.
There is a surprisingly small amount of content out there on how to competently engineer your CSS (and a lot of it is bad). Most people don't even think it's something you do.
But basic things like making your general rules generic and pushing context descriptively into the HTML go a long way into making your code understandable.
Open instagram.com in a browser :D
I have no doubt there is a 'logical reason' for the behaviour but it doesn't stop it being annoying to work with.
This explains a bit more about what you’re seeing
http://stackoverflow.com/questions/28353625/why-does-percent...
There's a well-defined algorithm (well, set of algorithms) that explain it, which you can learn if you so choose.
Sure, the box model is a prerequisite to understand CSS properly. But if you think the box model covers all aspects, you really don't know very much about CSS.
I will never ever do another layout without it, stuck together by glue, snot, and magical trial-and-error.
One explanation people like to give is:
CSS Grid is for layouts in 2 dimensions, Flexbox is for layouts along one dimension.
Which can be confusing because you absolutely can use Grid for layouts along one dimension too.
Here is my stupid sounding rule of thumb that I think is more useful: If you want a grid layout use grid, if you want a flexible layout use flexbox.
Grid quite literally splits the area into a grid but what if you want to just say "I want these two elements to be as far apart as possible within the container they are in" (ie a navbar, you want the logo on the left about 20 pixels away from the left of the viewpoert and you want the actual navigation to be on the right with the rightmost element 20px away from the right of the viewport). Flexbox is better for that.
(I'm considering proposing one myself).
Allowing scrolling both ways would have been perfect. Switching to left-aligned when content overflows would be acceptable. But completely prohibiting access to half the content when an overflow occurs? Absolutely asinine.
I believe there may be ways to get around this with layers of inner divs and weird `overflow: ` incantations, but that's exactly the kind of bullshit flex was supposed to solve.
See https://developer.mozilla.org/en-US/docs/Web/CSS/align-items. If you need to enable a "safe" mode to prevent data loss, and that isn't supported on any mainstream browsers... you fucked up.
It will take you from a n00b to a Grid pro in no time.
Grid systems existed long before CSS grid and were dead-easy to understand and use (960, Bootstrap etc). CSS grid, by comparison, is completely unintuitive. Sure, it’s definitely more powerful, but the barrier to entry is way higher.
Flexbox complements grid imo, it's not an alternative.
the framework part isn’t mandatory, but I suppose very small tweaks with something like tailwind do the trick for me.
I can’t work with css if there are massive classes and nested stuff etc. I guess composition over inheritance
Seems like there would be some sort of layer on top of it that someone built that makes things more consistent and then will compile down to the inconsistencies and odd behaviours for how CSS is supposed to be implemented.
I don't think any of those make CSS much easier, though. Quicker to use, easier to write certain things, sure. But you still need to know your way around CSS atleast somewhat before you jump in to some augmentation or replacement.
I've found that Kevin Powell [1] is a great resource for this approach, and he also helps with the model model aspect as a bonus.
I wish I could specialize on any one of these sometimes...but such is life at a startup. It's more interesting being able to do them all anyway and be able to build entire apps yourself. Just occasionally frustrating.
Last time I investigated having a uniform grid of items is impossible without falling back to custom C# layout code.
Barcelona is/was the internal name for Threads.
Copying something Meta did and playing with it just feels more interesting than an abstract example out of thin air.
Tech interview industry really misses the point sometimes
Personally I’d be hard-pressed to move an applicant with a less-than-obsessive attitude to naming forward to the next round.
When you’re an interviewer you have to make a decision based on way too little signal. This means you zoom in on the things you do see, and you accept the chance that you might reject a great candidate. I can completely imagine a company rejecting a candidate because they didn’t care about naming.
Now if you think “worried that candidate might have negative productivity due to careless attitude, soft reject” is obnoxious then fine but I think that makes you spoiled. You’re not entitled to a job, even a junior position, simply because you can write a loop or center a div. Real world engineering has more going on. Interviewers look for those signals, so better work on getting them right.
The idea that naming is about someMethod vs Some_Method is nuts to me. Just choose a thing and do it. Naming is about words and meaning. It’s hard, and it’s important.
So was I. Maybe next time respond to my actual words, not your slimmed-down interpretation of them? Some teams are perfectly ok with single-letter local variables, some are not. Some teams are perfectly ok with single-letter parameter names, some are not. Some APIs I've worked on even specified the units in quantity parameters (e.g. HeightInMeter, WeightInMilligram), others would only specify that in the documentation (if you're lucky).
Naming is about words and meaning. It’s hard, and it’s important.
When working on a piece of throwaway pseudo-code, no it's not important.
Every interviewer seems to have their own idiosyncratic version of what they consider "table stakes". So table stakes ends up being everything and nothing.
> I can completely imagine a company rejecting a candidate because they didn’t care about naming.
Didn't "care" about naming, or didn't focus on naming in some little throwaway sample code for a job interview?
Why would you assume that impromptu interview code would be the same as production code?
The insanity for job applicants is that you never know which kind of interviewer you're going to get until it's too late. Every interviewer has their own nitpicks, yet they somehow believe that their specific nitpicks should be assumed to be universal requirements.
And then hiring managers complain that good programmers are difficult to find, lacking the self-awareness to see how many candidates they arbitrarily exclude for dumb reasons. I've seen people say "I'd pass on a candidate for X" for more or less all X.
With CSS grid you don't need div elements, ever.
When I've witnessed Flexbox and Grid (esp. templates) for the first time I liked Grid more, but as I've seen Flexbox more commonly used in the industry
grid-template-areas:
"avatar header"
"avatar body"
". body"
". footer";So I expect that what you are mostly seeing is the evolution of CSS, from table to flexbox to grid. Table has no real responsiveness (to screen size), Flex does it _really_ well (especially for cases where the target is both PC and Phone etc.) But it has some limitations (mostly for me around column widths and the concept of "relative" column widths.)
Grid is really nice, it's a lot more like tables in concept, but at the same time has responsive abilities. These days I'm grid-first, although there are still a few places (depending on context) where flex is more appropriate.
Of course flex is also more "well known" (because it's older.) I feel a lot more comfortable there still, and until we have sub-grids I'm also a fan of using Grid layout for the "outside" and using Flex inside specific cells.
Though while grid borrowed a lot of ideas from flex, the creative usage of the grid template is so vast that you probably need to also learn by examples.
10 years later, kind of, I got back into web dev and css and learnt about flexbox, what an incredible difference. I was so thankful I wouldn't have to deal with floats ever again
Dealing with multiple screen/windows/paper sizes, as well as dynamic resizing & scaling is incredibly hard or impossible when you've baked a fixed idea of presentation into your content, see: Latex, PDFs & old school HTML with complex tables for layout, for examples.
Since it's done with JSX/Props, it's API is a 1:1 translation to a new HTML element.
This ensures that if a user adjusts their browsers font size for accessibility purposes or uses dynamic type, only the text will scale. You don’t want margins/paddings to scale with font size (at least not linearly) otherwise the layout gets cramped/unusable very quickly.
As others have mentioned CSS pixels have nothing to do with hardware pixels. So there are no issues with the differences in screen densities between devices.
Don't take my word for it, it's how it's defined in the CSS spec: https://www.w3.org/TR/css-values-3/#absolute-lengths
Hiring managers: "We don't have the time to read the blog posts of job applicants".
We get our programmers involved in that process since they are the only ones capable of knowing. Although we're a small company.