seek-oss / capsize

Flipping how we define typography in CSS.
https://seek-oss.github.io/capsize/
MIT License
1.51k stars 37 forks source link

Expose new `entireMetricsCollection` and `fontFamilyToCamelCase` APIs #129

Closed michaeltaranto closed 1 year ago

michaeltaranto commented 1 year ago

Expose two new APIs:

entireMetricsCollection: Expose all metrics indexed by family name

Provides the entire metrics collection as a JSON object, keyed by font family name.

⚠️ CAUTION: Importing this will result in a large JSON structure being pulled into your project! It is not recommended to use this client side.

import { entireMetricsCollection } from '@capsizecss/metrics/entireMetricsCollection';

const metrics = entireMetricsCollection['arial'];

and

fontFamilyToCamelCase: Expose utility to convert family name to import name

A helper function to support tooling that needs to convert the font family name to the correct casing for the relevant metrics import.


import { fontFamilyToCamelCase } from '@capsizecss/metrics';

const familyName = fontFamilyToCamelCase('--apple-system'); // => `appleSystem`
const metrics = await import(`@capsizecss/metrics/${familyName}`);
changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: fdbeedd068b2807b601dc5751733e4a67194c374

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------------------- | ----- | | @capsizecss/metrics | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR