Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/agoda-com/react-handyman

👨‍🔧 Enhance your React.js app with i18n, string formatting, ab tests and other handy packages!
https://github.com/agoda-com/react-handyman

ab-testing feature-toggle i18n internationalization jsx react reactjs string-formatter string-formatting

Last synced: 26 days ago
JSON representation

👨‍🔧 Enhance your React.js app with i18n, string formatting, ab tests and other handy packages!

Awesome Lists containing this project

README

        

# 👨‍🔧 React handyman

[![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![dependabot badge](https://badgen.net/dependabot/agoda-com/react-handyman/?icon=dependabot.svg)](https://dependabot.com/)

This is a monorepo containing all packages that can help you extend functionalities of your react.js based application. For detailed documentation about each package, checkout each README file for each package.

---

# [ab-test-jsx](/packages/ab-test-jsx)

[![npm](https://img.shields.io/npm/v/ab-test-jsx.svg)](https://www.npmjs.com/package/ab-test-jsx)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/ab-test-jsx.svg)](https://bundlephobia.com/result?p=ab-test-jsx)
![Build Status](https://github.com/agoda-com/react-handyman/workflows/Publish%20to%20NPM%20registry/badge.svg?branch=master)
[![codecov](https://codecov.io/gh/agoda-com/react-handyman/branch/master/graph/badge.svg)](https://codecov.io/gh/agoda-com/react-handyman)

React (JS) based client for consuming AB test logic in your app.

Do conditional rendering based on experiment allocation in your JSX with help of `ABTest` component:

```jsx
import { ABTest } from 'ab-test-jsx'

const Header: React.FC = () => (
<>

Old header implementation



New header!



>
)
```

Use custom hook to access allocation results and implement custom logic in your components:

```jsx
const SearchBox: React.FC = () => {
const { isB } = useABTests()
const apiEndpoint = isB('use-new-api') ? newApiUrl : apiUrl
return
}
```

Please see more examples, detailed documentation and other available components in the [package README file](/packages/ab-test-jsx)!

---

# [feature-toggle-jsx](/packages/feature-toggle-jsx)

[![npm](https://img.shields.io/npm/v/feature-toggle-jsx.svg)](https://www.npmjs.com/package/feature-toggle-jsx)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/feature-toggle-jsx.svg)](https://bundlephobia.com/result?p=feature-toggle-jsx)
![Build Status](https://github.com/agoda-com/react-handyman/workflows/Publish%20to%20NPM%20registry/badge.svg?branch=master)
[![codecov](https://codecov.io/gh/agoda-com/react-handyman/branch/master/graph/badge.svg)](https://codecov.io/gh/agoda-com/react-handyman)

Toggle visibility of your react components based on features configuration of your app.

```jsx
// HOC
export default withFeature(ChatComponent, 'chat')
export default withoutFeature(PlaceholderComponent, 'chat')
// with custom selector
export default withFeature(ChatComponent, 'chat', _ => _.someConfigValue == true)

// Hook
const [isEnabled, config] = useFeature('chat')

const [isEnabled] = useFeature('chat' _ => _.someConfigValue == 4)
```

Check out details and more examples in [package README file](/packages/feature-toggle-jsx).

---

# [i18n-jsx](/packages/i18n-jsx)

[![npm](https://img.shields.io/npm/v/i18n-jsx.svg)](https://www.npmjs.com/package/i18n-jsx)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/i18n-jsx.svg)](https://bundlephobia.com/result?p=i18n-jsx)
![Build Status](https://github.com/agoda-com/react-handyman/workflows/Publish%20to%20NPM%20registry/badge.svg?branch=master)
[![codecov](https://codecov.io/gh/agoda-com/react-handyman/branch/master/graph/badge.svg)](https://codecov.io/gh/agoda-com/react-handyman)

React (JS) text internationalization and externalizing. Supports string formatting and fallback to default values.

```jsx
import { I18n } from 'i18n-jsx'

const I18nExamples: React.FC = () => {
return (


Default fallback text that should not render


)
}
```

With `example.key.1` translation key set up as

```
'This is text under example.key.1 value'
```

I18nExamples component will render:

```html

This is text under example.key.1 value


```

Check out details and more examples in [package README file](/packages/i18n-jsx).

---

# [format-to-jsx](/packages/format-to-jsx)

[![npm](https://img.shields.io/npm/v/format-to-jsx.svg)](https://www.npmjs.com/package/format-to-jsx)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/format-to-jsx.svg)](https://bundlephobia.com/result?p=format-to-jsx)
![Build Status](https://github.com/agoda-com/react-handyman/workflows/Publish%20to%20NPM%20registry/badge.svg?branch=master)
[![codecov](https://codecov.io/gh/agoda-com/react-handyman/branch/master/graph/badge.svg)](https://codecov.io/gh/agoda-com/react-handyman)

Easy string formatting with support of injecting JSX elements and object based params

```ts
format('Example {1} with different placeholders order {0}', 1, 2)
// Example 2 with different placeholders order 1

format('Example {two} with different placeholders order {one}', { one: 1, two: 2 })
// Example 2 with different placeholders order 1

format('Example {1} with different placeholders order {0}', 1, 2)
// <>Example 2 with different placeholders order 1<>
```

Check out details and more examples in [package README file](/packages/format-to-jsx).

# [error-boundary-jsx](/packages/error-boundary-jsx)

[![npm](https://img.shields.io/npm/v/error-boundary.svg)](https://www.npmjs.com/package/error-boundary-jsx)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/error-boundary.svg)](https://bundlephobia.com/result?p=error-boundary-jsx)
![Build Status](https://github.com/agoda-com/react-handyman/workflows/Publish%20to%20NPM%20registry/badge.svg?branch=master)
[![codecov](https://codecov.io/gh/agoda-com/react-handyman/branch/master/graph/badge.svg)](https://codecov.io/gh/agoda-com/react-handyman)

Handle errors on wrapped component and provide a fall back.

```ts
import ErrorBoundary from 'error-boundary-jsx'

...component tree to handle errors

```

Check out details and more examples in [package README file](/packages/error-boundary-jsx).

---

## Contributors

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):



Maciej Małkowski

💻 📖 ⚠️ 👀

Nut Sornchumni

💻 📖 ⚠️ 👀

Thatchapon Unprasert

📖 💻 ⚠️ 👀

nickyshannon

💻 ⚠️ 👀

Nielsie

💻 ⚠️

Md Mahmudul Hasan

💻 ⚠️

Hasan AJ

💻



Soren Ullidtz

💻 ⚠️ 📖

Pramoch Viriyathomrongul

💻

Thammarith

📖

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!