mac-human-design 0.1.27 → 0.1.29

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.
package/changelog.md CHANGED
@@ -2,6 +2,38 @@
2
2
 
3
3
  This file tracks changes between published npm versions of `mac-human-design`.
4
4
 
5
+ ## 0.1.29
6
+
7
+ ### Added
8
+
9
+ - Added `SymbolIconButton` optical centering support through default
10
+ per-symbol offsets and an `opticalOffset` override prop.
11
+ - Added verifier coverage for symbol optical offset props, default offsets, and
12
+ CSS variable-based glyph translation.
13
+
14
+ ### Changed
15
+
16
+ - Tuned common toolbar SF Symbols such as refresh, upload, download, back,
17
+ trash, and folder-plus so their visual weight sits closer to the center of
18
+ the fixed macOS icon button.
19
+ - Bumped the package to `0.1.29`.
20
+
21
+ ## 0.1.28
22
+
23
+ ### Added
24
+
25
+ - Added formal coverage documentation for `MacDataTable`, `MacWindowToolbar`,
26
+ `MacSegmentedControl`, and `SymbolIconButton` in
27
+ `docs/macos-base-ui-coverage.md`.
28
+ - Documented the shared icon-button alignment guarantees that keep icon-only
29
+ buttons centered across normal, loading, hover, and pressed states.
30
+ - Extended the macOS design verifier to require the app-level component docs
31
+ and icon alignment guarantees before release.
32
+
33
+ ### Changed
34
+
35
+ - Bumped the package to `0.1.28`.
36
+
5
37
  ## 0.1.27
6
38
 
7
39
  ### Added
@@ -84,6 +84,27 @@ render UI.
84
84
  | Window sheet | `MacDialog.SheetPopup` |
85
85
  | Sidebar drawer | `MacDrawer.SidebarPopup` |
86
86
 
87
+ ## App-Level Components
88
+
89
+ These shared components cover reusable macOS/Tauri app patterns that should not
90
+ be reimplemented in consuming apps:
91
+
92
+ | App pattern | Export | Contract |
93
+ | --- | --- | --- |
94
+ | Finder-style grid/table primitive | `MacDataTable` | Uses `table` semantics for static rows, upgrades to `grid` semantics for interactive rows, exposes row/column metadata, busy state, keyboard activation, selected row state, and focus-visible row styling. |
95
+ | Tauri window toolbar | `MacWindowToolbar` | Provides a labelled `toolbar` landmark, labelled leading/content/trailing control groups, a root drag region, and no-drag regions around interactive controls. |
96
+ | Segmented control | `MacSegmentedControl` | Wraps the shared macOS segmented toggle styling with accessible labels, stable class names, full-width layout support, and class/style pass-through. |
97
+ | Centered SF Symbols icon button | `SymbolIconButton` | Renders through `MacIconButton`, defaults to `type="button"`, preserves fixed geometry while allowing style/class pass-through, supports tooltip offsets and per-symbol optical offsets, and exposes loading state with `aria-busy`. |
98
+
99
+ ## Icon Button Alignment Guarantees
100
+
101
+ Icon-only buttons use fixed-size grid containers with zero padding, zero
102
+ line-height, centered grid content, middle inline alignment, and center transform
103
+ origins. `SymbolIconButton` keeps the SF Symbol and loading spinner in the same
104
+ grid cell, centers generated symbol masks, trims transparent symbol padding in
105
+ the native symbol service, applies per-symbol optical offsets for asymmetric
106
+ SF Symbols, and avoids vertical Motion offsets for icon-only controls.
107
+
87
108
  The gallery at `examples/macos-base-ui-gallery` renders these wrappers across
88
109
  normal, selected, disabled, mixed, popup, dialog, and narrow-width states.
89
110
 
@@ -102,6 +123,8 @@ The gate typechecks the library and verifies:
102
123
  - every component family is listed in this coverage document,
103
124
  - required native variants are exported,
104
125
  - nested native variant parts such as pop-up buttons, sheets, and sidebar drawers are exported,
126
+ - shared app-level components and icon-button alignment guarantees are
127
+ documented in this coverage file,
105
128
  - every class assigned by the wrapper module has a matching CSS selector,
106
129
  - every public wrapper export is represented in the visual gallery source,
107
130
  - macOS design features are present: system font stack, dark mode, reduced motion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mac-human-design",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Reusable macOS-oriented UI primitives and SF Symbols bridge for Tauri apps.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -6,6 +6,7 @@ const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."
