@jjlmoya/utils-textiles 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/package.json +60 -0
  2. package/src/category/i18n/en.ts +76 -0
  3. package/src/category/i18n/es.ts +76 -0
  4. package/src/category/i18n/fr.ts +73 -0
  5. package/src/category/index.ts +17 -0
  6. package/src/category/seo.astro +15 -0
  7. package/src/components/PreviewNavSidebar.astro +116 -0
  8. package/src/components/PreviewToolbar.astro +143 -0
  9. package/src/data.ts +11 -0
  10. package/src/env.d.ts +5 -0
  11. package/src/index.ts +32 -0
  12. package/src/layouts/PreviewLayout.astro +117 -0
  13. package/src/pages/[locale]/[slug].astro +146 -0
  14. package/src/pages/[locale].astro +253 -0
  15. package/src/pages/index.astro +4 -0
  16. package/src/tests/faq_count.test.ts +19 -0
  17. package/src/tests/locale_completeness.test.ts +42 -0
  18. package/src/tests/mocks/astro_mock.js +2 -0
  19. package/src/tests/no_h1_in_components.test.ts +48 -0
  20. package/src/tests/seo_length.test.ts +22 -0
  21. package/src/tests/title_separators.test.ts +40 -0
  22. package/src/tests/tool_validation.test.ts +17 -0
  23. package/src/tool/burnTest/bibliography.astro +34 -0
  24. package/src/tool/burnTest/component.astro +602 -0
  25. package/src/tool/burnTest/i18n/en.ts +225 -0
  26. package/src/tool/burnTest/i18n/es.ts +225 -0
  27. package/src/tool/burnTest/i18n/fr.ts +225 -0
  28. package/src/tool/burnTest/index.ts +34 -0
  29. package/src/tool/burnTest/logic.ts +3 -0
  30. package/src/tool/burnTest/seo.astro +40 -0
  31. package/src/tool/burnTest/ui.ts +36 -0
  32. package/src/tool/clothingSizeConverter/bibliography.astro +34 -0
  33. package/src/tool/clothingSizeConverter/component.astro +1226 -0
  34. package/src/tool/clothingSizeConverter/i18n/en.ts +356 -0
  35. package/src/tool/clothingSizeConverter/i18n/es.ts +356 -0
  36. package/src/tool/clothingSizeConverter/i18n/fr.ts +356 -0
  37. package/src/tool/clothingSizeConverter/index.ts +34 -0
  38. package/src/tool/clothingSizeConverter/logic.ts +30 -0
  39. package/src/tool/clothingSizeConverter/seo.astro +40 -0
  40. package/src/tool/clothingSizeConverter/ui.ts +70 -0
  41. package/src/tool/fabricProjectCalculator/bibliography.astro +19 -0
  42. package/src/tool/fabricProjectCalculator/component.astro +914 -0
  43. package/src/tool/fabricProjectCalculator/i18n/en.ts +250 -0
  44. package/src/tool/fabricProjectCalculator/i18n/es.ts +250 -0
  45. package/src/tool/fabricProjectCalculator/i18n/fr.ts +250 -0
  46. package/src/tool/fabricProjectCalculator/index.ts +34 -0
  47. package/src/tool/fabricProjectCalculator/logic.ts +89 -0
  48. package/src/tool/fabricProjectCalculator/seo.astro +40 -0
  49. package/src/tool/fabricProjectCalculator/ui.ts +57 -0
  50. package/src/tool/fabricTruth/bibliography.astro +40 -0
  51. package/src/tool/fabricTruth/component.astro +708 -0
  52. package/src/tool/fabricTruth/i18n/en.ts +282 -0
  53. package/src/tool/fabricTruth/i18n/es.ts +316 -0
  54. package/src/tool/fabricTruth/i18n/fr.ts +282 -0
  55. package/src/tool/fabricTruth/index.ts +34 -0
  56. package/src/tool/fabricTruth/logic.ts +91 -0
  57. package/src/tool/fabricTruth/seo.astro +40 -0
  58. package/src/tool/fabricTruth/ui.ts +28 -0
  59. package/src/tool/fiberPrep/bibliography.astro +33 -0
  60. package/src/tool/fiberPrep/component.astro +987 -0
  61. package/src/tool/fiberPrep/i18n/en.ts +225 -0
  62. package/src/tool/fiberPrep/i18n/es.ts +225 -0
  63. package/src/tool/fiberPrep/i18n/fr.ts +225 -0
  64. package/src/tool/fiberPrep/index.ts +34 -0
  65. package/src/tool/fiberPrep/logic.ts +36 -0
  66. package/src/tool/fiberPrep/seo.astro +40 -0
  67. package/src/tool/fiberPrep/ui.ts +38 -0
  68. package/src/tool/knittingGauge/bibliography.astro +14 -0
  69. package/src/tool/knittingGauge/component.astro +828 -0
  70. package/src/tool/knittingGauge/i18n/en.ts +234 -0
  71. package/src/tool/knittingGauge/i18n/es.ts +234 -0
  72. package/src/tool/knittingGauge/i18n/fr.ts +234 -0
  73. package/src/tool/knittingGauge/index.ts +34 -0
  74. package/src/tool/knittingGauge/logic.ts +28 -0
  75. package/src/tool/knittingGauge/seo.astro +40 -0
  76. package/src/tool/knittingGauge/ui.ts +41 -0
  77. package/src/tool/laundryGuide/bibliography.astro +33 -0
  78. package/src/tool/laundryGuide/component.astro +486 -0
  79. package/src/tool/laundryGuide/data-en.ts +166 -0
  80. package/src/tool/laundryGuide/data-es.ts +166 -0
  81. package/src/tool/laundryGuide/data-fr.ts +103 -0
  82. package/src/tool/laundryGuide/i18n/en.ts +275 -0
  83. package/src/tool/laundryGuide/i18n/es.ts +275 -0
  84. package/src/tool/laundryGuide/i18n/fr.ts +291 -0
  85. package/src/tool/laundryGuide/index.ts +29 -0
  86. package/src/tool/laundryGuide/logic.ts +19 -0
  87. package/src/tool/laundryGuide/seo.astro +40 -0
  88. package/src/tool/needleConverter/bibliography.astro +14 -0
  89. package/src/tool/needleConverter/component.astro +518 -0
  90. package/src/tool/needleConverter/i18n/en.ts +217 -0
  91. package/src/tool/needleConverter/i18n/es.ts +217 -0
  92. package/src/tool/needleConverter/i18n/fr.ts +217 -0
  93. package/src/tool/needleConverter/index.ts +34 -0
  94. package/src/tool/needleConverter/logic.ts +31 -0
  95. package/src/tool/needleConverter/seo.astro +15 -0
  96. package/src/tool/needleConverter/ui.ts +17 -0
  97. package/src/tool/sewingPatternScaler/bibliography.astro +14 -0
  98. package/src/tool/sewingPatternScaler/component.astro +550 -0
  99. package/src/tool/sewingPatternScaler/i18n/en.ts +196 -0
  100. package/src/tool/sewingPatternScaler/i18n/es.ts +231 -0
  101. package/src/tool/sewingPatternScaler/i18n/fr.ts +187 -0
  102. package/src/tool/sewingPatternScaler/index.ts +34 -0
  103. package/src/tool/sewingPatternScaler/logic.ts +35 -0
  104. package/src/tool/sewingPatternScaler/seo.astro +49 -0
  105. package/src/tool/sewingPatternScaler/ui.ts +29 -0
  106. package/src/tool/shoeSizeConverter/bibliography.astro +34 -0
  107. package/src/tool/shoeSizeConverter/component.astro +437 -0
  108. package/src/tool/shoeSizeConverter/i18n/en.ts +188 -0
  109. package/src/tool/shoeSizeConverter/i18n/es.ts +188 -0
  110. package/src/tool/shoeSizeConverter/i18n/fr.ts +188 -0
  111. package/src/tool/shoeSizeConverter/index.ts +34 -0
  112. package/src/tool/shoeSizeConverter/logic.ts +8 -0
  113. package/src/tool/shoeSizeConverter/seo.astro +40 -0
  114. package/src/tool/shoeSizeConverter/ui.ts +21 -0
  115. package/src/tool/stainChemistry/bibliography.astro +40 -0
  116. package/src/tool/stainChemistry/component.astro +717 -0
  117. package/src/tool/stainChemistry/i18n/en.ts +303 -0
  118. package/src/tool/stainChemistry/i18n/es.ts +300 -0
  119. package/src/tool/stainChemistry/i18n/fr.ts +310 -0
  120. package/src/tool/stainChemistry/index.ts +34 -0
  121. package/src/tool/stainChemistry/logic.ts +11 -0
  122. package/src/tool/stainChemistry/seo.astro +40 -0
  123. package/src/tool/stainChemistry/ui.ts +51 -0
  124. package/src/tool/yarnCalculator/bibliography.astro +19 -0
  125. package/src/tool/yarnCalculator/component.astro +792 -0
  126. package/src/tool/yarnCalculator/i18n/en.ts +310 -0
  127. package/src/tool/yarnCalculator/i18n/es.ts +310 -0
  128. package/src/tool/yarnCalculator/i18n/fr.ts +310 -0
  129. package/src/tool/yarnCalculator/index.ts +34 -0
  130. package/src/tool/yarnCalculator/logic.ts +84 -0
  131. package/src/tool/yarnCalculator/seo.astro +14 -0
  132. package/src/tool/yarnCalculator/ui.ts +42 -0
  133. package/src/tools.ts +16 -0
  134. package/src/types.ts +72 -0
