@hackoregon/component-library
Version:
Official repo for Hack Oregon React component library
72 lines (63 loc) • 2.53 kB
JavaScript
function _templateObject() {
var data = _taggedTemplateLiteral(["\n display: inline-block;\n padding: 0 2em;\n height: 2em;\n line-height: 2em;\n border-radius: 1em;\n background-color: ", ";\n margin: 0.5em 0.5em;\n font-family: \"Roboto Condensed\", \"Helvetica Neue\", Helvetica, sans-serif;\n font-weight: bold;\n color: white;\n cursor: pointer;\n"]);
_templateObject = function _templateObject() {
return data;
};
return data;
}
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
import { jsx, css } from "@emotion/core";
import { Fragment } from "react";
import PropTypes from "prop-types";
import _ from "lodash";
import Collapsable from "../Collapsable/Collapsable";
import CivicVictoryTheme from "../VictoryTheme/CivicVictoryTheme";
var chipStyle = function chipStyle(index) {
return css(_templateObject(), CivicVictoryTheme.group.colorScale[index % CivicVictoryTheme.group.colorScale.length]);
};
export function Chip(_ref) {
var tag = _ref.tag,
index = _ref.index;
return jsx("span", {
css: chipStyle(index)
}, "#".concat(tag));
}
Chip.propTypes = {
tag: PropTypes.string,
index: PropTypes.number
};
export function Resource(_ref2) {
var item = _ref2.item;
return _.has(item, "section") ? jsx("h3", null, item.section) : jsx("li", null, jsx("a", {
href: item.link
}, item.description));
}
Resource.propTypes = {
item: PropTypes.shape({
link: PropTypes.string,
description: PropTypes.string
})
};
export function MetadataQuestion(_ref3) {
var item = _ref3.item;
return _.has(item, "section") ? jsx("h3", null, item.section) : item.answer.length > 0 && jsx(Fragment, null, jsx("h4", null, item.question), jsx("p", null, item.answer));
}
MetadataQuestion.propTypes = {
item: PropTypes.shape({
question: PropTypes.string,
answer: PropTypes.string
})
};
export function CollapsableSection(_ref4) {
var items = _ref4.items,
collapseAfter = _ref4.collapseAfter;
var beforeFold = _.slice(items, 0, collapseAfter);
var afterFold = _.slice(items, collapseAfter);
return (afterFold && afterFold.length) > 0 ? jsx(Collapsable, null, jsx(Collapsable.Section, null, beforeFold), jsx(Collapsable.Section, {
hidden: true
}, afterFold)) : jsx(Fragment, null, beforeFold);
}
CollapsableSection.propTypes = {
items: PropTypes.arrayOf(PropTypes.node),
collapseAfter: PropTypes.number
};