Skip to content

Commit

Permalink
refactor: isolate all components into separate packages
Browse files Browse the repository at this point in the history
  • Loading branch information
abelflopes committed Nov 8, 2023
1 parent b5468c6 commit ed052aa
Show file tree
Hide file tree
Showing 167 changed files with 1,094 additions and 54 deletions.
21 changes: 0 additions & 21 deletions packages/components/all/src/index.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/components/banner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Banner
3 changes: 3 additions & 0 deletions packages/components/banner/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: "@rck/babel-config",
};
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions packages/components/banner/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { config as default } from "@rck/jest-config";
38 changes: 38 additions & 0 deletions packages/components/banner/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@rck/banner",
"private": false,
"version": "1.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"/dist"
],
"homepage": "https://github.com/abelflopes/rck/tree/master/packages/components/banner#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/abelflopes/rck.git"
},
"scripts": {
"build": "NODE_ENV=production webpack",
"test": "npx -y npm-run-all -s test:*",
"test:unit": "jest --testPathPattern=\".unit.*\"",
"test:snapshot": "jest --testPathPattern=\".snapshot.*\"",
"test:snapshot:update": "jest --testPathPattern=\".snapshot.*\" -u"
},
"devDependencies": {
"@rck/babel-config": "^1.0.0",
"@rck/jest-config": "^1.0.0",
"@rck/typescript-config": "^1.0.0",
"@rck/webpack-config": "^1.0.0",
"@types/react": "^18.2.33"
},
"peerDependencies": {
"react": "^18.2.0"
},
"dependencies": {
"@rck/container": "^1.0.0",
"@rck/overlay": "^1.0.0",
"@rck/theme": "^1.0.0",
"classnames": "^2.3.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Snapshot Banner renders correctly 1`] = `
<div
className="root"
>
<div
className="root horizontal vertical big container"
>
Banner
</div>
<img
className="image"
/>
<div
className="root dark"
/>
</div>
`;
10 changes: 10 additions & 0 deletions packages/components/banner/specs/index.snapshot.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";
import { Banner } from "../src/index";
import renderer from "react-test-renderer";

describe("Snapshot Banner", () => {
test("renders correctly", async () => {
const tree = renderer.create(<Banner>Banner</Banner>).toJSON();
expect(tree).toMatchSnapshot();
});
});
13 changes: 13 additions & 0 deletions packages/components/banner/specs/index.unit.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";
import { Banner } from "../src/index";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";

describe("Unit Banner", () => {
test("renders correctly", async () => {
const content = "Banner";
render(<Banner>{content}</Banner>);
const find = await screen.findByText(content);
expect(find).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import styles from "./styles/index.module.scss";
import classNames from "classnames";
import { Container } from "../container";
import { Container } from "@rck/container";
import { ThemeContextProvider } from "@rck/theme";
import { Overlay } from "../overlay";
import { Overlay } from "@rck/overlay";

export interface BannerProps extends React.HTMLAttributes<HTMLDivElement> {
src: string;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion packages/components/button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"build": "NODE_ENV=production webpack",
"test": "npx -y npm-run-all -s test:*",
"test:unit": "jest --testPathPattern=\".unit.*\"",
"test:snapshot": "jest --testPathPattern=\".snapshot.*\""
"test:snapshot": "jest --testPathPattern=\".snapshot.*\"",
"test:snapshot:update": "jest --testPathPattern=\".snapshot.*\" -u"
},
"devDependencies": {
"@rck/babel-config": "^1.0.0",
Expand All @@ -29,6 +30,7 @@
"react": "^18.2.0"
},
"dependencies": {
"@rck/scss-utils": "^1.0.0",
"classnames": "^2.3.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Button renders correctly 1`] = `
exports[`Snapshot Button renders correctly 1`] = `
<button
className="root primary"
>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/button/specs/index.snapshot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { Button } from "../src/index";
import renderer from "react-test-renderer";

