ramda#identity JavaScript Examples

The following examples show how to use ramda#identity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Accordion.js    From lundium with MIT License 6 votes vote down vote up
Accordion = forwardRef(({ openItemIndex, className, children }, ref) => {
	const [indexOpen, setIndexOpen] = useState(openItemIndex);

	useEffect(() => {
		if (!isNaN(openItemIndex)) {
			setIndexOpen(openItemIndex);
		}
	}, [openItemIndex]);

	useImperativeHandle(ref, () => ({ setActiveIndex: setIndexOpen }));

	return (
		<Box className={cx('accordion', className)}>
			{Children.map(children, (child, index) =>
				cond([
					[
						o(equals(AccordionItem), prop('type')),
						clone({ index, indexOpen, setIndexOpen }),
					],
					[T, identity],
				])(child),
			)}
		</Box>
	);
})
Example #2
Source File: breakDownAllNodes.js    From gatsby-startbootstrap-agency with MIT License 6 votes vote down vote up
/**
 * break down all data retrieved in index.js
 */
export default function breakDownAllNodes(nodes) {
  const filterByFileName = propFilter(["fields", "fileName"]);
  const filterByDirectoryName = propFilter(["fields", "directoryName"]);

  // top part
  const topNode = nodes.find(filterByFileName(/top/i)) || {};
  // navbar
  const navBarNode = nodes.find(filterByFileName(/navbar/i)) || {};
  // footer
  const footerNode = nodes.find(filterByFileName(/footer/i)) || {};

  // sections part
  const sectionsNodes = nodes.filter(filterByDirectoryName(/sections/i));

  // anchors for NavBar
  const anchors = sectionsNodes.map(path(["frontmatter", "anchor"])).filter(identity);

  return {
    topNode,
    navBarNode,
    footerNode,
    sectionsNodes,
    anchors,
  };
}
Example #3
Source File: Notification.js    From lundium with MIT License 5 votes vote down vote up
getIcon = cond([
	[equals('danger'), always('status-rejected')],
	[equals('warning'), always('error')],
	[T, identity],
])
Example #4
Source File: classNamesByBreakpoint.js    From lundium with MIT License 5 votes vote down vote up
prepareBreakpointArray = cond([
	[isNilOrEmpty, alwaysEmptyArray],
	[isPlainObject, prepareBreakpointArrayFromObject],
	[isArray, identity],
	[T, of],
])
Example #5
Source File: classNamesByBreakpoint.js    From lundium with MIT License 5 votes vote down vote up
prepareClassNameFactory = useWith(__, [identity, getBreakpointByIndex])