Does Anyone Know of a PHP Content Locker Script?

Trying to have a script built that locks the content until user refers a friend to signup, then they are granted access. They have a set amount of time, as a timer counts down or their account is deactivated. Its for a game we are creating and want to use this type system. Is there anyone who has done this?

I have hired someone to build it but i see lol he doesnt know what he is doing......help please.

At my wits end… I think I’m being targetted.

So I've been plagued by things like this for almost three years now.

Anything I do online. If its related to money or employment, I cannot do it. Why? Because of things like these (screenshots).

https://ibb.co/dkX08gN
https://ibb.co/nnQQc3b

Lets see if I can explain whats going on.

Anything employment related inevitably fails.

I did doordash for about 8 months into 2020. Until I shut down my account and when I called the company they told me there was no way that I could have done that. I tried desperately to restart working for them but I could never login nor reset my credentials. Emails for credential resets didn't arrive, ever.

When I tried to sign up for uber the same thing happened. That was prior to Doordash being bought out by Uber. I've tried many other options and I just can't do anything because it all online and this stupid technical problem keeps rearing its hideous head!!! I know I'm not crazy!!

For a time I could not even login to my Navient student loans portal, and that was terrifying considering I hadn't gone into repayment yet having not yet graduated.

The most curious part is that this occurs across multiple devices. My phone. My two computers. Anything I log into with my personal accounts. Myself being geek with a CS degree I dont understand it. I want to say that some nation state hacker is getting its tendrils in my devices, but that is insane! I dont understand why I would be a target. I really don't. But its the only explanation I can think of, because apparently I am the only person on this entire planet experiencing this.

I'm seeing variations of this problem start to reoccur and its infuriating! Here's a link to my YT showcasing the problem.

https://youtu.be/uQvI0aKNO8w

If someone could shed some friggin light on this I would be very appreciative. I don't know whats causing this but it has got to stop!!

Jetpack 9.9 Released With a Refreshed Image Gallery Carousel

Today, Automattic released version 9.9 of its popular Jetpack plugin. The development team improved the modal animation and transition speed for the Instant Search module and added the Social Preview panel to the pre-publish sidebar. However, the most notable user-facing update was a refresh of its Carousel feature.

The module creates a fullscreen overlay gallery of a post’s images once one is clicked. Users can enable this feature via the Jetpack > Settings > Writing page in the WordPress admin. Users can also turn on the display of EXIF data and the media attachment commenting form.

Jetpack Carousel handles Image and Gallery blocks a bit differently. Regardless of whether Gallery images are linked or not, they will always be included in the image carousel when clicked. However, only Image blocks that specifically link to the attachment page are added.

I have never much cared for the Jetpack Carousel feature. There were always prettier image-overlay, lightbox-type solutions out in the wild. We use the plugin here at WP Tavern, so it is just something I have learned to live with. There was no sense in installing yet another plugin when we were already using the massive mono-project to run many other features on the site. And, it generally got the job done.

However, today, I can finally say that I am happy with the implementation. It is cleaner, offers a larger viewing area for individual images, and tucks unnecessary bits away for the average user.

The following is a screenshot of the carousel in all its fullscreen wonder:

Screenshot of an individual image in the Jetpack plugin carousel.
Jetpack carousel in version 9.9.

For comparison, here is what the same image slide looks like in Jetpack 9.8.1:

Screenshot of the Jetpack carousel feature in version 9.8.1.
Jetpack carousel in version 9.8.1.

In the new version, the image metadata and commenting form are hidden by default. The user must click the info or comment icon buttons to slide each section open. This is a better implementation because it decreases the noise in the carousel while still making the features available for those who want them.

Image metadata
Image metadata in the carousel.

Overall, I am enjoying this update. Swiping and scrolling through the gallery feels smoother.

I would love for WordPress to bring a standard set of functions and blocks for displaying media metadata to the development community. Every plugin and theme author who wants to showcase that info must build a custom system for their projects, such as formatting aperture, shutter speed, and focal length. The following is the output of an image attachment page from a theme I have worked on:

Custom theme media metadata.
Custom theme image info.

There is no reason that the theme and Jetpack should be working with custom wrappers for the metadata. WordPress stores EXIF and ID3 tags automatically. It just does not expose them to developers in any meaningful way.

How to Find and Replace Text in Google Docs with RegEx Search Patterns

