MCPcopy Index your code
hub / github.com/github/docs / getColorModePreference

Function getColorModePreference

components/lib/events.ts:158–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

156}
157
158function getColorModePreference() {
159 // color mode is set as attributes on <body>, we'll use that information
160 // along with media query checking rather than parsing the cookie value
161 // set by github.com
162 let color_mode_preference = document.querySelector('body')?.dataset.colorMode
163
164 if (color_mode_preference === 'auto') {
165 if (window.matchMedia('(prefers-color-scheme: light)').matches) {
166 color_mode_preference += ':light'
167 } else if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
168 color_mode_preference += ':dark'
169 }
170 }
171
172 return color_mode_preference
173}
174
175function getPerformance() {
176 const paint = performance

Callers 1

sendEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected