Did You Know About the :has CSS Selector?

Featured Imgs 23

File this under stuff you don’t need to know just yet, but I think the :has CSS selector is going to have a big impact on how we write CSS in the future. In fact, if it ever ships in browsers, I think it breaks my mental model for how CSS fundamentally works because it would be the first example of a parent selector in CSS.

Before I explain all that, let’s look at an example:

div:has(p) {
  background: red;
}

Although it’s not supported in any browser today, this line of CSS would change the background of a div only if it has a paragraph within it. So, if there’s a div with no paragraphs in it, then these styles would not apply.

That’s pretty handy and yet exceptionally weird, right? Here’s another example:

div:has(+ div) { 
  color: blue; 
}

This CSS would only apply to any div that directly has another div following it.

The way I think about :has is this: it’s a parent selector pseudo-class. That is CSS-speak for “it lets you change the parent element if it has a child or another element that follows it.” This is so utterly strange to me because it breaks with my mental model of how CSS works. This is how I’m used to thinking about CSS:

/* Not valid CSS, just an illustration */
.parent {
  .child {
    color: red;
  }
}

You can only style down, from parent to child, but never back up the tree. :has completely changes this because up until now there have been no parent selectors in CSS and there are some good reasons why. Because of the way in which browsers parse HTML and CSS, selecting the parent if certain conditions are met could lead to all sorts of performance concerns.

Putting those concerns aside though, if I just sit down and think about all the ways I might use :has today then I sort of get a headache. It would open up this pandora’s box of opportunities that have never been possible with CSS alone.

Okay, one last example: let’s say we want to only apply styles to links that have images in them:

a:has(> img) {
  border: 20px solid white;
}

This would be helpful from time to time. I can also see :has being used for conditionally adding margin and padding to elements depending on their content. That would be neat.

Although :has isn’t supported in browsers right now (probably for those performance reasons), it is part of the CSS Selectors Level 4 specification which is the same spec that has the extremely useful :not pseudo-class. Unlike :has, :not does have pretty decent browser support and I used it for the first time the other day:

ul li:not(:first-of-type) {
  color: red;
}

That’s great I also love how gosh darn readable it is; you don’t ever have to have seen this line of code to understand what it does.

Another way you can use :not is for margins:

ul li:not(:last-of-type) {
  margin-bottom: 20px;
}

So every element that is not the last item gets a margin. This is useful if you have a bunch of elements in a card, like this:

CSS Selectors Level 4 is also the same spec that has the :is selector that can be used like this today in a lot of browsers:

:is(section, article, aside, nav) :is(h1, h2, h3, h4, h5, h6) {
  color: #BADA55;
}

/* ... which would be the equivalent of: */
section h1, section h2, section h3, section h4, section h5, section h6, 
article h1, article h2, article h3, article h4, article h5, article h6, 
aside h1, aside h2, aside h3, aside h4, aside h5, aside h6, 
nav h1, nav h2, nav h3, nav h4, nav h5, nav h6 {
  color: #BADA55;
}

So that’s it! :has might not be useful today but its cousins :is and :not can be fabulously helpful already and that’s only a tiny glimpse — just three CSS pseudo-classes — that are available in this new spec.


The post Did You Know About the :has CSS Selector? appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Two New Editor Fonts from Toshi Omagari

Featured Imgs 23

Toshi Omagari makes fonts. I caught wind of the Codelia release just recently:

Fortunately, Toshi allowed us to purchase a license to allow you to use it on CodePen! You’ll find those options in your Settings > Editor area.

Codelia

I think Codelia is awfully nice, but in chatting with Toshi, their favorite is actually Comic Code, another coding font they have created.

Comic Code

I was like: No way, surely Comic Code is to jokey and childish to actually code in. But I’ll tell ya, I’ve been using it for about a week now and I’m still finding it fun and perfectly usable.

Looks good eh? Toshi thinks so:

The post Two New Editor Fonts from Toshi Omagari appeared first on CodePen Blog.

Lower Inventory Cash Burn in Your WooCommerce Store

Featured Imgs 26

Lower Inventory Cash Burn in Your WooCommerce StoreNo matter how successfully you market your e-commerce business, an inability to handle inventory can become a roadblock in your way to making efficient supply decisions. Your inventory management process becomes largely inefficient when you don’t have a grip on your inventory or keep a track of it with unorganized spreadsheets. To avoid inventory cash […]

The post Lower Inventory Cash Burn in Your WooCommerce Store appeared first on WPExplorer.

12 Effective Time Management Strategies to Get More Stuff Done