@@ -0,0 +1,34 @@
1
+ import type { TextilesToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
+ import FiberPrepComponent from './component.astro';
3
+ import FiberPrepSEO from './seo.astro';
4
+ import FiberPrepBibliography from './bibliography.astro';
5
+
6
+ import type { FiberPrepUI } from './ui';
7
+
8
+ export type FiberPrepLocaleContent = ToolLocaleContent<FiberPrepUI>;
9
+
10
+ import { content as es } from './i18n/es';
11
+ import { content as en } from './i18n/en';
12
+ import { content as fr } from './i18n/fr';
13
+
14
+ export const fiberPrep: TextilesToolEntry<FiberPrepUI> = {
15
+ id: 'fiber-prep',
16
+ icons: {
17
+ bg: 'mdi:beaker-outline',
18
+ fg: 'mdi:molecule',
19
+ },
20
+ i18n: {
21
+ es: async () => es,
22
+ en: async () => en,
23
+ fr: async () => fr,
24
+ },
25
+ };
26
+
27
+ export { FiberPrepComponent, FiberPrepSEO, FiberPrepBibliography };
28
+
29
+ export const FIBER_PREP_TOOL: ToolDefinition = {
30
+ entry: fiberPrep,
31
+ Component: FiberPrepComponent,
32
+ SEOComponent: FiberPrepSEO,
33
+ BibliographyComponent: FiberPrepBibliography,
34
+ };
@@ -0,0 +1,36 @@
1
+ export type FiberType = 'protein' | 'cellulosic';
2
+
3
+ export interface WOFResult {
4
+ alum: number;
5
+ creamOfTartar: number;
6
+ iron: number;
7
+ }
8
+
9
+ export interface PhStrings {
10
+ optimal: string;
11
+ raisePrefix: string;
12
+ raiseSuffix: string;
13
+ lowerPrefix: string;
14
+ lowerSuffix: string;
15
+ }
16
+
17
+ export function calculateWOF(weightG: number, fiberType: FiberType): WOFResult {
18
+ if (fiberType === 'protein') {
19
+ return { alum: weightG * 0.15, creamOfTartar: weightG * 0.02, iron: weightG * 0.01 };
20
+ }
21
+ return { alum: weightG * 0.2, creamOfTartar: 0, iron: weightG * 0.02 };
22
+ }
23
+
24
+ export function computePhAdvice(
25
+ ph: number,
26
+ target: number,
27
+ vol: number,
28
+ strings: PhStrings,
29
+ ): string {
30
+ const diff = target - ph;
31
+ if (Math.abs(diff) < 0.1) return strings.optimal;
32
+ if (diff > 0) {
33
+ return `${strings.raisePrefix} ${(diff * vol * 0.5).toFixed(1)}g ${strings.raiseSuffix} ${target}`;
34
+ }
35
+ return `${strings.lowerPrefix} ${(Math.abs(diff) * vol * 0.2).toFixed(1)}ml ${strings.lowerSuffix} ${target}`;
36
+ }
@@ -0,0 +1,40 @@
1
+ ---
2
+ import {
3
+ SEOTitle,
4
+ SEOCard,
5
+ SEOTip,
6
+ SEOList,
7
+ SEOArticle
8
+ } from '@jjlmoya/utils-shared';
9
+ import { fiberPrep } from './index';
10
+ import type { KnownLocale } from '../../types';
11
+
12
+ interface Props {
13
+ locale?: KnownLocale;
14
+ }
15
+
16
+ const { locale = 'es' } = Astro.props;
17
+ const content = await fiberPrep.i18n[locale]?.();
18
+ if (!content) return null;
19
+
20
+ const { seo } = content;
21
+ ---
22
+
23
+ <SEOArticle>
24
+ {seo.map((section: any) => {
25
+ switch (section.type) {
26
+ case 'title':
27
+ return <SEOTitle title={section.text} level={section.level || 2} />;
28
+ case 'paragraph':
29
+ return <p set:html={section.html} />;
30
+ case 'list':
31
+ return <SEOList items={section.items} />;
32
+ case 'card':
33
+ return <SEOCard title={section.title} icon={section.icon}><Fragment set:html={section.html} /></SEOCard>;
34
+ case 'tip':
35
+ return <SEOTip title={section.title}><Fragment set:html={section.html} /></SEOTip>;
36
+ default:
37
+ return null;
38
+ }
39
+ })}
40
+ </SEOArticle>
@@ -0,0 +1,38 @@
1
+ import type { PhStrings } from './logic';
2
+
3
+ export interface FiberPrepFiber {
4
+ id: string;
5
+ name: string;
6
+ icon: string;
7
+ }
8
+
9
+ export interface FiberPrepUI {
10
+ profileTitle: string;
11
+ profileDesc: string;
12
+ proteinTitle: string;
13
+ proteinOrigin: string;
14
+ proteinDesc: string;
15
+ cellulosicTitle: string;
16
+ cellulosicOrigin: string;
17
+ cellulosicDesc: string;
18
+ wofTitle: string;
19
+ weightLabel: string;
20
+ weightUnit: string;
21
+ wofEmptyMsg: string;
22
+ alumLabel: string;
23
+ cremLabel: string;
24
+ ironLabel: string;
25
+ rampTitle: string;
26
+ rampEmptyTitle: string;
27
+ rampEmptyDesc: string;
28
+ phTitle: string;
29
+ phDesc: string;
30
+ phVolumeLabel: string;
31
+ phSliderLabel: string;
32
+ phAcidLabel: string;
33
+ phAlkalineLabel: string;
34
+ phEmptyMsg: string;
35
+ phStrings: PhStrings;
36
+ proteinFibers: FiberPrepFiber[];
37
+ cellulosicFibers: FiberPrepFiber[];
38
+ }
@@ -0,0 +1,14 @@
1
+ ---
2
+ ---
3
+ <ul>
4
+ <li>
5
+ <a href="https://blog.tincanknits.com/2013/08/17/gauge/" target="_blank" rel="noopener noreferrer">
6
+ The Importance of Gauge - Tin Can Knits
7
+ </a>
8
+ </li>
9
+ <li>
10
+ <a href="https://elizabethsmithknits.com/2020/10/30/how-to-measure-your-gauge-swatch/" target="_blank" rel="noopener noreferrer">
11
+ Knitting Gauge: How to Measure Stitches and Rows - Elizabeth Smith Knits
12
+ </a>
13
+ </li>
14
+ </ul>