It is easy to search and replace text in Google Documents with the DocumentApp service of Google Apps Script. You can use use findText method with simple regular expressions to find text elements in the document that match a pattern and replace them with the specified text.

Here’s a simple code sample that replaces the first occurrence of the “GSuite” with “Google Workspace” in the active Google Document.

const searchAndReplaceInGoogleDocs = () => {
  const searchText = "GSuite";
  const replaceText = "Google Workspace";

  const document = DocumentApp.getActiveDocument();
  const documentBody = document.getBody();

  const searchResult = documentBody.findText(searchText);

  if (searchResult !== null) {
    const startIndex = searchResult.getStartOffset();
    const endIndex = searchResult.getEndOffsetInclusive();
    const textElement = searchResult.getElement().asText();
    textElement.deleteText(startIndex, endIndex);
    textElement.insertText(startIndex, replaceText);
  }

  document.saveAndClose();
};

All well and good but in some cases, this simple search and replace function may fail if the search text does not transform into a valid regular expression.

For instance, if you have a text block like Hello (World in the document (notice the extra open bracket) that you would like to replace with Hello World, the above snippet will fail with an error message that says Exception: Invalid regular expression pattern.

To get around the problem, it is a good idea to replace all the special characters in the search pattern that have a special meaning in the RegEx world. These include characters like hyphen, brackets, question marks or the plus symbol.

Our modified search and replace function would then become:

const escapeRegex = (str) => str.replace(/[-[\]/{}()*+?.\\^$|#]/g, "\\$&");

const searchAndReplaceInGoogleDocs = () => {
  const searchText = "Hello (World";
  const replaceText = "Hello World";

  const document = DocumentApp.getActiveDocument();
  const documentBody = document.getBody();

  const searchResult = documentBody.findText(escapeRegex(searchText));

  if (searchResult !== null) {
    const startIndex = searchResult.getStartOffset();
    const endIndex = searchResult.getEndOffsetInclusive();
    const textElement = searchResult.getElement().asText();
    textElement.deleteText(startIndex, endIndex);
    textElement.insertText(startIndex, replaceText);
  }

  document.saveAndClose();
};

Using Open Source Tools at Your Company

The open source community is the most pure expression of collaboration and engineering that exists today.

That’s why I asked Doron Gill, the VP of Engineering at Logz.io, to join me on Dev Interrupted to answer my questions about open source security, implementation, and which companies an open source tool stack is perfect for.

Tinybird Aims to Simplify Data Aggregation and Access via API

Tinybird is looking to simplify the process of building real-time data analytics products by offering infrastructure that assists in data aggregation and analysis. The Tinybird platform claims to be able to ingest millions of rows of data per second and provide developers with low-latency access to the resulting SQL database. 

The answer of the program in python

Write a Python function called sumList () which will receive a list of integers as input
parameter. sumList() must:
a) Print the list
b) Sum all the numbers in a list and print the total.
The main section of your program must:
c) Ask the user how many numbers the list should contain;
d) Create the list accordingly (containing randomly generated integers between 0
and 100);
e) Pass the list to sumList () for processing.
Example output if a list containing four numbers is passed to sumList()
[3, 47, 94, 1].
The total is: 145

The Beginner’s Guide to S-Corp vs. C-Corp

S-Corp and C-Corp are both separate legal entities that provide limited liability to owners and have similar ownership and capital generation provisions administering them. At the same time, they also have some important differences, with each option providing unique benefits, limitations around taxation, and ownership structures.

So how do you know which corporate structure is right for your business? Let’s find out.

What are S-Corp and C-Corp?

Before diving into the differences, you have to understand what the terms S-Corp and C-Corp mean.

What’s an S-Corp?

An S-Corp, also known as the S subchapter, is a type of corporation that allows its owners to pass income, along with other deductions, losses, and credits, directly to shareholders without the compulsion to pay federal corporate taxes.

Having an S-Corp status gives small businesses (100 or fewer shareholders) the regular benefits of incorporation while enjoying the tax-exempt privileges of a partnership business. It’s a federal tax status and not a legal business entity. Therefore, limited liability companies, limited liability partnerships, and traditional corporations may elect S Corporation status.

What’s a C-Corp?

A C-Corp is a legal structure for a company authorized by the state to transact business.

As the business is treated as a separate body from its owners, it has its own assets, liabilities, obligations, and rights and must pay corporate income taxes on profits. Owners receiving distributed profits will also have to pay taxes as personal income.