Featured Imgs 26
One of the trickiest things in life is to assume you have time. How often do you tell yourself “This shouldn’t take long” and then wonder why you only managed to finish half of what you had planned for the day? We are very good at getting busy but time doesn’t wait for us. It just passes, no matter if we manage to squeeze in some productivity or not. The best way to stay on top of things is to start employing efficient time management strategies!

Learning the Art of Electronics (A Hands-On Lab Course)

Featured Imgs 11

This introduction to circuit design is unusual in several respects. First, it offers not just explanations, but a full course. Each of the twenty-five sessions begins with a discussion of a particular sort of circuit followed by the chance to try it out and see how it actually behaves. Accordingly, students understand the circuit's operation in a way that is deeper and much more satisfying than the manipulation of formulas. Second, it describes circuits that more traditional engineering introductions would postpone: on the third day, we build a radio receiver; on the fifth day, we build an operational amplifier from an array of transistors. The digital half of the course centers on applying microcontrollers, but gives exposure to Verilog, a powerful Hardware Description Language. Third, it proceeds at a rapid pace but requires no prior knowledge of electronics. Students gain intuitive understanding through immersion in good circuit design
Click Here

MySize Launches Clothes Sizing SDK for eCommerce Platforms

Featured Imgs 23

MySize, Inc, the developer and creator of e-commerce measurement solutions, announced the launch of its MySizeID E-Commerce Plugin SDK. The SDK enables e-commerce companies to create a MySizeID plugin and share it with their customers (online store owners) over their app marketplace. The plugin enables business owners to provide their shoppers with the right size for apparel.

10 Popular APIs for Words

Featured Imgs 23

With all the changes in technology in the last half century, a main form of communication remains relevant: the written or spoken word. Words are powerful, dramatic, inspiring, expressive, meaningful, and a very important part of our society.

2nd Annual Atarim Web Agency Summit Kicks Off March 23

Featured Imgs 23

Atarim is launching its 2nd annual Web Agency Summit in a couple of weeks. The free event will run from March 23 – 26. The goal of the event is to help agencies and freelancers in the WordPress space grow sustainable businesses.

Atarim is the company formerly known as WP Feedback. In February, the business rebranded because its primary product had grown beyond a mere feedback plugin into an across-the-board agency solution.

“While I’m a big fan of WordCamps and a big believer in the value that events can bring to personal growth, we found that most events in our space focus on the technical Aspect of building a website,” said Vito Peleg, Atarim’s founder. “We take a more business-oriented approach. From finding the first clients through building solid recurring revenue and all the way to lessons from some of the biggest agencies in the world at full scale.”

The event has 36 sessions, which are broken down into four categories that focus on:

  • Build: Best practices for performance, SEO, accessibility, and the future of building websites.
  • Expand: Building recurring revenue and maintaining profits.
  • Scale: Project management, completing services, payment, and getting projects unstuck.
  • Thrive: Hiring, community building, profitability at scale, and exit strategies.

Peleg hopes that attendees can glean some knowledge in the sessions while saving years of trial and error.

“All are delivered through our own summit platform, so attendees don’t need to jump around between Zoom calls, YouTube Lives, and Slack channels,” he said. “We brought it all into our own interactive platform.”

Atarim has made several sessions publicly available from 2020’s event. For those on the fence, it should provide insight into the types of talks they can expect.

This year, each session will be running live — last year’s sessions were pre-recorded. This will allow attendees to be involved in real-time. There will also be a designated Q&A time for each session.

The event is free to attend through the last week of March for anyone. However, the sessions will eventually fall behind a paywall, which helps cover costs.

“We offer an All Access Pass for those that want to watch the replays for $97, which is the investment for those that get it before the event,” said Peleg. “This also includes 30+ sessions from last year’s event for a total of 50+ hours of expert advice, specifically designed to help web freelancers and agencies build a solid business.”

Success and Lessons Learned From 2020

Last year’s event kick-started as a response to the changing nature of conferences in the Covid-era. Peleg described the initiative as a way of “licking our own wounds” after his company had planned to attend, sponsor, and have its own retreat at WordCamp Asia in Thailand, which was canceled in 2020.

“This drove me into action, wanting to lift some spirits in the community,” he said. “I didn’t know that we would end up with the biggest event in the WordPress space and have such incredible partners that came along for the ride.”

Last year’s event had 5,725 attendees from 126 countries. In total, they watched 53,945 hours of videos. They also won 1,000s of prizes at sponsor booths that included iPads, board games, and more.

