Everything but the Kitchen Sink

A Way to Test Features in MDX. Every article template needs a kitchen sink!

5 min read—— views

DETROIT - This is the "Kitchen Sink" article, what follows is just a bunch of nonsense so I can dogfood my styling and featue set. I feel like this is a common practice as we do it at Graham Media Group, and the @tailwindcss/typography plugin has a great example of testing possible typography combinations.

Break up content with an h2 tag

Widespread power outages caused by intense winds have prompted DTE Energy to call in hundreds of out-of-state crews to help restore power to Southeastern Michigan residents.

Every line of code written comes at a price: maintenance. To avoid paying for a lot of code, we build reusable software. The problem with code re-use is that it gets in the way of changing your mind later on.

All of Metro Detroit faced a high wind warning Saturday, as the windy day produced gusts over 60 mph at times through the afternoon, causing tens of thousands of customers to lose power. At some point in the day, more than 160,000 customers had lost power due to the severe weather.

export const createStash = async (payload: CreateOrUpdateStashInput) => {
  /* ... */
};

Code blocks

Syntax highighting through rehype-prism-plus and a custom rehype plugin providing meta value parsing for filenames.

const users = await prisma.user.findMany({
  select: {
    id: true,
    email: true,
    firstName: true,
    team: true, // <-- just add the field I want
    stringValue: "this is a string",
  },
  where: {
    team: {
      id: {
        equals: "this is a string",
      },
    },
  },
});
import create from "zustand";

const useStore = create((set) => ({
  bears: 0,
  increasePopulation: () => set((state) => ({ bears: state.bears + 1 })),
  removeAllBears: () => set({ bears: 0 }),
}));
// Block without line numbers
const users: Array<{
  id: string;
  email: string;
  firstName: string;
  team: Team;
}>;
/* scope with class names */
.PrimaryButton {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
}

.TileGrid {
  /* ... */
}

/* or scope with data attributes to avoid concatenating
   className props, but it's really up to you */
[data-primary-button] {
  /* ... */
}

[data-tile-grid] {
  /* ... */
}

I love keyboard shortcuts, one of my favorites is the Cmd + K menu that has become a popular shortcut for navigating web apps.

Framer Motion is awesome, it helped me build the gallery

Detroit skyline
1/3

It's important to cover all of these use cases for a few reasons:

  1. We want everything to look good out of the box.
  2. Really just the first reason, that's the whole point of the plugin.
  3. Here's a third pretend reason though a list with three items looks more realistic than a list with two items.

Several neighborhoods faced uprooted trees and toppling power lines amid the high winds. Select any word from the following list.

Now I'm going to show you an example of an unordered list to make sure that looks good, too:

  • So here is the first item in this list.
  • In this example we're keeping the items short.
  • Later, we'll use longer, more complex list items.
import React from "react";
type LoaderData = Await<ReturnType<typeof getLoaderData>>;

async function getLoaderData() {
  const users = await prismaRead.user.findMany({
    select: {
      id: true,
      email: true,
      firstName: true,
      team: true,
      postReads: {
        select: {
          postSlug: true,
        },
      },
    },
  });
  return { users };
}

// export const loader: LoaderFunction = async ({ request }) => {
//   return json(await getLoaderData());
// };

export default function UsersPage() {
  const data = useLoaderData<LoaderData>();
  return (
    <div>
      <h1>Users</h1>
      <ul>
        {/* all this auto-completes and type checks!! */}
        {data.users.map((user) => (
          <li key={user.id}>
            <div>{user.firstName}</div>
          </li>
        ))}
      </ul>
    </div>
  );
}

Bye for now

According to DTE, the Metro Detroit area suffered from more than 1,500 downed wires, broken poles and tree-related damage.

As of 8:20 a.m. Sunday, about 70,000 DTE Energy customers were without power. At that time, power was restored to about 90,000 customers so far, officials said. We’re tracking Sunday power outages right here.

Clicking "reset" above will reset our component to a different state from its initial state which is probably a mistake, so we want that to not be possible. Click it multiple times and it's getting reset to something completely different every time. Now, I definitely agree with you. This is an example of someone using the API wrong. But if it's not a lot of work we may as well make this impossible right?

So, how can we grab hold of the actual initial value and ignore any changes to that prop? I've got a hint for you. It's not so complicated as useEffect with an isMounted boolean or whatever. It's actually pretty simple. And there are a few ways we could do it:

const { current: initialState } = React.useRef({ count: initialCount });
const [initialState] = React.useState({ count: initialCount });
const [initialState] = React.useReducer((s) => s, { count: initialCount });

// actual initial count is: initialState.count

The Detroit-based utility company said Saturday that it would be calling in 500 additional crews to help restore power to affected customers. Officials say power is expected to be restored to most customers, 80%-90%, by the end of the day Sunday.

The company says it hopes to have power restored to all schools in time for class on Monday.