{"id":23582486,"url":"https://github.com/fork/react-patterns","last_synced_at":"2025-05-06T23:44:31.832Z","repository":{"id":40507690,"uuid":"298005325","full_name":"fork/react-patterns","owner":"fork","description":"Basic React components, hooks and patterns","archived":false,"fork":false,"pushed_at":"2023-01-07T20:20:14.000Z","size":10687,"stargazers_count":6,"open_issues_count":5,"forks_count":0,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-03-31T04:11:18.262Z","etag":null,"topics":["hooks","jest","react","react-components","react-patterns","reactjs","storybook","unstable-media"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fork.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-23T14:58:16.000Z","updated_at":"2023-07-19T13:00:40.000Z","dependencies_parsed_at":"2023-02-08T00:45:45.080Z","dependency_job_id":null,"html_url":"https://github.com/fork/react-patterns","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fork%2Freact-patterns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fork%2Freact-patterns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fork%2Freact-patterns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fork%2Freact-patterns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fork","download_url":"https://codeload.github.com/fork/react-patterns/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252788404,"owners_count":21804280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hooks","jest","react","react-components","react-patterns","reactjs","storybook","unstable-media"],"created_at":"2024-12-27T01:11:45.026Z","updated_at":"2025-05-06T23:44:31.818Z","avatar_url":"https://github.com/fork.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"left\"\u003e\n    \u003cimg width=\"600\" title=\"React Patterns\" src=\"http://github.fork.de/ReactPatterns_201005.svg\"\u003e\n\u003c/div\u003e\n\nThis repository contains basic React Components, Hooks and Patterns, which we use as a starting point at [Fork Unstable Media](https://www.fork.de/).\n\n**Table of contents**\n\n- [Features](#features)\n- [Installation](#installation)\n- [Theming](#theming)\n- [Stylesheets](#stylesheets)\n- [Deployment](#deployment)\n- [Roadmap](#roadmap)\n\n\u003c!-- /TOC --\u003e\n\n---\n\n## Features\n\n- 📦 Basic React components to start with\n- 💅 styled-components for styling\n- 🔧 ESLint, Stylelint und Prettier already configured\n- 🧱 Storybook Integration with A11y, Docs, Viewport and Theme Playground Plugin\n- 📐 Styling helpers for color, spacings and media queries\n- ⚙️ Basic jest snapshot testing is already implemented\n\n## Installation\n\nClone the `react-patterns` repository.\n\n```sh\ngit clone https://github.com/fork/react-patterns\ncd react-patterns/\n```\n\nYou can copy the components in two different ways to your React project.\n\n### 1. Automatic migration\n\nRun the `migrate.sh` script with your project path as an argument.\n\n```sh\nbash .migration/migrate.sh /Users/path/to/your/project\n```\n\nFollow the steps and the script will copy and install all necessary files and dependecies.\n\n### 2. Manual migration\n\nCopy all components you need for your new project. All components consist of a `component.jsx`, `component.style.jsx`, `component.stories.jsx` and a `index.js` file. All components depend on design tokens and our stylesheet helpers, therefore you also need to copy the `stylesheets` and the `tokens` directory to your new project.\n\n\u003cdetails\u003e\n  \u003csummary\u003eInstall missing dependencies\u003c/summary\u003e\n\n```sh\n# Install dependencies\nyarn add react react-dom styled-components prop-types lazysizes picturefill what-input js-cookie @svgr/cli\n\n# Install dev dependencies\nyarn add -D @storybook/react @storybook/addon-a11y @storybook/theming @storybook/addon-docs @storybook/addon-viewport babel-loader @babel/core babel-jest enzyme enzyme-adapter-react-16 enzyme-to-json jest react-is react-test-renderer @4rk/staticpages-cli\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdd scripts to package.json\u003c/summary\u003e\n\n```sh\n\"storybook\": \"start-storybook -s ./public -p 8000\",\n\"storybook:build\": \"build-storybook\",\n\"deploy\": \"yarn storybook:build \u0026\u0026 staticpages-cli\",\n\"test\": \"jest --config ./jest.config.json\",\n\"test:update\": \"jest --config ./jest.config.json -u\",\n\"build:icons\": \"svgr --no-dimensions --typescript -d src/components/Icon/compiled src/components/Icon/icons\"\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eWrap your React tree in a \u003cb\u003eThemeProvider\u003c/b\u003e\u003c/summary\u003e\n\n```js\nimport React from 'react';\nimport { ThemeProvider } from 'path/to/stylesheets';\n\nexport default () =\u003e (\n  \u003cThemeProvider theme=\"default\"\u003e\n    \u003cReactTree /\u003e\n  \u003c/ThemeProvider\u003e\n);\n```\n\n\u003c/details\u003e\n\n## Theming\n\nThe theming of our components is based on a `tokens` file, where we store our main variables. The `tokens` file consists of colors, spacings, breakpoints, grid sizes, font-sizes or animation properties. A basic example is located at `./tokens/index.js`.\n\nYou need to wrap the whole React tree inside a `ThemeProvider` to make the tokens available for the components. Otherwise the styling helpers will return an error.\n\n```js\nimport { ThemeProvider } from 'path/to/stylesheets';\n\nconst App = ({ children }) =\u003e {\n  return \u003cThemeProvider theme=\"default\"\u003e{children}\u003c/ThemeProvider\u003e;\n};\n```\n\n## Stylesheets\n\nWe use `styled-components` to style our react components. There are several helper methods and tools in the `stylesheets` direcetory which will return theme aware design tokens.\n\n**Example**\n\n```js\nimport styled from 'styled-components';\nimport { color, space, mq } from 'path/to/stylesheets';\n\nconst StyledComponent = styled.h2`\n  margin: ${space('m')} 0;\n  color: ${color('primary')};\n\n  ${mq('m')} {\n    color: ${color('neutral', 30)};\n  }\n`;\n```\n\n## Deployment\n\n1. Copy `.env.example` to `.env` and add your staticpages `DEPLOY_KEY`.\n2. Run `yarn deploy` to deploy static storybook app via staticpages-cli.\n\n## Roadmap\n\nWrite something about future releases and whats on the list for the next development phase.\n\n- [x] Update readme\n- [x] Use Typescript\n- [ ] Add more jest tests\n\n---\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"http://github.fork.de/heart.png\" width=\"38\" height=\"41\" alt=\"Fork Logo\" /\u003e\n\n  \u003cp\u003eBrought to you by \u003ca href=\"https://www.fork.de\"\u003eFork Unstable Media GmbH\u003c/a\u003e\u003c/p\u003e\n\u003c/div\u003e\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffork%2Freact-patterns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffork%2Freact-patterns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffork%2Freact-patterns/lists"}