Skip to content

Commit

Permalink
Version Packages (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
seek-oss-ci authored Jan 31, 2023
1 parent 5d77f47 commit 03cc50b
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 146 deletions.
8 changes: 0 additions & 8 deletions .changeset/clever-mangos-clap.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/curvy-drinks-confess.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/kind-impalas-fail.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/loud-rules-warn.md

This file was deleted.

11 changes: 0 additions & 11 deletions .changeset/pretty-beds-know.md

This file was deleted.

47 changes: 0 additions & 47 deletions .changeset/tall-scissors-draw.md

This file was deleted.

131 changes: 94 additions & 37 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,111 @@
# @capsizecss/core

## 3.0.0
### Major Changes
## 3.1.0

### Minor Changes

- [#117](https://github.com/seek-oss/capsize/pull/117) [`0e969d8`](https://github.com/seek-oss/capsize/commit/0e969d8968a6b115fec96b1ac214c100480f9e65) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - Add `createFontStack` for metrics-based font family fallbacks.

Creates metrics-based `@font-face` declarations to improve the alignment of font family fallbacks, which can dramatically improve the [Cumulative Layout Shift](https://web.dev/cls/) metric for sites that depend on a web font.

### Example usage

```ts
import { createFontStack } from '@capsizecss/core';
import lobster from '@capsizecss/metrics/lobster';
import helveticaNeue from '@capsizecss/metrics/helveticaNeue';
import arial from '@capsizecss/metrics/arial';

const { fontFamily, fontFaces } = createFontStack([
lobster,
helveticaNeue,
arial,
]);
```

The returned values are the computed font family and the generated font face declarations:

```ts
// `fontFamily`
"Lobster, 'Lobster Fallback: Helvetica Neue', 'Lobster Fallback: Arial'";
```

```css
/* `fontFaces` */
@font-face {
font-family: 'Lobster Fallback: Helvetica Neue';
src: local('Helvetica Neue');
ascent-override: 115.1741%;
descent-override: 28.7935%;
size-adjust: 86.8251%;
}
@font-face {
font-family: 'Lobster Fallback: Arial';
src: local('Arial');
ascent-override: 113.5679%;
descent-override: 28.392%;
size-adjust: 88.053%;
}
```

### Patch Changes

- [#122](https://github.com/seek-oss/capsize/pull/122) [`8a15c86`](https://github.com/seek-oss/capsize/commit/8a15c8647bb12c85853c6807c1edc9d82a79e6dc) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - Add additional properties to `FontMetrics` type definition.

Previously the `FontMetrics` type captured only the metrics required by the options for the `createStyleObject` and `createStyleString` APIs.
With additional APIs coming that require a different subset of metrics, the type now reflects the structure of the data from the `metrics` package.

The additional properties are: `familyName`, `category`, `xHeight` and `xWidthAvg`.
See documentation for more details.

## 3.0.0

### Major Changes

- [#41](https://github.com/seek-oss/capsize/pull/41) [`beb400b`](https://github.com/seek-oss/capsize/commit/beb400beab5296353da32c4676466355184ab22b) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - The `capsize` package has been moved to its own organisation on npm called `@capsizecss`. This will allow an official ecosystem of tooling to be added over time.

### Features

#### `createStyleObject`

Accepts capsize `options` and returns a JS object representation of the capsize styles that is compatible with most css-in-js frameworks.

This replaces the default export of the previous version (see migration guide below).

```ts
import { createStyleObject } from '@capsizecss/core';

const capsizeStyles = createStyleObject({
fontSize: 18,
fontMetrics: {
// ...
}
},
});

<div
css={{
// fontFamily: '...' etc,
...capsizeStyles,
}}
>
My capsized text 🛶
</div>
</div>;
```

#### `createStyleString`

Accepts capsize `options` and returns a string representation of the capsize styles that can then be templated into a HTML `style` tag or appended to a stylesheet.

```ts
import { createStyleString } from '@capsizecss/core';

const capsizedStyleRule = createStyleString('capsizedText', {
fontSize: 18,
fontMetrics: {
// ...
}
},
});

document.write(`
<style type="text/css">
${capsizedStyleRule}
Expand All @@ -58,30 +115,30 @@
</div>
`);
```

#### `precomputeValues`

Accepts capsize `options` and returns all the information required to create styles for a specific font size given the provided font metrics. This is useful for integrations with different styling solutions.

### Breaking Change Migration Guide

#### Installation

Replace the previous `capsize` dependency with the new scoped version of the package `@capsizecss/core`:

```bash
npm uninstall capsize
npm install @capsizecss/core
```

#### API changes

There is no longer a default export, this behaviour is now available via the `createStyleObject` named export.

```diff
- import capsize from 'capsize';
+ import { createStyleObject } from '@capsizecss/core';

- const styles = capsize({
+ const styles = createStyleObject({
fontSize: 18,
Expand All @@ -90,32 +147,32 @@
}
});
```

#### Import changes

Both the `getCapHeight` function and `FontMetrics` type still exist, but the package name will need to be updated.

```diff
- import { getCapHeight, FontMetrics } from 'capsize';
+ import { getCapHeight, FontMetrics } from '@capsizecss/core';
```

#### Removals

The `CapsizeOptions` type has been removed, you can infer this from the first argument passed to `createStyleObject` using TypeScripts built-in `Parameters` utility:

```diff
- import type { CapsizeStyles } from 'capsize';
+ import type { createStyleObject } from '@capsizecss/core';

+ type CapsizeOptions = Parameters<typeof createStyleObject>[0];
```

The `CapsizeStyles` type has been removed, you can infer this from `createStyleObject` using TypeScripts built-in `ReturnType` utility:

```diff
- import type { CapsizeStyles } from 'capsize';
+ import type { createStyleObject } from '@capsizecss/core';

+ type CapsizeStyles = ReturnType<typeof createStyleObject>;
```
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capsizecss/core",
"version": "3.0.0",
"version": "3.1.0",
"description": "Flipping how we define typography",
"main": "dist/capsizecss-core.cjs.js",
"module": "dist/capsizecss-core.esm.js",
Expand Down
18 changes: 18 additions & 0 deletions packages/metrics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @capsizecss/metrics

## 1.0.0

### Major Changes

- [#125](https://github.com/seek-oss/capsize/pull/125) [`5d77f47`](https://github.com/seek-oss/capsize/commit/5d77f4758c32de8703f4869ff7b10cbf0b97af51) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - metrics, unpack: Cut v1 release

No actual breaking change here, but cutting the v1 release to mark the packages moving out of experimental phase.

### Minor Changes

- [#122](https://github.com/seek-oss/capsize/pull/122) [`8a15c86`](https://github.com/seek-oss/capsize/commit/8a15c8647bb12c85853c6807c1edc9d82a79e6dc) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - Update Google Fonts

- [#122](https://github.com/seek-oss/capsize/pull/122) [`8a15c86`](https://github.com/seek-oss/capsize/commit/8a15c8647bb12c85853c6807c1edc9d82a79e6dc) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - Calculate and expose `xWidthAvg`, the average width of lowercase characters.

- [#122](https://github.com/seek-oss/capsize/pull/122) [`8a15c86`](https://github.com/seek-oss/capsize/commit/8a15c8647bb12c85853c6807c1edc9d82a79e6dc) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - Add `category` field to describe the style of the font, e.g. “serif”, “sans-serif” etc.

Exposes the `category` field captured by Google Fonts, manually populating it for system fonts.

## 0.4.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/metrics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capsizecss/metrics",
"version": "0.4.0",
"version": "1.0.0",
"description": "Font metrics library for system and Google fonts",
"scripts": {
"clean": "ts-node scripts/clean",
Expand Down Expand Up @@ -33,7 +33,7 @@
"license": "MIT",
"dependencies": {},
"devDependencies": {
"@capsizecss/unpack": "^0.2.1",
"@capsizecss/unpack": "^1.0.0",
"@types/cli-progress": "^3.9.2",
"@types/dedent": "^0.7.0",
"@types/node": "^16.18.2",
Expand Down
12 changes: 12 additions & 0 deletions packages/unpack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @capsizecss/unpack

## 1.0.0

### Major Changes

- [#125](https://github.com/seek-oss/capsize/pull/125) [`5d77f47`](https://github.com/seek-oss/capsize/commit/5d77f4758c32de8703f4869ff7b10cbf0b97af51) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - metrics, unpack: Cut v1 release

No actual breaking change here, but cutting the v1 release to mark the packages moving out of experimental phase.

### Minor Changes

- [#122](https://github.com/seek-oss/capsize/pull/122) [`8a15c86`](https://github.com/seek-oss/capsize/commit/8a15c8647bb12c85853c6807c1edc9d82a79e6dc) Thanks [@michaeltaranto](https://github.com/michaeltaranto)! - Calculate and expose `xWidthAvg`, the average width of lowercase characters.

## 0.2.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/unpack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capsizecss/unpack",
"version": "0.2.1",
"version": "1.0.0",
"description": "Unpack capsize font metrics from fonts",
"main": "dist/capsizecss-unpack.cjs.js",
"module": "dist/capsizecss-unpack.esm.js",
Expand Down
Loading

0 comments on commit 03cc50b

Please sign in to comment.