Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

Site: follows the system's light or dark mode until you pick one with the toggle

Eric Brownroutb92c0923d995
diff --git a/site/content/home.html b/site/content/home.html
index 5267ce43..f47ce421 100644
--- a/site/content/home.html
+++ b/site/content/home.html
@@ -2,8 +2,8 @@
<html data-theme="light" data-hero-entry="pending" lang="en"><head><meta charset="utf-8"/><meta content="width=device-width,initial-scale=1" name="viewport"/><title>Yogurt · AI meeting notes that stay on your computer</title><meta content="Yogurt takes meeting notes with AI that runs locally on Mac, Windows and Linux. No bot joins the call. Free and open source." name="description"/><link id="theme-icon" href="/marketing/assets/mark.svg" rel="icon" type="image/svg+xml" sizes="any"/><link id="theme-icon-png" href="/marketing/assets/favicon-32.png" rel="icon" type="image/png" sizes="32x32"/><link href="/marketing/assets/apple-touch-icon.png" rel="apple-touch-icon" sizes="180x180"/><link as="font" crossorigin="" href="/marketing/assets/bricolage-grotesque.ttf" rel="preload" type="font/ttf"/><noscript><style>html .fragment-art picture{opacity:1!important}html .hero-still{display:block!important}html .product-window{visibility:visible!important}html .signal-wings,html [data-hero-entry],html[data-hero-entry=pending] :is(.yc-pill,.hero-copy h1,.hero-copy p,.hero-actions,.product-window){visibility:visible!important}html .transcript-turn,html .stream-word,html .summary-reveal,html .summary-reveal.action-item>i,html .result-paper .ready-label,html .result-check,html .answer-result{opacity:1;filter:none;transform:none}html .result-paper .writing-label{opacity:0}html .process-art *,html .roster-asset *{animation:none;transition:none}</style></noscript><link href="https://yogurt.so/" rel="canonical"/><meta content="#ffffff" name="theme-color"/><script>
(function(){
- var theme='light';
- try{if(localStorage.getItem('yogurt-theme')==='dark')theme='dark'}catch{}
+ var theme=matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';
+ try{var saved=localStorage.getItem('yogurt-theme');if(saved==='light'||saved==='dark')theme=saved}catch{}
document.documentElement.dataset.theme=theme;
if(theme==='dark'){
document.querySelector('meta[name="theme-color"]').content='#1B1B1D';
diff --git a/site/public/marketing/theme.mjs b/site/public/marketing/theme.mjs
index 63db8488..48447de7 100644
--- a/site/public/marketing/theme.mjs
+++ b/site/public/marketing/theme.mjs
@@ -1,5 +1,8 @@
const root=document.documentElement;
const toggle=document.querySelector('.theme-toggle');
+const systemTheme=matchMedia('(prefers-color-scheme: dark)');
+let preference;
+try{const saved=localStorage.getItem('yogurt-theme');if(saved==='light'||saved==='dark')preference=saved}catch{}
export function syncFrameTheme(frame){
const frameRoot=frame.contentDocument?.documentElement;
@@ -25,9 +28,17 @@ function render(){
toggle.addEventListener('click',()=>{
root.classList.add('theme-switching');
root.dataset.theme=root.dataset.theme==='dark'?'light':'dark';
- try{localStorage.setItem('yogurt-theme',root.dataset.theme)}catch{}
+ preference=root.dataset.theme;
+ try{localStorage.setItem('yogurt-theme',preference)}catch{}
render();
requestAnimationFrame(()=>requestAnimationFrame(()=>root.classList.remove('theme-switching')));
});
+function followSystem(){
+ if(preference)return;
+ root.dataset.theme=systemTheme.matches?'dark':'light';
+ render();
+}
+systemTheme.addEventListener('change',followSystem);
+followSystem();
render();
toggle.hidden=false;
diff --git a/site/scripts/theme.test.mjs b/site/scripts/theme.test.mjs
index 6998f9f2..b8629468 100644
--- a/site/scripts/theme.test.mjs
+++ b/site/scripts/theme.test.mjs
@@ -7,15 +7,16 @@ const bootstrap=html.match(/<script>\s*(\(function\(\)[\s\S]*?)<\/script>/)[1];
const script=readFileSync(new URL('../public/marketing/theme.mjs',import.meta.url),'utf8').replace('export function','function');
assert.ok(html.indexOf(bootstrap)<html.indexOf('href="/marketing/site.css"'));
-function page(saved,{blocked=false,search=''}={}){
- const classes=new Set();
+function page(saved,{blocked=false,search='',systemDark=false}={}){
+ const classes=new Set(),listeners=[];
+ const media={matches:systemDark,addEventListener:(_name,fn)=>listeners.push(fn)};
const root={dataset:{theme:'light'},classList:{add:v=>classes.add(v),remove:v=>classes.delete(v)}};
const toggle={hidden:true,setAttribute(k,v){this[k]=v},addEventListener(k,fn){this[k]=fn}};
const meta={content:'#ffffff'},icon={},fallback={};
const frames=[false,true].map(hero=>({classList:{contains:()=>hero},contentDocument:{documentElement:{dataset:{},style:{}}}}));
const storage=new Map(saved===undefined?[]:[['yogurt-theme',saved]]);
const context=vm.createContext({
- URLSearchParams,location:{search},
+ URLSearchParams,location:{search},matchMedia:()=>media,
document:{documentElement:root,querySelector:s=>s==='.theme-toggle'?toggle:meta,
getElementById:id=>id==='theme-icon'?icon:fallback,querySelectorAll:()=>frames},
localStorage:{getItem(k){if(blocked)throw Error('denied');return storage.get(k)},setItem(k,v){if(blocked)throw Error('denied');storage.set(k,v)}},
@@ -26,12 +27,12 @@ function page(saved,{blocked=false,search=''}={}){
assert.equal(meta.content,initial==='dark'?'#1B1B1D':'#ffffff');
if(initial==='dark')assert.equal(icon.href,'/marketing/assets/mark-dark.svg');
vm.runInContext(script,context);
- return {root,toggle,meta,icon,fallback,frames,storage,context,initial};
+ return {root,toggle,meta,icon,fallback,frames,storage,context,initial,system(dark){media.matches=dark;listeners.forEach(fn=>fn({matches:dark}))}};
}
-for(const saved of [undefined,'light','dark','invalid']){
- const p=page(saved);
- assert.equal(p.initial,saved==='dark'?'dark':'light');
+for(const systemDark of [false,true])for(const saved of [undefined,'light','dark','invalid']){
+ const p=page(saved,{systemDark});
+ assert.equal(p.initial,saved==='light'||saved==='dark'?saved:systemDark?'dark':'light');
assert.equal(p.toggle.hidden,false);
for(let i=0;i<2;i++){
const next=p.root.dataset.theme==='dark'?'light':'dark';
@@ -64,6 +65,29 @@ for(const saved of ['light','dark']){
assert.equal(p.root.dataset.heroEdge,undefined,'the hero edge has no URL switch');
}
+
+for(const saved of [undefined,'invalid']){
+ const p=page(saved,{systemDark:true});
+ assert.equal(p.initial,'dark','system dark applies before styles load');
+ for(const dark of [false,true,false]){
+ p.system(dark);
+ assert.equal(p.root.dataset.theme,dark?'dark':'light');
+ assert.equal(p.toggle['aria-pressed'],String(dark));
+ assert.equal(p.frames[0].contentDocument.documentElement.dataset.marketingTheme,dark?'dark':'light');
+ }
+ p.toggle.click();p.system(false);
+ assert.equal(p.root.dataset.theme,'dark','manual choice wins after system changes');
+}
+for(const saved of ['light','dark']){
+ const p=page(saved,{systemDark:saved==='light'});
+ p.system(false);p.system(true);
+ assert.equal(p.root.dataset.theme,saved,'stored preference wins');
+}
+const denied=page(undefined,{blocked:true,systemDark:true});
+assert.equal(denied.initial,'dark');
+denied.toggle.click();denied.system(true);
+assert.equal(denied.root.dataset.theme,'light','manual preference wins in memory when storage is denied');
+
function luminance(hex){
const channels=hex.match(/[\da-f]{2}/gi).map(v=>parseInt(v,16)/255).map(v=>v<=.04045?v/12.92:((v+.055)/1.055)**2.4);
return channels.reduce((sum,v,i)=>sum+v*[.2126,.7152,.0722][i],0);