fix(web): derive project rail labels from names
This commit is contained in:
@@ -42,6 +42,11 @@ for (const forbidden of ['森林Agent', 'SenlinAI Workbench']) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const projectRailSource = readFileSync('src/pages/projects/project-rail.tsx', 'utf8')
|
||||||
|
if (!projectRailSource.includes('projectNameLabel(project.name)')) {
|
||||||
|
failures.push('project rail labels must derive from the project name')
|
||||||
|
}
|
||||||
|
|
||||||
if (existsSync('src/App.tsx')) {
|
if (existsSync('src/App.tsx')) {
|
||||||
failures.push('legacy src/App.tsx should be removed after page split')
|
failures.push('legacy src/App.tsx should be removed after page split')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -360,11 +360,14 @@
|
|||||||
.project-button {
|
.project-button {
|
||||||
width: 48px;
|
width: 48px;
|
||||||
height: 48px;
|
height: 48px;
|
||||||
|
padding: 0 4px;
|
||||||
border: 1px solid var(--senlin-border);
|
border: 1px solid var(--senlin-border);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background: color-mix(in srgb, var(--project-color) 9%, white);
|
background: color-mix(in srgb, var(--project-color) 9%, white);
|
||||||
color: var(--project-color);
|
color: var(--project-color);
|
||||||
|
font-size: 12px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
|
overflow: hidden;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export function ProjectRail({
|
|||||||
style={{ '--project-color': project.color } as CSSProperties}
|
style={{ '--project-color': project.color } as CSSProperties}
|
||||||
title={project.name}
|
title={project.name}
|
||||||
>
|
>
|
||||||
{project.short}
|
{projectNameLabel(project.name)}
|
||||||
</button>
|
</button>
|
||||||
</Badge>
|
</Badge>
|
||||||
))}
|
))}
|
||||||
@@ -56,3 +56,9 @@ export function ProjectRail({
|
|||||||
</Sider>
|
</Sider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function projectNameLabel(name: string) {
|
||||||
|
const characters = Array.from(name.trim())
|
||||||
|
const limit = characters.some((character) => /\p{Script=Han}/u.test(character)) ? 2 : 4
|
||||||
|
return characters.slice(0, limit).join('')
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user