All Projects β†’ csvenke β†’ react-semantic-render

csvenke / react-semantic-render

Licence: MIT license
Semantic helper components for rendering content with React.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-semantic-render

Rails stuff
Collection of useful modules for Rails.
Stars: ✭ 110 (+746.15%)
Mutual labels:  utils, helpers
react-circle-flags
πŸš€ A React component with a collection of 300+ minimal circular SVG country flags. Wrapper of HatScripts/circle-flags
Stars: ✭ 29 (+123.08%)
Mutual labels:  react-components, react-component-library
Handlebars Helpers
Related projects
Stars: ✭ 2,024 (+15469.23%)
Mutual labels:  helpers, render
utils
⚑ A collection of common functions but with better performance, less allocations and less dependencies created for Fiber.
Stars: ✭ 21 (+61.54%)
Mutual labels:  utils, helpers
urley
πŸ“¦ An easy cross-platform utility library to work with URLs in Javascript.
Stars: ✭ 14 (+7.69%)
Mutual labels:  utils, helpers
sagittarius
🎯 A set of javascript most used utilsπŸ“‘
Stars: ✭ 42 (+223.08%)
Mutual labels:  utils, helpers
Semantic Ui React
The official Semantic-UI-React integration
Stars: ✭ 12,561 (+96523.08%)
Mutual labels:  react-library, react-components
Smart-Inspector
Fluent re-take on Unity Inspector UX. Packed with QoL improvements.
Stars: ✭ 680 (+5130.77%)
Mutual labels:  utils, helpers
Prosemirror Utils
βš’ Utils library for ProseMirror
Stars: ✭ 241 (+1753.85%)
Mutual labels:  utils, helpers
bezier-react
React components library that implements Bezier Design System.
Stars: ✭ 85 (+553.85%)
Mutual labels:  react-components
Registration-and-Login-using-MERN-stack
Simple Registration and Login component with MERN stack
Stars: ✭ 210 (+1515.38%)
Mutual labels:  react-components
react-semantic-redux-form
Semantic-ui-react components integration with Redux form
Stars: ✭ 57 (+338.46%)
Mutual labels:  semantic
best-of-react
πŸ† A ranked list of awesome React open-source libraries and tools. Updated weekly.
Stars: ✭ 364 (+2700%)
Mutual labels:  react-components
resource-center
New version of the resource center built with ReactJS
Stars: ✭ 89 (+584.62%)
Mutual labels:  react-components
react-native-tus-client
React Native client for the tus resumable upload protocol.
Stars: ✭ 38 (+192.31%)
Mutual labels:  react-library
rebass
βš›οΈ React primitive UI components built with styled-system.
Stars: ✭ 7,844 (+60238.46%)
Mutual labels:  react-components
exfatprogs
exFAT filesystem userspace utilities
Stars: ✭ 26 (+100%)
Mutual labels:  utils
cnode-react
a web app for cnode.org with react + react-router + react-redux
Stars: ✭ 23 (+76.92%)
Mutual labels:  react-components
php-helpers
An extensive set of PHP helper functions and classes.
Stars: ✭ 27 (+107.69%)
Mutual labels:  helpers
klyva
A state management library that follows the React component model
Stars: ✭ 53 (+307.69%)
Mutual labels:  react-components

react-semantic-render

Semantic helper components for rendering content with React.

npm package min bundle size master workflow pull request workflow

Install β€’ Usage β€’ Why β€’ Development β€’ Contributing β€’ License

Install

Using npm:

$ npm install --save react-semantic-render

Using yarn:

$ yarn add react-semantic-render

Usage

Show

Renders content if when equals true.

Property Type Description
when boolean Conditional statement
render function Shorthand for primary content
children node Primary content
import { Show } from "react-semantic-render";

<Show when={true}>
  <button>click me!</button>
</Show>;

Use the render prop when you dont want your content evaluated unless a condition is true

import { Show } from "react-semantic-render";

<Show when={!!label} render={() => <button>{label}</button>} />;

List

Renders content from specified callback function from either render or children on each element of items.

Property Type Description
items any[] Array to map
render function Shorthand for primary content
children node Primary content
import { List } from "react-semantic-render";

<List items={["Jack", "Jane", "Joe"]}>{name => <span>{name}</span>}</List>;

Switch

Renders content from first Switch.Case that matches value, else Switch.Default if it exists.

Property Type Description
value boolean Conditional statement
children node Primary content
import { Switch } from "react-semantic-render";

<Switch value={3}>
  <Switch.Case value={3}>
    <span>Render me!</span>
  </Switch.Case>
  <Switch.Default>
    <button>Click me!</button>
  </Switch.Default>
</Switch>;

Why

In the example below you see two very common use cases where you have to render something when a condition is true and render content from an array of data. This is usually solved with inline arrow functions that are hard to read and easily becomes unmanageable in more complex components.

const App = ({ isLoading, results }) => (
    {results.length > 0 ? (
      <ul>
        {result.map(user => (
          <li key={user.id}>
            <span>{user.name}</span>
          </li>
        ))}
      </ul>
    ) : null}
);

Here you see how the component above could be rewritten with components from react-semantic-render. While it is abit more verbose, the readability is greatly increased and you immeadiatly see whats going on.

import { List, Switch } from "react-semantic-render";

const App = ({ isLoading, results }) => (
  <Show when={results.length > 0}>
    <ul>
      <List items={results}>
        {user => (
          <li key={user.id}>
            <span>{user.name}</span>
          </li>
        )}
      </List>
    </ul>
  </Show>
);

The purpose of this library is to provide helpful semantic render components that makes the React.Component render method easier to read and follow.

Do you have an idea about a component you think belong here? Tell us here!

Development

Install dependencies
$ yarn install
Run tests
$ yarn test

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style.

Commit style guide

We use conventional commits style. Read up on it before doing your first commit. Don't worry about making mistakes, commitlint will stop you and you can try again.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].