chore: use full meta init

This commit is contained in:
Ibrahima G. Coulibaly
2025-04-17 08:03:18 +01:00
parent 779a5cfdb7
commit 6310fbdc0e
8 changed files with 31 additions and 23 deletions

View File

@@ -1,8 +1,11 @@
import type { GenericCalcType } from './types';
const ohmsLawCalc: GenericCalcType = {
title: "Ohm's Law",
name: 'ohms-law',
icon: 'mdi:ohm',
keywords: [],
shortDescription: '',
name: "Ohm's Law",
path: 'ohms-law',
description: 'Calculates voltage, current and resistance',
formula: 'V = I * R',
presets: [],

View File

@@ -1,8 +1,11 @@
import type { GenericCalcType } from './types';
const areaSphere: GenericCalcType = {
title: 'Area of a Sphere',
name: 'area-sphere',
icon: 'ph:sphere-duotone',
keywords: [],
shortDescription: '',
name: 'Area of a Sphere',
path: 'area-sphere',
description: 'Area of a Sphere',
formula: 'A = 4 * pi * r**2',
presets: [],

View File

@@ -1,8 +1,11 @@
import type { GenericCalcType } from './types';
const volumeSphere: GenericCalcType = {
title: 'Volume of a Sphere',
name: 'volume-sphere',
icon: 'gravity-ui:sphere',
keywords: [],
shortDescription: '',
name: 'Volume of a Sphere',
path: 'volume-sphere',
description: 'Volume of a Sphere',
formula: 'v = (4/3) * pi * r**3',
presets: [],

View File

@@ -1,4 +1,5 @@
import { DataTable } from '../../../../../datatables';
import { ToolMeta } from '@tools/defineTool';
export interface AlternativeVarInfo {
title: string;
@@ -7,12 +8,8 @@ export interface AlternativeVarInfo {
formula: string;
}
export interface GenericCalcType {
title: string;
name: string;
export interface GenericCalcType extends Omit<ToolMeta, 'component'> {
formula: string;
description?: string;
extraOutputs?: {
title: string;
formula: string;

View File

@@ -3,8 +3,11 @@ import material_electrical_properties from '../../../../../datatables/data/mater
import wire_gauge from '../../../../../datatables/data/wire_gauge';
const voltageDropInWire: GenericCalcType = {
title: 'Round trip voltage drop in cable',
name: 'cable-voltage-drop',
icon: 'simple-icons:wire',
keywords: [],
shortDescription: '',
name: 'Round trip voltage drop in cable',
path: 'cable-voltage-drop',
formula: 'x = (((p * L) / (A/10**6) ) *2) * I',
description:
'Calculates round trip voltage and power loss in a 2 conductor cable',

View File

@@ -236,7 +236,7 @@ export default async function makeTool(
inputComponent={null}
initialValues={initialValues}
toolInfo={{
title: calcData.title,
title: calcData.name,
description:
(calcData.description || '') +
' Generated from formula: ' +

View File

@@ -17,13 +17,13 @@ allGenericCalcs.forEach((x) => {
tools.push(
defineTool('number', {
name: x.title,
path: 'generic-calc/' + x.name,
icon: 'lsicon:number-filled',
name: x.name,
path: 'generic-calc/' + x.path,
icon: x.icon || '',
description: x.description || '',
shortDescription: '',
keywords: ['generic', 'calc'],
longDescription: '',
shortDescription: x.description || '',
keywords: ['calculator', 'math', ...x.keywords],
longDescription: x.longDescription || '',
component: lazy(importComponent2)
})
);

View File

@@ -2,7 +2,7 @@ import ToolLayout from '../components/ToolLayout';
import React, { JSXElementConstructor, LazyExoticComponent } from 'react';
import { IconifyIcon } from '@iconify/react';
interface ToolOptions {
export interface ToolMeta {
path: string;
component: LazyExoticComponent<JSXElementConstructor<ToolComponentProps>>;
keywords: string[];
@@ -23,7 +23,6 @@ export type ToolCategory =
| 'json'
| 'time'
| 'csv'
| 'time'
| 'pdf';
export interface DefinedTool {
@@ -44,7 +43,7 @@ export interface ToolComponentProps {
export const defineTool = (
basePath: ToolCategory,
options: ToolOptions
options: ToolMeta
): DefinedTool => {
const {
icon,