import { Studio, Product } from '@mindrat/ui'; const studio = new Studio({ locale: 'en' }); export default studio;import { Studio, Product } from '@mindrat/ui'; const studio = new Studio({ locale: 'en' }); export default studio;
const breakpoints = [360, 768, 1280]; layout.adapt(breakpoints); const grid = 'repeat(auto-fit, minmax(16rem, 1fr))';const breakpoints = [360, 768, 1280]; layout.adapt(breakpoints); const grid = 'repeat(auto-fit, minmax(16rem, 1fr))';
export const theme = { accent: '#65d6a0', surface: '#090d08' }; const tokens = createTokens(theme);export const theme = { accent: '#65d6a0', surface: '#090d08' }; const tokens = createTokens(theme);
const routes = ['/', '/services', '/work', '/contact']; routes.forEach((path) => router.preload(path));const routes = ['/', '/services', '/work', '/contact']; routes.forEach((path) => router.preload(path));
const project = await getProject(slug); render(<ProjectPreview project={project} />); images.decode();const project = await getProject(slug); render(<ProjectPreview project={project} />); images.decode();
const variants = { enter: { opacity: 1 }, exit: { opacity: 0 } }; const ease = [0.22, 1, 0.36, 1];const variants = { enter: { opacity: 1 }, exit: { opacity: 0 } }; const ease = [0.22, 1, 0.36, 1];
const image = new Image(); image.src = project.cover; await image.decode(); preview.append(image);const image = new Image(); image.src = project.cover; await image.decode(); preview.append(image);
const supported = ['en', 'tr']; const locale = selectLocale(supported); document.documentElement.lang = locale;const supported = ['en', 'tr']; const locale = selectLocale(supported); document.documentElement.lang = locale;
const palette = ['#257d57', '#00a65c', '#65d6a0']; const swatches = palette.map(createSwatch);const palette = ['#257d57', '#00a65c', '#65d6a0']; const swatches = palette.map(createSwatch);
const items = projects.filter(({ category }) => category === active); items.sort(compareByName);const items = projects.filter(({ category }) => category === active); items.sort(compareByName);
const measure = (element) => element.getBoundingClientRect(); const { width, height } = measure(stage);const measure = (element) => element.getBoundingClientRect(); const { width, height } = measure(stage);
const columns = Math.max(1, Math.floor(width / minSize)); layout.style.setProperty('--columns', columns);const columns = Math.max(1, Math.floor(width / minSize)); layout.style.setProperty('--columns', columns);
const prefersMotion = matchMedia('(prefers-reduced-motion: no-preference)'); const duration = prefersMotion.matches ? 600 : 0;const prefersMotion = matchMedia('(prefers-reduced-motion: no-preference)'); const duration = prefersMotion.matches ? 600 : 0;
const href = new URL('/work', location.origin); href.searchParams.set('category', category); nav.href = href;const href = new URL('/work', location.origin); href.searchParams.set('category', category); nav.href = href;
const devices = ['desktop', 'laptop', 'phone']; devices.forEach((device) => stage.append(createFrame(device)));const devices = ['desktop', 'laptop', 'phone']; devices.forEach((device) => stage.append(createFrame(device)));
const labels = services.map(({ title }) => title); const selected = labels.at(0); updateHeading(selected);const labels = services.map(({ title }) => title); const selected = labels.at(0); updateHeading(selected);
const assets = await Promise.all(project.images.map(loadImage)); assets.forEach((asset) => gallery.append(asset));const assets = await Promise.all(project.images.map(loadImage)); assets.forEach((asset) => gallery.append(asset));
const preferred = window.matchMedia('(prefers-color-scheme: dark)'); setTheme(preferred.matches ? 'dark' : 'light');const preferred = window.matchMedia('(prefers-color-scheme: dark)'); setTheme(preferred.matches ? 'dark' : 'light');
const formatDate = new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }); const date = formatDate.format(publishedAt);const formatDate = new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }); const date = formatDate.format(publishedAt);
const widths = [480, 960, 1440]; const srcset = widths.map((width) => buildSrcset(image, width)).join(', ');const widths = [480, 960, 1440]; const srcset = widths.map((width) => buildSrcset(image, width)).join(', ');
const sections = document.querySelectorAll('main section'); sections.forEach((section) => observer.observe(section));const sections = document.querySelectorAll('main section'); sections.forEach((section) => observer.observe(section));
const { title, summary } = project; const head = { title, description: summary }; applyMetadata(head);const { title, summary } = project; const head = { title, description: summary }; applyMetadata(head);
const cards = document.querySelectorAll('[data-project]'); const visibleCards = Array.from(cards).filter(isVisible);const cards = document.querySelectorAll('[data-project]'); const visibleCards = Array.from(cards).filter(isVisible);
const coordinate = Math.max(0, Math.min(1, progress)); meter.style.setProperty('--fill', coordinate);const coordinate = Math.max(0, Math.min(1, progress)); meter.style.setProperty('--fill', coordinate);
export function clampSize(size, min, max) { return Math.min(max, Math.max(min, size)); } const gap = clampSize(24, 12, 40);export function clampSize(size, min, max) { return Math.min(max, Math.max(min, size)); } const gap = clampSize(24, 12, 40);
const keys = ['ArrowLeft', 'ArrowRight', 'Home', 'End']; const handled = keys.includes(event.key);const keys = ['ArrowLeft', 'ArrowRight', 'Home', 'End']; const handled = keys.includes(event.key);
const style = { display: 'grid', gap: '1.25rem', alignItems: 'center' }; Object.assign(layout.style, style);const style = { display: 'grid', gap: '1.25rem', alignItems: 'center' }; Object.assign(layout.style, style);
const thumbnails = assets.slice(0, 4); render(<Gallery items={thumbnails} label={project.title} />);const thumbnails = assets.slice(0, 4); render(<Gallery items={thumbnails} label={project.title} />);
const heading = document.querySelector('h1'); const title = heading?.textContent?.trim(); document.title = title ?? 'MindRat';const heading = document.querySelector('h1'); const title = heading?.textContent?.trim(); document.title = title ?? 'MindRat';
const page = await routes.resolve(location.pathname); const { component, props } = page; render(component(props));const page = await routes.resolve(location.pathname); const { component, props } = page; render(component(props));
const post = await content.find(slug); const related = content.filterByTags(post.tags); renderReadingList(related);const post = await content.find(slug); const related = content.filterByTags(post.tags); renderReadingList(related);
const viewport = visualViewport ?? window; const scale = viewport.scale ?? 1; layout.update({ scale });const viewport = visualViewport ?? window; const scale = viewport.scale ?? 1; layout.update({ scale });
const styles = await import('./theme.css'); const breakpoint = matchMedia('(min-width: 960px)'); updateGrid(breakpoint.matches);const styles = await import('./theme.css'); const breakpoint = matchMedia('(min-width: 960px)'); updateGrid(breakpoint.matches);
const image = document.querySelector('img'); const ratio = image.naturalWidth / image.naturalHeight; setAspectRatio(ratio);const image = document.querySelector('img'); const ratio = image.naturalWidth / image.naturalHeight; setAspectRatio(ratio);
const preload = document.createElement('link'); preload.rel = 'preload'; preload.as = 'image'; preload.href = cover;const preload = document.createElement('link'); preload.rel = 'preload'; preload.as = 'image'; preload.href = cover;
const tiles = Array.from(gallery.children); const positions = tiles.map(tile => tile.offsetLeft); snapTo(positions[index]);const tiles = Array.from(gallery.children); const positions = tiles.map(tile => tile.offsetLeft); snapTo(positions[index]);
const languages = new Intl.DisplayNames(locale, { type: 'language' }); const label = languages.of('tr');const languages = new Intl.DisplayNames(locale, { type: 'language' }); const label = languages.of('tr');
const number = new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }); counter.textContent = number.format(index + 1);const number = new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }); counter.textContent = number.format(index + 1);
const anchors = document.querySelectorAll('a[href]'); const paths = Array.from(anchors, anchor => anchor.pathname);const anchors = document.querySelectorAll('a[href]'); const paths = Array.from(anchors, anchor => anchor.pathname);
const keyboard = (event) => event.key === 'Escape' && closeMenu(); document.addEventListener('keydown', keyboard);const keyboard = (event) => event.key === 'Escape' && closeMenu(); document.addEventListener('keydown', keyboard);
const state = { page: 1, filter: 'all' }; const query = new URLSearchParams(state); loadResults(query);const state = { page: 1, filter: 'all' }; const query = new URLSearchParams(state); loadResults(query);
const colors = Object.entries(tokens).map(([name, value]) => [`--${name}`, value]); applyStyles(colors);const colors = Object.entries(tokens).map(([name, value]) => [`--${name}`, value]); applyStyles(colors);
const entries = Object.values(projects); const latest = entries.toSorted(byDate).slice(0, 3); renderCards(latest);const entries = Object.values(projects); const latest = entries.toSorted(byDate).slice(0, 3); renderCards(latest);
const sections = ['intro', 'work', 'services']; const active = sections.find(isInViewport) ?? sections[0];const sections = ['intro', 'work', 'services']; const active = sections.find(isInViewport) ?? sections[0];
const card = template.content.cloneNode(true); card.querySelector('h2').textContent = heading; list.append(card);const card = template.content.cloneNode(true); card.querySelector('h2').textContent = heading; list.append(card);
const records = await Promise.allSettled(requests); const ready = records.filter(({ status }) => status === 'fulfilled');const records = await Promise.allSettled(requests); const ready = records.filter(({ status }) => status === 'fulfilled');
const settings = { size: 'cover', align: 'center' }; const layout = createLayout(settings); layout.mount(root);const settings = { size: 'cover', align: 'center' }; const layout = createLayout(settings); layout.mount(root);
const dimensions = { width: 1440, height: 900 }; const bounds = clampToViewport(dimensions); preview.resize(bounds);const dimensions = { width: 1440, height: 900 }; const bounds = clampToViewport(dimensions); preview.resize(bounds);