The taxing of profits from the business at both corporate and personal levels creates an interesting double taxation situation. This may sound unfavorable, but it really isn’t. C-Corps limit investor and owner liability, so if the business fails they are only out the amount of their investment.

The Basics of S-Corp vs. C-Corp

In this section, I’ll help you gain a better understanding of the differences and similarities between an S-Corp and a C-Corp, and how they impact your business’s bottom line.

Formation

How an S-Corp and C-Corp are formed is the most basic difference between the two.

In the case of C-Corp, the formation is by default. All you have to do is file articles of incorporation with your secretary of state to register your business as a corporation, and your company becomes a standard C-Corp.

However, to structure your company as an S-Corp, you must file IRS Form 2553 for federal tax purposes. You may also have to file additional papers at the state level to be treated as an S-Corp for state taxes.

Taxation

C-Corps are a separate legal entity and subject to double-taxation. Under this, every business is charged corporate income tax for the profits after which its shareholders have to pay personal income tax on the profit earned in the form of dividends.

Additionally, C Corporations can reduce their tax burden by deducting certain fringe benefits for employee welfare, such as life insurance and healthcare. This isn’t the case with S-Corps.

While S-Corps aren’t charged at the corporate level, business owners must pay personal income tax for the accrued gains attributed to them, similar to a sole proprietorship or a partnership model.

The cost of offering fringe benefits to employers, however, isn’t deductible. Instead, it’s added to the taxable income of all shareholders holding more than 2% of the stock.

Here’s an illustration of how this difference in taxation works:

Suppose you have a C-Corp with a taxable income of $100,000 (Total business revenue – Total deductible expenses).

First, you have to pay the 21% corporate income tax rate, amounting to $21,000. After deducting that, you’re left with $79,000. Assuming you take all that money as dividends, you also need to pay a 15% dividend tax ($11,850), which will make your tax bill amount to $32,850 ($21,000 + $11,850). But if you spent $25,000 on employee benefits, you could deduct that from the original $100,000 before taxes kicked in, thus reducing your tax burden by approximately 25%.

Contrarily, having an S-Corp with a taxable income of $100,000 will involve you filing a personal income tax return on the entire amount. As the current personal income tax rate is 24% for people earning between $86,376 and $164,925, your total tax bill would be $18,289.50. Your $25,000 in employee benefits could not be deducted, though other business expenses could be.

Ownership

C-Corps have the flexibility to list an unlimited number of shareholders, whose rights may be divided to enable implementing the different profit-sharing structures. It’s why this corporate structure is great for companies wanting to raise capital through IPOs (Initial Public Offering).

S-Corps cannot have more than 100 shareholders, with each holding equal voting rights since only one class of stock is permitted for distribution. All individuals must hold a U.S. passport or be an American resident to become a shareholder as well.

This makes artificial entities, such as trusts and other corporations, ineligible for ownership in such a company.

Scale of Operations

C-Corps tend to be large organizations–they have to be, to afford double taxation and still be profitable. Since smaller or new firms are likely to operate on losses for the first few years, the double taxation effect of C-Corp isn’t feasible for them.

Opting for an S structure would be more advantageous here as it allows owners to offset their income from other sources using the aforementioned losses, which, in turn, reduces their overall tax liability. Moreover, a few states don’t recognize S status and converted companies, even when recognized under federal laws, making them taxable under the C status structure.

Be sure to consider your regional legislation before alternating between business structures.

Corporation Similarities

There aren’t only differences; S-Corps and C-Corps share multiple similarities too. Let’s check them out.

  • Incorporation: You must follow the necessary steps for corporate formation, regardless of whether you structure your company as an S-Corp or C-Corp. This includes completing the proper incorporation documents, filing incorporation articles, appointing a registered agent, and creating corporate bylaws.
  • Limited Liability Protection: Having an S status or a C status makes corporations a legally separate entity from the owners and gives shareholders limited liability protection. In other words, they are not personally liable for the business’s debts or other obligations.
  • Compliance: S-Corps and C-Corps should meet certain documentation and compliance obligations, including issuing stock, paying fees, and holding shareholder and director meetings.
  • Corporation Structure: S-Corp or C-Corp shareholders don’t make all the company-related decisions. Management and policy issues are taken care of by the board of directors, elected by the shareholders. Whereas corporation officers—CEO, COO, and CTO—handle the daily activities of running the business.

