Skip to content

Commit

Permalink
chore(twmerge): 🚚 rename cx to tcm being more appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
navin-moorthy committed Sep 20, 2021
1 parent cadcfa9 commit 1b151ee
Show file tree
Hide file tree
Showing 69 changed files with 649 additions and 682 deletions.
9 changes: 1 addition & 8 deletions .storybook/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import type { Meta, Story } from "@storybook/react";
import type { Story } from "@storybook/react";

import theme from "../src/theme/defaultTheme";

Expand Down Expand Up @@ -65,10 +65,3 @@ export const createControls = (
console.log(e);
}
};

export type CSFType<M extends Meta> = M extends {
component: React.ComponentType<infer P>;
args: infer D;
}
? { args: Omit<P, keyof D> } & Story<P>
: never;
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@release-it/conventional-changelog": "^3.3.0",
"@storybook/addon-a11y": "6.3.8",
"@storybook/addon-actions": "6.3.8",
"@storybook/addon-essentials": "6.3.8",
"@storybook/addon-a11y": "^6.4.0-alpha.39",
"@storybook/addon-actions": "^6.4.0-alpha.39",
"@storybook/addon-essentials": "^6.4.0-alpha.39",
"@storybook/addon-postcss": "^2.0.0",
"@storybook/react": "^6.3.8",
"@storybook/react": "^6.4.0-alpha.39",
"@testing-library/dom": "^8.5.0",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.1.0",
Expand Down
5 changes: 2 additions & 3 deletions src/alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from "react";
import { twMerge as cx } from "tailwind-merge";

