Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bitext/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ bun.lockb

# Miscellaneous
/static/

# Lemula banner set, copied verbatim from the Lemula repo (marketing/aligner-banners)
/src/lib/components/lemula/blocks/
/src/lib/components/lemula/lemula-banners.css
1,040 changes: 658 additions & 382 deletions bitext/package-lock.json

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions bitext/src/lib/brand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ export const SITE_AUTHOR_URL = 'https://danipolani.github.io/en/';
/** User-facing product name in copy (legal/site title may differ). */
export const ALIGNER_DISPLAY_NAME = 'Aligner';

/** Multiline tooltip for partner link cards; shown on “?” hint. */
export const PARTNER_LINK_WHY_TOOLTIP = `Why is this here?

${ALIGNER_DISPLAY_NAME} stays free. Upkeep still has a cost, so we add a few partner links. Use them if you consider the service. It helps us to maintain the app. I recommend only the services I happily use myself.

Thanks,
Dani`;

/** Plain attribution line (matches standalone SVG export footer text). */
export const EXPORT_ATTRIBUTION_PLAIN = `Created with ${ALIGNER_SITE_HOST}`;

Expand Down
11 changes: 11 additions & 0 deletions bitext/src/lib/components/lemula/LemulaBlock.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script lang="ts">
// Global on purpose: the blocks are plain HTML, and Svelte's scoping would strip their styles.
import './lemula-banners.css';
import { lemulaBlockHtml, type LemulaBlockName } from './blocks.js';

let { name }: { name: LemulaBlockName } = $props();
</script>

<!-- Our own banner markup from `blocks/`; nothing in it comes from users. -->
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
{@html lemulaBlockHtml(name)}
90 changes: 90 additions & 0 deletions bitext/src/lib/components/lemula/LemulaStrip.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<script lang="ts">
import { browser } from '$app/environment';
import { ChevronDownOutline, ChevronUpOutline } from 'flowbite-svelte-icons';
import LemulaBlock from './LemulaBlock.svelte';
import type { LemulaStripPair } from '$lib/lemula/strip-rotation.js';
import { viewportStore } from '$lib/state/viewport.svelte.js';

// The banners live in the free space under a short diagram; when the diagram grows tall they
// auto collapse to a thin bar so they never steal canvas. `scrollEl` is the canvas scroll
// container we measure. Manual toggle overrides the automatic choice for the session.
let { pair, scrollEl }: { pair: LemulaStripPair; scrollEl: HTMLElement | null } = $props();

let manual = $state<'expanded' | 'collapsed' | null>(null);
let autoCollapsed = $state(false);
let stripEl = $state<HTMLElement | null>(null);

const collapsed = $derived(manual ? manual === 'collapsed' : autoCollapsed);
const blocks = $derived(viewportStore.isNarrow ? pair.slice(0, 1) : pair);

// Rough expanded height budget used as the auto-collapse threshold. Hysteresis: the strip's own
// height is added back so expanded↔collapsed decisions do not oscillate around one diagram size.
const EXPANDED_BUDGET_PX = 160;

function measure() {
if (!scrollEl) return;
const diagram = scrollEl.scrollHeight;
const available = scrollEl.clientHeight + (stripEl?.offsetHeight ?? 0);
autoCollapsed = diagram + EXPANDED_BUDGET_PX > available;
}

$effect(() => {
if (!browser || !scrollEl) return;
const el = scrollEl;
const schedule = () => requestAnimationFrame(measure);
const ro = new ResizeObserver(schedule);
ro.observe(el);
if (el.firstElementChild) ro.observe(el.firstElementChild);
if (stripEl) ro.observe(stripEl);
window.addEventListener('resize', schedule);
schedule();
return () => {
ro.disconnect();
window.removeEventListener('resize', schedule);
};
});

const toggleBtn =
'inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-none border-0 bg-transparent text-gray-500 hover:text-gray-800 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:text-gray-400 dark:hover:text-gray-200';
</script>