5 Tools to Improve S-Corp or C-Corp Incorporation

Whether you decide on a C-Corp or S-Corp, you can use online incorporation services to form a corporation without any hassle. Below are the five best feature-rich tools on the market.

LegalZoom

One of the most popular LLC services, LegalZoom also offers top-notch facilities for S-Corps and C-Corps, complete with comprehensive legal assistance in all 50 states.

This service goes beyond the basics of business formation and comes with a wide range of services. It has a user-friendly platform and great customer service. But what works best for me is that LegalZoom directly pairs you with attorneys to provide you with personalized advice.

Access to educational resources designed to answer common questions asked by business owners is another plus.

Rocket Lawyer

Another option offering comprehensive legal services, Rocket Lawyer includes actual attorneys among its staff to answer all your legal queries.

You get ongoing attorney services as a part of its monthly membership plan, where you can call or message any Rocket Lawyer attorney at any time during the business incorporation process for advice. Although the website can use a revamp, it has a fairly straightforward and easy business entity registration process.

What’s more, throughout the business formation process, the service provides you a link with pop-up boxes to facilitate decision-making. For instance, when you ask a question about a corporation’s management and ownership, Rocket Lawyer will show you a statistic about what percent of other Rocket Lawyer customers choose for their business and how you could benefit from choosing that option.

Northwest

Northwest cuts out any fluff during the incorporation process and aims to give complete privacy, transparency, and great customer service.

It primarily focuses on a core selection of services, such as business formation, registered agent services, and ongoing compliance. Northwest is also the only major nationwide registered agent service that scans every document they receive as your agent.

Signing up for a Northwest service will get you paired with a Corporate Guide, who will be an expert in your state’s rules. They will guide you throughout the incorporation process and be your personal customer support agent.

ZenBusiness


ZenBusiness’s clean and easy-to-use interface, which, when combined with its highly efficient customer service, makes it one of the best incorporation services on the market.

What sets ZenBusiness apart from rival incorporation services is its worry-free guarantee that includes two amendments to yearly corporate annual reports—something that’s sure to give you peace of mind.

Let’s not forget its highly competitive $39-price point and a free year of registered agent service and accounting assessment along with your incorporation. Therefore, not only are your ZenBusiness packages fully featured but also incredibly pocket-friendly.

Incfile

Incfile offers several useful features to help you kickstart your business.

Similar to ZenBusiness, you get a whole year of the registered agent service in every Incfile package free, which costs only $119 annually after that. Its premium plans come with extra features, like a federal tax ID number (EIN), corporate bylaws, meeting minutes, a banking resolution, and a personalized binder.

Plus, Incfile has several positive customer reviews raving about its prompt customer service and how they do a fantastic job at helping you form your dream business.

4 Tricks to Decide Between Becoming An S-Corp vs. A C-Corp

We’ve covered the basics of S-Corp and C-Corp, their similarities and differences, and tools that help you start your business. But how do you decide which corporate structure is best for your small business? Start by asking yourself the following questions:

Do you plan on selling your company down the line?

If you do, you might want to become a C-Corp.

Having the ability to be owned by other types of companies, C Corporations make much easier acquisitions in the long run. Additionally, you can have as many owners as you like, along with different classes of shareholders.

Do you want to limit your shareholders?

If yes, you should opt for an S-Corp.

S-Corps are limited to 100 shareholders and emphasize shareholder input—something that can be useful for small businesses wanting to stick to a smaller setup. Nonetheless, if you think your company could expand exponentially later, file yourself as a C-Corp.

Are you okay being under constant scrutiny?

If not, a C-Corp would be a great option for you.

All corporations have C-Corp as the default filing. Becoming an S-Corp, on the other hand, involves an extra layer of paperwork, which you must be prepared for if that’s your choice. Moreover, you have to ensure a spotless record at all times, as even a single mistake can cost you your S Corporation status.

Consider filing as a C-Corp if the extra scrutiny from the IRS seems too much to handle.

Does double taxation seem worth it to you?

You already know the answer to this one—C-Corp!

If you’re comfortable getting taxed at the corporate level and then again at the personal level, you can consider becoming a C-Corp. But if you want to save on corporate taxes and handle profit and losses to your personal income, incorporating as an S-Corp is the better choice.

What to Do Next

Once you decide the better fit between S-Corp vs. C-Corp, you can use the above incorporation service tools to get the ball rolling.