“This was way more than what we expected, and the summit platform even broke on the first day when we were getting more than 240,000 requests to the server in an hour,” said Peleg. “Luckily, there isn’t a better community for something like this to happen. Very quickly, some of the sponsors joined forces with some of the speakers and our team and got us back on the air for a full week of action. While they were working to get this sorted, I was mostly pacing back and forth in my office like a headless chicken, but this year we’ve come prepared, with load balancers, auto-scaling processes, and a much leaner platform to sustain the scale.”

There are no plans to switch to a physical Web Agency Summit in the coming years. For now, the virtual model is working.

“I’m very much looking forward to the return of WordCamps as physical events when [Covid-19] blows over, but I believe that virtual events are here to stay, so for the foreseeable future, once a year, we’ll bring back our summit as a celebration of the business side of the WordPress industry.”

Publish Text, Image, and Gallery Snippets With the Shortnotes WordPress Plugin

Category Image 091

Yesterday, Happy Prime owner and engineer Jeremy Felt released Shortnotes, a plugin for writing notes from the WordPress editor. The intention is for users to create short pieces of content, such as that found on Twitter, Instagram, and similar social networks. However, it does not come with a front-end posting interface, at least not in version 1.0.

The plugin works just like the post and page editor. It should be straightforward for most users.

While the Shortnotes plugin is relatively bare-bones for now, it serves as a foundation of something that could be more. Part of what makes social networks appealing is the ease of publishing quick content. Publishing notes through the plugin requires visiting the WordPress admin, clicking “Add New,” writing the content, publishing, and clicking a new link to view it on the front end. A quick-publishing interface either through a Dashboard widget or a front-end form would be a useful addition.

Notes post type from the WordPress block editor.
Note post type in the block editor.

Some new concepts that not all users may be familiar with are the “Reply to URL” and “Reply to name” fields. These are semantic fields for creating a note in reply to another post or person on the web. The plugin will automatically output this reply link on the front end.

The plugin integrates with the Webmention plugin. A Webmention is a standardized protocol for mentions and conversations across the web. The goal is a decentralized social “network” of sorts where everyone owns and controls their content. It is an alternative to what IndieWeb calls the “corporate” web in which large tech companies have control.

When entering a Reply to URL, Shortnotes will automatically send that URL through the Webmentions plugin system. It will also parse URLs in the post content as webmentions if they exist.

Users may also notice that the note title field is missing. This is intentional. The plugin automatically generates titles. They are needed for the <title> tag, which tools like search engines use.

The idea is for titles to not appear as part of the theme layout. Because most themes are not coded to check for post-type support before displaying them, there is a high chance that a user’s theme will output the auto-generated title on the front end. For now, that means editing a bit of theme code for those who do not want them to appear. Felt has an example of how he modified this for his site’s custom Twenty Twenty-One child theme. In the long run, as more themes begin supporting the upcoming site editor, users will be able to make this customization directly in the WordPress admin.

With a few tweaks like removing the title and some minor CSS adjustments, I was able to create a clean Notes archive page using the Genesis Block theme:

Archives view of notes from the Shortnotes plugin.
Modified notes archive.

One of my interests in checking this project out was diving into a real-world example of a plugin that limited which blocks could be used with the editor. The notes post type only allows the Paragraph, Image, and Gallery blocks. Again, the idea is to replicate the feel of what you can do on social networks. Overall, this feature worked as it should, limiting the notes to a subset of blocks.

However, I ran across a bug with the block editor. All block patterns, regardless of what blocks they contained, appeared in the inserter. Clicking on one containing a disallowed block would not insert it into a post. However, the editor did add a pop-up note that it had. There is a GitHub issue for this bug that has seen little movement since it was opened in June 2020.

Felt created a plugin to solve this called Unregister Broken Patterns. It removes any patterns that contain blocks that a post type does not support. At best, it is a temporary measure and needs to be addressed in WordPress.

Can accelerationism be changed in the future?

Featured Imgs 23

The Declaration of Accelerationist Politics" and subsequent works rejected the left-wing blind worship of so-called "folk politics": flat democratic organizations, space restrictions, slowing down of romanticism, and folk localism. Left-wing politics should better deal with global capitalism and its complex government and economic cycles. Here, accelerationists call for cognitive mapping to facilitate reality speculation and political manipulation. Regarding this understanding of speculation and production manipulation, the realization of a new understanding of the future in left-wing politics is observable. The future must be regained, and must be designed, not to follow unions, social movements or the latest occupation protests that lack vision and defensiveness. Armen Avanessian pointed out that when we look back at this open future, this kind of existence can be seen as accidental and can be manipulated and politically navigated. Regarding this fruitful understanding of political navigation and strategic manipulation, accelerationism also implies a positive acceleration of technological progress