Skip to content

Commit a27d7ac

Browse files
committed
feat: add grid component
1 parent 4ea4130 commit a27d7ac

22 files changed

+369
-1
lines changed

package-lock.json

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/components/grid/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# RCK | React Grid Component
2+
3+
The React Grid component features a robust 12-column system, providing developers with a flexible framework to create responsive and well-structured layouts. This system allows elements to be precisely positioned within the grid, offering granular control over their placement and alignment. With the ability to utilize these 12 columns, developers can design layouts that are visually balanced and optimized for different screen sizes.
4+
5+
Moreover, the React Grid component offers the convenience of both wrapping and nowrap behaviors. When set to wrap, the grid intelligently adjusts its content, allowing items to flow into new rows as needed. This ensures that the layout gracefully accommodates varying amounts of content without sacrificing its structure. Conversely, the nowrap option prevents items from wrapping onto new lines, maintaining a compact and streamlined appearance.
6+
7+
By combining the 12-column system with the flexibility to wrap or nowrap elements, developers can effortlessly create responsive designs that adapt to diverse devices and content lengths. This versatile component empowers developers to craft visually appealing interfaces that maintain consistency and readability across different screen sizes, enhancing the overall user experience.
8+
9+
### Installation
10+
11+
To integrate the this component into your React apps, you can install it using npm or yarn: `npm i --save @react-ck/grid` or `yarn add @react-ck/grid`.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: "@react-ck/babel-config",
3+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module "*.module.scss" {
2+
const content: Record<string, string>;
3+
export default content;
4+
}

packages/components/grid/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Hack for module resolution of non built packages
2+
export * from "./src/index";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { config as default } from "@react-ck/jest-config";
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@react-ck/grid",
3+
"private": false,
4+
"version": "1.0.0",
5+
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
7+
"files": [
8+
"/dist"
9+
],
10+
"homepage": "https://github.com/abelflopes/react-ck/tree/master/packages/components/banner#readme",
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/abelflopes/react-ck.git"
14+
},
15+
"scripts": {
16+
"build": "NODE_ENV=production webpack",
17+
"lint:typescript": "tsc --noEmit",
18+
"test": "npx -y npm-run-all -s test:*",
19+
"test:unit": "jest --testPathPattern=\".unit.*\"",
20+
"test:snapshot": "jest --testPathPattern=\".snapshot.*\"",
21+
"test:snapshot:update": "jest --testPathPattern=\".snapshot.*\" -u"
22+
},
23+
"devDependencies": {
24+
"@react-ck/babel-config": "^1.0.0",
25+
"@react-ck/jest-config": "^1.0.0",
26+
"@react-ck/typescript-config": "^1.0.0",
27+
"@react-ck/webpack-config": "^1.0.0",
28+
"@types/react": "^18.2.33"
29+
},
30+
"peerDependencies": {
31+
"react": "^18.2.0"
32+
},
33+
"dependencies": {
34+
"@react-ck/scss-utils": "^1.0.0",
35+
"@react-ck/theme": "^1.0.0",
36+
"classnames": "^2.3.2"
37+
}
38+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Snapshot GridColumn renders correctly 1`] = `
4+
<div
5+
className="root size_auto"
6+
style={
7+
{
8+
"--columns": 0,
9+
"--size": "auto",
10+
}
11+
}
12+
/>
13+
`;
14+
15+
exports[`Snapshot GridContainer renders correctly 1`] = `
16+
<div
17+
className="root wrap"
18+
/>
19+
`;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from "react";
2+
import { GridContainer, GridColumn } from "../src/index";
3+
import renderer from "react-test-renderer";
4+
5+
describe("Snapshot GridContainer", () => {
6+
test("renders correctly", async () => {
7+
const tree = renderer.create(<GridContainer />).toJSON();
8+
expect(tree).toMatchSnapshot();
9+
});
10+
});
11+
12+
describe("Snapshot GridColumn", () => {
13+
test("renders correctly", async () => {
14+
const tree = renderer.create(<GridColumn />).toJSON();
15+
expect(tree).toMatchSnapshot();
16+
});
17+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from "react";
2+
import { GridContainer, GridColumn } from "../src/index";
3+
import { render, screen } from "@testing-library/react";
4+
import "@testing-library/jest-dom";
5+
6+
describe("Unit GridContainer", () => {
7+
test("renders correctly", async () => {
8+
render(<GridContainer data-testid="container" />);
9+
const find = await screen.findByTestId("container");
10+
expect(find).toBeInTheDocument();
11+
});
12+
});
13+
14+
describe("Unit GridColumn", () => {
15+
test("renders correctly", async () => {
16+
render(<GridColumn data-testid="column" />);
17+
const find = await screen.findByTestId("column");
18+
expect(find).toBeInTheDocument();
19+
});
20+
});

0 commit comments

Comments
 (0)