These services are designed to take care of everything related to your business and make the process as seamless as possible. Be sure you choose an option that offers you round-the-clock customer service, competitive pricing, and accurate legal advice. If you are interested in looking more into LLC services instead, check out our guide on the best LLC services.

Here are a few additional QuickSprout guides to help you make the right decision:

Collaborative Editing Solutions for WordPress

Collaborative Editing Solutions for WordPressAs a website grows, more content creators are required. With this, there are more iterations of editing in content pieces. This leads to increased complications in collaborative or synchronized working. Now, while there still are efficient tools like Google Docs and grammar checkers for this, publishing the content on websites remains super-taxing. In the coming […]

The post Collaborative Editing Solutions for WordPress appeared first on WPExplorer.

Body Toggle

I appreciate the clarity of this trick that Mikael Ainalem posted over on Reddit:

It’s a one-liner that toggles the class on the <body> so you can mock up different states and toggle between them on click.

<body onclick="this.classList.toggle("active");">

Could be on any element as well!

This can be a big thing. See “The Power of Changing Classes” as a case in point. Even if you aren’t much of a JavaScript person, classList is perhaps the one API you should know.


The post Body Toggle appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

I’ve got one question about Jetpack for you.

And maybe an optional follow-up if you’re up for it.

Automattic, the makers of Jetpack and many other WordPress-y things, have sponsored my site (me = Chris Coyier; site = CSS-Tricks) for quite a while. I use Jetpack myself, and I’m always trying to tell people about its features and benefits.

Yet I get the sense that there is a decent amount of hesitancy (or even general negative feelings) toward Jetpack. I want to hone in on that and understand it better. This will be useful for me in my attempt to be a good sponsoree, and useful for Automattic to improve Jetpack.

Fill out my online form.

The post I’ve got one question about Jetpack for you. appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

The Lessons We Learned From Programming at Google w/ Hyrum Wright and Titus Winters – Part 2

The second and final episode of Dev Interrupted's two- part series with Senior Google Staff Engineers Hyrum Wright and Titus Winters has premiered.

If you haven't listened to their first episode, I highly recommend checking it out. Both guests bring a deep understanding of software engineering to the show: Hyrum is semi-famous as the "Hyrum" of Hyrum's Law; while Titus is responsible for managing 250 million lines of code and over 12,000 developers.

Is Blitz.js the JavaScript Framework I’ve Been Waiting For?

The year was 2007. I was about to leave corporate America and try my first startup. I had been a Java architect for the past 10+ years and was ready to try something new. A friend of mine introduced me to a framework called “Ruby on Rails.” She said it was amazing how fast you could build stuff. Here is a link to the original “How to build a blog engine in 15 minutes with Ruby on Rails” video where David Heinemeier Hansson (DHH) shows us how to build a blog using Rails. After watching the video, I was sold that it was worth a try. I spent most of the next year building my startup primarily programming in Ruby on Rails. It took me a while to climb the fairly steep learning curve of Rails, and also to really learn the Ruby programming language, but once I did, I could build stuff faster than at any point in my 20+ year career. Rails has a doctrine of what makes it great; you can look at the nine items here. Looking back, what made Rails great for me personally was a handful of key things:

  • Convention over Configuration – Now most frameworks follow this paradigm, but Rails was the first to bring it to the masses. No more struggling with configuration files to get your environment set up properly, everything works right out of the box, and if you follow the rules, it’s painless.
  • DRY Coding – (Do NOT repeat yourself) – The idea here is that you only need to code something in one place to get it done. You don’t need to copy and paste code into five different places to get something to work. 
  • Developer Happiness & Productivity – Rails came with generators to get you started. They would create all the code you need to CRUD (Create, Read, Update, Delete) your resources. Rails also came with a handy console where you could test and debug your code in a full working environment. You could also code everything in one language, Rails provided helpers to generate most of the JavaScript you would need. Rails eliminated the multiple layers upon layers of coding you used to have to do to get something done.
  • True Reuse – We have been looking for the ability to reuse code for 20+ years. We have tried many different approaches, but Rails, because it is a complete ecosystem, has done the best job at it. When you are building an app, you can find a “gem” (which is a library) to do just about anything you want. For example, authentication, authorization, uploading files, paginating results – all these things come for free by using “gems” that are open source.
  • Majestic Monolith – For most of the applications we build, having a fully integrated, simple, coherent platform, and structure is the easiest way to build things. Sure, microservices and serverless have their place, but for 80% of the applications out there, having everything set up in one platform is the easiest way to construct software. Rails comes with all you need to build your User Interface, API, business logic and database.

