Skip to content

feat: support badges on toolbar buttons - #76

Merged
rdlabo merged 10 commits into
mainfrom
feat/toolbar-button-badge
Nov 16, 2026
Merged

rdlabo merged 10 commits into
mainfrom
feat/toolbar-button-badge

Conversation

@rdlabo

@rdlabo rdlabo commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Direct-child ion-badge elements now overlay Material 3 toolbar buttons without changing the button layout. Standalone buttons and ion-buttons groups support empty, numeric and wide badges. Styling stays in ion-button.scss, scoped to toolbar buttons with a direct badge child and preserving theme opt-outs, Ionic colors and CSS-hidden states.

Usage and live standalone/grouped previews are in demo Docs / Special markup, generated from docs/special-markup.md. The comparison demo is reachable from Index and includes a back action. Existing image regression covers light/dark and device palettes, LTR/RTL and unaffected outside/nested badges. No separate JavaScript unit or dimension tests were added.

The native comparison uses Material Components 1.13.0 MaterialToolbar with the toolbar overload of BadgeUtils.attachBadgeDrawable, including its clipping offsets. The 6dp empty indicator is centered +9/-9dp from the icon center; the 16dp numeric badge is centered +8/-8dp.

Validation: final PR CI passed, including Ionic 8/9 screenshot regression, lint and package checks. The four new baseline images were generated by the repository's Linux CI update workflow; unrelated baselines remain unchanged.

Related: webview-native-ui/capacitor-plugin#26 and webview-native-ui/capacitor-plugin#57.

Linux CI baseline: Material 3 light

Linux CI baseline: Material 3 dark

Native MaterialToolbar badge geometry reference

@rdlabo

rdlabo commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

/update-screenshots

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Playwright test results

passed  286 passed

Details

stats  286 tests across 18 suites
duration  3 minutes, 30 seconds
commit  31b6c97
info  This detailed result covers Ionic 9 only. Ionic 8 runs against the same screenshots in a separate matrix job; check the workflow run for both results. To update the screenshots, comment with /update-screenshots.

github-actions Bot added a commit that referenced this pull request Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

📊 Ionic 9 Playwright Test Report

View the detailed Ionic 9 report: https://webview-native-ui.github.io/ionic-theme-md3/pr-76/

Ionic 8 runs against the same screenshots in a separate matrix job. View both results in the workflow run.

@rdlabo

rdlabo commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

/update-screenshots

@devin-ai-integration

Copy link
Copy Markdown
Contributor

レビュー

方針(CSSだけでの直下 ion-badge オーバーレイ、opt-out の維持、tabs や入れ子は対象外)は妥当です。マージ前に次を直す必要があります。

1. CI lint が落ちている(要修正)

demo/src/app/docs/docs-page.component.spec.ts:28 で figure.docs-example を固定数で数えており、docs/special-markup.md に html preview を2つ足したので expected 8 to be 6 で失敗しています。期待値を 8 に更新してください。

2. スクリーンショットのベースラインが未コミット

toolbar-badge ルートの4件(light / dark / device light / device dark)は、ベースラインがないので失敗しています。docs コミットの後にも /update-screenshots が投稿されていますが、PNG のコミットはまだ届いていません。1 を直してから再実行が必要です。

3. docs の「display: none で隠せる」がアプリ側の CSS では成り立たない

ion-toolbar-badge.scss のバッジには、詳細度の高いセレクタ(ion-toolbar.md:not(...) ion-button.md:has(...):not(...):not(...) > ion-badge:not(...))で display: block が付いています。このため、アプリ側の .badge-off { display: none; } のような通常のクラス指定は負けて、バッジが表示されたままになります。隠せるのは hidden、インライン style、!important だけです。

  • 対応案 A: docs から display: none を外し、hidden か要素の削除に絞る。
  • 対応案 B: display: block は Ionic の :host(:empty) { display: none } を打ち消すためだけに必要なので、:empty 側だけに置く。あるいは :where() で詳細度を下げる。

4. (軽微)空白を含む空バッジは :empty にマッチしない

<ion-badge>\n</ion-badge> のように、フォーマッタで改行が入ったマークアップでは :empty が効きません(現行ブラウザは空白だけのテキストを empty とみなしません)。6dp のドットにならず、文字のない 16dp のピルになります。docs に「中身を完全に空にする」と一言あると親切です。

ネイティブ側の描画は capacitor-plugin#26 に依存している点は、description の記載どおりで理解しています。

Written by Devin

github-actions Bot added a commit that referenced this pull request Nov 16, 2026
@rdlabo

rdlabo commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Devinのレビューへの対応です。

  1. Docsの既存テストのpreview数を6→8へ修正しました。既存のdemoテストは33ファイル・75テストが成功しています。
  2. 正式な基準画像は既存のLinux CI更新フローで生成します。今回の修正をpushしたため、4件の更新を再実行します。添付はMacでの表示確認用で、基準画像には使用していません。
  3. 高詳細度の display: block を削除し、空バッジにだけ :where(...:empty) で display: inline-block を指定しました。通常の .badge-off { display: none; } が優先されます。既存の画像回帰用画面へ数値・空バッジ両方のCSS非表示例を追加し、表示を確認しました。
  4. demo DocsのSpecial markupに、空のindicatorはタグ内へ空白・改行を入れない旨を追記しました。

新しいユニットテストや寸法テストは追加していません。build・lintも成功しています。

MD3 light: CSSで数値バッジと空バッジを非表示

MD3 dark: CSS非表示とRTL配置

@rdlabo

rdlabo commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

/update-screenshots

@rdlabo

rdlabo commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

/update-screenshots

@rdlabo

rdlabo commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

補足: バッジの装飾はbuttonの責務に留め、ion-button.scssへ直接記述しました。別モジュールを削除し、utilsへの抽出は行っていません。build・lintも再確認済みです。

github-actions Bot added a commit that referenced this pull request Nov 16, 2026
github-actions Bot added a commit that referenced this pull request Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❌ Failed to update screenshots.

Please check the workflow run for details.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Screenshots have been updated successfully!

The new screenshots have been committed to this PR.

github-actions Bot added a commit that referenced this pull request Nov 16, 2026
github-actions Bot added a commit that referenced this pull request Nov 16, 2026
@rdlabo

rdlabo commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

/update-screenshots

@github-actions

Copy link
Copy Markdown
Contributor

✅ Screenshots have been updated successfully!

The new screenshots have been committed to this PR.

github-actions Bot added a commit that referenced this pull request Nov 16, 2026
@rdlabo
rdlabo merged commit e697ec4 into main Nov 16, 2026
11 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

npm beta published

CI passed for the merge commit e697ec4ad734. Install the immutable version with:

npm install @rdlabo/ionic-theme-md3@9.2.2-beta.pr76.shae697ec4ad734

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant