Skip to content

Commit

Permalink
Use FF detection not for P3 but for error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Jan 17, 2024
1 parent 8d7e866 commit 2a56c80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 1 addition & 4 deletions stores/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ export let support = map<SupportValue>({
})

if (typeof window !== 'undefined') {
// FF can’t display P3 yet. Remove when this issue will be resolved.
// https://bugzilla.mozilla.org/show_bug.cgi?id=1626624
let isFF = navigator.userAgent.toLowerCase().includes('firefox')
if (CSS.supports('color', 'color(display-p3 1 1 1)') && !isFF) {
if (CSS.supports('color', 'color(display-p3 1 1 1)')) {
let media = window.matchMedia('(color-gamut:p3)')
support.set({ oklch: true, p3: media.matches })
media.addEventListener('change', () => {
Expand Down
7 changes: 6 additions & 1 deletion view/sample/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ let fallbackNote = document.querySelector<HTMLButtonElement>(
'.sample_fallback .sample_note'
)!

let postfix = support.get().oklch ? ' on this monitor' : ' in this browser'
// FF can’t display P3 yet. Remove when this issue will be resolved.
// https://bugzilla.mozilla.org/show_bug.cgi?id=1626624
let isFF = navigator.userAgent.toLowerCase().includes('firefox')

let postfix =
!isFF && support.get().oklch ? ' on this monitor' : ' in this browser'

visible.subscribe(({ fallback, real, space }) => {
sample.classList.toggle('is-srgb', space === 'srgb')
Expand Down

0 comments on commit 2a56c80

Please sign in to comment.