How favger/react-content-loader works
Project type and purpose
• This is an open-source UI component library (“react-content-loader”) that provides SVG-powered placeholder loading animations for both React DOM (web) and React Native.
• It exposes a core ContentLoader component, a set of built-in presets (Facebook, Instagram, Code, List, BulletList), and a custom mode API so consumers can craft arbitrary SVG skeleton screens.
File-structure analysis
• Top-level: project config and metadata (.eslintrc.json, .prettierrc.js, .travis.yml, package.json, rollup.config.js, tsconfig.*).
• docs & .storybook: configuration and source for the documentation site / storybook gallery.
• src/
• native/ – React Native implementation (ContentLoader.tsx, Svg.tsx, presets, tests).
• web/ – React DOM implementation (ContentLoader.tsx, Svg.tsx, presets, tests).
• shared/ – shared code (uid generator), plus any types.
• Each platform folder has its own index.ts → main entry, a local package.json in native to manage react-native-svg peer dependency.
• build pipeline: rollup.config.js generates separate bundles for web and native, producing minified UMD/Esm/CommonJS outputs.
• tests: jest.web.config.js and jest.native.config.js target each implementation, with __tests__ and snapshots alongside code.
README insights
• Describes dual-mode usage (import from 'react-content-loader' or '/native'), lists props & options, shows examples & CDN usage.
• Mentions dev scripts: build, dev (docz), test (TS checking, unit tests), storybook.
a. Main components
• Source modules (src/shared, src/web, src/native)
• Build & bundling (Rollup, Babel)
• Test harness (Jest configured per target)
• Documentation site (Docz + Storybook)
• CI pipeline (Travis CI integration)
• Published packages (NPM registry for web and native artifacts)
• External dependencies (React, react-native-svg)
b. Relationships & interactions
• src/shared is consumed by both web and native implementations.
• rollup.config.js reads src/web & src/native entry points, applies Babel/TypeScript transforms → emits dist/web/* & dist/native/*.
• jest.web.config.js & jest.native.config.js import built code (or raw TSX via Babel) for unit tests.
• .storybook loads web components from src/web to render examples; docs/index.stories.tsx wires both web & native presets.
• CI (Travis) orchestrates: npm run build → npm run test → npm run dev (docs smoke) → publishes to NPM on tags.
• Consumers import either “react-content-loader” (web) or “react-content-loader/native” (RN) from NPM.
c. Architectural patterns
• Monorepo-style split: one codebase, multiple platform targets.
• Single Responsibility: shared utilities isolated in shared/; platform specifics in web/ and native/.
• CI/CD pipeline enforces code quality (ESLint, Prettier, TS typing), testing, and automated releases.
d. Key technologies
• React & React Native (for rendering)
• react-native-svg (native SVG support)
• TypeScript (typed interfaces), Babel (JSX→JS)
• Rollup (bundle generation), Jest (testing)
• Storybook & Docz (component gallery & docs)
• Travis CI (continuous integration)
Final pointers
• Three outputs (web, native, docs) and their consumers.
• Don’t omit the shared/ layer—it’s the linchpin of code reuse.