diff --git a/.changeset/mighty-pugs-flow.md b/.changeset/mighty-pugs-flow.md new file mode 100644 index 00000000000..8276383fc76 --- /dev/null +++ b/.changeset/mighty-pugs-flow.md @@ -0,0 +1,5 @@ +--- +'@primer/react': minor +--- + +PageHeader: Update the layout styles to make it compatible with the new recommended dom ordering by keeping the visual design same. This is a breaking change however PageHeader is still a draft component so we are releasing the changes as minor. diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-colorblind-linux.png index fb4c87c11a3..3ae091e796b 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-colorblind-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-dimmed-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-dimmed-linux.png index 4ddb7579d4d..f877dd325c3 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-dimmed-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-dimmed-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-high-contrast-linux.png index d363107169f..1d0452ac56f 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-high-contrast-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-linux.png index 57c25a6bb6c..6e18eb8738a 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-tritanopia-linux.png index fb4c87c11a3..3ae091e796b 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-tritanopia-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-dark-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-colorblind-linux.png index eb4761bbc74..724c1c0b40e 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-colorblind-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-high-contrast-linux.png index 1396f518461..f166f564039 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-high-contrast-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-linux.png index da40e47155f..ef51d9504f5 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-tritanopia-linux.png index eb4761bbc74..724c1c0b40e 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-tritanopia-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-light-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-colorblind-linux.png index fb4c87c11a3..3ae091e796b 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-colorblind-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-dimmed-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-dimmed-linux.png index 4ddb7579d4d..f877dd325c3 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-dimmed-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-dimmed-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-high-contrast-linux.png index d363107169f..1d0452ac56f 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-high-contrast-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-linux.png index 57c25a6bb6c..6e18eb8738a 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-tritanopia-linux.png index fb4c87c11a3..3ae091e796b 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-tritanopia-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-dark-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-colorblind-linux.png index eb4761bbc74..724c1c0b40e 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-colorblind-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-high-contrast-linux.png index 1396f518461..f166f564039 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-high-contrast-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-linux.png index da40e47155f..ef51d9504f5 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-tritanopia-linux.png index eb4761bbc74..724c1c0b40e 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-tritanopia-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Files-Page-on-Narrow-Viewport-light-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-colorblind-linux.png new file mode 100644 index 00000000000..3e4fa9cd396 Binary files /dev/null and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-dimmed-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-dimmed-linux.png new file mode 100644 index 00000000000..8f62c1110e8 Binary files /dev/null and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-dimmed-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-high-contrast-linux.png new file mode 100644 index 00000000000..524f7ab4b42 Binary files /dev/null and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-linux.png new file mode 100644 index 00000000000..c0acd39457b Binary files /dev/null and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-tritanopia-linux.png new file mode 100644 index 00000000000..3e4fa9cd396 Binary files /dev/null and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-dark-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-light-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-light-colorblind-linux.png new file mode 100644 index 00000000000..3ec14d50357 Binary files /dev/null and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-light-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-light-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-light-high-contrast-linux.png new file mode 100644 index 00000000000..197b16c86d4 Binary files /dev/null and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-light-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-light-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-light-linux.png new file mode 100644 index 00000000000..2fbca858173 Binary files /dev/null and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-light-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-light-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-light-tritanopia-linux.png new file mode 100644 index 00000000000..3ec14d50357 Binary files /dev/null and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Large-Variant-with-Multiline-Title-light-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-colorblind-linux.png index 122b3fac8da..6ac42523150 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-colorblind-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-dimmed-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-dimmed-linux.png index e2e5c20535b..79510610f0d 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-dimmed-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-dimmed-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-high-contrast-linux.png index 3a9ee1b4a2e..698c496af4b 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-high-contrast-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-linux.png index 7cd0a615f62..302e81dce68 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-tritanopia-linux.png index d96ed482ba5..14d80f8020f 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-tritanopia-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-dark-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-colorblind-linux.png index f23d0f77b7c..02aaf375eb1 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-colorblind-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-high-contrast-linux.png index b87e3f1c719..25e06de1782 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-high-contrast-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-linux.png index 9e6aaf2805f..a2929b08f00 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-tritanopia-linux.png index facc86b63ce..09a4559f2ca 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-tritanopia-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-light-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-colorblind-linux.png index 122b3fac8da..6ac42523150 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-colorblind-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-dimmed-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-dimmed-linux.png index e2e5c20535b..79510610f0d 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-dimmed-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-dimmed-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-high-contrast-linux.png index 3a9ee1b4a2e..698c496af4b 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-high-contrast-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-linux.png index 7cd0a615f62..302e81dce68 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-tritanopia-linux.png index d96ed482ba5..14d80f8020f 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-tritanopia-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-dark-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-colorblind-linux.png index f23d0f77b7c..02aaf375eb1 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-colorblind-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-high-contrast-linux.png index b87e3f1c719..25e06de1782 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-high-contrast-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-linux.png index 9e6aaf2805f..a2929b08f00 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-tritanopia-linux.png index facc86b63ce..09a4559f2ca 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-tritanopia-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-Pull-Request-Page-on-Narrow-Viewport-light-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-colorblind-linux.png index a48ccf8b16e..244d78d37f7 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-colorblind-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-dimmed-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-dimmed-linux.png index 3751c490481..7fda017543c 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-dimmed-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-dimmed-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-high-contrast-linux.png index 6e62e4d84a3..10948550911 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-high-contrast-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-linux.png index 54be0fe3fbd..ab7436289f3 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-tritanopia-linux.png index a48ccf8b16e..244d78d37f7 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-tritanopia-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-dark-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-colorblind-linux.png index 5d7cbce8a95..d9d5648d19b 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-colorblind-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-high-contrast-linux.png index 0b26ac05bbe..baa255dd1e9 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-high-contrast-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-linux.png index e001f993cb6..65890f3ec93 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-tritanopia-linux.png index 5d7cbce8a95..d9d5648d19b 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-tritanopia-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Description-Slot-light-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-colorblind-linux.png index bb85294eb08..1189f37b75a 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-colorblind-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-dimmed-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-dimmed-linux.png index 1f8a8ba8573..82faa4ba149 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-dimmed-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-dimmed-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-high-contrast-linux.png index 0dd41bd0261..db6ad5eb989 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-high-contrast-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-linux.png index 81bff546325..72336fb86da 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-tritanopia-linux.png index 0aaba0effb4..b73d823ea25 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-tritanopia-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-dark-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-colorblind-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-colorblind-linux.png index 31541b70283..ee1d7ced68e 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-colorblind-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-high-contrast-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-high-contrast-linux.png index 7c739735eb3..fbb8f752b05 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-high-contrast-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-linux.png index 6ea202b82cf..43a8ff2a590 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-linux.png differ diff --git a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-tritanopia-linux.png b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-tritanopia-linux.png index af9b4208bb3..edbae8374e0 100644 Binary files a/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-tritanopia-linux.png and b/.playwright/snapshots/components/PageHeader.test.ts-snapshots/PageHeader-With-Page-Layout-light-tritanopia-linux.png differ diff --git a/e2e/components/PageHeader.test.ts b/e2e/components/PageHeader.test.ts index e19dddf0b30..577e6a3e906 100644 --- a/e2e/components/PageHeader.test.ts +++ b/e2e/components/PageHeader.test.ts @@ -673,4 +673,38 @@ test.describe('PageHeader', () => { }) } }) + + test.describe('Large Variant with Multiline Title', () => { + for (const theme of themes) { + test.describe(theme, () => { + test('default @vrt', async ({page}) => { + await visit(page, { + id: 'drafts-components-pageheader-devonly--large-variant-with-multiline-title', + globals: { + colorScheme: theme, + }, + }) + + // Default state + expect(await page.screenshot()).toMatchSnapshot(`PageHeader.Large Variant with Multiline Title.${theme}.png`) + }) + + test('axe @aat', async ({page}) => { + await visit(page, { + id: 'drafts-components-pageheader-devonly--large-variant-with-multiline-title', + globals: { + colorScheme: theme, + }, + }) + await expect(page).toHaveNoViolations({ + rules: { + 'color-contrast': { + enabled: theme !== 'dark_dimmed', + }, + }, + }) + }) + }) + } + }) }) diff --git a/script/generate-e2e-tests.js b/script/generate-e2e-tests.js index 484e0f90814..51e91333e26 100644 --- a/script/generate-e2e-tests.js +++ b/script/generate-e2e-tests.js @@ -871,6 +871,10 @@ const components = new Map([ id: 'drafts-components-pageheader-features--with-parent-link-and-actions-of-context-area', name: 'With Parent Link and Actions of Context Area', }, + { + id: 'drafts-components-pageheader-devonly--large-variant-with-multiline-title', + name: 'Large Variant with Multiline Title', + }, ], }, ], diff --git a/src/PageHeader/PageHeader.dev.stories.tsx b/src/PageHeader/PageHeader.dev.stories.tsx new file mode 100644 index 00000000000..b2510669467 --- /dev/null +++ b/src/PageHeader/PageHeader.dev.stories.tsx @@ -0,0 +1,43 @@ +import React from 'react' +import {Meta} from '@storybook/react' +import {Button, IconButton, Box} from '..' +import Label from '../Label' +import {GitBranchIcon, PencilIcon, SidebarExpandIcon} from '@primer/octicons-react' + +import {PageHeader} from './PageHeader' + +export default { + title: 'Drafts/Components/PageHeader/DevOnly', + parameters: { + layout: 'fullscreen', + controls: {expanded: true}, + }, +} as Meta + +export const LargeVariantWithMultilineTitle = () => ( + + + + + + + + + + + Title long title some extra loooong looong words here some extra loooong looong words here some extra loooong + looong words here some extra loooong looong words here some extra loooong looong words here + + + + + + + + + + + + + +) diff --git a/src/PageHeader/PageHeader.examples.stories.tsx b/src/PageHeader/PageHeader.examples.stories.tsx index e8f1d116a37..2c2a582a335 100644 --- a/src/PageHeader/PageHeader.examples.stories.tsx +++ b/src/PageHeader/PageHeader.examples.stories.tsx @@ -12,6 +12,7 @@ import { ArrowRightIcon, TriangleDownIcon, CheckIcon, + CopyIcon, } from '@primer/octicons-react' import {PageHeader} from './PageHeader' @@ -19,7 +20,6 @@ import {Hidden} from '../Hidden' import {UnderlineNav} from '../UnderlineNav' import {ActionMenu} from '../ActionMenu' import {ActionList} from '../ActionList' -import VisuallyHidden from '../_VisuallyHidden' const meta: Meta = { title: 'Drafts/Components/PageHeader/Examples', @@ -38,22 +38,24 @@ const setViewportParamToNarrow = { export const Webhooks = () => ( - - Repository settings - Webhooks - - - - - - - - - - + + Repository settings + context bar + + + + + + + + + + + + ) @@ -67,36 +69,35 @@ WebhooksOnNarrowViewport.parameters = setViewportParamToNarrow export const PullRequestPage = () => ( - - Pull requests - PageHeader component initial layout explorations extra long pull request title - - - - - - - - - alert('Edit button action')}>Edit - alert('Code button action')}>Code - - - - - - - - - - - - + + Pull requests + + + + + + + + + + alert('Edit button action')}>Edit + alert('Code button action')}>Code + + + + + + + + + + + Open @@ -145,8 +146,15 @@ PullRequestPageOnNarrowViewport.parameters = setViewportParamToNarrow export const FilesPage = () => ( + + / + + PageHeader.tsx + + + - Files + Files @@ -209,60 +217,63 @@ export const FilesPage = () => ( - + {/* This is a hack for now. Breadcrumbs are not leading visuals but for now we are displaying them as leading action until we find a better solution. */} + + + + + + + + + + + + + + alert('Download')}>Download + + + alert('Jump to line')}> + Jump to line + L + + + alert('Copy path')}> + Copy path + ⌘⇧. + + alert('Copy permalink')}> + Copy permalink + ⌘⇧, + + + + alert('Show code folding buttons')}> + Show code folding buttons - - - - - + alert('Wrap lines')}>Wrap lines + alert('Center content')}>Center content + + + alert('Delete file clicked')}> + Delete file + ⌘D + + + + + ) @@ -276,38 +287,38 @@ export const WithPageLayout = () => { - - Pull requests - PageHeader component initial layout explorations extra long pull request title   #1831 - - - {/* Pop up actions */} - - - - - - - alert('Edit button action')}>Edit - alert('Code button action')}>Code - - - - - - - - - - - - + + Pull requests + + + + {/* Pop up actions */} + + + + + + + alert('Edit button action')}>Edit + alert('Code button action')}>Code + + + + + + + + + + + + Open @@ -354,6 +365,7 @@ export const WithPageLayout = () => { Assignees + No one — - - + + + + + + ) export const WithDescriptionSlot = () => ( - - add-pageheader-docs - - - - - broccolinisoup - {' '} - created this branch 5 days ago · 14 commits · updated today - - + + + add-pageheader-docs + + + + + broccolinisoup + {' '} + created this branch 5 days ago · 14 commits · updated today + + + ) @@ -194,14 +175,14 @@ export const WithLeadingAndTrailingActions = () => ( - - - Title - - - + + + + + + ) @@ -209,6 +190,9 @@ export const WithLeadingAndTrailingActions = () => ( export const WithParentLinkAndActionsOfContextArea = () => ( + + Title + Parent Link @@ -219,9 +203,6 @@ export const WithParentLinkAndActionsOfContextArea = () => ( - - Title - ) @@ -235,6 +216,9 @@ WithParentLinkAndActionsOfContextArea.parameters = { export const WithContextBarAndActionsOfContextArea = () => ( + + Title + @@ -255,9 +239,6 @@ export const WithContextBarAndActionsOfContextArea = () => ( - - Title - ) @@ -272,15 +253,15 @@ export const WithActionsThatHaveResponsiveContent = () => ( Webhooks - - - - - - - - + + + + + + + + ) diff --git a/src/PageHeader/PageHeader.stories.tsx b/src/PageHeader/PageHeader.stories.tsx index b9b4921872d..12601d26c4c 100644 --- a/src/PageHeader/PageHeader.stories.tsx +++ b/src/PageHeader/PageHeader.stories.tsx @@ -186,6 +186,21 @@ export default { export const Playground: Story = args => ( + + + + + - - - - - - - + + + + + ) } @@ -246,22 +346,27 @@ const LeadingAction: React.FC> = ({ sx = {}, hidden = hiddenOnNarrow, }) => { - const {titleAreaHeight} = React.useContext(TitleAreaContext) - + const style: CSSCustomProperties = {} + // @ts-ignore sx has height attribute + const {height} = sx + if (height) style['--custom-height'] = height return ( ( { + gridRow: GRID_ROW_ORDER.LeadingAction, + gridArea: 'leading-action', + paddingRight: '0.5rem', display: 'flex', - order: TITLE_AREA_REGION_ORDER.LeadingAction, ...getBreakpointDeclarations(hidden, 'display', value => { return value ? 'none' : 'flex' }), alignItems: 'center', - height: titleAreaHeight, }, sx, )} + style={style} > {children} @@ -270,21 +375,26 @@ const LeadingAction: React.FC> = ({ // PageHeader.LeadingVisual and PageHeader.TrailingVisual should remain visible on narrow viewports. const LeadingVisual: React.FC> = ({children, sx = {}, hidden = false}) => { - const {titleAreaHeight} = React.useContext(TitleAreaContext) + const style: CSSCustomProperties = {} + // @ts-ignore sx has height attribute + const {height} = sx + if (height) style['--custom-height'] = height return ( ( { + // using flex and order to display the leading visual in the title area. display: 'flex', order: TITLE_AREA_REGION_ORDER.LeadingVisual, ...getBreakpointDeclarations(hidden, 'display', value => { return value ? 'none' : 'flex' }), alignItems: 'center', - height: titleAreaHeight, }, sx, )} + style={style} > {children} @@ -296,32 +406,25 @@ export type TitleProps = { } & ChildrenPropTypes const Title: React.FC> = ({children, sx = {}, hidden = false, as = 'h2'}) => { - const {titleVariant} = React.useContext(TitleAreaContext) + const style: CSSCustomProperties = {} + // @ts-ignore sxProp can have color attribute + const {fontSize, lineHeight, fontWeight} = sx + if (fontSize) style['--custom-font-size'] = fontSize + if (lineHeight) style['--custom-line-height'] = lineHeight + if (fontWeight) style['--custom-font-weight'] = fontWeight + return ( ( { - fontSize: { - large: '2rem', - medium: '1.25rem', - subtitle: '1.25rem', - }[titleVariant], - // line-height is calculated with calc(height/font-size) and the below numbers are from @primer/primitives - lineHeight: { - large: 1.5, // calc(48/32) - medium: 1.6, // calc(32/20) - subtitle: 1.6, // calc(32/20) - }[titleVariant], - fontWeight: { - large: '400', - medium: '600', - subtitle: '400', - }[titleVariant], + // using flex and order to display the title in the title area. display: 'flex', order: TITLE_AREA_REGION_ORDER.Title, ...getBreakpointDeclarations(hidden, 'display', value => { - return value ? 'none' : 'flex' + return value ? 'none' : 'block' }), }, sx, @@ -334,22 +437,26 @@ const Title: React.FC> = ({children, sx = {} // PageHeader.LeadingVisual and PageHeader.TrailingVisual should remain visible on narrow viewports. const TrailingVisual: React.FC> = ({children, sx = {}, hidden = false}) => { - const {titleAreaHeight} = React.useContext(TitleAreaContext) - + const style: CSSCustomProperties = {} + // @ts-ignore sx has height attribute + const {height} = sx + if (height) style['--custom-height'] = height return ( ( { + // using flex and order to display the trailing visual in the title area. display: 'flex', order: TITLE_AREA_REGION_ORDER.TrailingVisual, ...getBreakpointDeclarations(hidden, 'display', value => { return value ? 'none' : 'flex' }), alignItems: 'center', - height: titleAreaHeight, }, sx, )} + style={style} > {children} @@ -361,22 +468,27 @@ const TrailingAction: React.FC> = ({ sx = {}, hidden = hiddenOnNarrow, }) => { - const {titleAreaHeight} = React.useContext(TitleAreaContext) - + const style: CSSCustomProperties = {} + // @ts-ignore sx has height attribute + const {height} = sx + if (height) style['--custom-height'] = height return ( ( { + gridRow: GRID_ROW_ORDER.TrailingAction, + gridArea: 'trailing-action', + paddingLeft: '0.5rem', display: 'flex', - order: TITLE_AREA_REGION_ORDER.TrailingAction, ...getBreakpointDeclarations(hidden, 'display', value => { return value ? 'none' : 'flex' }), alignItems: 'center', - height: titleAreaHeight, }, sx, )} + style={style} > {children} @@ -384,25 +496,31 @@ const TrailingAction: React.FC> = ({ } const Actions: React.FC> = ({children, sx = {}, hidden = false}) => { - const {titleAreaHeight} = React.useContext(TitleAreaContext) + const style: CSSCustomProperties = {} + // @ts-ignore sx has height attribute + const {height} = sx + if (height) style['--custom-height'] = height return ( ( { + gridRow: GRID_ROW_ORDER.Actions, + gridArea: 'actions', display: 'flex', - order: TITLE_AREA_REGION_ORDER.Actions, ...getBreakpointDeclarations(hidden, 'display', value => { return value ? 'none' : 'flex' }), flexDirection: 'row', + paddingLeft: '0.5rem', gap: '0.5rem', flexGrow: '1', justifyContent: 'right', - height: titleAreaHeight, alignItems: 'center', }, sx, )} + style={style} > {children} @@ -415,13 +533,15 @@ const Description: React.FC> = ({chil ( { + gridRow: GRID_ROW_ORDER.Description, + gridArea: 'description', display: 'flex', - order: REGION_ORDER.Description, ...getBreakpointDeclarations(hidden, 'display', value => { return value ? 'none' : 'flex' }), flexDirection: 'row', alignItems: 'center', + paddingTop: '0.5rem', gap: '0.5rem', }, sx, @@ -447,15 +567,11 @@ const Navigation: React.FC> = ({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, }) => { - // TODO: use warning utility function when it is merged https://github.com/primer/react/pull/2901/ - if (__DEV__) { - if (as === 'nav' && !ariaLabel && !ariaLabelledBy) { - // eslint-disable-next-line no-console - console.warn( - 'Use `aria-label` or `aria-labelledby` prop to provide an accessible label to the `nav` landmark for assistive technology', - ) - } - } + warning( + as === 'nav' && !ariaLabel && !ariaLabelledBy, + 'Use `aria-label` or `aria-labelledby` prop to provide an accessible label to the `nav` landmark for assistive technology', + ) + return ( > = ({ aria-labelledby={as === 'nav' ? ariaLabelledBy : undefined} sx={merge( { + gridRow: GRID_ROW_ORDER.Navigation, + gridArea: 'navigation', + paddingTop: '0.5rem', display: 'flex', - order: REGION_ORDER.Navigation, ...getBreakpointDeclarations(hidden, 'display', value => { return value ? 'none' : 'block' }), @@ -482,8 +600,8 @@ export const PageHeader = Object.assign(Root, { ContextArea, ParentLink, ContextBar, - ContextAreaActions, TitleArea, + ContextAreaActions, LeadingAction, LeadingVisual, Title, @@ -493,3 +611,5 @@ export const PageHeader = Object.assign(Root, { Description, Navigation, }) + +PageHeader.displayName = 'PageHeader' diff --git a/src/PageHeader/__snapshots__/PageHeader.test.tsx.snap b/src/PageHeader/__snapshots__/PageHeader.test.tsx.snap index 6094c0b4893..5aae3666622 100644 --- a/src/PageHeader/__snapshots__/PageHeader.test.tsx.snap +++ b/src/PageHeader/__snapshots__/PageHeader.test.tsx.snap @@ -1,18 +1,74 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`PageHeader renders default layout 1`] = ` +exports[`PageHeader renders consistently 1`] = ` .c0 { + display: grid; + grid-template-columns: auto auto auto 1fr; + grid-template-areas: 'context-area context-area context-area context-area' 'leading-action title-area trailing-action actions' 'description description description description' 'navigation navigation navigation navigation'; +} + +.c0[data-size-variant="large"] [data-component="PH_LeadingAction"], +.c0[data-size-variant="large"] [data-component="PH_TrailingAction"], +.c0[data-size-variant="large"] [data-component="PH_Actions"], +.c0[data-size-variant="large"] [data-component="PH_LeadingVisual"], +.c0[data-size-variant="large"] [data-component="PH_TrailingVisual"] { + height: var(--custom-height,3rem); +} + +.c0[data-size-variant="medium"] [data-component="PH_LeadingAction"], +.c0[data-size-variant="medium"] [data-component="PH_TrailingAction"], +.c0[data-size-variant="medium"] [data-component="PH_Actions"], +.c0[data-size-variant="medium"] [data-component="PH_LeadingVisual"], +.c0[data-size-variant="medium"] [data-component="PH_TrailingVisual"] { + height: var(--custom-height,2rem); +} + +.c0[data-size-variant="subtitle"] [data-component="PH_LeadingAction"], +.c0[data-size-variant="subtitle"] [data-component="PH_TrailingAction"], +.c0[data-size-variant="subtitle"] [data-component="PH_Actions"], +.c0[data-size-variant="subtitle"] [data-component="PH_LeadingVisual"], +.c0[data-size-variant="subtitle"] [data-component="PH_TrailingVisual"] { + height: var(--custom-height,2rem); +} + +.c1 { + grid-row: 2; + grid-area: title-area; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; gap: 0.5rem; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: flex-start; + -webkit-box-align: flex-start; + -ms-flex-align: flex-start; + align-items: flex-start; } -.c1 { +.c1[data-size-variant="large"] [data-component="PH_Title"] { + font-size: var(--custom-font-size,var(--text-title-size-large,2rem)); + line-height: var(--custom-line-height,var(--text-title-lineHeight-large,1.5)); + font-weight: var(--custom-font-weight,var(--base-text-weight-normal,400)); +} + +.c1[data-size-variant="medium"] [data-component="PH_Title"] { + font-size: var(--custom-font-size,var(--text-title-size-medium,1.25rem)); + line-height: var(--custom-line-height,var(--text-title-lineHeight-medium,1.6)); + font-weight: var(--custom-font-weight,var(--base-text-weight-semibold,600)); +} + +.c1[data-size-variant="subtitle"] [data-component="PH_Title"] { + font-size: var(--custom-font-size,var(--text-title-size-medium,1.25rem)); + line-height: var(--custom-line-height,var(--text-title-lineHeight-medium,1.6)); + font-weight: var(--custom-font-weight,var(--base-text-weight-normal,400)); +} + +.c2 { + grid-row: 1; + grid-area: context-area; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -24,21 +80,110 @@ exports[`PageHeader renders default layout 1`] = ` -webkit-box-align: center; -ms-flex-align: center; align-items: center; + padding-bottom: 0.5rem; gap: 0.5rem; - -webkit-order: 0; - -ms-flex-order: 0; - order: 0; } -.c2 { +.c3 { + grid-row: 3; + grid-area: description; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + padding-top: 0.5rem; + gap: 0.5rem; +} + +.c4 { + grid-row: 4; + grid-area: navigation; + padding-top: 0.5rem; + display: block; +} + +@media screen and (max-width:calc(768px - 0.02px)) { + .c2 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + } +} + +@media screen and (min-width:768px) { + .c2 { + display: none; + } +} + +
+
+
+
+
+
+`; + +exports[`PageHeader renders default layout 1`] = ` +.c0 { + display: grid; + grid-template-columns: auto auto auto 1fr; + grid-template-areas: 'context-area context-area context-area context-area' 'leading-action title-area trailing-action actions' 'description description description description' 'navigation navigation navigation navigation'; +} + +.c0[data-size-variant="large"] [data-component="PH_LeadingAction"], +.c0[data-size-variant="large"] [data-component="PH_TrailingAction"], +.c0[data-size-variant="large"] [data-component="PH_Actions"], +.c0[data-size-variant="large"] [data-component="PH_LeadingVisual"], +.c0[data-size-variant="large"] [data-component="PH_TrailingVisual"] { + height: var(--custom-height,3rem); +} + +.c0[data-size-variant="medium"] [data-component="PH_LeadingAction"], +.c0[data-size-variant="medium"] [data-component="PH_TrailingAction"], +.c0[data-size-variant="medium"] [data-component="PH_Actions"], +.c0[data-size-variant="medium"] [data-component="PH_LeadingVisual"], +.c0[data-size-variant="medium"] [data-component="PH_TrailingVisual"] { + height: var(--custom-height,2rem); +} + +.c0[data-size-variant="subtitle"] [data-component="PH_LeadingAction"], +.c0[data-size-variant="subtitle"] [data-component="PH_TrailingAction"], +.c0[data-size-variant="subtitle"] [data-component="PH_Actions"], +.c0[data-size-variant="subtitle"] [data-component="PH_LeadingVisual"], +.c0[data-size-variant="subtitle"] [data-component="PH_TrailingVisual"] { + height: var(--custom-height,2rem); +} + +.c1 { + grid-row: 2; + grid-area: title-area; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; gap: 0.5rem; - -webkit-order: 1; - -ms-flex-order: 1; - order: 1; -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; @@ -48,14 +193,49 @@ exports[`PageHeader renders default layout 1`] = ` align-items: flex-start; } +.c1[data-size-variant="large"] [data-component="PH_Title"] { + font-size: var(--custom-font-size,var(--text-title-size-large,2rem)); + line-height: var(--custom-line-height,var(--text-title-lineHeight-large,1.5)); + font-weight: var(--custom-font-weight,var(--base-text-weight-normal,400)); +} + +.c1[data-size-variant="medium"] [data-component="PH_Title"] { + font-size: var(--custom-font-size,var(--text-title-size-medium,1.25rem)); + line-height: var(--custom-line-height,var(--text-title-lineHeight-medium,1.6)); + font-weight: var(--custom-font-weight,var(--base-text-weight-semibold,600)); +} + +.c1[data-size-variant="subtitle"] [data-component="PH_Title"] { + font-size: var(--custom-font-size,var(--text-title-size-medium,1.25rem)); + line-height: var(--custom-line-height,var(--text-title-lineHeight-medium,1.6)); + font-weight: var(--custom-font-weight,var(--base-text-weight-normal,400)); +} + +.c2 { + grid-row: 1; + grid-area: context-area; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + padding-bottom: 0.5rem; + gap: 0.5rem; +} + .c3 { + grid-row: 3; + grid-area: description; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; - -webkit-order: 2; - -ms-flex-order: 2; - order: 2; -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; @@ -63,18 +243,19 @@ exports[`PageHeader renders default layout 1`] = ` -webkit-box-align: center; -ms-flex-align: center; align-items: center; + padding-top: 0.5rem; gap: 0.5rem; } .c4 { + grid-row: 4; + grid-area: navigation; + padding-top: 0.5rem; display: block; - -webkit-order: 3; - -ms-flex-order: 3; - order: 3; } @media screen and (max-width:calc(768px - 0.02px)) { - .c1 { + .c2 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -83,7 +264,7 @@ exports[`PageHeader renders default layout 1`] = ` } @media screen and (min-width:768px) { - .c1 { + .c2 { display: none; } } @@ -91,16 +272,19 @@ exports[`PageHeader renders default layout 1`] = `
- ContextArea + TitleArea
- TitleArea + ContextArea