Also worth noting is that Enterprise Java was the “state of the art” application architecture before Rails. The architecture of Enterprise Java looked something like this:

Community Contribution: Nebula Graph 2.0 Performance Testing

This article is shared by Fanfan from the Nebula Graph community. It is about his practice of performance testing on Nebula Graph 2.0 and optimizing the data import performance of Nebula Importer. In this article, “I” refers to the author.

Background

I did some research on Nebula Graph and did tests to evaluate its performance. During the process, I got a lot of help from the Nebula Graph team. I would like to give thanks to them.

The Dilemma of Naming Font Size Variables

Normally, a project will have a set of pre-determined font sizes, usually as variables named in such a way that seeks some semblance of order and consistency. Any project of considerable size can use something like that. There are always headings, paragraphs, lists, etc. You could set font sizes explicitly and directly everywhere (e.g. font-size: 18px). Raw CSS, as it were. I do see that occasionally — mixing not just sizes but also units like px, rem and em in mindless chaos.

That’s why the CSS of a project typically uses variables or mixins — we’re shooting for structure, maintainability and, ultimately, consistency. We all know naming is hard and it doesn’t take looking much further than naming font size variables to see why. How should we name a small font size variable so it’s clear that it’s smaller than a large font size variable? And what happens if we need to insert a new variable in between them — is that one named in a way that clearly explains its relationship to the other size variables?

We’ll continue talking about naming font size variables in this post. But, really, the issue extends beyond font sizes to any sort of size or length value. Think paddings, margins, widths, heights, border radii, etc. These things need structure and consistency, too!

How do you define font sizes in your project? Does it look something like this with custom variables:

:root {
  /* Font size variables */
  --small: 12px;
  --medium: 16px;
  --large: 24px;
}

Or perhaps in Sass (which is what we’ll be using throughout this article) you might have variables for $small, $medium, and $large font sizes.

Fine. After a while, let’s say the designer adds a new <h1> heading for a hero section. And it is very large. Larger than anything you have in the project. No problem, you reply. You add an $xlarge to the project, and go about your day.

The following day, the designer makes a nice form label, which again has a new font size. This new size, though, is larger than small, but smaller than medium.

Here we go.

What should you call it? $small-medium? $small-2? $smedium? Whatever you name it, you won’t be happy with it. Because there is no word for that.

Or should you maybe refactor it? Create a new $xsmall, and change all instances of $small to $xsmall? And then you can use $small for the form label? There’s a small risk that you will forget to change somewhere and, hey, presto: a bug. What happens next time, when something is introduced that has a larger size than the $medium variable value? Do we have to refactor $large and $xlarge too?

I suggest adhering to a scale, always. An easy fix would be to further abstraction, perhaps ditching numbers and sizes in favor of functional names, like $form-label instead of $small-2 or $xsmall.

But imagine having a set of font sizes like this:

$small: 12px;
$form-label: 14px;
$medium: 16px;
$large: 24px;

That is a broken scale. It’s a size concept and a component concept mixed together. It raises questions. Should an alert or a button be allowed to use $form-label? Yuck.

Maybe you have a Greek thing going on, naming the variables $alpha, $beta, $gamma? Let me ask you then, what is then bigger than $alpha? $alpha-large? Or wait, is $alpha the small one?

I have also seen names like $button-font-size, $label-font-size, $blockquote-font-size. That seems to me like one variable per element used, instead of a scale, and sounds like it could be a lot of duplicated code if the same value is being used in multiple places, but with different names.

Perhaps you’re working with one base font size and percentages only? Sure, but I would say you need variables for the percentages. That’s how Geoff handles font sizing and even he admits that the setup raises his own eyebrows. Calculations with subjectively-named variables might be clear to you, but crazy-looking and complicated for anyone else jumping into the project.

h1 {
  font-size: clamp(var(--text-size-large), calc(var(--text-size-base) * var(--text-size-scaler)), var(--text-size-huge));
}

We need a better system

Adding and removing stuff constantly is the way we want to work. This is modern day development — MVP, Agile, and all the other hot buzzwords.

What we need is a scale syntax that allows room for changes. Adding a new size to the scale should be easy without introducing breaking changes. I’m thinking of a kind of scale that is both flexible and infinite. It must be more sophisticated than $small, $medium and $large.

