UNPKG

@neo4j-ndl/react

Version:

React implementation of Neo4j Design System

71 lines 2.64 kB
/** * * Copyright (c) "Neo4j" * Neo4j Sweden AB [http://neo4j.com] * * This file is part of Neo4j. * * Neo4j is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { tokens } from '@neo4j-ndl/base'; export function validateValue(value, validate) { return __awaiter(this, void 0, void 0, function* () { if (!validate) { return null; } const validation = validate(value); let isValid; if (validation instanceof Promise) { isValid = yield validation; } else { isValid = validation; } if (typeof isValid === 'string') { return isValid; } return null; }); } export function getIconSizeForVariant(variant) { switch (variant) { case 'display': case 'title-1': return 24; case 'title-2': case 'title-3': case 'title-4': case 'subheading-large': return 20; default: return 16; } } export const getIconStyle = (variant) => ({ height: `${getIconSizeForVariant(variant)}px`, width: `${getIconSizeForVariant(variant)}px`, }); export const getMinHeight = (variant) => { return `${tokens.typography[variant].lineHeight * parseFloat(tokens.typography[variant].fontSize)}rem`; }; //# sourceMappingURL=utils.js.map