UNPKG

@drivy/cobalt

Version:

Opinionated design system for Drivy's projects.

28 lines (27 loc) 1.37 kB
import { jsx } from "react/jsx-runtime"; import classnames from "classnames"; import * as __rspack_external__icons_countries_index_js_3b77489c from "../../icons/countries/index.js"; import { countries } from "../../tokens/index.js"; import { eqSet } from "../utils/index.js"; if (!eqSet(new Set(Object.keys(__rspack_external__icons_countries_index_js_3b77489c)), new Set(Object.keys(countries.flags)))) throw new Error("Flag sources and tokens are not consistent. Did you add the source and export it"); const BUNDLED_FLAGS = Object.freeze(Object.keys(countries.flags).reduce((bundledFlags, name)=>{ bundledFlags[name] = __rspack_external__icons_countries_index_js_3b77489c[name]; return bundledFlags; }, {})); const Flag = ({ country, size = 24, className })=>{ const _className = classnames("cobalt-Flag", className, { "cobalt-Flag--size16": 16 === size, "cobalt-Flag--size20": 20 === size, "cobalt-Flag--size32": 32 === size }); const countryFlag = BUNDLED_FLAGS[country]; if (null == countryFlag) throw new Error(`'${country}' Flag can not be found. Did you add the source and export it`); return /*#__PURE__*/ jsx("span", { className: _className, dangerouslySetInnerHTML: { __html: countryFlag } }); }; export { BUNDLED_FLAGS, Flag }; //# sourceMappingURL=index.js.map