It should be also be descriptive and intuitive. Preferably, you shouldn’t have to look up the variable names in the settings file or the config, or wherever you store these things. I don’t have the slightest clue if $epsilon comes before or after $sigma. Do you?

Using existing systems

Before trying to invent something new, is there an existing syntax or system we can leverage? Here are a few I’ve encountered.

International system of units

Surely, you’re familiar with terms like “kilobyte” and “megabyte.” Europeans are very used to “millimeter” and “centimeter.” Other examples are “giga,” “tera,” and “peta.” These prefixes can be used for length, weight, volume and more. Could a $centi font size work? It is intuitive to a certain extent, that is, if you’re familiar with the metric system. This is a finite scale. And there’s no room to add new sizes because they are already set.

Traditional point-size names

Long before computers and desktop publishing, books and newspapers were printed with lead type. The type setters had different names for different sizes. The sizes have a reference to a point size (pt) and could, in theory, be used for pixel sizes (px).

The type sizes in this system are called “Nonpareil,” “Pica,” “Cicero,” and “Great Primer,” just to name a few. The names are different depending on continent and country. Plus, the same name can have different sizes, so… quite confusing.

That said, I do like this system in a way because it would be like paying respect to an old craftsmanship from times past. But the names are so weird and specifically meant for type sizing, that it feels like a stretch to use for things like breakpoints and spacing.

Placing everyday objects on a scale

How about using stuff from our everyday life? Say chili peppers.

There are many kinds of chili peppers. The $habanero, is hotter than the $cayenne, which is hotter than the $jalapeno. That would be fun, yeah?

But as much as I enjoy the idea of writing font-size: $tabasco, I see two problems. If you’re not into peppers, you cannot know which pepper is hotter than another pepper — so, it’s not universally intuitive. Also, the bell pepper is 0 on the Scoville scale, and nothing is below that. Carolina Reaper is the hottest pepper in the world, so the scale is finite.

And yeah, peppers scale-wise are not larger or smaller, they are hotter. Bad concept. Maybe something more common, like types of balls?

There‘s a large range of different kinds of balls. You have handballs, soccer balls, volleyballs, etc. Need something larger than a medicine ball? Use $beach. Something smaller than a tennis ball? Use $pingpong. This is very intuitive, as I’d imagine everyone has played with all sorts of balls at some point, or at least are familiar of them from sports.

But is a ping pong ball larger than a golf ball? Who knows? Further, a bowling ball and a soccer ball are actually the same size. So… again, not perfect.

Scaling up to planets could work, but you would have to be knowledgeable in astronomy.

How about straight-up numbers? We’re unable to use numbers alone because tools like stylelinter will protest. But would something like this work:

$font-14: 14px;
$font-16: 16px;
$font-24: 24px;

Well, it’s infinite as there is always room for new additions. But it’s also incredibly specific, and there are some downsides to have the actual value be part of the name like that. Let’s assume that $font-18 is used in a lot of places. And now, they say, all places with 18px must be changed to 19px (because reasons). Now we need to rename the variable from $font-18 to $font-19 then change the value of $font-19 from 18px to 19px. And that’s before we finally update all places using $font-18 to $font-19. This is almost like using raw CSS. Low score for maintainability.

What about the animal kingdom?

Mother Nature has provided a myriad of species on this earth, which comes in handy in this situation. Imagine something like this:

$mouse: 12px;
$dog: 16px;
$hippo: 24px;

Need something smaller than a mouse? Use $bee, $ant or $flea. Larger than a bear? Try $moose or $hippo. Larger than an elephant? Well, you have the $whale, or heck, we can go prehistoric and use $t-rex. There’s always an animal to squeeze in here. Very versatile, very intuitive, also infinite (almost). And fun, too — I wouldn’t mind doing font-size: $squirrel. 🤩

But then again, even that might require needing to reference the variables, unless we know exactly which animals are contained in our zoo of font sizes. But maybe that’s not a big deal as long as it scales.

I have spent way too much time pondering this

Or have I? The code base is where you spend your working hours. It’s your work environment, just like chairs and monitors. And the workplace should be a nice place.

How do you handle your font size scales? Do you have one system for fonts and another for things like margins? Can anyone jump right into your code and understand how everything is organized? Please tell in the comments!


The post The Dilemma of Naming Font Size Variables appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.