describe("Button", () => {
describe("Snapshot Button", () => {
test("renders correctly", async () => {
const tree = renderer.create(<Button>Button</Button>).toJSON();
expect(tree).toMatchSnapshot();
Expand Down
2 changes: 1 addition & 1 deletion packages/components/button/specs/index.unit.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button } from "../src/index";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";

describe("Button", () => {
describe("Unit Button", () => {
test("renders correctly", async () => {
const content = "Button";
render(<Button>{content}</Button>);
Expand Down
1 change: 1 addition & 0 deletions packages/components/card/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Card
3 changes: 3 additions & 0 deletions packages/components/card/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: "@rck/babel-config",
};
4 changes: 4 additions & 0 deletions packages/components/card/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "*.module.scss" {
const content: Record<string, string>;
export default content;
}
2 changes: 2 additions & 0 deletions packages/components/card/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Hack for module resolution of non built packages
export * from "./src/index";
1 change: 1 addition & 0 deletions packages/components/card/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { config as default } from "@rck/jest-config";
36 changes: 36 additions & 0 deletions packages/components/card/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@rck/card",
"private": false,
"version": "1.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"/dist"
],
"homepage": "https://github.com/abelflopes/rck/tree/master/packages/components/card#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/abelflopes/rck.git"
},
"scripts": {
"build": "NODE_ENV=production webpack",
"test": "npx -y npm-run-all -s test:*",
"test:unit": "jest --testPathPattern=\".unit.*\"",
"test:snapshot": "jest --testPathPattern=\".snapshot.*\"",
"test:snapshot:update": "jest --testPathPattern=\".snapshot.*\" -u"
},
"devDependencies": {
"@rck/babel-config": "^1.0.0",
"@rck/jest-config": "^1.0.0",
"@rck/typescript-config": "^1.0.0",
"@rck/webpack-config": "^1.0.0",
"@types/react": "^18.2.33"
},
"peerDependencies": {
"react": "^18.2.0"
},
"dependencies": {
"@rck/theme": "^1.0.0",
"classnames": "^2.3.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Snapshot Card renders correctly 1`] = `
<div
className="root"
>
Card
</div>
`;
10 changes: 10 additions & 0 deletions packages/components/card/specs/index.snapshot.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";
import { Card } from "../src/index";
import renderer from "react-test-renderer";

describe("Snapshot Card", () => {
test("renders correctly", async () => {
const tree = renderer.create(<Card>Card</Card>).toJSON();
expect(tree).toMatchSnapshot();
});
});
13 changes: 13 additions & 0 deletions packages/components/card/specs/index.unit.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";
import { Card } from "../src/index";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";

describe("Unit Card", () => {
test("renders correctly", async () => {
const content = "Card";
render(<Card>{content}</Card>);
const find = await screen.findByText(content);
expect(find).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from "classnames";
import styles from "./index.module.scss";
import styles from "./styles/index.module.scss";
import React from "react";

export const Card = ({
Expand Down
7 changes: 7 additions & 0 deletions packages/components/card/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@rck/typescript-config/tsconfig.build.json",
"compilerOptions": {
"outDir": "./dist"
},
"include": ["./*.d.ts", "./src/**/*", "./src/index.ts*"]
}
4 changes: 4 additions & 0 deletions packages/components/card/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "@rck/typescript-config/tsconfig.json",
"include": ["./**/*"]
}
6 changes: 6 additions & 0 deletions packages/components/card/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { getWebpackConfig } from "@rck/webpack-config";
import packageJson from "./package.json";

export default getWebpackConfig({
cssHashSalt: packageJson.name,
});
1 change: 1 addition & 0 deletions packages/components/chip/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Chip
3 changes: 3 additions & 0 deletions packages/components/chip/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: "@rck/babel-config",
};
4 changes: 4 additions & 0 deletions packages/components/chip/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "*.module.scss" {
const content: Record<string, string>;
export default content;
}
2 changes: 2 additions & 0 deletions packages/components/chip/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Hack for module resolution of non built packages
export * from "./src/index";
1 change: 1 addition & 0 deletions packages/components/chip/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { config as default } from "@rck/jest-config";
36 changes: 36 additions & 0 deletions packages/components/chip/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@rck/chip",
"private": false,
"version": "1.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"/dist"
],
"homepage": "https://github.com/abelflopes/rck/tree/master/packages/components/chip#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/abelflopes/rck.git"
},
"scripts": {
"build": "NODE_ENV=production webpack",
"test": "npx -y npm-run-all -s test:*",
"test:unit": "jest --testPathPattern=\".unit.*\"",
"test:snapshot": "jest --testPathPattern=\".snapshot.*\"",
"test:snapshot:update": "jest --testPathPattern=\".snapshot.*\" -u"
},
"devDependencies": {
"@rck/babel-config": "^1.0.0",
"@rck/jest-config": "^1.0.0",
"@rck/typescript-config": "^1.0.0",
"@rck/webpack-config": "^1.0.0",
"@types/react": "^18.2.33"
},
"peerDependencies": {
"react": "^18.2.0"
},
"dependencies": {
"@rck/theme": "^1.0.0",
"classnames": "^2.3.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Snapshot Chip renders correctly 1`] = `
<div
className="root"
>
Chip
</div>
`;
10 changes: 10 additions & 0 deletions packages/components/chip/specs/index.snapshot.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";
import { Chip } from "../src/index";
import renderer from "react-test-renderer";

describe("Snapshot Chip", () => {
test("renders correctly", async () => {
const tree = renderer.create(<Chip>Chip</Chip>).toJSON();
expect(tree).toMatchSnapshot();
});
});
13 changes: 13 additions & 0 deletions packages/components/chip/specs/index.unit.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";
import { Chip } from "../src/index";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";

describe("Unit Chip", () => {
test("renders correctly", async () => {
const content = "Chip";
render(<Chip>{content}</Chip>);
const find = await screen.findByText(content);
expect(find).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from "classnames";
import styles from "./index.module.scss";
import styles from "./styles/index.module.scss";
import React from "react";

export interface ChipProps extends React.HTMLAttributes<HTMLDivElement> {
Expand Down
7 changes: 7 additions & 0 deletions packages/components/chip/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@rck/typescript-config/tsconfig.build.json",
"compilerOptions": {
"outDir": "./dist"
},
"include": ["./*.d.ts", "./src/**/*", "./src/index.ts*"]
}
4 changes: 4 additions & 0 deletions packages/components/chip/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "@rck/typescript-config/tsconfig.json",
"include": ["./**/*"]
}
Loading

0 comments on commit ed052aa

Please sign in to comment.