6
6
  const stylesPath = path.join(repoRoot, "src", "styles", "macosBaseUi.css");
7
7
  const packageJsonPath = path.join(repoRoot, "package.json");
8
8
  const readmePath = path.join(repoRoot, "README.md");
9
+ const coverageDocsPath = path.join(repoRoot, "docs", "macos-base-ui-coverage.md");
9
10
  const wrapperPath = path.join(repoRoot, "src", "components", "MacBaseUI.tsx");
10
11
  const symbolIconButtonPath = path.join(repoRoot, "src", "components", "SymbolIconButton.tsx");
11
12
  const galleryPath = path.join(repoRoot, "src", "components", "MacBaseUIGallery.tsx");
@@ -50,6 +51,7 @@ const sources = new Map(
50
51
  const stylesSource = readText(stylesPath);
51
52
  const packageJson = JSON.parse(readText(packageJsonPath));
52
53
  const readmeSource = readText(readmePath);
54
+ const coverageDocsSource = readText(coverageDocsPath);
53
55
  const wrapperSource = readText(wrapperPath);
54
56
  const symbolIconButtonSource = readText(symbolIconButtonPath);
55
57
  const gallerySource = readText(galleryPath);
@@ -157,6 +159,10 @@ requireCssDeclarations(".hd-mac-symbol-icon", [
157
159
  ["horizontal glyph centering", /justify-content\s*:\s*center\s*;/],
158
160
  ["automatic optical centering margin", /margin\s*:\s*auto\s*;/],
159
161
  ["center transform origin", /transform-origin\s*:\s*center\s*;/],
162
+ [
163
+ "symbol optical centering translate",
164
+ /translate\s*:\s*var\(--hd-mac-symbol-offset-x,\s*0px\)\s*var\(--hd-mac-symbol-offset-y,\s*0px\)\s*;/,
165
+ ],
160
166
  ]);
161
167
 
162
168
  const sharedIconButtonRule = stylesSource.match(
@@ -197,6 +203,9 @@ const symbolIconRequirements = [
197
203
  ["SymbolIconButton render element is MacIconButton", /render=\{\s*<MacIconButton\b/],
198
204
  ["SymbolIconButton applies hd-mac-symbol-icon-button class", /joinClasses\("hd-mac-symbol-icon-button", className\)/],
199
205
  ["SymbolIconButton defaults to button type", /type=["']button["']/],
206
+ ["SymbolIconButton supports optical offset prop", /opticalOffset\?: SymbolIconOpticalOffset/],
207
+ ["SymbolIconButton includes default optical offsets", /DEFAULT_SYMBOL_OPTICAL_OFFSETS/],
208
+ ["SymbolIconButton sets symbol offset CSS variable", /"--hd-mac-symbol-offset-x": offsetToCssValue/],
200
209
  ["SymbolIconButton supports className pass-through", /\bclassName,\s*\n\s*style,/],
201
210
  ["SymbolIconButton supports style pass-through after fixed geometry", /\.\.\.style/],
202
211
  ["SymbolIconButton supports tooltip offset", /tooltipSideOffset = 5/],
@@ -325,6 +334,27 @@ if (missingPublicDocs.length > 0) {
325
334
  );
326
335
  }
327
336
 
337
+ const missingCoverageDocs = [
338
+ ["coverage docs include app-level section", /## App-Level Components/],
339
+ ["coverage docs document MacDataTable", /Finder-style grid\/table primitive[\s\S]*`MacDataTable`/],
340
+ ["coverage docs document MacWindowToolbar", /Tauri window toolbar[\s\S]*`MacWindowToolbar`/],
341
+ ["coverage docs document MacSegmentedControl", /Segmented control[\s\S]*`MacSegmentedControl`/],
342
+ ["coverage docs document SymbolIconButton", /Centered SF Symbols icon button[\s\S]*`SymbolIconButton`/],
343
+ ["coverage docs include icon alignment section", /## Icon Button Alignment Guarantees/],
344
+ ["coverage docs mention fixed-size grid containers", /fixed-size grid containers/],
345
+ ["coverage docs mention zero line-height", /zero[\s-]line-height/],
346
+ ["coverage docs mention loading spinner grid cell", /loading spinner[\s\S]*same\s+grid\s+cell/],
347
+ ["coverage docs mention transparent symbol padding trim", /trims transparent symbol padding/],
348
+ ["coverage docs mention no vertical Motion offsets", /avoids vertical Motion offsets/],
349
+ ].filter(([, pattern]) => !pattern.test(coverageDocsSource));
350
+
351
+ if (missingCoverageDocs.length > 0) {
352
+ fail(
353
+ "Missing coverage documentation for shared macOS app components and icon-button alignment.",
354
+ missingCoverageDocs.map(([label]) => label),
355
+ );
356
+ }
357
+
328
358
  const missingSegmentedControlRequirements = [
329
359
  ["stable segmented control class", /"hd-mac-segmented-control"/],
330
360
  ["default accessible label", /ariaLabel = "Segmented control"/],
@@ -10,6 +10,7 @@ type SymbolIconButtonProps = {
10
10
  disabled?: boolean;
11
11
  isLoading?: boolean;
12
12
  iconSizePx?: number;
13
+ opticalOffset?: SymbolIconOpticalOffset;
13
14
  symbolEnabled?: boolean;
14
15
  className?: string;
15
16
  style?: CSSProperties;
@@ -19,10 +20,31 @@ type SymbolIconButtonProps = {
19
20
  const ICON_BUTTON_SIZE = "30px";
20
21
  const ICON_BUTTON_RADIUS = "7px";
21
22
 
23
+ type SymbolIconOpticalOffset = {
24
+ x?: number | string;
25
+ y?: number | string;
26
+ };
27
+
28
+ const DEFAULT_SYMBOL_OPTICAL_OFFSETS: Record<string, SymbolIconOpticalOffset> = {
29
+ "arrow.clockwise": { y: 0.5 },
30
+ "square.and.arrow.up": { y: 0.35 },
31
+ "square.and.arrow.down": { y: 0.35 },
32
+ "folder.badge.plus": { x: -0.65 },
33
+ "chevron.left": { x: 0.6 },
34
+ trash: { y: 0.25 },
35
+ };
36
+
22
37
  function joinClasses(...classes: Array<string | undefined | false>) {
23
38
  return classes.filter(Boolean).join(" ");
24
39
  }
25
40
 
41
+ function offsetToCssValue(value: number | string | undefined) {
42
+ if (typeof value === "number") {
43
+ return `${value}px`;
44
+ }
45
+ return value ?? "0px";
46
+ }
47
+
26
48
  export function SymbolIconButton({
27
49
  label,
28
50
  symbolName,
@@ -31,6 +53,7 @@ export function SymbolIconButton({
31
53
  disabled,
32
54
  isLoading,
33
55
  iconSizePx = 18,
56
+ opticalOffset,
34
57
  symbolEnabled = true,
35
58
  className,
36
59
  style,
@@ -42,6 +65,13 @@ export function SymbolIconButton({
42
65
  enabled: symbolEnabled,
43
66
  });
44
67
  const glyphPx = `${iconSizePx}px`;
68
+ const resolvedOpticalOffset = opticalOffset ?? DEFAULT_SYMBOL_OPTICAL_OFFSETS[symbolName];
69
+ const iconStyle = {
70
+ width: glyphPx,
71
+ height: glyphPx,
72
+ "--hd-mac-symbol-offset-x": offsetToCssValue(resolvedOpticalOffset?.x),
73
+ "--hd-mac-symbol-offset-y": offsetToCssValue(resolvedOpticalOffset?.y),
74
+ } as CSSProperties;
45
75
 
46
76
  return (
47
77
  <MacTooltip.Root>
@@ -70,8 +100,7 @@ export function SymbolIconButton({
70
100
  aria-hidden
71
101
  className="hd-mac-symbol-icon hd-mac-symbol-icon-mask"
72
102
  style={{
73
- width: glyphPx,
74
- height: glyphPx,
103
+ ...iconStyle,
75
104
  color: "currentColor",
76
105
  backgroundColor: "currentColor",
77
106
  WebkitMaskImage: `url("${symbolDataUrl}")`,
@@ -89,8 +118,7 @@ export function SymbolIconButton({
89
118
  aria-hidden
90
119
  className="hd-mac-symbol-icon hd-mac-symbol-icon-fallback"
91
120
  style={{
92
- width: glyphPx,
93
- height: glyphPx,
121
+ ...iconStyle,
94
122
  fontSize: glyphPx,
95
123
  }}
96
124
  >
@@ -297,6 +297,7 @@
297
297
  flex-shrink: 0;
298
298
  margin: auto;
299
299
  transform-origin: center;
300
+ translate: var(--hd-mac-symbol-offset-x, 0px) var(--hd-mac-symbol-offset-y, 0px);
300
301
  }
301
302
 
302
303
  .hd-mac-symbol-icon-mask {