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
338 changes: 338 additions & 0 deletions src/components/TrustTopbar.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,338 @@
---
type PageKey = 'trust' | 'threatmodel';
type Locale = 'en' | 'zh-cn' | 'ko' | 'ja';

interface LanguageLink {
label: string;
trust: string;
threatmodel: string;
}

interface Props {
activePage: PageKey;
locale: Locale;
wide?: boolean;
labels: {
trust: string;
threatModel: string;
};
langLinks: Record<Locale, LanguageLink>;
}

const { activePage, locale, wide = false, labels, langLinks } = Astro.props;

const languageOrder: Locale[] = ['en', 'zh-cn', 'ko', 'ja'];
const currentLinks = langLinks[locale];
const currentLanguageLabel = langLinks[locale].label;
const languageEntries = languageOrder.map((language) => ({
code: language,
href: langLinks[language][activePage],
label: langLinks[language].label,
isActive: language === locale,
}));
---

<nav class="trust-topbar" aria-label="Trust site">
<div class:list={['trust-topbar-inner', { wide }]}>
<a href="https://openclaw.ai" class="trust-topbar-brand">
<img src="/openclaw-logo-text-dark.png" alt="OpenClaw" />
</a>

<div class="trust-topbar-nav">
<div class="trust-topbar-tabs">
<a
href={currentLinks.trust}
class:list={['trust-topbar-link', { active: activePage === 'trust' }]}
aria-current={activePage === 'trust' ? 'page' : undefined}
>
{labels.trust}
</a>
<a
href={currentLinks.threatmodel}
class:list={['trust-topbar-link', { active: activePage === 'threatmodel' }]}
aria-current={activePage === 'threatmodel' ? 'page' : undefined}
>
{labels.threatModel}
</a>
</div>

<div class="trust-lang-switcher" aria-label="Languages">
{languageEntries.map((language) => (
<a
href={language.href}
class:list={['trust-lang-link', { active: language.isActive }]}
aria-current={language.isActive ? 'page' : undefined}
>
{language.label}
</a>
))}
</div>

<label class="trust-lang-select-wrap">
<span class="sr-only">Language</span>
<select
class="trust-lang-select"
aria-label="Language"
onchange="if (this.value) window.location.href = this.value"
>
{languageEntries.map((language) => (
<option
value={language.href}
selected={language.isActive}
>
{language.label}
</option>
))}
</select>
<span class="trust-lang-select-label">{currentLanguageLabel}</span>
<span class="trust-lang-select-icon" aria-hidden="true">▾</span>
</label>
</div>
</div>
</nav>

<style>
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}

.trust-topbar {
position: sticky;
top: 0;
z-index: 100;
background: var(--bg);
border-bottom: 1px solid var(--gray-200);
}

.trust-topbar-inner {
max-width: 720px;
margin: 0 auto;
padding: 0 24px;
min-height: 52px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
}

.trust-topbar-inner.wide {
max-width: 1800px;
}

.trust-topbar-brand {
display: flex;
align-items: center;
text-decoration: none;
color: var(--gray-900);
flex-shrink: 0;
}

.trust-topbar-brand:hover {
color: var(--gray-900);
}

.trust-topbar-brand img {
height: 28px;
width: auto;
display: block;
}

.trust-topbar-nav {
display: flex;
align-items: center;
flex-wrap: nowrap;
gap: 12px;
min-width: 0;
}

.trust-topbar-tabs {
display: flex;
align-items: center;
flex-wrap: nowrap;
gap: 4px;
min-width: 0;
flex: 0 1 auto;
}

.trust-topbar-link {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 0;
padding: 6px 14px;
border-radius: 8px;
font-family: var(--heading);
font-size: 14px;
font-weight: 500;
color: var(--gray-500);
transition: color 0.15s, background 0.15s;
text-align: center;
}

.trust-topbar-link:hover {
color: var(--gray-900);
background: var(--gray-50);
}

.trust-topbar-link.active {
color: var(--primary);
font-weight: 600;
}

.trust-lang-switcher {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 2px;
margin-left: 8px;
padding-left: 10px;
border-left: 1px solid var(--gray-200);
}

.trust-lang-link {
padding: 4px 8px;
border-radius: 6px;
font-family: var(--heading);
font-size: 12px;
font-weight: 500;
color: var(--gray-400);
transition: color 0.15s, background 0.15s;
}

.trust-lang-link:hover {
color: var(--gray-900);
background: var(--gray-50);
}

.trust-lang-link.active {
color: var(--primary);
font-weight: 600;
}

.trust-lang-select-wrap {
display: none;
position: relative;
flex: 0 0 86px;
min-width: 86px;
}

.trust-lang-select {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
}

.trust-lang-select-label {
display: inline-flex;
align-items: center;
width: 100%;
min-height: 34px;
padding: 7px 28px 7px 10px;
border: 1px solid var(--gray-200);
border-radius: 8px;
font-family: var(--heading);
font-size: 12px;
font-weight: 600;
color: var(--primary);
background: var(--bg);
}

.trust-lang-select-icon {
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-50%);
color: var(--gray-400);
pointer-events: none;
font-size: 10px;
}

@media (max-width: 820px) {
.trust-topbar-inner {
padding: 10px 16px;
min-height: 52px;
gap: 8px;
}

.trust-topbar-brand img {
height: 24px;
}

.trust-topbar-nav {
flex: 1 1 auto;
justify-content: flex-end;
gap: 6px;
}

.trust-topbar-tabs {
flex: 0 1 auto;
gap: 2px;
}

.trust-topbar-link {
flex: 0 1 auto;
min-width: 0;
padding: 8px 4px;
font-size: 12px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.trust-lang-switcher {
display: none;
}

.trust-lang-select-wrap {
display: block;
flex: 0 0 80px;
min-width: 80px;
}
}

@media (max-width: 380px) {
.trust-topbar-inner {
padding: 10px 12px;
gap: 6px;
}

.trust-topbar-brand img {
height: 20px;
}

.trust-topbar-nav {
gap: 4px;
}

.trust-topbar-link {
font-size: 11px;
padding: 8px 2px;
}

.trust-lang-select-wrap {
flex-basis: 72px;
min-width: 72px;
}

.trust-lang-select-label {
min-height: 32px;
padding: 6px 24px 6px 8px;
font-size: 11px;
}

.trust-lang-select-icon {
right: 8px;
}
}
</style>
Loading
Loading