├── src ├── components │ └── bento-grid │ │ ├── index.ts │ │ └── bento-grid.tsx ├── styles │ └── globals.css ├── index.ts ├── lib │ └── index.ts └── types.ts ├── .husky └── pre-commit ├── public ├── example.png └── react_bento.png ├── postcss.config.js ├── global.d.ts ├── tailwind.config.cjs ├── _gitignore ├── .gitignore ├── tsconfig.json ├── .eslintrc.json ├── rollup.config.js ├── package.json └── README.md /src/components/bento-grid/index.ts: -------------------------------------------------------------------------------- 1 | export {BentoGrid} from "./bento-grid" -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx lint-staged 5 | -------------------------------------------------------------------------------- /public/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anbrela/react-bento/HEAD/public/example.png -------------------------------------------------------------------------------- /src/styles/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | -------------------------------------------------------------------------------- /public/react_bento.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anbrela/react-bento/HEAD/public/react_bento.png -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import "./styles/globals.css"; 2 | 3 | export * from "./components/bento-grid"; 4 | export * from "./types"; 5 | -------------------------------------------------------------------------------- /global.d.ts: -------------------------------------------------------------------------------- 1 | // global.d.ts 2 | declare module "*.css" { 3 | const content: { [className: string]: string }; 4 | export default content; 5 | } 6 | -------------------------------------------------------------------------------- /src/lib/index.ts: -------------------------------------------------------------------------------- 1 | import { clsx, type ClassValue } from "clsx"; 2 | import { twMerge } from "tailwind-merge"; 3 | 4 | export function cn(...args: ClassValue[]) { 5 | return twMerge(clsx(args)); 6 | } -------------------------------------------------------------------------------- /tailwind.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | purge: ["./src/**/*.{js,jsx,ts,tsx}", "./public/index.html"], 3 | content: ["./src/**/*.{html,js, ts, tsx}"], 4 | darkMode: false, 5 | theme: { 6 | extend: {}, 7 | }, 8 | variants: { 9 | extend: {}, 10 | }, 11 | plugins: [], 12 | }; 13 | -------------------------------------------------------------------------------- /_gitignore: -------------------------------------------------------------------------------- 1 | # Node modules 2 | node_modules/ 3 | 4 | # Build output 5 | dist/ 6 | 7 | # Logs 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | 12 | # Dependency directories 13 | jspm_packages/ 14 | 15 | # TypeScript cache 16 | *.tsbuildinfo 17 | 18 | # Optional eslint cache 19 | .eslintcache 20 | 21 | # Mac system files 22 | .DS_Store 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Node modules 2 | node_modules/ 3 | 4 | # Build output 5 | dist/ 6 | 7 | # Logs 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | 12 | # Dependency directories 13 | jspm_packages/ 14 | 15 | # TypeScript cache 16 | *.tsbuildinfo 17 | 18 | # Optional eslint cache 19 | .eslintcache 20 | 21 | # Mac system files 22 | .DS_Store 23 | 24 | /example -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "jsx": "react-jsx", 6 | "strict": true, 7 | "moduleResolution": "node", 8 | "esModuleInterop": true, 9 | "skipLibCheck": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "declaration": true, 12 | "declarationDir": "./dist/types", 13 | "outDir": "./dist" 14 | }, 15 | "include": ["src"] 16 | } 17 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export type BentoItem = { 4 | id: number; 5 | title: string; 6 | element: React.ReactNode; 7 | width: number; 8 | color?: string; 9 | height: number; 10 | }; 11 | 12 | export type BentoItems = BentoItem[]; 13 | 14 | export type ClassNames = { 15 | container?: string; 16 | elementContainer?: string; 17 | }; 18 | 19 | export type BentoGridProps = { 20 | items: BentoItems; 21 | gridCols?: number; 22 | rowHeight?: number; 23 | classNames: ClassNames; 24 | }; 25 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2021": true 5 | }, 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:react/recommended", 9 | "plugin:@typescript-eslint/recommended" 10 | ], 11 | "parser": "@typescript-eslint/parser", 12 | "parserOptions": { 13 | "ecmaFeatures": { 14 | "jsx": true 15 | }, 16 | "ecmaVersion": 12, 17 | "sourceType": "module" 18 | }, 19 | "plugins": ["react", "@typescript-eslint"], 20 | "rules": { 21 | "react/react-in-jsx-scope": "off" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import external from "rollup-plugin-peer-deps-external"; 2 | import resolve from "@rollup/plugin-node-resolve"; 3 | import commonjs from "@rollup/plugin-commonjs"; 4 | import typescript from "@rollup/plugin-typescript"; 5 | import postcss from "rollup-plugin-postcss"; 6 | import tailwindcss from "tailwindcss"; 7 | import autoprefixer from "autoprefixer"; 8 | 9 | export default { 10 | input: "src/index.ts", 11 | output: [ 12 | { 13 | file: "dist/index.cjs.js", 14 | format: "cjs", 15 | sourcemap: true, 16 | exports: "auto", 17 | }, 18 | { 19 | file: "dist/index.esm.js", 20 | format: "esm", 21 | sourcemap: true, 22 | }, 23 | ], 24 | plugins: [ 25 | external(), 26 | resolve(), 27 | commonjs(), 28 | typescript({ 29 | tsconfig: "./tsconfig.json", 30 | declaration: true, 31 | declarationDir: "./dist/types", 32 | rootDir: "src", 33 | }), 34 | postcss({ 35 | plugins: [tailwindcss(), autoprefixer()], 36 | extensions: [".css"], 37 | minimize: true, 38 | inject: { 39 | insertAt: "top", 40 | }, 41 | }), 42 | ], 43 | external: ["react", "react-dom"], 44 | }; 45 | -------------------------------------------------------------------------------- /src/components/bento-grid/bento-grid.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import "../../styles/globals.css"; 3 | import { cn } from "../../lib/index"; 4 | import { BentoGridProps, BentoItem } from "../../types"; 5 | 6 | export const BentoGrid = ({ 7 | items, 8 | gridCols, 9 | rowHeight = 100, 10 | classNames, 11 | }: BentoGridProps): React.ReactNode => { 12 | return ( 13 |
48 | In 2015 I founded a theatre company that is still running. 49 |
50 |51 | In 2017 I created an Escape Room which is still running. 52 |
53 |54 | I love the responsibility of new projects. 55 |
56 |