import {
AlertIcon,
Expand All @@ -12,7 +11,7 @@ import { Box, BoxProps } from "../box";
import { AlertBody } from "./AlertBody";
import { useMediaQuery } from "../hooks";
import { AlertActions } from "./AlertActions";
import { createContext, runIfFn } from "../utils";
import { createContext, runIfFn, tcm } from "../utils";
import { AlertCloseButton } from "./AlertCloseButton";
import { forwardRefWithAs, RenderProp } from "../utils/types";

Expand Down Expand Up @@ -92,7 +91,7 @@ export const Alert = forwardRefWithAs<AlertProps, HTMLDivElement, "div">(
const context = { status, isTablet };

const theme = useTheme();
const alertStyles = cx(
const alertStyles = tcm(
theme.alert.base,
theme.alert.status[status].base,
className,
Expand Down
7 changes: 3 additions & 4 deletions src/alert/AlertActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { twMerge as cx } from "tailwind-merge";

import { useTheme } from "../index";
import { tcm } from "../utils";
import { useTheme } from "../theme";
import { useAlertContext } from "./Alert";
import { Button, ButtonProps } from "../button";
import { forwardRefWithAs } from "../utils/types";
Expand All @@ -16,7 +15,7 @@ export const AlertActionButton = forwardRefWithAs<
const { className, ...rest } = props;

const theme = useTheme();
const alertActionButtonStyles = cx(
const alertActionButtonStyles = tcm(
theme.alert.actionButton.base,
isTablet
? theme.alert.actionButton.mobile
Expand Down
7 changes: 3 additions & 4 deletions src/alert/AlertActions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { twMerge as cx } from "tailwind-merge";

import { useTheme } from "../index";
import { tcm } from "../utils";
import { useTheme } from "../theme";
import { Box, BoxProps } from "../box";
import { useAlertContext } from "./Alert";
import { forwardRefWithAs } from "../utils/types";
Expand All @@ -16,7 +15,7 @@ export const AlertActions = forwardRefWithAs<
const { isTablet } = useAlertContext();

const theme = useTheme();
const alertActionsStyles = cx(
const alertActionsStyles = tcm(
theme.alert.actionsWrapper.base,
isTablet
? theme.alert.actionsWrapper.mobile
Expand Down
7 changes: 3 additions & 4 deletions src/alert/AlertBody.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { twMerge as cx } from "tailwind-merge";

import { useTheme } from "../index";
import { tcm } from "../utils";
import { useTheme } from "../theme";
import { Box, BoxProps } from "../box";
import { useAlertContext } from "./Alert";
import { forwardRefWithAs } from "../utils/types";
Expand All @@ -16,7 +15,7 @@ export const AlertBody = forwardRefWithAs<
const { isTablet } = useAlertContext();

const theme = useTheme();
const alertBodyStyles = cx(
const alertBodyStyles = tcm(
theme.alert.body.base,
isTablet ? theme.alert.body.mobile : theme.alert.body.desktop,
className,
Expand Down
7 changes: 3 additions & 4 deletions src/alert/AlertCloseButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { twMerge as cx } from "tailwind-merge";

import { useTheme } from "../index";
import { tcm } from "../utils";
import { useTheme } from "../theme";
import { useAlertContext } from "./Alert";
import { forwardRefWithAs } from "../utils/types";
import { CloseButton, CloseButtonProps } from "../button";
Expand All @@ -16,7 +15,7 @@ export const AlertCloseButton = forwardRefWithAs<
const { className, ...rest } = props;

const theme = useTheme();
const alertCloseButtonStyles = cx(
const alertCloseButtonStyles = tcm(
theme.alert.closeButton,
theme.alert.status[status].actionButton,
className,
Expand Down
7 changes: 3 additions & 4 deletions src/alert/AlertDescription.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { twMerge as cx } from "tailwind-merge";

import { useTheme } from "../index";
import { tcm } from "../utils";
import { useTheme } from "../theme";
import { Box, BoxProps } from "../box";
import { useAlertContext } from "./Alert";
import { forwardRefWithAs } from "../utils/types";
Expand All @@ -16,7 +15,7 @@ export const AlertDescription = forwardRefWithAs<
const { isTablet } = useAlertContext();

const theme = useTheme();
const alertDescriptionStyles = cx(
const alertDescriptionStyles = tcm(
theme.alert.description.base,
isTablet ? theme.alert.description.mobile : theme.alert.description.desktop,
className,
Expand Down
7 changes: 3 additions & 4 deletions src/alert/AlertIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { twMerge as cx } from "tailwind-merge";

import {
InfoCircleIcon,
CheckCircleIcon,
ExclamationTriangleIcon,
} from "../icons";
import { useTheme } from "../index";
import { tcm } from "../utils";
import { useTheme } from "../theme";
import { Box, BoxProps } from "../box";
import { useAlertContext } from "./Alert";
import { forwardRefWithAs } from "../utils/types";
Expand All @@ -30,7 +29,7 @@ export const AlertIcon = forwardRefWithAs<
const Icon = STATUS_ICONS[status];

const theme = useTheme();
const alertIconBaseStyles = cx(
const alertIconBaseStyles = tcm(
theme.alert.icon,
theme.alert.status[status].icon,
className,
Expand Down
7 changes: 3 additions & 4 deletions src/alert/AlertTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { twMerge as cx } from "tailwind-merge";

import { useTheme } from "../index";
import { tcm } from "../utils";
import { useTheme } from "../theme";
import { Box, BoxProps } from "../box";
import { forwardRefWithAs } from "../utils/types";

Expand All @@ -14,7 +13,7 @@ export const AlertTitle = forwardRefWithAs<
const { className, ...rest } = props;

const theme = useTheme();
const alertTitleStyles = cx(theme.alert.title, className);
const alertTitleStyles = tcm(theme.alert.title, className);

return <Box className={alertTitleStyles} ref={ref} {...rest} />;
});
Expand Down
5 changes: 2 additions & 3 deletions src/avatar/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from "react";
import { twMerge as cx } from "tailwind-merge";

import { useTheme } from "../theme";
import { Box, BoxProps } from "../box";
Expand All @@ -10,7 +9,7 @@ import { AvatarImage } from "./AvatarImage";
import { AvatarBadge } from "./AvatarBadge";
import { useImage } from "../hooks/useImage";
import { useAvatarGroup } from "./AvatarGroup";
import { createContext, runIfFn } from "../utils";
import { createContext, runIfFn, tcm } from "../utils";
import { forwardRefWithAs, RenderProp } from "../utils/types";

export type AvatarInitialProps = {
Expand Down Expand Up @@ -104,7 +103,7 @@ export const Avatar = forwardRefWithAs<AvatarProps, HTMLDivElement, "div">(
const _showBorder = showBorder || group?.showBorder || false;
const _borderColor = borderColor || group?.borderColor || false;
const theme = useTheme();
const avatarStyles = cx(
const avatarStyles = tcm(
theme.avatar.base,
theme.avatar.size[_size],
_showBorder ? theme.avatar.border.width[_size] : "",
Expand Down
14 changes: 7 additions & 7 deletions src/avatar/AvatarBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import { twMerge as cx } from "tailwind-merge";

import { tcm } from "../utils";
import { useTheme } from "../theme";
import { Box, BoxProps } from "../box";
import { MoonIcon, DotIcon } from "../icons";
Expand All @@ -24,7 +24,7 @@ export const AvatarBadge = forwardRefWithAs<

const _status = status || contextStatus || "online";

const badgeStyles = cx(
const badgeStyles = tcm(
theme.avatar.badge.base,
theme.avatar.badge.size[size],
theme.avatar.badge.position[position],
Expand All @@ -35,7 +35,7 @@ export const AvatarBadge = forwardRefWithAs<
if (_status === "online")
return (
<DotIcon
className={cx(
className={tcm(
theme.avatar.status.online.base,
theme.avatar.status.online.size[size],
)}
Expand All @@ -44,7 +44,7 @@ export const AvatarBadge = forwardRefWithAs<
if (_status === "offline")
return (
<MoonIcon
className={cx(
className={tcm(
theme.avatar.status.offline.base,
theme.avatar.status.offline.size[size],
)}
Expand All @@ -53,7 +53,7 @@ export const AvatarBadge = forwardRefWithAs<
if (_status === "typing")
return (
<TypingAnimation
className={cx(
className={tcm(
theme.avatar.status.typing.base,
theme.avatar.status.typing.size[size],
)}
Expand Down Expand Up @@ -96,12 +96,12 @@ export const TypingAnimation = forwardRefWithAs<
const theme = useTheme();
const { size = "md" } = useAvatarContext();

const baseStyles = cx(
const baseStyles = tcm(
theme.avatar.status.typing.base,
theme.avatar.status.typing.size[size],
className,
);
const typingStyles = cx(theme.avatar.status.typing.circle, circleStyle);
const typingStyles = tcm(theme.avatar.status.typing.circle, circleStyle);

return (
<Box ref={ref} className={baseStyles} {...rest}>
Expand Down
7 changes: 3 additions & 4 deletions src/avatar/AvatarGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useMemo } from "react";
import { twMerge as cx } from "tailwind-merge";

import { useTheme } from "../theme";
import { Box, BoxProps } from "../box";
import { forwardRefWithAs } from "../utils/types";
import { createContext, getValidChildren } from "../utils";
import { Avatar, AvatarContents, AvatarProps } from "./Avatar";
import { createContext, getValidChildren, tcm } from "../utils";

export type AvatarGroupContext = Pick<
AvatarProps,
Expand Down Expand Up @@ -64,7 +63,7 @@ export const AvatarGroup = forwardRefWithAs<
ref={ref}
role="group"
aria-label="Avatar group"
className={cx(theme.avatar.group.base, className)}
className={tcm(theme.avatar.group.base, className)}
{...rest}
>
{childrenWithinMax}
Expand All @@ -91,7 +90,7 @@ const AvatarExcess = ({
}) => {
const theme = useTheme();

const excessStyles = cx(
const excessStyles = tcm(
theme.avatar.group.excess.text.base,
theme.avatar.group.excess.text.size[size],
);
Expand Down
8 changes: 4 additions & 4 deletions src/avatar/AvatarIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { isValidElement, cloneElement } from "react";
import { Box, BoxProps } from "reakit";
import { twMerge as cx } from "tailwind-merge";
import { isValidElement, cloneElement } from "react";

import { tcm } from "../utils";
import { useTheme } from "../theme";
import { forwardRefWithAs } from "../utils/types";
import { useAvatarContext } from "./Avatar";
import { forwardRefWithAs } from "../utils/types";

export type AvatarIconProps = BoxProps & {};

Expand All @@ -24,7 +24,7 @@ export const AvatarIcon = forwardRefWithAs<
})
: children;

const iconStyles = cx(
const iconStyles = tcm(
theme.avatar.icon.base,
theme.avatar.icon.size[size],
className,
Expand Down
5 changes: 2 additions & 3 deletions src/avatar/AvatarImage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { twMerge as cx } from "tailwind-merge";

import { tcm } from "../utils";
import { useTheme } from "../theme";
import { Box, BoxProps } from "../box";
import { useAvatarContext } from "./Avatar";
Expand All @@ -24,7 +23,7 @@ export const AvatarImage = forwardRefWithAs<
src={src}
alt={name}
loading={loading}
className={cx(theme.avatar.image, className)}
className={tcm(theme.avatar.image, className)}
{...rest}
/>
);
Expand Down
5 changes: 2 additions & 3 deletions src/avatar/AvatarName.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { twMerge as cx } from "tailwind-merge";

import { tcm } from "../utils";
import { useTheme } from "../theme";
import { Box, BoxProps } from "../box";
import { forwardRefWithAs } from "../utils/types";
Expand All @@ -16,7 +15,7 @@ export const AvatarName = forwardRefWithAs<AvatarNameProps>((props, ref) => {

if (!initial) return null;

const nameStyles = cx(
const nameStyles = tcm(
theme.avatar.initials.base,
theme.avatar.initials.size[size],
className,
Expand Down
4 changes: 2 additions & 2 deletions src/badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { twMerge as cx } from "tailwind-merge";
import { tcm } from "../utils";

import { useTheme } from "../theme";
import { Box, BoxProps } from "../box";
Expand Down Expand Up @@ -38,7 +38,7 @@ export const Badge = forwardRefWithAs<BadgeProps, HTMLSpanElement, "span">(
} = props;

const badge = useTheme("badge");
const badgeStyles = cx(
const badgeStyles = tcm(
badge.base,
badge.size[size],
badge.variant[variant][themeColor],
Expand Down
Loading

0 comments on commit 1b151ee

Please sign in to comment.