<aside
bind:this={stripEl}
class="shrink-0 border-t border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900"
aria-label="Lemula banners"
>
{#if collapsed}
<div class="flex items-center gap-2 py-1 pr-4">
<!-- The bar is a link over its whole width, so the expand button sits beside it. -->
<div class="min-w-0 flex-1">
<LemulaBlock name="bar" />
</div>
<button
type="button"
class={toggleBtn}
onclick={() => (manual = 'expanded')}
aria-expanded="false"
aria-label="Expand the Lemula banner"
>
<ChevronUpOutline class="h-4 w-4 shrink-0" aria-hidden="true" />
</button>
</div>
{:else}
<div class="flex justify-end px-4 pt-1">
<button
type="button"
class={toggleBtn}
onclick={() => (manual = 'collapsed')}
aria-expanded="true"
aria-label="Collapse the Lemula banner"
>
<ChevronDownOutline class="h-4 w-4 shrink-0" aria-hidden="true" />
</button>
</div>
<div class="grid gap-3 px-4 pb-3 {blocks.length === 2 ? 'sm:grid-cols-2' : ''}">
{#each blocks as name (name)}
<LemulaBlock {name} />
{/each}
</div>
{/if}
</aside>
17 changes: 17 additions & 0 deletions bitext/src/lib/components/lemula/blocks.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, expect, it } from 'vitest';
import { lemulaBlockHtml } from './blocks.js';

describe('lemulaBlockHtml', () => {
it('marks the call-to-action link for affiliate_click with the block name', () => {
const html = lemulaBlockHtml('card-history');
expect(html).toContain(
'<a data-partner="lemula" data-product="card-history" class="affiliate-link lmb-cta'
);
expect(html.match(/affiliate-link/g)).toHaveLength(1);
});

it('keeps the UTM tags that tell the blocks apart in Lemula analytics', () => {
expect(lemulaBlockHtml('feature')).toContain('utm_source=aligner');
expect(lemulaBlockHtml('feature')).toContain('utm_content=feature');
});
});
43 changes: 43 additions & 0 deletions bitext/src/lib/components/lemula/blocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import bar from './blocks/bar.html?raw';
import boldMorph from './blocks/bold-morph.html?raw';
import boldRule from './blocks/bold-rule.html?raw';
import boldSentence from './blocks/bold-sentence.html?raw';
import boldTree from './blocks/bold-tree.html?raw';
import cardBorrowing from './blocks/card-borrowing.html?raw';
import cardCompound from './blocks/card-compound.html?raw';
import cardGlossed from './blocks/card-glossed.html?raw';
import cardHistory from './blocks/card-history.html?raw';
import feature from './blocks/feature.html?raw';

/** Markup of the Lemula house banners, copied verbatim from the Lemula repo. */
const BLOCK_HTML = {
bar,
'bold-morph': boldMorph,
'bold-rule': boldRule,
'bold-sentence': boldSentence,
'bold-tree': boldTree,
'card-borrowing': cardBorrowing,
'card-compound': cardCompound,
'card-glossed': cardGlossed,
'card-history': cardHistory,
feature
} as const;

export type LemulaBlockName = keyof typeof BLOCK_HTML;

const CTA_OPENING = '<a class="lmb-cta';

/**
* A block's markup with Aligner's click tracking on its link: the `affiliate_click` handler
* listens on `a.affiliate-link` and reads the partner and product from data attributes.
*/
export function lemulaBlockHtml(name: LemulaBlockName): string {
const html = BLOCK_HTML[name];
if (!html.includes(CTA_OPENING)) {
throw new Error(`Lemula block "${name}" has no call-to-action link to track`);
}
return html.replace(
CTA_OPENING,
`<a data-partner="lemula" data-product="${name}" class="affiliate-link lmb-cta`
);
}
4 changes: 4 additions & 0 deletions bitext/src/lib/components/lemula/blocks/bar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="lmb lmb-bar">
<span class="lmb-tagline">Naturalistic language evolution engine</span>
<a class="lmb-cta lmb-link" href="https://lemula.app/?utm_source=aligner&amp;utm_medium=banner&amp;utm_campaign=house_ads&amp;utm_content=bar" target="_blank" rel="noopener">Try Lemula <span aria-hidden="true">→</span></a>
</div>
36 changes: 36 additions & 0 deletions bitext/src/lib/components/lemula/blocks/bold-morph.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<article class="lmb lmb-bold lmb-bold--morph" aria-label="Lemula">
<div class="lmb-bold__in">
<div class="lmb-bold__text">
<p class="lmb-bold__title">Follow a word through two thousand years.</p>
<a class="lmb-cta lmb-pill" href="https://lemula.app/?utm_source=aligner&amp;utm_medium=banner&amp;utm_campaign=house_ads&amp;utm_content=bold-morph" target="_blank" rel="noopener">Try Lemula</a>
</div>
<div class="lmb-bold__visual" aria-hidden="true">
<div class="lmb-bold__caption">
<span>night</span>
<span class="lmb-morph__dots"><i></i><i></i><i></i><i></i></span>
</div>
<div class="lmb-morph__stack">
<div class="lmb-morph__step">
<span class="lmb-form">ˈnoktem</span>
<span class="lmb-morph__meta">Classical Latin · c. 100 BC</span>
<span class="lmb-morph__rule">earliest form</span>
</div>
<div class="lmb-morph__step">
<span class="lmb-form">ˈnɔkte</span>
<span class="lmb-morph__meta">Vulgar Latin · c. 300 AD</span>
<span class="lmb-morph__rule">o[+stress] &gt; ɔ; m &gt; ∅ / _ #</span>
</div>
<div class="lmb-morph__step">
<span class="lmb-form">ˈnojte</span>
<span class="lmb-morph__meta">Ibero-Romance · c. 700</span>
<span class="lmb-morph__rule">k &gt; j / _ t; ɔ &gt; o / _ j</span>
</div>
<div class="lmb-morph__step">
<span class="lmb-form">ˈnot͡ʃe</span>
<span class="lmb-morph__meta">Old Castilian · c. 1200</span>
<span class="lmb-morph__rule">jt &gt; t͡ʃ</span>
</div>
</div>
</div>
</div>
</article>
17 changes: 17 additions & 0 deletions bitext/src/lib/components/lemula/blocks/bold-rule.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<article class="lmb lmb-bold lmb-bold--rule" aria-label="Lemula">
<span class="lmb-bold__glyph" aria-hidden="true">&gt;</span>
<div class="lmb-bold__in">
<div class="lmb-bold__text">
<p class="lmb-bold__title">Write sound changes the way linguists do.</p>
<a class="lmb-cta lmb-pill" href="https://lemula.app/?utm_source=aligner&amp;utm_medium=banner&amp;utm_campaign=house_ads&amp;utm_content=bold-rule" target="_blank" rel="noopener">Try Lemula</a>
</div>
<div class="lmb-bold__visual" aria-hidden="true">
<div class="lmb-bold__caption"><span>Ibero-Romance · c. 700</span></div>
<ol class="lmb-rules">
<li><b>k</b> &gt; <b>j</b> / _ t</li>
<li><em>ɔ</em> &gt; <em>o</em> / _ j</li>
</ol>
<p class="lmb-rules__forms"><span class="lmb-form">ˈn<em>ɔ</em><b>k</b>te</span> <span class="lmb-arrow">→</span> <span class="lmb-form">ˈn<em>o</em><b>j</b>te</span></p>
</div>
</div>
</article>
25 changes: 25 additions & 0 deletions bitext/src/lib/components/lemula/blocks/bold-sentence.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<article class="lmb lmb-bold lmb-bold--sentence" aria-label="Lemula">
<div class="lmb-bold__in">
<div class="lmb-bold__text">
<p class="lmb-bold__title">Your glossed sentences, stage by stage.</p>
<a class="lmb-cta lmb-pill" href="https://lemula.app/?utm_source=aligner&amp;utm_medium=banner&amp;utm_campaign=house_ads&amp;utm_content=bold-sentence" target="_blank" rel="noopener">Try Lemula</a>
</div>
<div class="lmb-bold__visual" aria-hidden="true">
<p class="lmb-sentence__translation">‘The wolf calls the hound’</p>
<div class="lmb-sentence">
<div class="lmb-sentence__row">
<span class="lmb-form">ˈlopus ˈkane ˈklamat</span>
<span class="lmb-sentence__stage">Classical Latin</span>
</div>
<div class="lmb-sentence__row">
<span class="lmb-form">ˈlobus ˈklamat ˈkane</span>
<span class="lmb-sentence__stage">Proto-Romance</span>
</div>
<div class="lmb-sentence__row">
<span class="lmb-form">el ˈlobo ˈʎama el ˈkan</span>
<span class="lmb-sentence__stage">Modern Spanish</span>
</div>
</div>
</div>
</div>
</article>
35 changes: 35 additions & 0 deletions bitext/src/lib/components/lemula/blocks/bold-tree.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<article class="lmb lmb-bold lmb-bold--tree" aria-label="Lemula">
<div class="lmb-bold__in">
<div class="lmb-bold__text">
<p class="lmb-bold__title">Grow a family of languages from one.</p>
<a class="lmb-cta lmb-pill" href="https://lemula.app/?utm_source=aligner&amp;utm_medium=banner&amp;utm_campaign=house_ads&amp;utm_content=bold-tree" target="_blank" rel="noopener">Try Lemula</a>
</div>
<div class="lmb-bold__visual" aria-hidden="true">
<svg class="lmb-tree" viewBox="0 0 280 112">
<text class="lmb-tree__root" x="140" y="17">ˈnoktem</text>
<text class="lmb-tree__lang" x="140" y="30">Latin</text>
<path class="lmb-tree__line" pathLength="1" d="M140 35 V48 M35 62 V54 Q35 48 41 48 H239 Q245 48 245 54 V62 M105 48 V62 M175 48 V62" />
<g class="lmb-tree__leaf">
<circle cx="35" cy="66" r="3.5" />
<text x="35" y="88">ˈnot͡ʃe</text>
<text class="lmb-tree__lang" x="35" y="103">Spanish</text>
</g>
<g class="lmb-tree__leaf">
<circle cx="105" cy="66" r="3.5" />
<text x="105" y="88">ˈnojtɨ</text>
<text class="lmb-tree__lang" x="105" y="103">Portuguese</text>
</g>
<g class="lmb-tree__leaf">
<circle cx="175" cy="66" r="3.5" />
<text x="175" y="88">nɥi</text>
<text class="lmb-tree__lang" x="175" y="103">French</text>
</g>
<g class="lmb-tree__leaf">
<circle cx="245" cy="66" r="3.5" />
<text x="245" y="88">ˈnɔtte</text>
<text class="lmb-tree__lang" x="245" y="103">Italian</text>
</g>
</svg>
</div>
</div>
</article>
12 changes: 12 additions & 0 deletions bitext/src/lib/components/lemula/blocks/card-borrowing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<article class="lmb lmb-card" aria-label="Lemula">
<div class="lmb-card__in">
<p class="lmb-card__title">Historical linguistics for your conlang</p>
<a class="lmb-cta lmb-link lmb-card__cta" href="https://lemula.app/?utm_source=aligner&amp;utm_medium=banner&amp;utm_campaign=house_ads&amp;utm_content=card-borrowing" target="_blank" rel="noopener">Try Lemula <span aria-hidden="true">→</span></a>
<div class="lmb-card__specimen" aria-hidden="true">
<span class="lmb-pair"><span class="lmb-gloss">Old French</span><span class="lmb-form lmb-old">ʒarˈdin</span></span>
<span class="lmb-arrow">→</span>
<span class="lmb-pair"><span class="lmb-gloss">Castilian</span><span class="lmb-form">xaɾˈdin</span></span>
<span class="lmb-gloss lmb-narrow-drop">garden</span>
</div>
</div>
</article>
13 changes: 13 additions & 0 deletions bitext/src/lib/components/lemula/blocks/card-compound.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<article class="lmb lmb-card" aria-label="Lemula">
<div class="lmb-card__in">
<p class="lmb-card__title">Naturalistic language evolution engine</p>
<a class="lmb-cta lmb-link lmb-card__cta" href="https://lemula.app/?utm_source=aligner&amp;utm_medium=banner&amp;utm_campaign=house_ads&amp;utm_content=card-compound" target="_blank" rel="noopener">Try Lemula <span aria-hidden="true">→</span></a>
<div class="lmb-card__specimen" aria-hidden="true">
<span class="lmb-pair"><span class="lmb-form lmb-old">ˈtatih</span><span class="lmb-gloss lmb-narrow-drop">eye</span></span>
<span class="lmb-arrow">+</span>
<span class="lmb-pair"><span class="lmb-form lmb-old">ˈtaho</span><span class="lmb-gloss lmb-narrow-drop">water</span></span>
<span class="lmb-arrow">→</span>
<span class="lmb-pair"><span class="lmb-form">ˈtatihˌtaho</span><span class="lmb-gloss">tear</span></span>
</div>
</div>
</article>
11 changes: 11 additions & 0 deletions bitext/src/lib/components/lemula/blocks/card-glossed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<article class="lmb lmb-card" aria-label="Lemula">
<div class="lmb-card__in">
<p class="lmb-card__title">Naturalistic language evolution engine</p>
<a class="lmb-cta lmb-link lmb-card__cta" href="https://lemula.app/?utm_source=aligner&amp;utm_medium=banner&amp;utm_campaign=house_ads&amp;utm_content=card-glossed" target="_blank" rel="noopener">Try Lemula <span aria-hidden="true">→</span></a>
<div class="lmb-card__specimen" aria-hidden="true">
<span class="lmb-form lmb-old">ˈlopus ˈkane ˈklamat</span>
<span class="lmb-arrow">→</span>
<span class="lmb-form">el ˈlobo ˈʎama el ˈkan</span>
</div>
</div>
</article>
15 changes: 15 additions & 0 deletions bitext/src/lib/components/lemula/blocks/card-history.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<article class="lmb lmb-card" aria-label="Lemula">
<div class="lmb-card__in">
<p class="lmb-card__title">Historical linguistics for your conlang</p>
<a class="lmb-cta lmb-link lmb-card__cta" href="https://lemula.app/?utm_source=aligner&amp;utm_medium=banner&amp;utm_campaign=house_ads&amp;utm_content=card-history" target="_blank" rel="noopener">Try Lemula <span aria-hidden="true">→</span></a>
<div class="lmb-card__specimen" aria-hidden="true">
<span class="lmb-form lmb-old">ˈnoktem</span>
<span class="lmb-arrow lmb-narrow-drop">→</span>
<span class="lmb-form lmb-old lmb-narrow-drop">ˈnɔkte</span>
<span class="lmb-arrow lmb-narrow-drop">→</span>
<span class="lmb-form lmb-old lmb-narrow-drop">ˈnojte</span>
<span class="lmb-arrow">→</span>
<span class="lmb-pair"><span class="lmb-form">ˈnot͡ʃe</span><span class="lmb-gloss">night</span></span>
</div>
</div>
</article>
Loading
Loading