Skip to content

Commit

Permalink
chore: update styling method to use clsx and camel case
Browse files Browse the repository at this point in the history
  • Loading branch information
Diedra committed Mar 26, 2021
1 parent 8c34ef1 commit 7ed3d73
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 46 deletions.
10 changes: 2 additions & 8 deletions packages/components/src/TestComponent/TestComponent.module.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
.testComponent--container {
@apply text-body leading-body;
@apply text-brand-700;
.container {
@apply w-full;
}

.testComponent--align-left {
@apply text-left;
}

.testComponent--align-right {
.alignRight {
@apply text-right;
}
13 changes: 4 additions & 9 deletions packages/components/src/TestComponent/TestComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React, { ReactNode } from "react";

import classNames from "classnames/bind";
import clsx from "clsx";
import styles from "./TestComponent.module.css";

const cx = classNames.bind(styles);

type Props = {
/**
* Child node(s) that can be nested inside component.
Expand All @@ -17,16 +15,13 @@ type Props = {
};

/**
* This component is a replica of the template created by plop found in plop-templates.
* TODO: Find a way to keep these 2 files in sync.
* A super cool component that does a really awesome thing.
* TODO: Update to describe your component!
*/
function TestComponent({ children, align }: Props) {
return (
<div
className={cx(
"testComponent--container",
`testComponent--align-${align}`
)}
className={clsx(styles.container, align === "right" && styles.alignRight)}
>
{children}
</div>
Expand Down

This file was deleted.

10 changes: 2 additions & 8 deletions plop-templates/Component/Component.module.css.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
.{{camelCase name}}--container {
@apply text-body leading-body;
@apply text-brand-700;
.container {
@apply w-full;
}

.{{camelCase name}}--align-left {
@apply text-left;
}

.{{camelCase name}}--align-right {
.alignRight {
@apply text-right;
}
11 changes: 7 additions & 4 deletions plop-templates/Component/Component.tsx.hbs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React, { ReactNode } from "react";

import classNames from "classnames/bind";
import clsx from "clsx";
import styles from "./{{pascalCase name}}.module.css";

const cx = classNames.bind(styles);

type Props = {
/**
* Child node(s) that can be nested inside component.
Expand All @@ -22,7 +20,12 @@ type Props = {
*/
function {{pascalCase name}}({ children, align }: Props) {
return (
<div className={cx("{{camelCase name}}--container", `{{camelCase name}}--align-${align}`)}>
<div
className={clsx(
styles.container,
align === "right" && styles.alignRight,
)}
>
{children}
</div>
);
Expand Down

0 comments on commit 7ed3d73

Please sign in to comment.